From: Jim Meyering Date: Thu, 23 Dec 1993 00:29:36 +0000 (+0000) Subject: GNU shell utilities X-Git-Tag: SHELLUTILS-1_9_2a X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=1671692479f417b9e1215121540266b62d9e0c43;p=gnulib.git GNU shell utilities --- diff --git a/lib/getdate.y b/lib/getdate.y index ff0aa66a3..35d064f48 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -35,20 +35,6 @@ solely to allow compilation by non GNU-C compilers of the C parser produced from this file by old versions of bison. Newer versions of bison include a block similar to this one in bison.simple. */ - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#ifdef HAVE_ALLOCA_H -#include -#else -#ifdef _AIX - #pragma alloca -#else -void *alloca (); -#endif -#endif -#endif #ifdef __GNUC__ #undef alloca @@ -315,6 +301,12 @@ date : tUNUMBER '/' tUNUMBER { yyMonth = -$2; yyDay = -$3; } + | tUNUMBER tMONTH tSNUMBER { + /* e.g. 17-JUN-1992. */ + yyDay = $1; + yyMonth = $2; + yyYear = -$3; + } | tMONTH tUNUMBER { yyMonth = $1; yyDay = $2; @@ -376,25 +368,24 @@ number : tUNUMBER { yyYear = $1; else { if($1>10000) { - time_t date_part; - - date_part= $1/10000; yyHaveDate++; - yyDay= (date_part)%100; - yyMonth= (date_part/100)%100; - yyYear = date_part/10000; - } - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; + yyDay= ($1)%100; + yyMonth= ($1/100)%100; + yyYear = $1/10000; } else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; + yyHaveTime++; + if ($1 < 100) { + yyHour = $1; + yyMinutes = 0; + } + else { + yyHour = $1 / 100; + yyMinutes = $1 % 100; + } + yySeconds = 0; + yyMeridian = MER24; + } } } ; diff --git a/lib/strftime.c b/lib/strftime.c index 569a3d448..071d5ddc2 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -36,6 +36,7 @@ Numeric modifiers (a nonstandard extension): - do not pad the field _ pad the field with spaces + %s time in seconds since 00:00:00, Jan 1, 1970 Time fields: %H hour (00..23) @@ -84,6 +85,7 @@ #endif #endif +#include #include #if defined(TM_IN_SYS_TIME) || (!defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)) #include @@ -91,6 +93,10 @@ #include #endif +#ifndef STDC_HEADERS +time_t mktime (); +#endif + #if defined(HAVE_TZNAME) extern char *tzname[2]; #endif @@ -175,7 +181,7 @@ add_num3 (string, num, max, pad) static int add_str (to, from, max) char *to; - char *from; + const char *from; int max; { int i; @@ -185,6 +191,25 @@ add_str (to, from, max) return i; } +static int +add_num_time_t (string, max, num) + char *string; + int max; + time_t num; +{ + /* This buffer is large enough to hold the character representation + (including the trailing NUL) of any unsigned decimal quantity + whose binary representation fits in 128 bits. */ + char buf[40]; + int length; + + if (sizeof (num) > 16) + abort (); + sprintf (buf, "%lu", (unsigned long) num); + length = add_str (string, buf, max); + return length; +} + /* Return the week in the year of the time in TM, with the weeks starting on Sundays. */ @@ -330,6 +355,16 @@ strftime (string, max, format, tm) length += strftime (&string[length], max - length, "%H:%M", tm); break; + + case 's': + { + struct tm writable_tm; + writable_tm = *tm; + length += add_num_time_t (&string[length], max - length, + mktime (&writable_tm)); + } + break; + case 'S': length += add_num2 (&string[length], tm->tm_sec, max - length, pad); diff --git a/lib/strtod.c b/lib/strtod.c index d28975368..01dafc8fb 100644 --- a/lib/strtod.c +++ b/lib/strtod.c @@ -31,16 +31,20 @@ Cambridge, MA 02139, USA. */ #include #include -#if STDC_HEADERS +#ifdef HAVE_FLOAT_H #include +#else +#define DBL_MAX 1.7976931348623159e+308 +#define DBL_MIN 2.2250738585072010e-308 +#endif +#endif + +#if STDC_HEADERS #include #include #else #define NULL 0 -#define DBL_MAX 1.7976931348623159e+308 -#define DBL_MIN 2.2250738585072010e-308 extern int errno; -#endif #ifndef HUGE_VAL #define HUGE_VAL HUGE #endif