X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetdate.y;h=cbf3ca104aa877d3192335843f03cc3f723aa335;hb=fe0f080532b2357794d4e25d66a35f4aedc4f93a;hp=cfa299f38a4f9b2c55efd1b9a8123db193ad2ad3;hpb=707f67871e2915afb4ae832a723429cca5203265;p=gnulib.git diff --git a/lib/getdate.y b/lib/getdate.y index cfa299f38..cbf3ca104 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -1,7 +1,7 @@ %{ /* Parse a string into an internal time stamp. - Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software + Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -32,11 +32,10 @@ /* FIXME: Check for arithmetic overflow in all cases, not just some of them. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include "getdate.h" +#include "timespec.h" /* There's no need to extend the stack, so there's no need to involve alloca. */ @@ -68,27 +67,20 @@ #include "setenv.h" #include "xalloc.h" -#if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII) -# define IN_CTYPE_DOMAIN(c) 1 -#else -# define IN_CTYPE_DOMAIN(c) isascii (c) -#endif - -#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) -#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) -#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c)) /* ISDIGIT differs from isdigit, as follows: - - Its arg may be any int or unsigned int; it need not be an unsigned char. - - It's guaranteed to evaluate its argument exactly once. + - Its arg may be any int or unsigned int; it need not be an unsigned char + or EOF. - It's typically faster. POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to isdigit unless it's important to use the locale's definition of `digit' even when the host does not conform to POSIX. */ #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) -#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ -# define __attribute__(x) +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ +# define __attribute__(x) +# endif #endif #ifndef ATTRIBUTE_UNUSED @@ -204,7 +196,7 @@ typedef struct union YYSTYPE; static int yylex (union YYSTYPE *, parser_control *); -static int yyerror (parser_control *, char *); +static int yyerror (parser_control const *, char const *); static long int time_zone_hhmm (textint, long int); %} @@ -894,8 +886,7 @@ lookup_word (parser_control const *pc, char *word) for (p = word; *p; p++) { unsigned char ch = *p; - if (ISLOWER (ch)) - *p = toupper (ch); + *p = toupper (ch); } for (tp = meridian_table; tp->name; tp++) @@ -960,7 +951,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) for (;;) { - while (c = *pc->input, ISSPACE (c)) + while (c = *pc->input, isspace (c)) pc->input++; if (ISDIGIT (c) || c == '-' || c == '+') @@ -971,7 +962,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; - while (c = *++pc->input, ISSPACE (c)) + while (c = *++pc->input, isspace (c)) continue; if (! ISDIGIT (c)) /* skip the '-' sign */ @@ -1075,7 +1066,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) } } - if (ISALPHA (c)) + if (isalpha (c)) { char buff[20]; char *p = buff; @@ -1087,7 +1078,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) *p++ = c; c = *++pc->input; } - while (ISALPHA (c) || c == '.'); + while (isalpha (c) || c == '.'); *p = '\0'; tp = lookup_word (pc, buff); @@ -1116,7 +1107,8 @@ yylex (YYSTYPE *lvalp, parser_control *pc) /* Do nothing if the parser reports an error. */ static int -yyerror (parser_control *pc ATTRIBUTE_UNUSED, char *s ATTRIBUTE_UNUSED) +yyerror (parser_control const *pc ATTRIBUTE_UNUSED, + char const *s ATTRIBUTE_UNUSED) { return 0; } @@ -1199,7 +1191,7 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) if (! tmp) return false; - while (c = *p, ISSPACE (c)) + while (c = *p, isspace (c)) p++; if (strncmp (p, "TZ=\"", 4) == 0)