~mdw
/
cfd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support Automake's `aclocal' scheme. Deposit Autoconf fragments in
[cfd]
/
getdate.y
diff --git
a/getdate.y
b/getdate.y
index
a11c0ac
..
a9de991
100644
(file)
--- a/
getdate.y
+++ b/
getdate.y
@@
-14,6
+14,7
@@
#include <stdio.h>
#include <ctype.h>
#include <stdio.h>
#include <ctype.h>
+#include <stdlib.h>
#define ISSPACE(c) (isspace ((unsigned char)c))
#define ISALPHA(c) (isalpha ((unsigned char)c))
#define ISSPACE(c) (isspace ((unsigned char)c))
#define ISALPHA(c) (isalpha ((unsigned char)c))
@@
-91,7
+92,8
@@
static int yylex ();
static int yyerror ();
#define EPOCH 1970
static int yyerror ();
#define EPOCH 1970
-#define HOUR(x) ((x) * 60)
+#define HOUR(x) ((time_t)(x) * 60)
+#define SECSPERDAY (24L * 60L * 60L)
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
@@
-319,7
+321,7
@@
relunit : tUNUMBER tYEAR_UNIT {
yyRelYear += $1 * $2;
}
| tYEAR_UNIT {
yyRelYear += $1 * $2;
}
| tYEAR_UNIT {
- yyRelYear
++
;
+ yyRelYear
+= $1
;
}
| tUNUMBER tMONTH_UNIT {
yyRelMonth += $1 * $2;
}
| tUNUMBER tMONTH_UNIT {
yyRelMonth += $1 * $2;
@@
-328,7
+330,7
@@
relunit : tUNUMBER tYEAR_UNIT {
yyRelMonth += $1 * $2;
}
| tMONTH_UNIT {
yyRelMonth += $1 * $2;
}
| tMONTH_UNIT {
- yyRelMonth
++
;
+ yyRelMonth
+= $1
;
}
| tUNUMBER tDAY_UNIT {
yyRelDay += $1 * $2;
}
| tUNUMBER tDAY_UNIT {
yyRelDay += $1 * $2;
@@
-337,7
+339,7
@@
relunit : tUNUMBER tYEAR_UNIT {
yyRelDay += $1 * $2;
}
| tDAY_UNIT {
yyRelDay += $1 * $2;
}
| tDAY_UNIT {
- yyRelDay
++
;
+ yyRelDay
+= $1
;
}
| tUNUMBER tHOUR_UNIT {
yyRelHour += $1 * $2;
}
| tUNUMBER tHOUR_UNIT {
yyRelHour += $1 * $2;
@@
-346,7
+348,7
@@
relunit : tUNUMBER tYEAR_UNIT {
yyRelHour += $1 * $2;
}
| tHOUR_UNIT {
yyRelHour += $1 * $2;
}
| tHOUR_UNIT {
- yyRelHour
++
;
+ yyRelHour
+= $1
;
}
| tUNUMBER tMINUTE_UNIT {
yyRelMinutes += $1 * $2;
}
| tUNUMBER tMINUTE_UNIT {
yyRelMinutes += $1 * $2;
@@
-355,7
+357,7
@@
relunit : tUNUMBER tYEAR_UNIT {
yyRelMinutes += $1 * $2;
}
| tMINUTE_UNIT {
yyRelMinutes += $1 * $2;
}
| tMINUTE_UNIT {
- yyRelMinutes
++
;
+ yyRelMinutes
+= $1
;
}
| tUNUMBER tSEC_UNIT {
yyRelSeconds += $1 * $2;
}
| tUNUMBER tSEC_UNIT {
yyRelSeconds += $1 * $2;
@@
-364,7
+366,7
@@
relunit : tUNUMBER tYEAR_UNIT {
yyRelSeconds += $1 * $2;
}
| tSEC_UNIT {
yyRelSeconds += $1 * $2;
}
| tSEC_UNIT {
- yyRelSeconds
++
;
+ yyRelSeconds
+= $1
;
}
;
}
;
@@
-465,7
+467,7
@@
static TABLE const OtherTable[] = {
{ "now", tMINUTE_UNIT, 0 },
{ "last", tUNUMBER, -1 },
{ "this", tMINUTE_UNIT, 0 },
{ "now", tMINUTE_UNIT, 0 },
{ "last", tUNUMBER, -1 },
{ "this", tMINUTE_UNIT, 0 },
- { "next", tUNUMBER,
2
},
+ { "next", tUNUMBER,
1 /* Was bogusly 2 [mdw] */
},
{ "first", tUNUMBER, 1 },
/* { "second", tUNUMBER, 2 }, */
{ "third", tUNUMBER, 3 },
{ "first", tUNUMBER, 1 },
/* { "second", tUNUMBER, 2 }, */
{ "third", tUNUMBER, 3 },
@@
-835,6
+837,8
@@
yylex ()
#define TM_YEAR_ORIGIN 1900
#define TM_YEAR_ORIGIN 1900
+#ifndef GETDATE_IGNORE_TIMEZONE
+
/* Yield A - B, measured in seconds. */
static long
difftm (a, b)
/* Yield A - B, measured in seconds. */
static long
difftm (a, b)
@@
-857,6
+861,8
@@
difftm (a, b)
+ (a->tm_sec - b->tm_sec));
}
+ (a->tm_sec - b->tm_sec));
}
+#endif
+
time_t
get_date (p, now)
const char *p;
time_t
get_date (p, now)
const char *p;
@@
-926,6
+932,7
@@
get_date (p, now)
zone by 24 hours to compensate. This algorithm assumes that
there is no DST transition within a day of the time_t boundaries. */
zone by 24 hours to compensate. This algorithm assumes that
there is no DST transition within a day of the time_t boundaries. */
+#ifndef GETDATE_IGNORE_TIMEZONE
if (yyHaveZone)
{
tm = tm0;
if (yyHaveZone)
{
tm = tm0;
@@
-941,6
+948,7
@@
get_date (p, now)
}
Start = mktime (&tm);
}
}
Start = mktime (&tm);
}
+#endif
if (Start == (time_t) -1)
return Start;
if (Start == (time_t) -1)
return Start;
@@
-955,6
+963,7
@@
get_date (p, now)
return Start;
}
return Start;
}
+#ifndef GETDATE_IGNORE_TIMEZONE
if (yyHaveZone)
{
long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
if (yyHaveZone)
{
long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
@@
-962,6
+971,7
@@
get_date (p, now)
return -1; /* time_t overflow */
Start += delta;
}
return -1; /* time_t overflow */
Start += delta;
}
+#endif
return Start;
}
return Start;
}