version 1.7, 2005/05/19 04:17:24 |
version 1.8, 2005/05/20 17:15:49 |
|
|
static int yyerror (const char *, ...); |
static int yyerror (const char *, ...); |
static int yylex (void); |
static int yylex (void); |
static int yyparse (void); |
static int yyparse (void); |
|
static int lookup (char *); |
|
|
%} |
%} |
|
|
|
|
|
|
|
|
static int |
static int |
LookupWord(char *buff) |
lookup(char *buff) |
{ |
{ |
char *p, *q; |
char *p, *q; |
int i, abbrev; |
int i, abbrev; |
|
|
*p++ = c; |
*p++ = c; |
*p = '\0'; |
*p = '\0'; |
yyInput--; |
yyInput--; |
return LookupWord(buff); |
return lookup(buff); |
} |
} |
if (c != '(') |
if (c != '(') |
return *yyInput++; |
return *yyInput++; |
|
|
+ (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); |
+ (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); |
} |
} |
|
|
|
/* |
|
* cvs_date_parse() |
|
* |
|
* Returns the number of seconds since the Epoch corresponding to the date. |
|
*/ |
time_t |
time_t |
cvs_date_parse(const char *p) |
cvs_date_parse(const char *p) |
{ |
{ |
|
|
struct tm *gmt_ptr; |
struct tm *gmt_ptr; |
|
|
now = &ftz; |
now = &ftz; |
(void)time (&nowtime); |
(void)time(&nowtime); |
|
|
gmt_ptr = gmtime (&nowtime); |
gmt_ptr = gmtime(&nowtime); |
if (gmt_ptr != NULL) { |
if (gmt_ptr != NULL) { |
/* Make a copy, in case localtime modifies *tm (I think |
/* Make a copy, in case localtime modifies *tm (I think |
* that comment now applies to *gmt_ptr, but I am too |
* that comment now applies to *gmt_ptr, but I am too |
|
|
gmt = *gmt_ptr; |
gmt = *gmt_ptr; |
} |
} |
|
|
if (!(tm = localtime (&nowtime))) |
if (!(tm = localtime(&nowtime))) |
return (-1); |
return (-1); |
|
|
if (gmt_ptr != NULL) |
if (gmt_ptr != NULL) |
ftz.timezone = difftm (&gmt, tm) / 60; |
ftz.timezone = difftm(&gmt, tm) / 60; |
else |
|
/* We are on a system like VMS, where the system clock is |
|
in local time and the system has no concept of timezones. |
|
Hopefully we can fake this out (for the case in which the |
|
user specifies no timezone) by just saying the timezone |
|
is zero. */ |
|
ftz.timezone = 0; |
|
|
|
if(tm->tm_isdst) |
if(tm->tm_isdst) |
ftz.timezone += 60; |
ftz.timezone += 60; |
|
|
(void)printf("Enter date, or blank line to exit.\n\t> "); |
(void)printf("Enter date, or blank line to exit.\n\t> "); |
(void)fflush(stdout); |
(void)fflush(stdout); |
while (fgets(buff, sizeof(buff), stdin) && buff[0]) { |
while (fgets(buff, sizeof(buff), stdin) && buff[0]) { |
d = get_date(buff, (struct timeb *)NULL); |
d = cvs_date_parse(buff); |
if (d == -1) |
if (d == -1) |
(void)printf("Bad format - couldn't convert.\n"); |
(void)printf("Bad format - couldn't convert.\n"); |
else |
else |