summaryrefslogtreecommitdiff
path: root/libguile/stime.c
AgeCommit message (Collapse)AuthorFilesLines
2019-06-30'strftime' and 'strptime' honor the locale encoding.Ludovic Courtès1-12/+12
Fixes <https://bugs.gnu.org/35920>. Reported by Christopher Lam <christopher.lck@gmail.com>. * libguile/stime.c (scm_strftime): Use 'scm_to_locale_stringn' instead of 'scm_to_utf8_stringn'. (scm_strptime): Likewise, and use 'scm_string_length' instead of 'u8_strnlen'. * test-suite/tests/time.test ("strftime")["strftime passes wide characters"]: Wrap body in 'with-locale'. ["strftime fr_FR.utf8", "strftime fr_FR.iso88591"]: New tests. ("strptime")["strftime fr_FR.utf8", "strftime fr_FR.iso88591"]: New tests.
2019-04-16Avoid passing NULL to 'memcpy' and 'memcmp'.Mark H Weaver1-1/+2
Reported by Jeffrey Walton <noloader@gmail.com> in <https://lists.gnu.org/archive/html/guile-devel/2019-03/msg00001.html>. Note that C11 section 7.1.4 (Use of library functions) states that: "unless explicitly stated otherwise in the detailed descriptions [of library functions] that follow: If an argument to a function has an invalid value (such as ... a null pointer ...) ..., the behavior is undefined." Note that 'strxfrm' is an example of a standard C function that explicitly states otherwise, allowing NULL to be passed in the first argument if the size argument is zero, but no similar allowance is specified for 'memcpy' or 'memcmp'. * libguile/bytevectors.c (scm_uniform_array_to_bytevector): Call memcpy only if 'byte_len' is non-zero. * libguile/srfi-14.c (charsets_equal): Call memcmp only if the number of ranges is non-zero. * libguile/stime.c (setzone): Pass 1-character buffer to 'scm_to_locale_stringbuf', instead of NULL. * libguile/strings.c (scm_to_locale_stringbuf): Call memcpy only if the number of bytes to copy is non-zero.
2019-02-09Fix strftime compile with null threadsMike Gran1-2/+2
* libguile/stime.c (scm_strftime): use correct pthread lock function
2018-10-17Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.Mark H Weaver1-3/+3
Partial fix for <https://bugs.gnu.org/33044>. Reported by Tom de Vries <tdevries@suse.de>. Fix several instances of the mistake of using 'scm_from_locale_*' for C strings that originally came from a C string literal. Change several uses of 'scm_from_latin1_*' as well, to promote the practice of writing code that works for arbitrary C string literals. Also add missing years to the copyright notices of changed files, based on the git history. * libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c, libguile/eval.c, libguile/expand.c, libguile/extensions.c, libguile/filesys.c, libguile/init.c, libguile/load.c, libguile/modules.c, libguile/pairs.c, libguile/posix.c, libguile/print.c, libguile/random.c, libguile/read.c, libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c, libguile/stacks.c, libguile/stime.c, libguile/strports.c, libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
2017-01-19Fix build warningAndy Wingo1-2/+0
* libguile/stime.c (scm_init_stime): Remove unused variable.
2017-01-08Fix scm_init_stime for macOSAndy Wingo1-4/+1
* libguile/stime.c (scm_init_stime): Remove needless test of clock_getcpuclockid. Fixes build on macOS; thanks to Matt Wette for the report and fix.
2016-12-07Fix --without-threadsAndy Wingo1-2/+2
* libguile/dynl.c: * libguile/gc.c: * libguile/keywords.c: * libguile/scmsigs.c: * libguile/stime.c: Use scm_i_dynamic_link instead of scm_dynamic_link so that things compile in without-threads configurations.
2016-11-01Mutexes instead of critical sections in stime.cAndy Wingo1-15/+16
* libguile/stime.c (scm_current_time): No need for a critical section around time(). (tz_lock): New mutex. (scm_localtime): Use tz_lock in a dynwind. Fixes bug in which critical section was never left on error. (scm_gmtime, scm_mktime, scm_strftime, scm_strptime): Use a normal mutex instead of a critical section.
2016-07-25Use non-deprecated HAVE_STRUCT_TM_TM_ZONEAndy Wingo1-5/+5
* libguile/stime.c: Change uses of the deprecated HAVE_TM_ZONE to the new HAVE_STRUCT_TM_TM_ZONE.
2016-07-25Add missing 'const' qualifier.Ludovic Courtès1-1/+1
* libguile/stime.c (tzvar): Add 'const'.
2016-07-25Unconditionally include <time.h> from Gnulib.Ludovic Courtès1-5/+1
* libguile/stime.c: Unconditionally include <time.h>.
2014-04-25Merge branch 'stable-2.0'v2.1.0Mark H Weaver1-3/+2
Conflicts: GUILE-VERSION NEWS guile-readline/ice-9/readline.scm libguile/async.c libguile/backtrace.c libguile/deprecated.h libguile/gc-malloc.c libguile/gdbint.c libguile/init.c libguile/ioext.c libguile/mallocs.c libguile/print.c libguile/rw.c libguile/scmsigs.c libguile/script.c libguile/simpos.c libguile/snarf.h libguile/strports.c libguile/threads.c libguile/vm-i-scheme.c libguile/vm-i-system.c module/srfi/srfi-18.scm test-suite/Makefile.am test-suite/standalone/test-num2integral.c
2014-02-27Rely on Gnulib for <unistd.h>.Mark H Weaver1-3/+2
* libguile/async.c: * libguile/backtrace.c: * libguile/error.c: * libguile/filesys.c: * libguile/fports.c: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/init.c: * libguile/ioext.c: * libguile/load.c: * libguile/mallocs.c: * libguile/mkstemp.c: * libguile/ports.c: * libguile/posix.c: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/rw.c: * libguile/scmsigs.c: * libguile/script.c: * libguile/simpos.c: * libguile/socket.c: * libguile/stime.c: * libguile/strports.c: * libguile/threads.c: Unconditionally include <unistd.h>.
2014-02-08Change uses of scm_is_simple_vector to scm_is_vectorDaniel Llorens1-1/+1
* libguile/filesys.c, libguile/random.c, libguile/stime.c, libguile/trees.c, libguile/validate.h: use scm_is_vector instead of scm_is_simple_vector. * libguile/sort.c (scm_sort_x, scm_sort, scm_stable_sort_x) (scm_stable_sort): Remove scm_is_vector check; scm_is_array is sufficient. * test-suite/tests/arrays.test: Fix header. * test-suite/tests/random.test: New coverage test covering random:normal-vector!. * test-suite/Makefile.am: Include random.test in make check.
2013-04-10stime: Remove #ifdef HAVE_*_H for headers provided by Gnulib.Ludovic Courtès1-10/+2
* libguile/stime.c: Remove #ifdef HAVE_SYS_TIMES_H, HAVE_SYS_TYPES_H, and HAVE_STRING_H since those headers are always provided by Gnulib when the corresponding macro is undefined. Fixes a regression on MinGW introduced by commit 40e2a31.
2013-04-09fix stime patch for HAVE_TIMES removalAndy Wingo1-3/+14
* libguile/stime.c (scm_init_stime): Fix previous patch. At this point in the source, we definitely have a run-time function, but don't necessarily have a real-time function.
2013-04-09simplify configure checks for functionality provided by gnulibAndy Wingo1-21/+0
* configure.ac: Remove checks for pipe, stftime, times, and select, as our Gnulib modules already ensure they are provided. * libguile/stime.c: Rely on gnulib providing `times'.
2013-03-09simplify stime back-compat shims for tznameAndy Wingo1-8/+1
* libguile/stime.c: Remove tzname declarations for ancient mingw and SGI RS6000.
2012-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-8/+9
* libguile/alist.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/bitvectors.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/generalized-arrays.c: * libguile/hashtab.c: * libguile/ioext.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/promises.c: * libguile/simpos.c: * libguile/socket.c: * libguile/srfi-1.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/symbols.c: * libguile/threads.c: * libguile/weak-table.c: * libguile/weak-vector.c: Make the variable names in the C docstrings more consistent. Replace a few instances of @var with @code when appropriate.
2011-05-20clocktime freebsd portabilityAndy Wingo1-3/+7
* libguile/stime.c (HAVE_POSIX_CPUTIME): Hack around buggy FreeBSD implementation of _POSIX_CPUTIME.
2011-05-04scm_c_get_internal_run_time is more preciseAndy Wingo1-79/+165
* libguile/stime.h (SCM_TIME_UNITS_PER_SECOND): Redefine to point to a C variable instead of being a pure preprocessor thing. This has the possibility to break existing compiled C extensions' interpretation of the internal-time-units-per-second, but hopefully there's no too much of that code out there, and in the worst case they can just recompile. Scheme code will get it right without the need to recompile. * libguile/stime.c (TIME_UNITS_PER_SECOND): New local define, and increase to nanosecond resolution if we are on a system in which this is useful and practical. (time_from_seconds_and_nanoseconds): New helper. (get_internal_real_time, get_internal_run_time): New global vars: function pointers. (get_internal_real_time_posix_timer): (get_internal_run_time_posix_timer): (get_internal_real_time_gettimeofday): (get_internal_run_time_times): (get_internal_real_time_fallback): Various implementations. (scm_get_internal_real_time): Return the get_internal_real_time() result. (scm_c_get_internal_run_time): Likewise. (scm_gettimeofday): No need for a critical section, and remove obsolete ftime block. (scm_init_stime): Init all of the new time bases, and decide on implementations of real time and run time accessors.
2011-01-07add scm_{to,from}_{utf8,latin1}_string{n,}Andy Wingo1-17/+14
* libguile/strings.h: * libguile/strings.c (scm_from_latin1_string, scm_to_latin1_string): New functions, in terms of the latin1_stringn variants. (scm_from_utf8_string, scm_from_utf8_stringn) (scm_to_utf8_string, scm_to_utf8_stringn): New functions. (scm_i_from_utf8_string, scm_i_to_utf8_string): Removed these internal functions. (scm_from_stringn): Handle -1 as a length. Unlike the previous behavior of scm_from_locale_string (NULL), which returned the empty string, we now raise an error. The null pointer is not the same as the empty string. * libguile/stime.c (scm_strftime, scm_strptime): Adapt to publishing of utf8 functions.
2009-11-17Fix stylistic issues revealed by "make syntax-check".Ludovic Courtès1-5/+4
* libguile/gc-malloc.c (scm_must_free): Remove unnecessary `if' before `free ()'. * libguile/stime.c (scm_localtime, scm_mktime): Likewise. * libguile/eval.i.c (ceval): Don't cast the result of alloca(3). * libguile/i18n.c (SCM_STRING_TO_U32_BUF): Likewise. * test-suite/standalone/test-unwind.c: Likewise. * libguile/strings.c (scm_i_deprecated_string_chars): Don't end error message in period.
2009-08-23Modify socket and time functions for wide stringsMichael Gran1-15/+35
* libguile/socket.c (scm_recv): receive the message without holding the stringbuf writing lock (scm_send): try to narrow a string before using it * libguile/stime.c (strftime): convert string to UTF-8 so that it can be safely passed to strftime (strptime): convert input string to UTF-8 so that it can be safely passed through strptime * libguile/strings.c (narrow_stringbuf): new function (scm_i_try_narrow_string): new function * libguile/strings.h: new declaration for scm_i_try_narrow_string
2009-06-17Change Guile license to LGPLv3+Neil Jerram1-6/+7
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2009-05-26gnulib-tool --import environ; rely on gnulib for environ definitionsAndy Wingo1-13/+0
* libguile/posix.c: * libguile/stime.c: Remove environ definition, gnulib provides it now.
2008-09-13Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès1-1/+1
2008-09-02Use Gnulib's `strftime' to address bug #24130.Ludovic Courtès1-4/+4
* libguile/stime.c (scm_strftime): Use `nstrftime ()' from Gnulib. This provides the same semantics on all platforms, thereby fixing bug #24130. * doc/ref/posix.texi (Time): Remove note about non-portable `%Z' behavior. Describe the new, portable behavior. * test-suite/tests/time.test ("strftime")["strftime %Z doesn't return garbage"]: Reinstate. ["C99 %z format"](have-strftime-%z): Remove. ("GMT", "EST+5"): Don't use `have-strftime-%z'.
2008-08-20Never define `_GNU_SOURCE' explicitly since `AC_USE_SYSTEM_EXTENSIONS'Ludovic Courtès1-2/+1
takes care of it. Conflicts: ChangeLog configure.in libguile/eval.c libguile/srfi-14.c libguile/threads.c
2007-08-23Changes from arch/CVS synchronizationLudovic Courtès1-1/+3
2007-08-16Add #define _REENTRANT, to get gmtime_r() prototype onKevin Ryde1-1/+2
solaris 2.6. Reported by anirkko.
2006-10-09merge from 1.8 branchKevin Ryde1-2/+16
2006-04-17merge from 1.8 branchKevin Ryde1-1/+1
2006-01-29Renamed the "frames" that are related to dynamic-wind to "dynamicMarius Vollmer1-4/+4
contexts. Renamed all functions from scm_frame_ to scm_dynwind_. Updated documentation.
2005-11-06(scm_mktime): Use scm_frame_critical_section instead ofMarius Vollmer1-2/+2
SCM_CRITICAL_SECTION_START/END since the code inside the critical section might exit non-locally.
2005-10-23(scm_strftime): Update docstring from posix.texi.Kevin Ryde1-7/+16
2005-06-05* hashtab.h: Bugfix: use SCM_API (WAS: extern).Marius Vollmer1-6/+5
* socket.c: Remove obsolete comment about socklen_t. (s_scm_setsockopt)[!HAVE_IP_MREQ]: Do not use ip_mreq code. * numbers.h (isnan)[__MINGW32__]: Remove. * Makefile.am (gen_scmconfig_SOURCES): Bugfix: Add DEFAULT_INCLUDES when cross compiling. * threads.c (ETIMEDOUT, pipe)[__MINGW32__]: Add defines. * stime.c (s_scm_strftime)[!HAVE_TM_ZONE]: Use SCM_SIMPLE_VECTOR_REF instead of SCM_VELTS. (Changed slightly from Jan's patch.)
2005-05-23The FSF has a new address.Marius Vollmer1-1/+1
2005-03-07Include "libguile/async.h" for SCM_CRITICAL_SECTION_START/END.Marius Vollmer1-0/+1
2005-03-02See ChangeLog from 2005-03-02.Marius Vollmer1-17/+17
2005-01-10(scm_mktime): Missing default errno=EINVAL from prev change.Kevin Ryde1-1/+2
2005-01-04(scm_strftime): Free t.tm_zone produced by bdtime2c.Kevin Ryde1-0/+3
Reported by Bill Schottstaedt.
2005-01-02Use new vector elements API or simple vector API, as appropriate.Marius Vollmer1-42/+32
Removed SCM_HAVE_ARRAYS ifdefery. Replaced all uses of SCM_HASHTABLE_BUCKETS with SCM_HASHTABLE_BUCKET.
2004-09-08(_POSIX_C_SOURCE): Use this only on hpux, itKevin Ryde1-1/+14
causes too many problems elsewhere (glibc, freebsd, mingw). Reported by Andreas Vögele.
2004-09-07(scm_current_time, scm_gettimeofday, scm_strptime): Don'tKevin Ryde1-8/+22
throw error before unlocking mutex with SCM_ALLOW_INTS.
2004-09-032004-09-03 Stefan Jahn <stefan@lkcc.org>Stefan Jahn1-1/+5
* configure.in (isinf): Let configure find the isinf() function on MinGW32 systems. 2004-09-03 Stefan Jahn <stefan@lkcc.org> * threads.c (scm_threads_mark_stacks): Fixed local variable definitions. * strings.c (scm_i_substring_copy, s_scm_string_append): Fixed local variable definitions. * stime.c (_POSIX_C_SOURCE): Do not define this item on MinGW32 because it conflicts with its pthread headers. (s_scm_mktime): Consider the HAVE_STRUCT_TM_TM_ZONE define. (s_scm_strftime): Using scm_from_locale_string() instead of scm_makfrom0str(). * posix.c (s_scm_putenv): Fixed typo in the !HAVE_UNSETENV part. * numbers.c (scm_init_numbers): Removed check_sanity() call inside GUILE_DEBUG. The function has been removed somewhen... * filesys.c (_POSIX_C_SOURCE): Do not define this item on MinGW32 because it conflicts with its pthread headers. 2004-09-03 Stefan Jahn <stefan@lkcc.org> * srfi-1.c, srfi-1.h: Renamed any 'lst1' into 'list1' because lst1 is a #define on Win32 systems.
2004-08-19* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,Marius Vollmer1-9/+18
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all uses. (scm_i_make_string, scm_c_make_string): New, to replace scm_allocate_string. Updated all uses. (SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS, SCM_STRING_LENGTH): Deprecated. (scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string, scm_str2string, scm_makfrom0str, scm_makfrom0str_opt): Discouraged. Replaced all uses with scm_from_locale_string or similar, as appropriate. (scm_c_string_length, scm_c_string_ref, scm_c_string_set_x, scm_c_substring, scm_c_substring_shared, scm_c_substring_copy, scm_substring_shared, scm_substring_copy): New. * symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC, SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS, SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol, scm_str2symbol, scm_mem2uninterned_symbol): Discouraged. (SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str): Deprecated. (SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS, SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed. (scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln): New, to replace scm_str2symbol and scm_mem2symbol, respectively. Updated all uses. (scm_gensym): Generate only the number suffix in the buffer, just string-append the prefix.
2004-08-10* stime.c, socket.c, simpos.c, procs.c, posix.c, ports.c,Marius Vollmer1-5/+9
net_db.c, fports.c, filesys.c, eval.c, deprecation.c, dynl.c: Replaced uses of SCM_STRING_CHARS with proper uses of scm_to_locale_string. Replaced SCM_STRINGP with scm_is_string. Replaced scm_mem2string with scm_from_locale_string. * simpos.c, posix.c (allocate_string_pointers, environ_list_to_c): Removed, replaced all uses with scm_i_allocate_string_pointers.
2004-08-02* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,Marius Vollmer1-16/+18
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num, scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long): Discouraged by moving to discouraged.h and discouraged.c and reimplementing in terms of scm_from_* and scm_to_*. Changed all uses to the new scm_from_* and scm_to_* functions.
2004-07-23* deprecated.h, deprecated.c, numbers.h (SCM_INUMP, SCM_NINUMP,Marius Vollmer1-27/+28
SCM_INUM): Deprecated by reenaming them to SCM_I_INUMP, SCM_I_NINUMP and SCM_I_INUM, respectively and adding deprecated versions to deprecated.h and deprecated.c. Changed all uses to either use the SCM_I_ variants or scm_is_*, scm_to_*, or scm_from_*, as appropriate.