shishi-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS shishi/gl


From: shishi-commit
Subject: CVS shishi/gl
Date: Wed, 12 Oct 2005 15:24:41 +0200

Update of /home/cvs/shishi/gl
In directory dopio:/tmp/cvs-serv26416

Modified Files:
        Makefile.am getaddrinfo.c getaddrinfo.h getdate.y getdelim.c 
        getopt_.h strcasecmp.c strncasecmp.c xgethostname.c 
        xreadlink.c 
Added Files:
        gc-gnulib.c gc-libgcrypt.c gc-pbkdf2-sha1.c gc.h hmac-sha1.c 
        hmac.h memxor.c memxor.h sha1.c sha1.h stdint_.h 
Log Message:
Add.

--- /home/cvs/shishi/gl/Makefile.am     2005/09/20 09:23:20     1.68
+++ /home/cvs/shishi/gl/Makefile.am     2005/10/12 13:24:41     1.69
@@ -8,7 +8,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl 
--m4-base=gl/m4 --aux-dir=. --avoid=xalloc-die --libtool --macro-prefix=gl 
base64 error getaddrinfo getdate gethostname getline getopt getpass getsubopt 
progname realloc setenv socklen strcase strchrnul strdup strndup strtok_r 
timegm vasnprintf vasprintf xalloc xgetdomainname xgethostname xreadlink 
xstrndup xvasprintf
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl 
--m4-base=gl/m4 --aux-dir=. --avoid=xalloc-die --libtool --macro-prefix=gl 
base64 error gc-pbkdf2-sha1 getaddrinfo getdate gethostname getline getopt 
getpass getsubopt progname realloc setenv socklen strcase strchrnul strdup 
strndup strtok_r timegm vasnprintf vasprintf xalloc xgetdomainname xgethostname 
xreadlink xstrndup xvasprintf
 
 AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
 
@@ -51,6 +51,12 @@
 
 ## end   gnulib module base64
 
+## begin gnulib module gc
+
+libgnu_la_LIBADD += $(LIBGCRYPT)
+
+## end   gnulib module gc
+
 ## begin gnulib module getaddrinfo
 
 libgnu_la_SOURCES += getaddrinfo.h
@@ -99,7 +105,7 @@
 
 ## begin gnulib module mbchar
 
-libgnu_la_SOURCES += mbchar.h mbchar.c
+libgnu_la_SOURCES += mbchar.h
 
 ## end   gnulib module mbchar
 
@@ -141,6 +147,20 @@
 
 ## end   gnulib module stdbool
 
+## begin gnulib module stdint
+
+BUILT_SOURCES += $(STDINT_H)
+EXTRA_DIST += stdint_.h
+
+# We need the following in order to create <stdint.h> when the system
+# doesn't have one that works with the given compiler.
+stdint.h: stdint_.h
+       sed -e 
's/@''HAVE_LONG_64BIT''@/$(HAVE_LONG_64BIT)/g;s/@''HAVE_LONG_LONG_64BIT@/$(HAVE_LONG_LONG_64BIT)/g'
 < $(srcdir)/stdint_.h > address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += stdint.h stdint.h-t
+
+## end   gnulib module stdint
+
 ## begin gnulib module strcase
 
 libgnu_la_SOURCES += strcase.h
@@ -165,18 +185,18 @@
 
 ## end   gnulib module strtok_r
 
-## begin gnulib module timegm
-
-libgnu_la_SOURCES += timegm.h
-
-## end   gnulib module timegm
-
 ## begin gnulib module time_r
 
 libgnu_la_SOURCES += time_r.h
 
 ## end   gnulib module time_r
 
+## begin gnulib module timegm
+
+libgnu_la_SOURCES += timegm.h
+
+## end   gnulib module timegm
+
 ## begin gnulib module vasnprintf
 
 libgnu_la_SOURCES += printf-args.h printf-parse.h vasnprintf.h
@@ -201,12 +221,6 @@
 
 ## end   gnulib module xgethostname
 
-## begin gnulib module xreadlink
-
-libgnu_la_SOURCES += xreadlink.h xreadlink.c
-
-## end   gnulib module xreadlink
-
 ## begin gnulib module xsize
 
 libgnu_la_SOURCES += xsize.h
--- /home/cvs/shishi/gl/getaddrinfo.c   2005/09/20 09:20:12     1.5
+++ /home/cvs/shishi/gl/getaddrinfo.c   2005/10/12 13:24:41     1.6
@@ -22,15 +22,16 @@
 
 #include "getaddrinfo.h"
 
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+
 /* Get calloc. */
 #include <stdlib.h>
 
 /* Get memcpy. */
 #include <string.h>
 
-/* Get struct hostent. */
-#include <netdb.h>
-
 #include <stdbool.h>
 
 #include "gettext.h"
@@ -65,9 +66,22 @@
             struct addrinfo **restrict res)
 {
   struct addrinfo *tmp;
-  struct servent *se;
+  struct servent *se = NULL;
   struct hostent *he;
-  size_t sinlen;
+  void *storage;
+  size_t size;
+#if HAVE_IPV6
+  struct v6_pair {
+    struct addrinfo addrinfo;
+    struct sockaddr_in6 sockaddr_in6;
+  };
+#endif
+#if HAVE_IPV4
+  struct v4_pair {
+    struct addrinfo addrinfo;
+    struct sockaddr_in sockaddr_in;
+  };
+#endif
 
   if (hints && (hints->ai_flags & ~AI_CANONNAME))
     /* FIXME: Support more flags. */
@@ -106,13 +120,13 @@
     {
 #if HAVE_IPV6
     case PF_INET6:
-      sinlen = sizeof (struct sockaddr_in6);
+      size = sizeof (struct v6_pair);
       break;
 #endif
 
 #if HAVE_IPV4
     case PF_INET:
-      sinlen = sizeof (struct sockaddr_in);
+      size = sizeof (struct v4_pair);
       break;
 #endif
 
@@ -120,8 +134,8 @@
       return EAI_NODATA;
     }
 
-  tmp = calloc (1, sizeof (*tmp) + sinlen);
-  if (!tmp)
+  storage = calloc (1, size);
+  if (!storage)
     return EAI_MEMORY;
 
   switch (he->h_addrtype)
@@ -129,18 +143,23 @@
 #if HAVE_IPV6
     case PF_INET6:
       {
-       struct sockaddr_in6 *sinp = (char *) tmp + sizeof (*tmp);
+       struct v6_pair *p = storage;
+       struct sockaddr_in6 *sinp = &p->sockaddr_in6;
+       tmp = &p->addrinfo;
 
        if (se)
          sinp->sin6_port = se->s_port;
 
        if (he->h_length != sizeof (sinp->sin6_addr))
-         return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
+         {
+           free (storage);
+           return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
+         }
 
-       memcpy (&sinp->sin6_addr, he->h_addr_list[0], he->h_length);
+       memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr);
 
        tmp->ai_addr = (struct sockaddr *) sinp;
-       tmp->ai_addrlen = sinlen;
+       tmp->ai_addrlen = sizeof *sinp;
       }
       break;
 #endif
@@ -148,24 +167,29 @@
 #if HAVE_IPV4
     case PF_INET:
       {
-       struct sockaddr_in *sinp = (char *) tmp + sizeof (*tmp);
+       struct v4_pair *p = storage;
+       struct sockaddr_in *sinp = &p->sockaddr_in;
+       tmp = &p->addrinfo;
 
        if (se)
          sinp->sin_port = se->s_port;
 
        if (he->h_length != sizeof (sinp->sin_addr))
-         return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
+         {
+           free (storage);
+           return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
+         }
 
-       memcpy (&sinp->sin_addr, he->h_addr_list[0], he->h_length);
+       memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr);
 
        tmp->ai_addr = (struct sockaddr *) sinp;
-       tmp->ai_addrlen = sinlen;
+       tmp->ai_addrlen = sizeof *sinp;
       }
       break;
 #endif
 
     default:
-      free (tmp);
+      free (storage);
       return EAI_NODATA;
     }
 
@@ -180,7 +204,7 @@
       tmp->ai_canonname = strdup (cn);
       if (!tmp->ai_canonname)
        {
-         free (tmp);
+         free (storage);
          return EAI_MEMORY;
        }
     }
--- /home/cvs/shishi/gl/getaddrinfo.h   2005/09/19 16:04:42     1.4
+++ /home/cvs/shishi/gl/getaddrinfo.h   2005/10/12 13:24:41     1.5
@@ -19,13 +19,16 @@
 #ifndef GETADDRINFO_H
 # define GETADDRINFO_H
 
-/* Get getaddrinfo declarations, if available.  Also get 'socklen_t',
-   and 'struct sockaddr' via sys/types.h which are used below. */
+/* sys/socket.h in i386-unknown-freebsd4.10 and
+   powerpc-apple-darwin5.5 require sys/types.h, so include it first.
+   Then we'll also get 'socklen_t' and 'struct sockaddr' which are
+   used below. */
 # include <sys/types.h>
+/* Get all getaddrinfo related declarations, if available.  */
 # include <sys/socket.h>
 # include <netdb.h>
 
-# if !HAVE_GETADDRINFO
+# ifndef HAVE_STRUCT_ADDRINFO
 
 /* Structure to contain information about address of a service provider.  */
 struct addrinfo
@@ -39,38 +42,47 @@
   char *ai_canonname;          /* Canonical name for service location.  */
   struct addrinfo *ai_next;    /* Pointer to next in list.  */
 };
+# endif
 
 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
-# define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
-# define AI_CANONNAME  0x0002  /* Request for canonical name.  */
-# define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
-# define AI_V4MAPPED   0x0008  /* IPv4 mapped addresses are acceptable.  */
-# define AI_ALL                0x0010  /* Return IPv4 mapped and IPv6 
addresses.  */
-# define AI_ADDRCONFIG 0x0020  /* Use configuration of this host to choose
+# ifndef AI_PASSIVE
+#  define AI_PASSIVE   0x0001  /* Socket address is intended for `bind'.  */
+#  define AI_CANONNAME 0x0002  /* Request for canonical name.  */
+#  define AI_NUMERICHOST 0x0004        /* Don't use name resolution.  */
+#  define AI_V4MAPPED  0x0008  /* IPv4 mapped addresses are acceptable.  */
+#  define AI_ALL       0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
+#  define AI_ADDRCONFIG        0x0020  /* Use configuration of this host to 
choose
                                   returned address type..  */
+# endif
 
 /* Error values for `getaddrinfo' function.  */
-# define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' field.  */
-# define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
-# define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
-# define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
-# define EAI_NODATA      -5    /* No address associated with NAME.  */
-# define EAI_FAMILY      -6    /* `ai_family' not supported.  */
-# define EAI_SOCKTYPE    -7    /* `ai_socktype' not supported.  */
-# define EAI_SERVICE     -8    /* SERVICE not supported for `ai_socktype'.  */
-# define EAI_ADDRFAMILY          -9    /* Address family for NAME not 
supported.  */
-# define EAI_MEMORY      -10   /* Memory allocation failure.  */
-# define EAI_SYSTEM      -11   /* System error returned in `errno'.  */
-# define EAI_OVERFLOW    -12   /* Argument buffer overflow.  */
+# ifndef EAI_BADFLAGS
+#  define EAI_BADFLAGS   -1    /* Invalid value for `ai_flags' field.  */
+#  define EAI_NONAME     -2    /* NAME or SERVICE is unknown.  */
+#  define EAI_AGAIN      -3    /* Temporary failure in name resolution.  */
+#  define EAI_FAIL       -4    /* Non-recoverable failure in name res.  */
+#  define EAI_NODATA     -5    /* No address associated with NAME.  */
+#  define EAI_FAMILY     -6    /* `ai_family' not supported.  */
+#  define EAI_SOCKTYPE   -7    /* `ai_socktype' not supported.  */
+#  define EAI_SERVICE    -8    /* SERVICE not supported for `ai_socktype'.  */
+#  define EAI_ADDRFAMILY  -9   /* Address family for NAME not supported.  */
+#  define EAI_MEMORY     -10   /* Memory allocation failure.  */
+#  define EAI_SYSTEM     -11   /* System error returned in `errno'.  */
+#  define EAI_OVERFLOW   -12   /* Argument buffer overflow.  */
+# endif
+
 # ifdef __USE_GNU
-#  define EAI_INPROGRESS  -100 /* Processing request in progress.  */
-#  define EAI_CANCELED   -101  /* Request canceled.  */
-#  define EAI_NOTCANCELED -102 /* Request not canceled.  */
-#  define EAI_ALLDONE    -103  /* All requests done.  */
-#  define EAI_INTR       -104  /* Interrupted by a signal.  */
-#  define EAI_IDN_ENCODE  -105 /* IDN encoding failed.  */
+#  ifndef EAI_INPROGRESS
+#   define EAI_INPROGRESS      -100    /* Processing request in progress.  */
+#   define EAI_CANCELED                -101    /* Request canceled.  */
+#   define EAI_NOTCANCELED     -102    /* Request not canceled.  */
+#   define EAI_ALLDONE         -103    /* All requests done.  */
+#   define EAI_INTR            -104    /* Interrupted by a signal.  */
+#   define EAI_IDN_ENCODE      -105    /* IDN encoding failed.  */
+#  endif
 # endif
 
+# ifndef HAVE_DECL_GETADDRINFO
 /* Translate name of a service location and/or a service name to set of
    socket addresses.
    For more details, see the POSIX:2001 specification
@@ -79,17 +91,20 @@
                        const char *restrict servname,
                        const struct addrinfo *restrict hints,
                        struct addrinfo **restrict res);
+# endif
 
+# ifndef HAVE_DECL_FREEADDRINFO
 /* Free `addrinfo' structure AI including associated storage.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
 extern void freeaddrinfo (struct addrinfo *ai);
+# endif
 
+# ifndef HAVE_DECL_GAI_STRERROR
 /* Convert error return from getaddrinfo() to a string.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
 extern const char *gai_strerror (int ecode);
-
-# endif /* !HAVE_GETADDRINFO */
+# endif
 
 #endif /* GETADDRINFO_H */
--- /home/cvs/shishi/gl/getdate.y       2005/05/26 15:07:53     1.15
+++ /home/cvs/shishi/gl/getdate.y       2005/10/12 13:24:41     1.16
@@ -137,6 +137,25 @@
 
 enum { BILLION = 1000000000, LOG10_BILLION = 9 };
 
+/* Relative times.  */
+typedef struct
+{
+  /* Relative year, month, day, hour, minutes, seconds, and nanoseconds.  */
+  long int year;
+  long int month;
+  long int day;
+  long int hour;
+  long int minutes;
+  long int seconds;
+  long int ns;
+} relative_time;
+
+#if HAVE_COMPOUND_LITERALS
+# define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 })
+#else
+static relative_time const RELATIVE_TIME_0;
+#endif
+
 /* Information passed to and from the parser.  */
 typedef struct
 {
@@ -167,13 +186,7 @@
   struct timespec seconds; /* includes nanoseconds */
 
   /* Relative year, month, day, hour, minutes, seconds, and nanoseconds.  */
-  long int rel_year;
-  long int rel_month;
-  long int rel_day;
-  long int rel_hour;
-  long int rel_minutes;
-  long int rel_seconds;
-  long int rel_ns;
+  relative_time rel;
 
   /* Presence or counts of nonterminals of various flavors parsed so far.  */
   bool timespec_seen;
@@ -210,13 +223,16 @@
   long int intval;
   textint textintval;
   struct timespec timespec;
+  relative_time rel;
 }
 
 %token tAGO tDST
 
-%token <intval> tDAY tDAY_UNIT tDAYZONE tHOUR_UNIT tLOCAL_ZONE tMERIDIAN
-%token <intval> tMINUTE_UNIT tMONTH tMONTH_UNIT tORDINAL
-%token <intval> tSEC_UNIT tYEAR_UNIT tZONE
+%token tYEAR_UNIT tMONTH_UNIT tHOUR_UNIT tMINUTE_UNIT tSEC_UNIT
+%token <intval> tDAY_UNIT
+
+%token <intval> tDAY tDAYZONE tLOCAL_ZONE tMERIDIAN
+%token <intval> tMONTH tORDINAL tZONE
 
 %token <textintval> tSNUMBER tUNUMBER
 %token <timespec> tSDECIMAL_NUMBER tUDECIMAL_NUMBER
@@ -224,6 +240,8 @@
 %type <intval> o_colon_minutes o_merid
 %type <timespec> seconds signed_seconds unsigned_seconds
 
+%type <rel> relunit relunit_snumber
+
 %%
 
 spec:
@@ -322,7 +340,15 @@
     tZONE
       { pc->time_zone = $1; }
   | tZONE relunit_snumber
-      { pc->time_zone = $1; pc->rels_seen = true; }
+      { pc->time_zone = $1;
+       pc->rel.ns += $2.ns;
+       pc->rel.seconds += $2.seconds;
+       pc->rel.minutes += $2.minutes;
+       pc->rel.hour += $2.hour;
+       pc->rel.day += $2.day;
+       pc->rel.month += $2.month;
+       pc->rel.year += $2.year;
+        pc->rels_seen = true; }
   | tZONE tSNUMBER o_colon_minutes
       { pc->time_zone = $1 + time_zone_hhmm ($2, $3); }
   | tDAYZONE
@@ -430,74 +456,83 @@
 rel:
     relunit tAGO
       {
-       pc->rel_ns = -pc->rel_ns;
-       pc->rel_seconds = -pc->rel_seconds;
-       pc->rel_minutes = -pc->rel_minutes;
-       pc->rel_hour = -pc->rel_hour;
-       pc->rel_day = -pc->rel_day;
-       pc->rel_month = -pc->rel_month;
-       pc->rel_year = -pc->rel_year;
+       pc->rel.ns -= $1.ns;
+       pc->rel.seconds -= $1.seconds;
+       pc->rel.minutes -= $1.minutes;
+       pc->rel.hour -= $1.hour;
+       pc->rel.day -= $1.day;
+       pc->rel.month -= $1.month;
+       pc->rel.year -= $1.year;
       }
   | relunit
+      {
+       pc->rel.ns += $1.ns;
+       pc->rel.seconds += $1.seconds;
+       pc->rel.minutes += $1.minutes;
+       pc->rel.hour += $1.hour;
+       pc->rel.day += $1.day;
+       pc->rel.month += $1.month;
+       pc->rel.year += $1.year;
+      }
   ;
 
 relunit:
     tORDINAL tYEAR_UNIT
-      { pc->rel_year += $1 * $2; }
+      { $$ = RELATIVE_TIME_0; $$.year = $1; }
   | tUNUMBER tYEAR_UNIT
-      { pc->rel_year += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.year = $1.value; }
   | tYEAR_UNIT
-      { pc->rel_year += $1; }
+      { $$ = RELATIVE_TIME_0; $$.year = 1; }
   | tORDINAL tMONTH_UNIT
-      { pc->rel_month += $1 * $2; }
+      { $$ = RELATIVE_TIME_0; $$.month = $1; }
   | tUNUMBER tMONTH_UNIT
-      { pc->rel_month += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.month = $1.value; }
   | tMONTH_UNIT
-      { pc->rel_month += $1; }
+      { $$ = RELATIVE_TIME_0; $$.month = 1; }
   | tORDINAL tDAY_UNIT
-      { pc->rel_day += $1 * $2; }
+      { $$ = RELATIVE_TIME_0; $$.day = $1 * $2; }
   | tUNUMBER tDAY_UNIT
-      { pc->rel_day += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.day = $1.value * $2; }
   | tDAY_UNIT
-      { pc->rel_day += $1; }
+      { $$ = RELATIVE_TIME_0; $$.day = $1; }
   | tORDINAL tHOUR_UNIT
-      { pc->rel_hour += $1 * $2; }
+      { $$ = RELATIVE_TIME_0; $$.hour = $1; }
   | tUNUMBER tHOUR_UNIT
-      { pc->rel_hour += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.hour = $1.value; }
   | tHOUR_UNIT
-      { pc->rel_hour += $1; }
+      { $$ = RELATIVE_TIME_0; $$.hour = 1; }
   | tORDINAL tMINUTE_UNIT
-      { pc->rel_minutes += $1 * $2; }
+      { $$ = RELATIVE_TIME_0; $$.minutes = $1; }
   | tUNUMBER tMINUTE_UNIT
-      { pc->rel_minutes += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.minutes = $1.value; }
   | tMINUTE_UNIT
-      { pc->rel_minutes += $1; }
+      { $$ = RELATIVE_TIME_0; $$.minutes = 1; }
   | tORDINAL tSEC_UNIT
-      { pc->rel_seconds += $1 * $2; }
+      { $$ = RELATIVE_TIME_0; $$.seconds = $1; }
   | tUNUMBER tSEC_UNIT
-      { pc->rel_seconds += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.seconds = $1.value; }
   | tSDECIMAL_NUMBER tSEC_UNIT
-      { pc->rel_seconds += $1.tv_sec * $2; pc->rel_ns += $1.tv_nsec * $2; }
+      { $$ = RELATIVE_TIME_0; $$.seconds = $1.tv_sec; $$.ns = $1.tv_nsec; }
   | tUDECIMAL_NUMBER tSEC_UNIT
-      { pc->rel_seconds += $1.tv_sec * $2; pc->rel_ns += $1.tv_nsec * $2; }
+      { $$ = RELATIVE_TIME_0; $$.seconds = $1.tv_sec; $$.ns = $1.tv_nsec; }
   | tSEC_UNIT
-      { pc->rel_seconds += $1; }
+      { $$ = RELATIVE_TIME_0; $$.seconds = 1; }
   | relunit_snumber
   ;
 
 relunit_snumber:
     tSNUMBER tYEAR_UNIT
-      { pc->rel_year += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.year = $1.value; }
   | tSNUMBER tMONTH_UNIT
-      { pc->rel_month += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.month = $1.value; }
   | tSNUMBER tDAY_UNIT
-      { pc->rel_day += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.day = $1.value * $2; }
   | tSNUMBER tHOUR_UNIT
-      { pc->rel_hour += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.hour = $1.value; }
   | tSNUMBER tMINUTE_UNIT
-      { pc->rel_minutes += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.minutes = $1.value; }
   | tSNUMBER tSEC_UNIT
-      { pc->rel_seconds += $1.value * $2; }
+      { $$ = RELATIVE_TIME_0; $$.seconds = $1.value; }
   ;
 
 seconds: signed_seconds | unsigned_seconds;
@@ -1215,13 +1250,7 @@
   tm.tm_isdst = tmp->tm_isdst;
 
   pc.meridian = MER24;
-  pc.rel_ns = 0;
-  pc.rel_seconds = 0;
-  pc.rel_minutes = 0;
-  pc.rel_hour = 0;
-  pc.rel_day = 0;
-  pc.rel_month = 0;
-  pc.rel_year = 0;
+  pc.rel = RELATIVE_TIME_0;
   pc.timespec_seen = false;
   pc.rels_seen = false;
   pc.dates_seen = 0;
@@ -1318,7 +1347,7 @@
        }
 
       /* Let mktime deduce tm_isdst if we have an absolute time stamp.  */
-      if (!pc.rels_seen)
+      if (pc.dates_seen | pc.days_seen | pc.times_seen)
        tm.tm_isdst = -1;
 
       /* But if the input explicitly specifies local time with or without
@@ -1396,14 +1425,14 @@
        }
 
       /* Add relative date.  */
-      if (pc.rel_year | pc.rel_month | pc.rel_day)
+      if (pc.rel.year | pc.rel.month | pc.rel.day)
        {
-         int year = tm.tm_year + pc.rel_year;
-         int month = tm.tm_mon + pc.rel_month;
-         int day = tm.tm_mday + pc.rel_day;
-         if (((year < tm.tm_year) ^ (pc.rel_year < 0))
-             | ((month < tm.tm_mon) ^ (pc.rel_month < 0))
-             | ((day < tm.tm_mday) ^ (pc.rel_day < 0)))
+         int year = tm.tm_year + pc.rel.year;
+         int month = tm.tm_mon + pc.rel.month;
+         int day = tm.tm_mday + pc.rel.day;
+         if (((year < tm.tm_year) ^ (pc.rel.year < 0))
+             | ((month < tm.tm_mon) ^ (pc.rel.month < 0))
+             | ((day < tm.tm_mday) ^ (pc.rel.day < 0)))
            goto fail;
          tm.tm_year = year;
          tm.tm_mon = month;
@@ -1421,20 +1450,20 @@
         must be applied before relative times, and if mktime is applied
         again the time zone will be lost.  */
       {
-       long int sum_ns = pc.seconds.tv_nsec + pc.rel_ns;
+       long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns;
        long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION;
        time_t t0 = Start;
-       long int d1 = 60 * 60 * pc.rel_hour;
+       long int d1 = 60 * 60 * pc.rel.hour;
        time_t t1 = t0 + d1;
-       long int d2 = 60 * pc.rel_minutes;
+       long int d2 = 60 * pc.rel.minutes;
        time_t t2 = t1 + d2;
-       long int d3 = pc.rel_seconds;
+       long int d3 = pc.rel.seconds;
        time_t t3 = t2 + d3;
        long int d4 = (sum_ns - normalized_ns) / BILLION;
        time_t t4 = t3 + d4;
 
-       if ((d1 / (60 * 60) ^ pc.rel_hour)
-           | (d2 / 60 ^ pc.rel_minutes)
+       if ((d1 / (60 * 60) ^ pc.rel.hour)
+           | (d2 / 60 ^ pc.rel.minutes)
            | ((t1 < t0) ^ (d1 < 0))
            | ((t2 < t1) ^ (d2 < 0))
            | ((t3 < t2) ^ (d3 < 0))
--- /home/cvs/shishi/gl/getdelim.c      2005/09/20 09:20:12     1.3
+++ /home/cvs/shishi/gl/getdelim.c      2005/10/12 13:24:41     1.4
@@ -23,11 +23,18 @@
 # include <config.h>
 #endif
 
+#include "getdelim.h"
+
+#include <limits.h>
 #include <stdlib.h>
 #include <errno.h>
 
-#include "getdelim.h"
-
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
 #if !HAVE_FLOCKFILE
 # undef flockfile
 # define flockfile(x) ((void) 0)
@@ -46,9 +53,8 @@
 ssize_t
 getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
 {
-  int result = 0;
-  ssize_t cur_len = 0;
-  ssize_t len;
+  ssize_t result;
+  size_t cur_len = 0;
 
   if (lineptr == NULL || n == NULL || fp == NULL)
     {
@@ -71,23 +77,26 @@
 
   for (;;)
     {
-      char *t;
       int i;
 
       i = getc (fp);
       if (i == EOF)
-      {
-       result = -1;
-       break;
-      }
+       {
+         result = -1;
+         break;
+       }
 
       /* Make enough space for len+1 (for final NUL) bytes.  */
       if (cur_len + 1 >= *n)
        {
-         size_t needed = 2 * (cur_len + 1) + 1;   /* Be generous. */
+         size_t needed_max =
+           SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+         size_t needed = 2 * *n + 1;   /* Be generous. */
          char *new_lineptr;
 
-         if (needed < cur_len)
+         if (needed_max < needed)
+           needed = needed_max;
+         if (cur_len + 1 >= needed)
            {
              result = -1;
              goto unlock_return;
--- /home/cvs/shishi/gl/getopt_.h       2005/05/26 15:07:54     1.7
+++ /home/cvs/shishi/gl/getopt_.h       2005/10/12 13:24:41     1.8
@@ -1,5 +1,5 @@
 /* Declarations for getopt.
-   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+   Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -34,9 +34,7 @@
 #if defined __GETOPT_PREFIX && !defined __need_getopt
 # include <stdlib.h>
 # include <stdio.h>
-# if HAVE_UNISTD_H
-#  include <unistd.h>
-# endif
+# include <unistd.h>
 # undef __need_getopt
 # undef getopt
 # undef getopt_long
--- /home/cvs/shishi/gl/strcasecmp.c    2005/09/19 16:04:42     1.3
+++ /home/cvs/shishi/gl/strcasecmp.c    2005/10/12 13:24:41     1.4
@@ -25,6 +25,7 @@
 #include "strcase.h"
 
 #include <ctype.h>
+#include <limits.h>
 
 #if HAVE_MBRTOWC
 # include "mbuiter.h"
@@ -93,6 +94,12 @@
        }
       while (c1 == c2);
 
-      return c1 - c2;
+      if (UCHAR_MAX <= INT_MAX)
+       return c1 - c2;
+      else
+       /* On machines where 'char' and 'int' are types of the same size, the
+          difference of two 'unsigned char' values - including the sign bit -
+          doesn't fit in an 'int'.  */
+       return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
     }
 }
--- /home/cvs/shishi/gl/strncasecmp.c   2005/09/20 09:20:12     1.3
+++ /home/cvs/shishi/gl/strncasecmp.c   2005/10/12 13:24:41     1.4
@@ -1,5 +1,5 @@
 /* strncasecmp.c -- case insensitive string comparator
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2005 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
@@ -23,6 +23,7 @@
 #include "strcase.h"
 
 #include <ctype.h>
+#include <limits.h>
 
 #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
 
@@ -54,5 +55,11 @@
     }
   while (c1 == c2);
 
-  return c1 - c2;
+  if (UCHAR_MAX <= INT_MAX)
+    return c1 - c2;
+  else
+    /* On machines where 'char' and 'int' are types of the same size, the
+       difference of two 'unsigned char' values - including the sign bit -
+       doesn't fit in an 'int'.  */
+    return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
 }
--- /home/cvs/shishi/gl/xgethostname.c  2005/05/26 15:07:54     1.5
+++ /home/cvs/shishi/gl/xgethostname.c  2005/10/12 13:24:41     1.6
@@ -28,10 +28,7 @@
 
 #include <stdlib.h>
 #include <errno.h>
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
 
 #include "xalloc.h"
 
--- /home/cvs/shishi/gl/xreadlink.c     2005/09/20 09:20:12     1.8
+++ /home/cvs/shishi/gl/xreadlink.c     2005/10/12 13:24:41     1.9
@@ -30,9 +30,7 @@
 #include <limits.h>
 #include <sys/types.h>
 #include <stdlib.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
 
 #ifndef SIZE_MAX
 # define SIZE_MAX ((size_t) -1)

--- /home/cvs/shishi/gl/gc-gnulib.c     2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/gc-gnulib.c     2005/10/12 13:24:42     1.1
/* gc-gl-common.c --- Common gnulib internal crypto interface functions
 * Copyright (C) 2002, 2003, 2004, 2005  Simon Josefsson
 *
 * This file 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 2, or (at your
 * option) any later version.
 *
 * This file 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 file; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 */

/* Note: This file is only built if GC uses internal functions. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

/* Get prototype. */
#include <gc.h>

#include <stdlib.h>
#include <string.h>

/* For randomize. */
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>

#ifdef GC_USE_MD5
# include "md5.h"
#endif
#ifdef GC_USE_SHA1
# include "sha1.h"
#endif
#ifdef GC_USE_HMAC_MD5
# include "hmac.h"
#endif

Gc_rc
gc_init (void)
{
  return GC_OK;
}

void
gc_done (void)
{
  return;
}

/* Randomness. */

static Gc_rc
randomize (int level, char *data, size_t datalen)
{
  int fd;
  const char *device;
  size_t len = 0;
  int rc;

  switch (level)
    {
    case 0:
      device = NAME_OF_NONCE_DEVICE;
      break;

    case 1:
      device = NAME_OF_PSEUDO_RANDOM_DEVICE;
      break;

    default:
      device = NAME_OF_RANDOM_DEVICE;
      break;
    }

  fd = open (device, O_RDONLY);
  if (fd < 0)
    return GC_RANDOM_ERROR;

  do
    {
      ssize_t tmp;

      tmp = read (fd, data, datalen);

      if (tmp < 0)
        {
          int save_errno = errno;
          close (fd);
          errno = save_errno;
          return GC_RANDOM_ERROR;
        }

      len += tmp;
    }
  while (len < datalen);

  rc = close (fd);
  if (rc < 0)
    return GC_RANDOM_ERROR;

  return GC_OK;
}

Gc_rc
gc_nonce (char *data, size_t datalen)
{
  return randomize (0, data, datalen);
}

Gc_rc
gc_pseudo_random (char *data, size_t datalen)
{
  return randomize (1, data, datalen);
}

Gc_rc
gc_random (char *data, size_t datalen)
{
  return randomize (2, data, datalen);
}

/* Memory allocation. */

void
gc_set_allocators (gc_malloc_t func_malloc,
                   gc_malloc_t secure_malloc,
                   gc_secure_check_t secure_check,
                   gc_realloc_t func_realloc, gc_free_t func_free)
{
  return;
}

/* Hashes. */

Gc_rc
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
{
  switch (hash)
    {
#ifdef GC_USE_MD5
    case GC_MD5:
      md5_buffer (in, inlen, resbuf);
      break;
#endif

#ifdef GC_USE_SHA1
    case GC_SHA1:
      sha1_buffer (in, inlen, resbuf);
      break;
#endif

    default:
      return GC_INVALID_HASH;
    }

  return GC_OK;
}

#ifdef GC_USE_MD5
Gc_rc
gc_md5 (const void *in, size_t inlen, void *resbuf)
{
  md5_buffer (in, inlen, resbuf);
  return GC_OK;
}
#endif

#ifdef GC_USE_SHA1
Gc_rc
gc_sha1 (const void *in, size_t inlen, void *resbuf)
{
  sha1_buffer (in, inlen, resbuf);
  return GC_OK;
}
#endif

#ifdef GC_USE_HMAC_MD5
Gc_rc
gc_hmac_md5 (const void *key, size_t keylen,
             const void *in, size_t inlen, char *resbuf)
{
  hmac_md5 (key, keylen, in, inlen, resbuf);
  return GC_OK;
}
#endif

#ifdef GC_USE_HMAC_SHA1
Gc_rc
gc_hmac_sha1 (const void *key, size_t keylen,
              const void *in, size_t inlen, char *resbuf)
{
  hmac_sha1 (key, keylen, in, inlen, resbuf);
  return GC_OK;
}
#endif
--- /home/cvs/shishi/gl/gc-libgcrypt.c  2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/gc-libgcrypt.c  2005/10/12 13:24:42     1.1
/* gc-libgcrypt.c --- Crypto wrappers around Libgcrypt for GC.
 * Copyright (C) 2002, 2003, 2004, 2005  Simon Josefsson
 *
 * This file 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 2, or (at your
 * option) any later version.
 *
 * This file 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 file; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 */

/* Note: This file is only built if GC uses Libgcrypt. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

/* Get prototype. */
#include "gc.h"

/* Get libgcrypt API. */
#include <gcrypt.h>

#include <assert.h>

/* Initialization. */

Gc_rc
gc_init (void)
{
  gcry_error_t err;

  err = gcry_control (GCRYCTL_ANY_INITIALIZATION_P);
  if (err == GPG_ERR_NO_ERROR)
    {
      if (gcry_check_version (GCRYPT_VERSION) == NULL)
        return GC_INIT_ERROR;

      err = gcry_control (GCRYCTL_INITIALIZATION_FINISHED, NULL, 0);
      if (err != GPG_ERR_NO_ERROR)
        return GC_INIT_ERROR;
    }

  return GC_OK;
}

void
gc_done (void)
{
  return;
}

/* Randomness. */

Gc_rc
gc_nonce (char *data, size_t datalen)
{
  gcry_create_nonce ((unsigned char *) data, datalen);
  return GC_OK;
}

Gc_rc
gc_pseudo_random (char *data, size_t datalen)
{
  gcry_randomize ((unsigned char *) data, datalen, GCRY_STRONG_RANDOM);
  return GC_OK;
}

Gc_rc
gc_random (char *data, size_t datalen)
{
  gcry_randomize ((unsigned char *) data, datalen, GCRY_VERY_STRONG_RANDOM);
  return GC_OK;
}

/* Memory allocation. */

void
gc_set_allocators (gc_malloc_t func_malloc,
                   gc_malloc_t secure_malloc,
                   gc_secure_check_t secure_check,
                   gc_realloc_t func_realloc, gc_free_t func_free)
{
  gcry_set_allocation_handler (func_malloc, secure_malloc, secure_check,
                               func_realloc, func_free);
}

/* Hashes. */

Gc_rc
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
{
  int gcryalg;

  switch (hash)
    {
#ifdef GC_USE_MD5
    case GC_MD5:
      gcryalg = GCRY_MD_MD5;
      break;
#endif

#ifdef GC_USE_SHA1
    case GC_SHA1:
      gcryalg = GCRY_MD_SHA1;
      break;
#endif

    default:
      return GC_INVALID_HASH;
    }

  gcry_md_hash_buffer (gcryalg, resbuf, in, inlen);

  return GC_OK;
}

/* One-call interface. */

#ifdef GC_USE_MD5
Gc_rc
gc_md5 (const void *in, size_t inlen, void *resbuf)
{
  size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD5);
  gcry_md_hd_t hd;
  gpg_error_t err;
  unsigned char *p;

  assert (outlen == GC_MD5_DIGEST_SIZE);

  err = gcry_md_open (&hd, GCRY_MD_MD5, 0);
  if (err != GPG_ERR_NO_ERROR)
    return GC_INVALID_HASH;

  gcry_md_write (hd, in, inlen);

  p = gcry_md_read (hd, GCRY_MD_MD5);
  if (p == NULL)
    {
      gcry_md_close (hd);
      return GC_INVALID_HASH;
    }

  memcpy (resbuf, p, outlen);

  gcry_md_close (hd);

  return GC_OK;
}
#endif

#ifdef GC_USE_SHA1
Gc_rc
gc_sha1 (const void *in, size_t inlen, void *resbuf)
{
  size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
  gcry_md_hd_t hd;
  gpg_error_t err;
  unsigned char *p;

  assert (outlen == GC_SHA1_DIGEST_SIZE);

  err = gcry_md_open (&hd, GCRY_MD_SHA1, 0);
  if (err != GPG_ERR_NO_ERROR)
    return GC_INVALID_HASH;

  gcry_md_write (hd, in, inlen);

  p = gcry_md_read (hd, GCRY_MD_SHA1);
  if (p == NULL)
    {

[91 lines skipped]
--- /home/cvs/shishi/gl/gc-pbkdf2-sha1.c        2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/gc-pbkdf2-sha1.c        2005/10/12 13:24:42     1.1

[278 lines skipped]
--- /home/cvs/shishi/gl/gc.h    2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/gc.h    2005/10/12 13:24:42     1.1

[519 lines skipped]
--- /home/cvs/shishi/gl/hmac-sha1.c     2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/hmac-sha1.c     2005/10/12 13:24:42     1.1

[595 lines skipped]
--- /home/cvs/shishi/gl/hmac.h  2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/hmac.h  2005/10/12 13:24:42     1.1

[636 lines skipped]
--- /home/cvs/shishi/gl/memxor.c        2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/memxor.c        2005/10/12 13:24:42     1.1

[673 lines skipped]
--- /home/cvs/shishi/gl/memxor.h        2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/memxor.h        2005/10/12 13:24:42     1.1

[704 lines skipped]
--- /home/cvs/shishi/gl/sha1.c  2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/sha1.c  2005/10/12 13:24:42     1.1

[1127 lines skipped]
--- /home/cvs/shishi/gl/sha1.h  2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/sha1.h  2005/10/12 13:24:42     1.1

[1214 lines skipped]
--- /home/cvs/shishi/gl/stdint_.h       2005/10/12 13:24:42     NONE
+++ /home/cvs/shishi/gl/stdint_.h       2005/10/12 13:24:42     1.1

[1497 lines skipped]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]