--- gawk-3.1.4/node.c.flonum 2004-07-28 15:45:04.000000000 +0200 +++ gawk-3.1.4/node.c 2004-11-09 15:53:03.353119096 +0100 @@ -91,7 +91,7 @@ if (do_non_decimal_data) { errno = 0; - if (! do_traditional && isnondecimal(cp)) { + if (! do_traditional && isnondecimal(cp, TRUE)) { n->numbr = nondec2awknum(cp, cpend - cp); goto finish; } @@ -584,3 +584,38 @@ return c; } } + +/* isnondecimal --- return true if number is not a decimal number */ + +int +isnondecimal(const char *str, int use_locale) +{ + int dec_point = '.'; +#if ENABLE_NLS && defined(HAVE_LOCALE_H) + if (use_locale) + dec_point = loc.decimal_point[0]; /* XXX --- assumes one char */ +#endif + + if (str[0] != '0') + return FALSE; + + /* leading 0x or 0X */ + if (str[1] == 'x' || str[1] == 'X') + return TRUE; + + /* + * Numbers with '.', 'e', or 'E' are decimal. + * Have to check so that things like 00.34 are handled right. + * + * These beasts can have trailing whitespace. Deal with that too. + */ + for (; *str != '\0'; str++) { + if (*str == 'e' || *str == 'E' || *str == dec_point) + return FALSE; + else if (! ISDIGIT(*str)) + break; + } + + return TRUE; +} + --- gawk-3.1.4/awkgram.y.flonum 2004-07-26 16:11:12.000000000 +0200 +++ gawk-3.1.4/awkgram.y 2004-11-09 15:53:03.355118792 +0100 @@ -2069,12 +2069,14 @@ eof_warned = TRUE; } tokadd('\0'); - if (! do_traditional && isnondecimal(tokstart)) { - static short warned = FALSE; - if (do_lint && ! warned) { - warned = TRUE; - lintwarn("numeric constant `%.*s' treated as octal or hexadecimal", - strlen(tokstart)-1, tokstart); + if (! do_traditional && isnondecimal(tokstart, FALSE)) { + if (do_lint) { + if (ISDIGIT(tokstart[1])) /* not an 'x' or 'X' */ + lintwarn("numeric constant `%.*s' treated as octal", + strlen(tokstart)-1, tokstart); + else if (tokstart[1] == 'x' || tokstart[1] == 'X') + lintwarn("numeric constant `%.*s' treated as hexadecimal", + strlen(tokstart)-1, tokstart); } yylval.nodeval = make_number(nondec2awknum(tokstart, strlen(tokstart))); } else --- gawk-3.1.4/builtin.c.flonum 2004-07-13 09:55:28.000000000 +0200 +++ gawk-3.1.4/builtin.c 2004-11-09 15:53:03.357118488 +0100 @@ -2779,7 +2779,7 @@ if ((tmp->flags & (NUMBER|NUMCUR)) != 0) d = (double) force_number(tmp); - else if (isnondecimal(tmp->stptr)) + else if (isnondecimal(tmp->stptr, TRUE)) d = nondec2awknum(tmp->stptr, tmp->stlen); else d = (double) force_number(tmp); --- gawk-3.1.4/awk.h.flonum 2004-07-26 16:11:05.000000000 +0200 +++ gawk-3.1.4/awk.h 2004-11-09 15:53:03.358118336 +0100 @@ -742,8 +742,6 @@ /* ------------------------- Pseudo-functions ------------------------- */ #define is_identchar(c) (isalnum(c) || (c) == '_') -#define isnondecimal(str) (((str)[0]) == '0' && (ISDIGIT((str)[1]) \ - || (str)[1] == 'x' || (str)[1] == 'X')) #define var_uninitialized(n) ((n)->var_value == Nnull_string) @@ -1138,6 +1136,7 @@ extern int avoid_dfa P((NODE *re, char *str, size_t len)); /* temporary */ extern int reisstring P((const char *text, size_t len, Regexp *re, const char *buf)); extern int remaybelong P((const char *text, size_t len)); +extern int isnondecimal P((const char *str, int use_locale)); /* strncasecmp.c */ #ifndef BROKEN_STRNCASECMP