diff options
author | Jim Meyering <meyering@redhat.com> | 2008-08-02 15:40:39 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-08-04 07:44:56 +0200 |
commit | 316a91c6f78b93aed27747bdbdc1ed0fdb9c5419 (patch) | |
tree | 5a029e3d21cbd4cb86631a18087fde2f7d1e028c | |
parent | 5f0d8cd17a0f60afc2cf280b073ad314f7700225 (diff) | |
download | gnulib-316a91c6f78b93aed27747bdbdc1ed0fdb9c5419.tar.gz |
getdate.y: avoid locale-dependent date parsing failure
In Turkish locales, getdate would fail to recognize keywords
containing a lowercase "i". The solution is not to rely on
locale-sensitive case-conversion.
* lib/getdate.y: Include <c-ctype.h> rather than <ctype.h>.
(lookup_word): Use c_toupper in place of toupper.
(yylex, get_date): Use c_ prefixed variants of isspace and isalpha, too.
Reported by Vefa Bicakci <bicave@superonline.com> in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14184>.
* modules/getdate (Depends-on): Add c-ctype.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | lib/getdate.y | 14 | ||||
-rw-r--r-- | modules/getdate | 1 |
3 files changed, 21 insertions, 7 deletions
@@ -1,3 +1,16 @@ +2008-08-02 Jim Meyering <meyering@redhat.com> + + getdate.y: avoid locale-dependent date parsing failure + In Turkish locales, getdate would fail to recognize keywords + containing a lowercase "i". The solution is not to rely on + locale-sensitive case-conversion. + * lib/getdate.y: Include <c-ctype.h> rather than <ctype.h>. + (lookup_word): Use c_toupper in place of toupper. + (yylex, get_date): Use c_ prefixed variants of isspace and isalpha, too. + Reported by Vefa Bicakci <bicave@superonline.com> in + <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14184>. + * modules/getdate (Depends-on): Add c-ctype. + 2008-08-02 Bruno Haible <bruno@clisp.org> * gnulib-tool (func_import): When updating or creating a .gitignore diff --git a/lib/getdate.y b/lib/getdate.y index 695fd59c47..a94bf8be56 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -60,7 +60,7 @@ # undef static #endif -#include <ctype.h> +#include <c-ctype.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> @@ -900,7 +900,7 @@ lookup_word (parser_control const *pc, char *word) for (p = word; *p; p++) { unsigned char ch = *p; - *p = toupper (ch); + *p = c_toupper (ch); } for (tp = meridian_table; tp->name; tp++) @@ -965,7 +965,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) for (;;) { - while (c = *pc->input, isspace (c)) + while (c = *pc->input, c_isspace (c)) pc->input++; if (ISDIGIT (c) || c == '-' || c == '+') @@ -976,7 +976,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; - while (c = *++pc->input, isspace (c)) + while (c = *++pc->input, c_isspace (c)) continue; if (! ISDIGIT (c)) /* skip the '-' sign */ @@ -1080,7 +1080,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) } } - if (isalpha (c)) + if (c_isalpha (c)) { char buff[20]; char *p = buff; @@ -1092,7 +1092,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc) *p++ = c; c = *++pc->input; } - while (isalpha (c) || c == '.'); + while (c_isalpha (c) || c == '.'); *p = '\0'; tp = lookup_word (pc, buff); @@ -1205,7 +1205,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, c_isspace (c)) p++; if (strncmp (p, "TZ=\"", 4) == 0) diff --git a/modules/getdate b/modules/getdate index 59c1abf833..1328c221f9 100644 --- a/modules/getdate +++ b/modules/getdate @@ -10,6 +10,7 @@ m4/tm_gmtoff.m4 m4/getdate.m4 Depends-on: +c-ctype stdbool gettime intprops |