changeset 176:10b9f9091b11

.
author Jim Meyering <jim@meyering.net>
date Thu, 23 Dec 1993 00:08:30 +0000
parents 5ae2aa44f4f5
children 6d70bc3b54e3
files lib/getdate.y lib/strftime.c lib/strtod.c
diffstat 3 files changed, 60 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -315,6 +315,12 @@
 	    yyMonth = -$2;
 	    yyDay = -$3;
 	}
+	| tUNUMBER tMONTH tSNUMBER {
+	    /* e.g. 17-JUN-1992.  */
+	    yyDay = $1;
+	    yyMonth = $2;
+	    yyYear = -$3;
+	}
 	| tMONTH tUNUMBER {
 	    yyMonth = $1;
 	    yyDay = $2;
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -46,6 +46,7 @@
    %p	locale's AM or PM
    %r	time, 12-hour (hh:mm:ss [AP]M)
    %R	time, 24-hour (hh:mm)
+   %s   time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension)
    %S	second (00..61)
    %T	time, 24-hour (hh:mm:ss)
    %X	locale's time representation (%H:%M:%S)
@@ -84,6 +85,7 @@
 #endif
 #endif
 
+#include <stdio.h>
 #include <sys/types.h>
 #if defined(TM_IN_SYS_TIME) || (!defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME))
 #include <sys/time.h>
@@ -91,6 +93,10 @@
 #include <time.h>
 #endif
 
+#ifndef STDC_HEADERS
+time_t mktime ();
+#endif
+
 #if defined(HAVE_TZNAME)
 extern char *tzname[2];
 #endif
@@ -175,7 +181,7 @@
 static int
 add_str (to, from, max)
      char *to;
-     char *from;
+     const char *from;
      int max;
 {
   int i;
@@ -185,6 +191,25 @@
   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 @@
 	      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);
--- a/lib/strtod.c
+++ b/lib/strtod.c
@@ -16,28 +16,39 @@
 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
+#ifdef HAVE_CONFIG_H
+#if defined (CONFIG_BROKETS)
+/* We use <config.h> instead of "config.h" so that a compilation
+   using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+   (which it would do because it found this file in $srcdir).  */
+#include <config.h>
+#else
+#include "config.h"
+#endif
+#endif
+
 #include <errno.h>
 #include <ctype.h>
 #include <math.h>
 
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#else
+#define DBL_MAX 1.7976931348623159e+308
+#define DBL_MIN 2.2250738585072010e-308
+#endif
+
 #if STDC_HEADERS
-#include <float.h>
 #include <stdlib.h>
 #include <string.h>
 #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
 
-#if !__STDC__
-#define const
-#endif
-
 /* Convert NPTR to a double.  If ENDPTR is not NULL, a pointer to the
    character after the last one used in the number is put in *ENDPTR.  */
 double