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 <alloca.h>
-#else
-#ifdef _AIX
- #pragma alloca
-#else
-void *alloca ();
-#endif
-#endif
-#endif
#ifdef __GNUC__
#undef alloca
yyMonth = -$2;
yyDay = -$3;
}
+ | tUNUMBER tMONTH tSNUMBER {
+ /* e.g. 17-JUN-1992. */
+ yyDay = $1;
+ yyMonth = $2;
+ yyYear = -$3;
+ }
| tMONTH tUNUMBER {
yyMonth = $1;
yyDay = $2;
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;
+ }
}
}
;
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)
#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>
#include <time.h>
#endif
+#ifndef STDC_HEADERS
+time_t mktime ();
+#endif
+
#if defined(HAVE_TZNAME)
extern char *tzname[2];
#endif
static int
add_str (to, from, max)
char *to;
- char *from;
+ const char *from;
int max;
{
int i;
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. */
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);
#include <ctype.h>
#include <math.h>
-#if STDC_HEADERS
+#ifdef HAVE_FLOAT_H
#include <float.h>
+#else
+#define DBL_MAX 1.7976931348623159e+308
+#define DBL_MIN 2.2250738585072010e-308
+#endif
+#endif
+
+#if STDC_HEADERS
#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