From: Bruno Haible Date: Tue, 14 Aug 2001 11:49:07 +0000 (+0000) Subject: Correct use of functions. X-Git-Tag: v0.11~550 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8af193fbf37556ba3797f59cbdc78439f7c32224;p=thirdparty%2Fgettext.git Correct use of functions. --- diff --git a/intl/ChangeLog b/intl/ChangeLog index b70893bbf..cbe031f33 100644 --- a/intl/ChangeLog +++ b/intl/ChangeLog @@ -1,3 +1,12 @@ +2001-07-28 Bruno Haible + + * l10nflist.c (_nl_normalize_codeset): Cast isalnum, isalpha, isdigit, + tolower argument to 'unsigned char'. + * loadmsgcat.c (_nl_load_domain): Cast isspace argument to + 'unsigned char'. + * localealias.c (read_alias_file): Cast isspace argument to + 'unsigned char'. + 2001-07-23 Bruno Haible * gettext.h: Assume exists. diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 557253eb9..291a74231 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -355,11 +355,11 @@ _nl_normalize_codeset (codeset, name_len) size_t cnt; for (cnt = 0; cnt < name_len; ++cnt) - if (isalnum (codeset[cnt])) + if (isalnum ((unsigned char) codeset[cnt])) { ++len; - if (isalpha (codeset[cnt])) + if (isalpha ((unsigned char) codeset[cnt])) only_digit = 0; } @@ -373,9 +373,9 @@ _nl_normalize_codeset (codeset, name_len) wp = retval; for (cnt = 0; cnt < name_len; ++cnt) - if (isalpha (codeset[cnt])) - *wp++ = tolower (codeset[cnt]); - else if (isdigit (codeset[cnt])) + if (isalpha ((unsigned char) codeset[cnt])) + *wp++ = tolower ((unsigned char) codeset[cnt]); + else if (isdigit ((unsigned char) codeset[cnt])) *wp++ = codeset[cnt]; *wp = '\0'; diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index d589243b2..fd73bd98f 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -507,7 +507,7 @@ _nl_load_domain (domain_file, domainbinding) struct parse_args args; nplurals += 9; - while (*nplurals != '\0' && isspace (*nplurals)) + while (*nplurals != '\0' && isspace ((unsigned char) *nplurals)) ++nplurals; #if defined HAVE_STRTOUL || defined _LIBC n = strtoul (nplurals, &endp, 10); diff --git a/intl/localealias.c b/intl/localealias.c index 76f19a9aa..76d99fc24 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -243,21 +243,21 @@ read_alias_file (fname, fname_len) cp = buf; /* Ignore leading white space. */ - while (isspace (cp[0])) + while (isspace ((unsigned char) cp[0])) ++cp; /* A leading '#' signals a comment line. */ if (cp[0] != '\0' && cp[0] != '#') { alias = cp++; - while (cp[0] != '\0' && !isspace (cp[0])) + while (cp[0] != '\0' && !isspace ((unsigned char) cp[0])) ++cp; /* Terminate alias name. */ if (cp[0] != '\0') *cp++ = '\0'; /* Now look for the beginning of the value. */ - while (isspace (cp[0])) + while (isspace ((unsigned char) cp[0])) ++cp; if (cp[0] != '\0') @@ -266,7 +266,7 @@ read_alias_file (fname, fname_len) size_t value_len; value = cp++; - while (cp[0] != '\0' && !isspace (cp[0])) + while (cp[0] != '\0' && !isspace ((unsigned char) cp[0])) ++cp; /* Terminate value. */ if (cp[0] == '\n') diff --git a/lib/ChangeLog b/lib/ChangeLog index 858c6069b..7091b26d7 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2001-07-28 Bruno Haible + + * printf-parse.h: Don't include . + (ISDIGIT): New macro. + (read_int, parse_one_spec): Use ISDIGIT instead of isdigit. + 2001-08-05 Bruno Haible * stdbool.h.in (_Bool): Define differently in C++ mode. diff --git a/lib/printf-parse.h b/lib/printf-parse.h index 899323a56..d363eada9 100644 --- a/lib/printf-parse.h +++ b/lib/printf-parse.h @@ -1,5 +1,5 @@ /* Internal header for parsing printf format strings. - Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 1998, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ /* We use some extension so define this here. */ #define _GNU_SOURCE 1 -#include #include #if HAVE_STDDEF_H # include @@ -69,6 +68,11 @@ # endif #endif +/* Locale independent test for a decimal digit. + Argument can be 'char' or 'unsigned char'. (Whereas the argument of + isdigit must be an 'unsigned char'.) */ +#define ISDIGIT(c) ((unsigned int) ((c) - '0') < 10) + struct printf_spec { /* Information parsed from the format spec. */ @@ -126,7 +130,7 @@ read_int (pstr) { unsigned int retval = **pstr - '0'; - while (isdigit (*++(*pstr))) + while (ISDIGIT (*++(*pstr))) { retval *= 10; retval += **pstr - '0'; @@ -177,7 +181,7 @@ parse_one_spec (format, posn, spec, max_ref_arg) spec->info.pad = ' '; /* Test for positional argument. */ - if (isdigit (*format)) + if (ISDIGIT (*format)) { const char *begin = format; @@ -240,7 +244,7 @@ parse_one_spec (format, posn, spec, max_ref_arg) A negative field width indicates left justification. */ const char *begin = ++format; - if (isdigit (*format)) + if (ISDIGIT (*format)) { /* The width argument might be found in a positional parameter. */ n = read_int (&format); @@ -261,7 +265,7 @@ parse_one_spec (format, posn, spec, max_ref_arg) format = begin; /* Step back and reread. */ } } - else if (isdigit (*format)) + else if (ISDIGIT (*format)) /* Constant width specification. */ spec->info.width = read_int (&format); @@ -277,7 +281,7 @@ parse_one_spec (format, posn, spec, max_ref_arg) /* The precision is given in an argument. */ const char *begin = ++format; - if (isdigit (*format)) + if (ISDIGIT (*format)) { n = read_int (&format); @@ -297,7 +301,7 @@ parse_one_spec (format, posn, spec, max_ref_arg) format = begin; } } - else if (isdigit (*format)) + else if (ISDIGIT (*format)) spec->info.prec = read_int (&format); else /* "%.?" is treated like "%.0?". */ diff --git a/src/ChangeLog b/src/ChangeLog index 6f4939506..ea5dc0cec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-07-28 Bruno Haible + + * po-lex.c: Include c-ctype.h instead of . + (control_sequence): Use C locale character classifications. + * xgettext.c (main): Cast isspace argument to 'unsigned char'. + 2001-07-28 Bruno Haible * po-lex.h (lex_start, lex_end): New declarations. diff --git a/src/po-lex.c b/src/po-lex.c index 7437c11d8..6d456b0bd 100644 --- a/src/po-lex.c +++ b/src/po-lex.c @@ -23,7 +23,6 @@ # include "config.h" #endif -#include #include #include #include @@ -35,6 +34,7 @@ # include #endif +#include "c-ctype.h" #include "linebreak.h" #include "libgettext.h" #define _(str) gettext(str) @@ -883,7 +883,8 @@ control_sequence () case 'x': lex_getc (mbc); - if (mb_iseof (mbc) || mb_len (mbc) != 1 || !isxdigit (mb_ptr (mbc) [0])) + if (mb_iseof (mbc) || mb_len (mbc) != 1 + || !c_isxdigit (mb_ptr (mbc) [0])) break; val = 0; @@ -891,10 +892,10 @@ control_sequence () { char c = mb_ptr (mbc) [0]; val *= 16; - if (isdigit (c)) + if (c_isdigit (c)) /* Warning: not portable, can't depend on '0'..'9' ordering */ val += c - '0'; - else if (isupper (c)) + else if (c_isupper (c)) /* Warning: not portable, can't depend on 'A'..'F' ordering */ val += c - 'A' + 10; else diff --git a/src/xgettext.c b/src/xgettext.c index 415951be6..3dc800365 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -228,7 +228,7 @@ main (argc, argv) add_all_comments = false; comment_tag = optarg; /* We ignore leading white space. */ - while (isspace (*comment_tag)) + while (isspace ((unsigned char) *comment_tag)) ++comment_tag; } break;