|
From: <cli...@li...> - 2010-09-29 13:24:28
|
Send clisp-cvs mailing list submissions to cli...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/clisp-cvs or, via email, send a message with subject or body 'help' to cli...@li... You can reach the person managing the list at cli...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of clisp-cvs digest..." CLISP CVS commits for today Today's Topics: 1. clisp/modules/syscalls/glm4 bison.m4, NONE, 1.1 clock_time.m4, NONE, 1.1 error.m4, NONE, 1.1 getdate.m4, NONE, 1.1 gettime.m4, NONE, 1.1 inline.m4, NONE, 1.1 timespec.m4, NONE, 1.1 xalloc.m4, NONE, 1.1 gnulib-cache.m4, 1.11, 1.12 gnulib-comp.m4, 1.12, 1.13 (Sam Steingold) 2. clisp/src ChangeLog,1.7533,1.7534 NEWS,1.548,1.549 (Sam Steingold) 3. clisp Makefile.devel,1.283,1.284 (Sam Steingold) 4. clisp/modules/syscalls calls.c, 1.315, 1.316 configure.in, 1.92, 1.93 syscalls.xml, 1.134, 1.135 (Sam Steingold) 5. clisp/modules/syscalls/gllib c-ctype.c, NONE, 1.1 c-ctype.h, NONE, 1.1 getdate.h, NONE, 1.1 getdate.y, NONE, 1.1 gettext.h, NONE, 1.1 gettime.c, NONE, 1.1 timespec.h, NONE, 1.1 xalloc.h, NONE, 1.1 xmalloc.c, NONE, 1.1 Makefile.am, 1.19, 1.20 (Sam Steingold) ---------------------------------------------------------------------- Message: 1 Date: Wed, 29 Sep 2010 13:24:16 +0000 From: Sam Steingold <sd...@us...> Subject: clisp/modules/syscalls/glm4 bison.m4, NONE, 1.1 clock_time.m4, NONE, 1.1 error.m4, NONE, 1.1 getdate.m4, NONE, 1.1 gettime.m4, NONE, 1.1 inline.m4, NONE, 1.1 timespec.m4, NONE, 1.1 xalloc.m4, NONE, 1.1 gnulib-cache.m4, 1.11, 1.12 gnulib-comp.m4, 1.12, 1.13 To: cli...@li... Message-ID: <E1P...@sf...> Update of /cvsroot/clisp/clisp/modules/syscalls/glm4 In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5536/modules/syscalls/glm4 Modified Files: gnulib-cache.m4 gnulib-comp.m4 Added Files: bison.m4 clock_time.m4 error.m4 getdate.m4 gettime.m4 inline.m4 timespec.m4 xalloc.m4 Log Message: implement POSIX:GETDATE using gnulib * Makefile.devel (gnulib-imported): import getdate into syscalls * modules/syscalls/calls.c (tm_to_lisp): extract from STRING-TIME (POSIX:GETDATE, xalloc_die): implement * modules/syscalls/configure.in: call gl_GETDATE --- NEW FILE: xalloc.m4 --- # xalloc.m4 serial 16 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2010 Free Software dnl Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_XALLOC], [ AC_LIBOBJ([xmalloc]) gl_PREREQ_XALLOC gl_PREREQ_XMALLOC ]) # Prerequisites of lib/xalloc.h. AC_DEFUN([gl_PREREQ_XALLOC], [ AC_REQUIRE([gl_INLINE]) : ]) # Prerequisites of lib/xmalloc.c. AC_DEFUN([gl_PREREQ_XMALLOC], [ : ]) --- NEW FILE: clock_time.m4 --- # clock_time.m4 serial 10 dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. # Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME. # For a program named, say foo, you should add a line like the following # in the corresponding Makefile.am file: # foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) AC_DEFUN([gl_CLOCK_TIME], [ dnl Persuade glibc and Solaris <time.h> to declare these functions. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* # programs in the package would end up linked with that potentially-shared # library, inducing unnecessary run-time overhead. LIB_CLOCK_GETTIME= AC_SUBST([LIB_CLOCK_GETTIME]) gl_saved_libs=$LIBS AC_SEARCH_LIBS([clock_gettime], [rt posix4], [test "$ac_cv_search_clock_gettime" = "none required" || LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime]) AC_CHECK_FUNCS([clock_gettime clock_settime]) LIBS=$gl_saved_libs ]) --- NEW FILE: getdate.m4 --- # getdate.m4 serial 16 dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Define HAVE_COMPOUND_LITERALS if the C compiler supports compound literals dnl as in ISO C99. dnl Note that compound literals such as (struct s) { 3, 4 } can be used for dnl initialization of stack-allocated variables, but are not constant dnl expressions and therefore cannot be used as initializer for global or dnl static variables (even though gcc supports this in pre-C99 mode). AC_DEFUN([gl_C_COMPOUND_LITERALS], [ AC_CACHE_CHECK([for compound literals], [gl_cv_compound_literals], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[struct s { int i, j; };]], [[struct s t = (struct s) { 3, 4 }; if (t.i != 0) return 0;]])], gl_cv_compound_literals=yes, gl_cv_compound_literals=no)]) if test $gl_cv_compound_literals = yes; then AC_DEFINE([HAVE_COMPOUND_LITERALS], [1], [Define if you have compound literals.]) fi ]) AC_DEFUN([gl_GETDATE], [ dnl Prerequisites of lib/getdate.h. AC_REQUIRE([AM_STDBOOL_H]) AC_REQUIRE([gl_TIMESPEC]) dnl Prerequisites of lib/getdate.y. AC_REQUIRE([gl_BISON]) AC_REQUIRE([gl_C_COMPOUND_LITERALS]) AC_STRUCT_TIMEZONE AC_REQUIRE([gl_CLOCK_TIME]) AC_REQUIRE([gl_TM_GMTOFF]) AC_COMPILE_IFELSE( [AC_LANG_SOURCE([[ #include <time.h> /* for time_t */ #include <limits.h> /* for CHAR_BIT, LONG_MIN, LONG_MAX */ #define TYPE_MINIMUM(t) \ ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) #define TYPE_MAXIMUM(t) \ ((t) ((t) 0 < (t) -1 ? (t) -1 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) typedef int verify_min[2 * (LONG_MIN <= TYPE_MINIMUM (time_t)) - 1]; typedef int verify_max[2 * (TYPE_MAXIMUM (time_t) <= LONG_MAX) - 1]; ]])], [AC_DEFINE([TIME_T_FITS_IN_LONG_INT], [1], [Define to 1 if all 'time_t' values fit in a 'long int'.]) ]) ]) --- NEW FILE: inline.m4 --- # inline.m4 serial 4 dnl Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Test for the 'inline' keyword or equivalent. dnl Define 'inline' to a supported equivalent, or to nothing if not supported, dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an dnl equivalent is effectively supported, i.e. if the compiler is likely to dnl drop unused 'static inline' functions. AC_DEFUN([gl_INLINE], [ AC_REQUIRE([AC_C_INLINE]) AC_CACHE_CHECK([whether the compiler generally respects inline], [gl_cv_c_inline_effective], [if test $ac_cv_c_inline = no; then gl_cv_c_inline_effective=no else dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is dnl specified. dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result dnl depends on optimization flags, which can be in CFLAGS. dnl (AC_EGREP_CPP looks only at the CPPFLAGS.) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[]], [[#ifdef __NO_INLINE__ #error "inline is not effective" #endif]])], [gl_cv_c_inline_effective=yes], [gl_cv_c_inline_effective=no]) fi ]) if test $gl_cv_c_inline_effective = yes; then AC_DEFINE([HAVE_INLINE], [1], [Define to 1 if the compiler supports one of the keywords 'inline', '__inline__', '__inline' and effectively inlines functions marked as such.]) fi ]) Index: gnulib-comp.m4 =================================================================== RCS file: /cvsroot/clisp/clisp/modules/syscalls/glm4/gnulib-comp.m4,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- gnulib-comp.m4 28 Sep 2010 18:43:29 -0000 1.12 +++ gnulib-comp.m4 29 Sep 2010 13:24:14 -0000 1.13 @@ -29,7 +29,12 @@ # Code from module alignof: # Code from module arg-nonnull: # Code from module c++defs: + # Code from module c-ctype: + # Code from module clock-time: + # Code from module getdate: # Code from module gethostname: + # Code from module gettime: + # Code from module inline: # Code from module intprops: # Code from module mbrlen: # Code from module mktime: @@ -45,9 +50,11 @@ # Code from module sys_utsname: # Code from module time: # Code from module time_r: + # Code from module timespec: # Code from module uname: # Code from module unistd: # Code from module warn-on-use: + # Code from module xalloc: ]) # This macro should be invoked from ./configure.ac, in the section @@ -69,9 +76,18 @@ # Code from module alignof: # Code from module arg-nonnull: # Code from module c++defs: + # Code from module c-ctype: + # Code from module clock-time: + gl_CLOCK_TIME + # Code from module getdate: + gl_GETDATE # Code from module gethostname: gl_FUNC_GETHOSTNAME gl_UNISTD_MODULE_INDICATOR([gethostname]) + # Code from module gettime: + gl_GETTIME + # Code from module inline: + gl_INLINE # Code from module intprops: # Code from module mbrlen: gl_FUNC_MBRLEN @@ -109,13 +125,16 @@ # Code from module time_r: gl_TIME_R gl_TIME_MODULE_INDICATOR([time_r]) + # Code from module timespec: + gl_TIMESPEC # Code from module uname: gl_FUNC_UNAME gl_SYS_UTSNAME_MODULE_INDICATOR([uname]) # Code from module unistd: gl_UNISTD_H # Code from module warn-on-use: - # Code from module dummy: + # Code from module xalloc: + gl_XALLOC # End of code from modules m4_ifval(sc_gl_LIBSOURCES_LIST, [ m4_syscmd([test ! -d ]m4_defn([sc_gl_LIBSOURCES_DIR])[ || @@ -259,9 +278,14 @@ build-aux/arg-nonnull.h build-aux/c++defs.h build-aux/warn-on-use.h + doc/getdate.texi lib/alignof.h - lib/dummy.c + lib/c-ctype.c + lib/c-ctype.h + lib/getdate.h + lib/getdate.y lib/gethostname.c + lib/gettime.c lib/intprops.h lib/mbrlen.c lib/mktime-internal.h @@ -279,12 +303,20 @@ lib/sys_utsname.in.h lib/time.in.h lib/time_r.c + lib/timespec.h lib/uname.c lib/unistd.in.h lib/w32sock.h + lib/xalloc.h + lib/xmalloc.c m4/00gnulib.m4 + m4/bison.m4 + m4/clock_time.m4 + m4/getdate.m4 m4/gethostname.m4 + m4/gettime.m4 m4/gnulib-common.m4 + m4/inline.m4 m4/mbrlen.m4 m4/mbstate_t.m4 m4/mktime.m4 @@ -301,9 +333,11 @@ m4/sys_utsname_h.m4 m4/time_h.m4 m4/time_r.m4 + m4/timespec.m4 m4/tm_gmtoff.m4 m4/uname.m4 m4/unistd_h.m4 m4/warn-on-use.m4 m4/wchar_t.m4 + m4/xalloc.m4 ]) --- NEW FILE: bison.m4 --- # serial 5 # Copyright (C) 2002, 2005, 2009, 2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_BISON], [ # getdate.y works with bison only. : ${YACC='bison -y'} dnl dnl Declaring YACC & YFLAGS precious will not be necessary after GNULIB dnl requires an Autoconf greater than 2.59c, but it will probably still be dnl useful to override the description of YACC in the --help output, re dnl getdate.y assuming `bison -y'. AC_ARG_VAR([YACC], [The `Yet Another C Compiler' implementation to use. Defaults to `bison -y'. Values other than `bison -y' will most likely break on most systems.])dnl AC_ARG_VAR([YFLAGS], [YFLAGS contains the list arguments that will be passed by default to Bison. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications.])dnl ]) Index: gnulib-cache.m4 =================================================================== RCS file: /cvsroot/clisp/clisp/modules/syscalls/glm4/gnulib-cache.m4,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- gnulib-cache.m4 28 Sep 2010 18:43:29 -0000 1.11 +++ gnulib-cache.m4 29 Sep 2010 13:24:14 -0000 1.12 @@ -15,11 +15,12 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=modules/syscalls/gllib --m4-base=modules/syscalls/glm4 --doc-base=doc --tests-base=tests --aux-dir=src/build-aux --avoid=no-c++ --avoid=stdint --avoid=stdbool --avoid=havelib --avoid=gettext --avoid=localcharset --avoid=uniwidth/width --avoid=streq --avoid=uniname/uniname --avoid=unitypes --avoid=link-follow --avoid=host-cpu-c-abi --avoid=socklen --avoid=sockets --avoid=close-hook --avoid=setenv --avoid=unsetenv --avoid=errno --avoid=nocrash --avoid=libsigsegv --avoid=gnu-make --avoid=gettimeofday --avoid=getpagesize --avoid=sys_time --avoid=sys_wait --avoid=alloca-opt --avoid=alloca --avoid=extensions --avoid=include_next --avoid=verify --avoid=string --avoid=mbsinit --avoid=wchar --avoid=wctype --avoid=mbrtowc --avoid=mbsrtowcs --avoid=memchr --avoid=nl_langinfo --no-libtool --macro-prefix=sc_gl --no-vc-files mktime strerror strftime strptime strverscmp uname +# gnulib-tool --import --dir=. --lib=libgnu --source-base=modules/syscalls/gllib --m4-base=modules/syscalls/glm4 --doc-base=doc --tests-base=tests --aux-dir=src/build-aux --avoid=no-c++ --avoid=stdint --avoid=stdbool --avoid=havelib --avoid=gettext --avoid=localcharset --avoid=uniwidth/width --avoid=streq --avoid=uniname/uniname --avoid=unitypes --avoid=link-follow --avoid=host-cpu-c-abi --avoid=socklen --avoid=sockets --avoid=close-hook --avoid=setenv --avoid=unsetenv --avoid=errno --avoid=nocrash --avoid=libsigsegv --avoid=gnu-make --avoid=gettimeofday --avoid=getpagesize --avoid=sys_time --avoid=sys_wait --avoid=alloca-opt --avoid=alloca --avoid=extensions --avoid=include_next --avoid=verify --avoid=string --avoid=mbsinit --avoid=wchar --avoid=wctype --avoid=mbrtowc --avoid=mbsrtowcs --avoid=memchr --avoid=nl_langinfo --avoid=xalloc-die --no-libtool --macro-prefix=sc_gl --no-vc-files getdate mktime strerror strftime strptime strverscmp uname # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) gl_MODULES([ + getdate mktime strerror strftime @@ -27,7 +28,7 @@ strverscmp uname ]) -gl_AVOID([ no-c++ stdint stdbool havelib gettext localcharset uniwidth/width streq uniname/uniname unitypes link-follow host-cpu-c-abi socklen sockets close-hook setenv unsetenv errno nocrash libsigsegv gnu-make gettimeofday getpagesize sys_time sys_wait alloca-opt alloca extensions include_next verify string mbsinit wchar wctype mbrtowc mbsrtowcs memchr nl_langinfo]) +gl_AVOID([ no-c++ stdint stdbool havelib gettext localcharset uniwidth/width streq uniname/uniname unitypes link-follow host-cpu-c-abi socklen sockets close-hook setenv unsetenv errno nocrash libsigsegv gnu-make gettimeofday getpagesize sys_time sys_wait alloca-opt alloca extensions include_next verify string mbsinit wchar wctype mbrtowc mbsrtowcs memchr nl_langinfo xalloc-die]) gl_SOURCE_BASE([modules/syscalls/gllib]) gl_M4_BASE([modules/syscalls/glm4]) gl_PO_BASE([]) --- NEW FILE: gettime.m4 --- # gettime.m4 serial 7 dnl Copyright (C) 2002, 2004-2006, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_GETTIME], [ AC_LIBOBJ([gettime]) dnl Prerequisites of lib/gettime.c. AC_REQUIRE([gl_CLOCK_TIME]) AC_REQUIRE([gl_TIMESPEC]) AC_CHECK_FUNCS_ONCE([gettimeofday nanotime]) ]) --- NEW FILE: error.m4 --- #serial 13 # Copyright (C) 1996-1998, 2001-2004, 2009-2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_ERROR], [ AC_FUNC_ERROR_AT_LINE dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]). gl_PREREQ_ERROR ]) # Redefine AC_FUNC_ERROR_AT_LINE, because it is no longer maintained in # Autoconf. AC_DEFUN([AC_FUNC_ERROR_AT_LINE], [ AC_LIBSOURCES([error.h, error.c])dnl AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include <error.h>]], [[error_at_line (0, 0, "", 0, "an error occurred");]])], [ac_cv_lib_error_at_line=yes], [ac_cv_lib_error_at_line=no])]) if test $ac_cv_lib_error_at_line = no; then AC_LIBOBJ([error]) fi ]) # Prerequisites of lib/error.c. AC_DEFUN([gl_PREREQ_ERROR], [ AC_REQUIRE([AC_FUNC_STRERROR_R]) AC_REQUIRE([AC_C_INLINE]) : ]) --- NEW FILE: timespec.m4 --- #serial 14 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. dnl From Jim Meyering AC_DEFUN([gl_TIMESPEC], [ dnl Prerequisites of lib/timespec.h. AC_REQUIRE([AC_C_INLINE]) ]) ------------------------------ Message: 2 Date: Wed, 29 Sep 2010 13:24:16 +0000 From: Sam Steingold <sd...@us...> Subject: clisp/src ChangeLog,1.7533,1.7534 NEWS,1.548,1.549 To: cli...@li... Message-ID: <E1P...@sf...> Update of /cvsroot/clisp/clisp/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5536/src Modified Files: ChangeLog NEWS Log Message: implement POSIX:GETDATE using gnulib * Makefile.devel (gnulib-imported): import getdate into syscalls * modules/syscalls/calls.c (tm_to_lisp): extract from STRING-TIME (POSIX:GETDATE, xalloc_die): implement * modules/syscalls/configure.in: call gl_GETDATE Index: NEWS =================================================================== RCS file: /cvsroot/clisp/clisp/src/NEWS,v retrieving revision 1.548 retrieving revision 1.549 diff -u -d -r1.548 -r1.549 --- NEWS 28 Sep 2010 20:40:40 -0000 1.548 +++ NEWS 29 Sep 2010 13:24:14 -0000 1.549 @@ -27,6 +27,9 @@ * New function POSIX:FILE-TREE-WALK calls nftw(). See <http://clisp.cons.org/impnotes/syscalls.html#file-tree-walk> for details. +* New function POSIX:GETDATE calls getdate(). + See <http://clisp.cons.org/impnotes/syscalls.html#getdate> for details + * FFI now converts REALs to FLOATs automatically as necessary. * Bug fixes: Index: ChangeLog =================================================================== RCS file: /cvsroot/clisp/clisp/src/ChangeLog,v retrieving revision 1.7533 retrieving revision 1.7534 diff -u -d -r1.7533 -r1.7534 --- ChangeLog 28 Sep 2010 20:40:40 -0000 1.7533 +++ ChangeLog 29 Sep 2010 13:24:14 -0000 1.7534 @@ -1,5 +1,22 @@ 2010-09-28 Sam Steingold <sd...@gn...> + implement POSIX:GETDATE using gnulib + * Makefile.devel (gnulib-imported): import getdate into syscalls + * modules/syscalls/calls.c (tm_to_lisp): extract from STRING-TIME + (POSIX:GETDATE, xalloc_die): implement + * modules/syscalls/configure.in: call gl_GETDATE + * modules/syscalls/gllib/c-ctype.c, modules/syscalls/gllib/c-ctype.h: + * modules/syscalls/gllib/getdate.h, modules/syscalls/gllib/getdate.y: + * modules/syscalls/gllib/gettext.h, modules/syscalls/gllib/gettime.c: + * modules/syscalls/gllib/timespec.h, modules/syscalls/gllib/xalloc.h: + * modules/syscalls/gllib/xmalloc.c, modules/syscalls/glm4/bison.m4: + * modules/syscalls/glm4/clock_time.m4, modules/syscalls/glm4/error.m4: + * modules/syscalls/glm4/getdate.m4, modules/syscalls/glm4/gettime.m4: + * modules/syscalls/glm4/inline.m4, modules/syscalls/glm4/timespec.m4: + * modules/syscalls/glm4/xalloc.m4: add + +2010-09-28 Sam Steingold <sd...@gn...> + fix bug#3076160: pass the top-level configure arguments --build= & --host= to the module configures * makemake.in (module_configure_flags): ------------------------------ Message: 3 Date: Wed, 29 Sep 2010 13:24:16 +0000 From: Sam Steingold <sd...@us...> Subject: clisp Makefile.devel,1.283,1.284 To: cli...@li... Message-ID: <E1P...@sf...> Update of /cvsroot/clisp/clisp In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5536 Modified Files: Makefile.devel Log Message: implement POSIX:GETDATE using gnulib * Makefile.devel (gnulib-imported): import getdate into syscalls * modules/syscalls/calls.c (tm_to_lisp): extract from STRING-TIME (POSIX:GETDATE, xalloc_die): implement * modules/syscalls/configure.in: call gl_GETDATE Index: Makefile.devel =================================================================== RCS file: /cvsroot/clisp/clisp/Makefile.devel,v retrieving revision 1.283 retrieving revision 1.284 diff -u -d -r1.283 -r1.284 --- Makefile.devel 28 Sep 2010 19:26:41 -0000 1.283 +++ Makefile.devel 29 Sep 2010 13:24:14 -0000 1.284 @@ -397,8 +397,10 @@ $(GNULIB_COMMON) | tee -a $(GNULIB_IMPORTED_LOG) $(GNULIB_TOOL) --source-base=modules/syscalls/gllib \ --macro-prefix=sc_gl --m4-base=modules/syscalls/glm4 \ - $(GNULIB_AVOID) mktime strftime strptime strverscmp uname \ - strerror | tee -a $(GNULIB_IMPORTED_LOG) + $(GNULIB_AVOID) --avoid=xalloc-die \ + mktime strftime strptime strverscmp uname \ + strerror getdate | tee -a $(GNULIB_IMPORTED_LOG) + $(RM) doc/getdate.texi $(GNULIB_TOOL) --source-base=modules/regexp/gllib \ --macro-prefix=rx_gl --m4-base=modules/regexp/glm4 \ $(GNULIB_AVOID) regex | tee -a $(GNULIB_IMPORTED_LOG) ------------------------------ Message: 4 Date: Wed, 29 Sep 2010 13:24:16 +0000 From: Sam Steingold <sd...@us...> Subject: clisp/modules/syscalls calls.c, 1.315, 1.316 configure.in, 1.92, 1.93 syscalls.xml, 1.134, 1.135 To: cli...@li... Message-ID: <E1P...@sf...> Update of /cvsroot/clisp/clisp/modules/syscalls In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5536/modules/syscalls Modified Files: calls.c configure.in syscalls.xml Log Message: implement POSIX:GETDATE using gnulib * Makefile.devel (gnulib-imported): import getdate into syscalls * modules/syscalls/calls.c (tm_to_lisp): extract from STRING-TIME (POSIX:GETDATE, xalloc_die): implement * modules/syscalls/configure.in: call gl_GETDATE Index: calls.c =================================================================== RCS file: /cvsroot/clisp/clisp/modules/syscalls/calls.c,v retrieving revision 1.315 retrieving revision 1.316 diff -u -d -r1.315 -r1.316 --- calls.c 28 Sep 2010 18:43:29 -0000 1.315 +++ calls.c 29 Sep 2010 13:24:14 -0000 1.316 @@ -547,6 +547,17 @@ #endif /* HAVE_SYSLOG */ /* ========================== time conversion ========================== */ +/* call ENCODE-UNIVERSAL-TIME on struct tm and timezone */ +static Values tm_to_lisp (struct tm *tm, object timezone) { + pushSTACK(fixnum(tm.tm_sec)); + pushSTACK(fixnum(tm.tm_min)); + pushSTACK(fixnum(tm.tm_hour)); + pushSTACK(fixnum(tm.tm_mday)); + pushSTACK(fixnum(1+tm.tm_mon)); + pushSTACK(fixnum(1900+tm.tm_year)); + pushSTACK(timezone); + funcall(S(encode_universal_time),7); +} DEFUN(POSIX:STRING-TIME, format &optional datum timezone) { /* http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html http://www.opengroup.org/onlinepubs/009695399/functions/strftime.html */ @@ -572,15 +583,7 @@ pushSTACK(TheSubr(subr_self)->name); error(error_condition,GETTEXT("~S: invalid format ~S or datum ~S")); } - pushSTACK(fixnum(tm.tm_sec)); - pushSTACK(fixnum(tm.tm_min)); - pushSTACK(fixnum(tm.tm_hour)); - pushSTACK(fixnum(tm.tm_mday)); - pushSTACK(fixnum(1+tm.tm_mon)); - pushSTACK(fixnum(1900+tm.tm_year)); - pushSTACK(STACK_(0+6)); /* timezone */ - funcall(S(encode_universal_time),7); - /* value1 from ENCODE-UNIVERSAL-TIME */ + tm_to_lisp(&tm,STACK_0); /* set value1 */ value2 = tm.tm_isdst > 0 ? T : NIL; value3 = fixnum(offset); mv_count = 3; @@ -616,6 +619,34 @@ } else error_string_integer(STACK_1); } +nonreturning_function(extern, xalloc_die, (void)) { + pushSTACK(TheSubr(subr_self)->name); + error(storage_condition,GETTEXT("~S: malloc() failed")); +} + +DEFUN(POSIX:GETDATE, timespec &optional timezone) +{ /* http://www.opengroup.org/onlinepubs/009695399/functions/getdate.html */ + struct tm *tm; + getdate_restart: + STACK_1 = check_string(STACK_1); + with_string_0(STACK_1,GLO(misc_encoding),timespec, { + begin_system_call(); + tm = getdate(timespec); + end_system_call(); + }); + if (tm == NULL) { + pushSTACK(NIL); /* no PLACE */ + pushSTACK(fixnum(getdate_err)); + pushSTACK(STACK_(1+2)); + pushSTACK(TheSubr(subr_self)->name); + check_value(error_condition,GETTEXT("~S(~S): getdate error ~S")); + STACK_1 = value1; + goto getdate_restart; + } + tm_to_lisp(tm,STACK_0); + skipSTACK(2); +} + /* ========================== string comparison ========================== */ /* call strverscmp() on STACK_0 & STACK_1 and remove them from STACK */ static /*maygc*/ int string_version_compare (void) { Index: syscalls.xml =================================================================== RCS file: /cvsroot/clisp/clisp/modules/syscalls/syscalls.xml,v retrieving revision 1.134 retrieving revision 1.135 diff -u -d -r1.134 -r1.135 --- syscalls.xml 21 Sep 2010 16:09:48 -0000 1.134 +++ syscalls.xml 29 Sep 2010 13:24:14 -0000 1.135 @@ -821,15 +821,21 @@ <listitem><simpara>Calls <function role="unix">setutxent</function>. </simpara></listitem></varlistentry></variablelist></section> -<section id="strtime"><title>Time conversion</title> -<para><code>(OS:STRING-TIME &fmt-r; &optional-amp; &object-r; timezone)</code> - <itemizedlist><listitem><simpara>When &object-r; is a &string-t;, is is - parsed according to &fmt-r; by <function role="unix">strptime</function>. - </simpara></listitem><listitem><simpara>When it is an &integer-t;, it - is formatted according to &fmt-r; by - <function role="unix">strftime</function>. +<section id="posix-time"><title>Time and Data Conversion</title> +<variablelist><varlistentry id="strtime"><term><code>(OS:STRING-TIME + &fmt-r; &optional-amp; &object-r; timezone)</code></term> + <listitem><itemizedlist><listitem><simpara>When &object-r; is a &string-t;, + it is parsed into a universal time according to &fmt-r; by + <function role="unix">strptime</function>.</simpara></listitem> + <listitem><simpara>When it is an &integer-t;, it is formatted according + to &fmt-r; by <function role="unix">strftime</function>. &object-r; defaults to <code>(&get-universal-time;)</code>. -</simpara></listitem></itemizedlist></para></section> +</simpara></listitem></itemizedlist></listitem></varlistentry> +<varlistentry id="getdate"><term><code>(OS:GETDATE &string-r; + &optional-amp; timezone)</code></term> + <listitem><simpara>Parse the &string-r; into a universal time using + <function role="unix">getdate</function>.</simpara></listitem></varlistentry> +</variablelist></section> <section id="strverscmp"><title>String comparision</title> <para>Functions <simplelist columns="1"> Index: configure.in =================================================================== RCS file: /cvsroot/clisp/clisp/modules/syscalls/configure.in,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- configure.in 28 Sep 2010 18:43:29 -0000 1.92 +++ configure.in 29 Sep 2010 13:24:14 -0000 1.93 @@ -57,6 +57,7 @@ gl_FUNC_GNU_STRFTIME gl_FUNC_STRPTIME gl_TIME_MODULE_INDICATOR([strptime]) +gl_GETDATE gl_FUNC_STRVERSCMP gl_STRING_MODULE_INDICATOR([strverscmp]) gl_FUNC_UNAME ------------------------------ Message: 5 Date: Wed, 29 Sep 2010 13:24:16 +0000 From: Sam Steingold <sd...@us...> Subject: clisp/modules/syscalls/gllib c-ctype.c, NONE, 1.1 c-ctype.h, NONE, 1.1 getdate.h, NONE, 1.1 getdate.y, NONE, 1.1 gettext.h, NONE, 1.1 gettime.c, NONE, 1.1 timespec.h, NONE, 1.1 xalloc.h, NONE, 1.1 xmalloc.c, NONE, 1.1 Makefile.am, 1.19, 1.20 To: cli...@li... Message-ID: <E1P...@sf...> Update of /cvsroot/clisp/clisp/modules/syscalls/gllib In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5536/modules/syscalls/gllib Modified Files: Makefile.am Added Files: c-ctype.c c-ctype.h getdate.h getdate.y gettext.h gettime.c timespec.h xalloc.h xmalloc.c Log Message: implement POSIX:GETDATE using gnulib * Makefile.devel (gnulib-imported): import getdate into syscalls * modules/syscalls/calls.c (tm_to_lisp): extract from STRING-TIME (POSIX:GETDATE, xalloc_die): implement * modules/syscalls/configure.in: call gl_GETDATE --- NEW FILE: c-ctype.h --- /* Character handling in C locale. These functions work like the corresponding functions in <ctype.h>, except that they have the C (POSIX) locale hardwired, whereas the <ctype.h> functions' behaviour depends on the current locale set via setlocale. Copyright (C) 2000-2003, 2006, 2008-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef C_CTYPE_H #define C_CTYPE_H #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif /* The functions defined in this file assume the "C" locale and a character set without diacritics (ASCII-US or EBCDIC-US or something like that). Even if the "C" locale on a particular system is an extension of the ASCII character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it is ISO-8859-1), the functions in this file recognize only the ASCII characters. */ /* Check whether the ASCII optimizations apply. */ /* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that '0', '1', ..., '9' have consecutive integer values. */ #define C_CTYPE_CONSECUTIVE_DIGITS 1 #if ('A' <= 'Z') \ && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \ && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \ && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \ && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \ && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \ && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \ && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \ && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \ && ('Y' + 1 == 'Z') #define C_CTYPE_CONSECUTIVE_UPPERCASE 1 #endif #if ('a' <= 'z') \ && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \ && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \ && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \ && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \ && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \ && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \ && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \ && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \ && ('y' + 1 == 'z') #define C_CTYPE_CONSECUTIVE_LOWERCASE 1 #endif #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126) /* The character set is ASCII or one of its variants or extensions, not EBCDIC. Testing the value of '\n' and '\r' is not relevant. */ #define C_CTYPE_ASCII 1 #endif /* Function declarations. */ /* Unlike the functions in <ctype.h>, which require an argument in the range of the 'unsigned char' type, the functions here operate on values that are in the 'unsigned char' range or in the 'char' range. In other words, when you have a 'char' value, you need to cast it before using it as argument to a <ctype.h> function: const char *s = ...; if (isalpha ((unsigned char) *s)) ... but you don't need to cast it for the functions defined in this file: const char *s = ...; if (c_isalpha (*s)) ... */ extern bool c_isascii (int c); /* not locale dependent */ extern bool c_isalnum (int c); extern bool c_isalpha (int c); extern bool c_isblank (int c); extern bool c_iscntrl (int c); extern bool c_isdigit (int c); extern bool c_islower (int c); extern bool c_isgraph (int c); extern bool c_isprint (int c); extern bool c_ispunct (int c); extern bool c_isspace (int c); extern bool c_isupper (int c); extern bool c_isxdigit (int c); extern int c_tolower (int c); extern int c_toupper (int c); #if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS /* ASCII optimizations. */ #undef c_isascii #define c_isascii(c) \ ({ int __c = (c); \ (__c >= 0x00 && __c <= 0x7f); \ }) #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII #undef c_isalnum #define c_isalnum(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \ }) #else #undef c_isalnum #define c_isalnum(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || (__c >= 'A' && __c <= 'Z') \ || (__c >= 'a' && __c <= 'z')); \ }) #endif #endif #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII #undef c_isalpha #define c_isalpha(c) \ ({ int __c = (c); \ ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \ }) #else #undef c_isalpha #define c_isalpha(c) \ ({ int __c = (c); \ ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \ }) #endif #endif #undef c_isblank #define c_isblank(c) \ ({ int __c = (c); \ (__c == ' ' || __c == '\t'); \ }) #if C_CTYPE_ASCII #undef c_iscntrl #define c_iscntrl(c) \ ({ int __c = (c); \ ((__c & ~0x1f) == 0 || __c == 0x7f); \ }) #endif #if C_CTYPE_CONSECUTIVE_DIGITS #undef c_isdigit #define c_isdigit(c) \ ({ int __c = (c); \ (__c >= '0' && __c <= '9'); \ }) #endif #if C_CTYPE_CONSECUTIVE_LOWERCASE #undef c_islower #define c_islower(c) \ ({ int __c = (c); \ (__c >= 'a' && __c <= 'z'); \ }) #endif #if C_CTYPE_ASCII #undef c_isgraph #define c_isgraph(c) \ ({ int __c = (c); \ (__c >= '!' && __c <= '~'); \ }) #endif #if C_CTYPE_ASCII #undef c_isprint #define c_isprint(c) \ ({ int __c = (c); \ (__c >= ' ' && __c <= '~'); \ }) #endif #if C_CTYPE_ASCII #undef c_ispunct #define c_ispunct(c) \ ({ int _c = (c); \ (c_isgraph (_c) && ! c_isalnum (_c)); \ }) #endif #undef c_isspace #define c_isspace(c) \ ({ int __c = (c); \ (__c == ' ' || __c == '\t' \ || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \ }) #if C_CTYPE_CONSECUTIVE_UPPERCASE #undef c_isupper #define c_isupper(c) \ ({ int __c = (c); \ (__c >= 'A' && __c <= 'Z'); \ }) #endif #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII #undef c_isxdigit #define c_isxdigit(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \ }) #else #undef c_isxdigit #define c_isxdigit(c) \ ({ int __c = (c); \ ((__c >= '0' && __c <= '9') \ || (__c >= 'A' && __c <= 'F') \ || (__c >= 'a' && __c <= 'f')); \ }) #endif #endif #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #undef c_tolower #define c_tolower(c) \ ({ int __c = (c); \ (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \ }) #undef c_toupper #define c_toupper(c) \ ({ int __c = (c); \ (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \ }) #endif #endif /* optimizing for speed */ #ifdef __cplusplus } #endif #endif /* C_CTYPE_H */ --- NEW FILE: getdate.y --- %{ /* Parse a string into an internal time stamp. Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ [...1533 lines suppressed...] if (! get_date (&d, buff, NULL)) printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (&d.tv_sec))) { long int sec = d.tv_sec; printf ("localtime (%ld) failed\n", sec); } else { int ns = d.tv_nsec; printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, ns); } printf ("\t> "); fflush (stdout); } return 0; } #endif /* TEST */ --- NEW FILE: gettime.c --- /* gettime -- get the system clock Copyright (C) 2002, 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* Written by Paul Eggert. */ #include <config.h> #include "timespec.h" #include <sys/time.h> /* Get the system time into *TS. */ void gettime (struct timespec *ts) { #if HAVE_NANOTIME nanotime (ts); #else # if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME if (clock_gettime (CLOCK_REALTIME, ts) == 0) return; # endif { struct timeval tv; gettimeofday (&tv, NULL); ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * 1000; } #endif } --- NEW FILE: xmalloc.c --- /* xmalloc.c -- malloc with out of memory checking Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #if ! HAVE_INLINE # define static_inline #endif #include "xalloc.h" #undef static_inline #include <stdlib.h> #include <string.h> /* 1 if calloc is known to be compatible with GNU calloc. This matters if we are not also using the calloc module, which defines HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ #if defined HAVE_CALLOC_GNU || defined __GLIBC__ enum { HAVE_GNU_CALLOC = 1 }; #else enum { HAVE_GNU_CALLOC = 0 }; #endif /* Allocate N bytes of memory dynamically, with error checking. */ void * xmalloc (size_t n) { void *p = malloc (n); if (!p && n != 0) xalloc_die (); return p; } /* Change the size of an allocated block of memory P to N bytes, with error checking. */ void * xrealloc (void *p, size_t n) { p = realloc (p, n); if (!p && n != 0) xalloc_die (); return p; } /* If P is null, allocate a block of at least *PN bytes; otherwise, reallocate P so that it contains more than *PN bytes. *PN must be nonzero unless P is null. Set *PN to the new block's size, and return the pointer to the new block. *PN is never set to zero, and the returned pointer is never null. */ void * x2realloc (void *p, size_t *pn) { return x2nrealloc (p, pn, 1); } /* Allocate S bytes of zeroed memory dynamically, with error checking. There's no need for xnzalloc (N, S), since it would be equivalent to xcalloc (N, S). */ void * xzalloc (size_t s) { return memset (xmalloc (s), 0, s); } /* Allocate zeroed memory for N elements of S bytes, with error checking. S must be nonzero. */ void * xcalloc (size_t n, size_t s) { void *p; /* Test for overflow, since some calloc implementations don't have proper overflow checks. But omit overflow and size-zero tests if HAVE_GNU_CALLOC, since GNU calloc catches overflow and never returns NULL if successful. */ if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s)) || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0))) xalloc_die (); return p; } /* Clone an object P of size S, with error checking. There's no need for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any need for an arithmetic overflow check. */ void * xmemdup (void const *p, size_t s) { return memcpy (xmalloc (s), p, s); } /* Clone STRING. */ char * xstrdup (char const *string) { return xmemdup (string, strlen (string) + 1); } --- NEW FILE: c-ctype.c --- /* Character handling in C locale. Copyright 2000-2003, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <config.h> /* Specification. */ #define NO_C_CTYPE_MACROS #include "c-ctype.h" /* The function isascii is not locale dependent. Its use in EBCDIC is questionable. */ bool c_isascii (int c) { return (c >= 0x00 && c <= 0x7f); } bool c_isalnum (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII return ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')); #else return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); #endif #else switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return 1; default: return 0; } #endif } bool c_isalpha (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'); #else return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); #endif #else switch (c) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return 1; default: return 0; } #endif } bool c_isblank (int c) { return (c == ' ' || c == '\t'); } bool c_iscntrl (int c) { #if C_CTYPE_ASCII return ((c & ~0x1f) == 0 || c == 0x7f); #else switch (c) { case ' ': case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': return 0; default: return 1; } #endif } bool c_isdigit (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS return (c >= '0' && c <= '9'); #else switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return 1; default: return 0; } #endif } bool c_islower (int c) { #if C_CTYPE_CONSECUTIVE_LOWERCASE return (c >= 'a' && c <= 'z'); #else switch (c) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': return 1; default: return 0; } #endif } bool c_isgraph (int c) { #if C_CTYPE_ASCII return (c >= '!' && c <= '~'); #else switch (c) { case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': return 1; default: return 0; } #endif } bool c_isprint (int c) { #if C_CTYPE_ASCII return (c >= ' ' && c <= '~'); #else switch (c) { case ' ': case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': return 1; default: return 0; } #endif } bool c_ispunct (int c) { #if C_CTYPE_ASCII return ((c >= '!' && c <= '~') && !((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'))); #else switch (c) { case '!': case '"': case '#': case '$': case '%': case '&': case '\'': case '(': case ')': case '*': case '+': case ',': case '-': case '.': case '/': case ':': case ';': case '<': case '=': case '>': case '?': case '@': case '[': case '\\': case ']': case '^': case '_': case '`': case '{': case '|': case '}': case '~': return 1; default: return 0; } #endif } bool c_isspace (int c) { return (c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'); } bool c_isupper (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE return (c >= 'A' && c <= 'Z'); #else switch (c) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': return 1; default: return 0; } #endif } bool c_isxdigit (int c) { #if C_CTYPE_CONSECUTIVE_DIGITS \ && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE #if C_CTYPE_ASCII return ((c >= '0' && c <= '9') || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F')); #else return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); #endif #else switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': return 1; default: return 0; } #endif } int c_tolower (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c); #else switch (c) { case 'A': return 'a'; case 'B': return 'b'; case 'C': return 'c'; case 'D': return 'd'; case 'E': return 'e'; case 'F': return 'f'; case 'G': return 'g'; case 'H': return 'h'; case 'I': return 'i'; case 'J': return 'j'; case 'K': return 'k'; case 'L': return 'l'; case 'M': return 'm'; case 'N': return 'n'; case 'O': return 'o'; case 'P': return 'p'; case 'Q': return 'q'; case 'R': return 'r'; case 'S': return 's'; case 'T': return 't'; case 'U': return 'u'; case 'V': return 'v'; case 'W': return 'w'; case 'X': return 'x'; case 'Y': return 'y'; case 'Z': return 'z'; default: return c; } #endif } int c_toupper (int c) { #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c); #else switch (c) { case 'a': return 'A'; case 'b': return 'B'; case 'c': return 'C'; case 'd': return 'D'; case 'e': return 'E'; case 'f': return 'F'; case 'g': return 'G'; case 'h': return 'H'; case 'i': return 'I'; case 'j': return 'J'; case 'k': return 'K'; case 'l': return 'L'; case 'm': return 'M'; case 'n': return 'N'; case 'o': return 'O'; case 'p': return 'P'; case 'q': return 'Q'; case 'r': return 'R'; case 's': return 'S'; case 't': return 'T'; case 'u': return 'U'; case 'v': return 'V'; case 'w': return 'W'; case 'x': return 'X'; case 'y': return 'Y'; case 'z': return 'Z'; default: return c; } #endif } --- NEW FILE: timespec.h --- /* timespec -- System time interface Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #if ! defined TIMESPEC_H # define TIMESPEC_H # include <time.h> /* Return negative, zero, positive if A < B, A == B, A > B, respectively. For each time stamp T, this code assumes that either: * T.tv_nsec is in the range 0..999999999; or * T.tv_sec corresponds to a valid leap second on a host that supports leap seconds, and T.tv_nsec is in the range 1000000000..1999999999; or * T.tv_sec is the minimum time_t value and T.tv_nsec is -1; or T.tv_sec is the maximum time_t value and T.tv_nsec is 2000000000. This allows for special struct timespec values that are less or greater than all possible valid time stamps. In all these cases, it is safe to subtract two tv_nsec values and convert the result to integer without worrying about overflow on any platform of interest to the GNU project, since all such platforms have 32-bit int or wider. Replacing "(int) (a.tv_nsec - b.tv_nsec)" with something like "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause this function to work in some cases where the above assumption is violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the extra instructions. Using a subtraction has the advantage of detecting some invalid cases on platforms that detect integer overflow. The (int) cast avoids a gcc -Wconversion warning. */ static inline int timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 : a.tv_sec > b.tv_sec ? 1 : (int) (a.tv_nsec - b.tv_nsec)); } void gettime (struct timespec *); int settime (struct timespec const *); #endif --- NEW FILE: getdate.h --- /* Parse a string into an internal time stamp. Copyright (C) 1995, 1997, 1998, 2003, 2004, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdbool.h> #include <time.h> bool get_date (struct timespec *, char const *, struct timespec const *); --- NEW FILE: xalloc.h --- /* xalloc.h -- malloc with out-of-memory checking Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef XALLOC_H_ # define XALLOC_H_ # include <stddef.h> # ifdef __cplusplus extern "C" { # endif # ifndef __attribute__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) # define __attribute__(x) # endif # endif # ifndef ATTRIBUTE_NORETURN # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # endif # ifndef ATTRIBUTE_MALLOC # if __GNUC__ >= 3 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) # else # define ATTRIBUTE_MALLOC # endif # endif /* This function is always triggered when memory is exhausted. It must be defined by the application, either explicitly or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ ... [truncated message content] |