From: Bruno Haible Date: Sun, 23 Mar 2025 19:17:56 +0000 (+0100) Subject: Refactor: Use more of c-ctype.h. X-Git-Tag: v0.25~75 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9158c623020e4933b98259f5b803e4ce54eb0c67;p=thirdparty%2Fgettext.git Refactor: Use more of c-ctype.h. * gettext-tools/src/format-awk.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-boost.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-c-parse.h (isdigit): Remove macro. (format_parse_entrails): Use c_isdigit instead. * gettext-tools/src/format-c++-brace.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-elisp.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-gcc-internal.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-gfc-internal.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-go.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-java-printf.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-javascript.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-librep.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-lua.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-pascal.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-perl.c (isdigit): Remove macro. (c_isnonzerodigit): Renamed from isnonzerodigit. (format_parse): Use c_isdigit instead of isdigit. * gettext-tools/src/format-php.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-python.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-ruby.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. * gettext-tools/src/format-tcl.c (isdigit): Remove macro. (format_parse): Use c_isdigit instead. --- diff --git a/gettext-tools/src/format-awk.c b/gettext-tools/src/format-awk.c index 57b5bcb35..bdacf3eea 100644 --- a/gettext-tools/src/format-awk.c +++ b/gettext-tools/src/format-awk.c @@ -1,5 +1,5 @@ /* awk format strings. - Copyright (C) 2001-2004, 2006-2007, 2009, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify @@ -75,12 +75,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -118,7 +112,7 @@ format_parse (const char *format, bool translated, char *fdi, FDI_SET (format - 1, FMTDIR_START); spec.directives++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -128,7 +122,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -155,7 +149,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -165,7 +159,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -224,9 +218,9 @@ format_parse (const char *format, bool translated, char *fdi, unnumbered_arg_count++; } } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -240,7 +234,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -250,7 +244,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -309,9 +303,9 @@ format_parse (const char *format, bool translated, char *fdi, unnumbered_arg_count++; } } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } } diff --git a/gettext-tools/src/format-boost.c b/gettext-tools/src/format-boost.c index c191ff1b3..eb7e2ece2 100644 --- a/gettext-tools/src/format-boost.c +++ b/gettext-tools/src/format-boost.c @@ -1,5 +1,5 @@ /* Boost format strings. - Copyright (C) 2001-2004, 2006-2007, 2009, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -96,12 +96,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -151,7 +145,7 @@ format_parse (const char *format, bool translated, char *fdi, brackets = true; } - if (isdigit (*format) && *format != '0') + if (c_isdigit (*format) && *format != '0') { const char *f = format; unsigned int m = 0; @@ -161,7 +155,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if ((!brackets && *f == '%') || *f == '$') { @@ -202,7 +196,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -212,7 +206,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -275,9 +269,9 @@ format_parse (const char *format, bool translated, char *fdi, unnumbered_arg_count++; } } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -291,7 +285,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -301,7 +295,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -364,9 +358,9 @@ format_parse (const char *format, bool translated, char *fdi, unnumbered_arg_count++; } } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } } diff --git a/gettext-tools/src/format-c++-brace.c b/gettext-tools/src/format-c++-brace.c index 33fa027fe..28968af18 100644 --- a/gettext-tools/src/format-c++-brace.c +++ b/gettext-tools/src/format-c++-brace.c @@ -1,5 +1,5 @@ /* C++ format strings. - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2023. This program is free software: you can redistribute it and/or modify @@ -195,12 +195,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -251,7 +245,7 @@ format_parse (const char *format, bool translated, char *fdi, unsigned int presentation; /* Parse arg-id. */ - if (isdigit (*format)) + if (c_isdigit (*format)) { /* Numbered argument. */ unsigned int arg_id; @@ -262,7 +256,7 @@ format_parse (const char *format, bool translated, char *fdi, else { format++; - while (isdigit (*format)) + while (c_isdigit (*format)) { if (arg_id >= UINT_MAX / 10) { @@ -355,16 +349,16 @@ format_parse (const char *format, bool translated, char *fdi, } /* Parse width. */ - if (isdigit (*format) && *format != '0') + if (c_isdigit (*format) && *format != '0') { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); } else if (*format == '{') { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { /* Numbered argument. */ unsigned int width_arg_id; @@ -375,7 +369,7 @@ format_parse (const char *format, bool translated, char *fdi, else { format++; - while (isdigit (*format)) + while (c_isdigit (*format)) { if (width_arg_id >= UINT_MAX / 10) { @@ -447,18 +441,18 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); have_precision = true; } else if (*format == '{') { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { /* Numbered argument. */ unsigned int precision_arg_id; @@ -469,7 +463,7 @@ format_parse (const char *format, bool translated, char *fdi, else { format++; - while (isdigit (*format)) + while (c_isdigit (*format)) { if (precision_arg_id >= UINT_MAX / 10) { diff --git a/gettext-tools/src/format-c-parse.h b/gettext-tools/src/format-c-parse.h index 42d2e1d29..0b52d4081 100644 --- a/gettext-tools/src/format-c-parse.h +++ b/gettext-tools/src/format-c-parse.h @@ -1,5 +1,5 @@ /* Parsing C format strings. - Copyright (C) 2001-2004, 2006-2007, 2009-2010, 2018, 2020, 2022-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify @@ -149,12 +149,6 @@ struct spec const char **sysdep_directives; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - /* Whether to recognize the 'I' flag. */ #if SYSDEP_SEGMENTS_PROCESSED /* The 'I' flag can only occur in glibc >= 2.2. On other platforms, gettext() @@ -212,7 +206,7 @@ format_parse_entrails (const char *format, bool translated, FDI_SET (format - 1, FMTDIR_START); spec.directives++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -222,7 +216,7 @@ format_parse_entrails (const char *format, bool translated, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -269,7 +263,7 @@ format_parse_entrails (const char *format, bool translated, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -279,7 +273,7 @@ format_parse_entrails (const char *format, bool translated, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -339,9 +333,9 @@ format_parse_entrails (const char *format, bool translated, spec.unnumbered_arg_count++; } } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -355,7 +349,7 @@ format_parse_entrails (const char *format, bool translated, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -365,7 +359,7 @@ format_parse_entrails (const char *format, bool translated, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -425,9 +419,9 @@ format_parse_entrails (const char *format, bool translated, spec.unnumbered_arg_count++; } } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } } diff --git a/gettext-tools/src/format-elisp.c b/gettext-tools/src/format-elisp.c index d041cd3b3..438d7c6aa 100644 --- a/gettext-tools/src/format-elisp.c +++ b/gettext-tools/src/format-elisp.c @@ -1,5 +1,5 @@ /* Emacs Lisp format strings. - Copyright (C) 2001-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify @@ -76,12 +76,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -117,7 +111,7 @@ format_parse (const char *format, bool translated, char *fdi, FDI_SET (format - 1, FMTDIR_START); spec.directives++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -127,7 +121,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$' && m > 0) { @@ -157,9 +151,9 @@ format_parse (const char *format, bool translated, char *fdi, number++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -182,9 +176,9 @@ format_parse (const char *format, bool translated, char *fdi, number++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } } diff --git a/gettext-tools/src/format-gcc-internal.c b/gettext-tools/src/format-gcc-internal.c index ce5ea66dd..4e7335b1e 100644 --- a/gettext-tools/src/format-gcc-internal.c +++ b/gettext-tools/src/format-gcc-internal.c @@ -1,5 +1,5 @@ /* GCC internal format strings. - Copyright (C) 2003-2009, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -140,12 +140,6 @@ struct spec bool uses_err_no; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -197,7 +191,7 @@ format_parse (const char *format, bool translated, char *fdi, format_arg_type_t size; format_arg_type_t type; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -207,7 +201,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -274,11 +268,11 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); if (*format != 's') { @@ -304,7 +298,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -314,7 +308,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { diff --git a/gettext-tools/src/format-gfc-internal.c b/gettext-tools/src/format-gfc-internal.c index 04a9b6d8b..ebb1ab7a4 100644 --- a/gettext-tools/src/format-gfc-internal.c +++ b/gettext-tools/src/format-gfc-internal.c @@ -1,5 +1,5 @@ /* GFC (GNU Fortran Compiler) internal format strings. - Copyright (C) 2003-2023 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2009. This program is free software: you can redistribute it and/or modify @@ -100,12 +100,6 @@ struct spec bool uses_currentloc; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -146,7 +140,7 @@ format_parse (const char *format, bool translated, char *fdi, { format_arg_type_t type; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -156,7 +150,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { diff --git a/gettext-tools/src/format-go.c b/gettext-tools/src/format-go.c index ae651afa4..259a3b397 100644 --- a/gettext-tools/src/format-go.c +++ b/gettext-tools/src/format-go.c @@ -97,12 +97,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -148,7 +142,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format == '[') { - if (isdigit (format[1])) + if (c_isdigit (format[1])) { const char *f = format + 1; unsigned int m = 0; @@ -159,7 +153,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == ']') { @@ -203,7 +197,7 @@ format_parse (const char *format, bool translated, char *fdi, } /* Parse width other than [m]*. */ - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int width = 0; @@ -214,7 +208,7 @@ format_parse (const char *format, bool translated, char *fdi, width = 10 * width + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (width > 1000000) { @@ -249,7 +243,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (format[1] == '[') { - if (isdigit (format[2])) + if (c_isdigit (format[2])) { const char *f = format + 2; unsigned int m = 0; @@ -260,7 +254,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == ']') { @@ -307,7 +301,7 @@ format_parse (const char *format, bool translated, char *fdi, } /* Parse precision other than [m]*. */ - if (isdigit (format[1])) + if (c_isdigit (format[1])) { const char *f = format + 1; unsigned int precision = 0; @@ -318,7 +312,7 @@ format_parse (const char *format, bool translated, char *fdi, precision = 10 * precision + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (precision > 1000000) { @@ -351,7 +345,7 @@ format_parse (const char *format, bool translated, char *fdi, parse_value: if (*format == '[') { - if (isdigit (format[1])) + if (c_isdigit (format[1])) { const char *f = format + 1; unsigned int m = 0; @@ -362,7 +356,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == ']') { diff --git a/gettext-tools/src/format-java-printf.c b/gettext-tools/src/format-java-printf.c index 1e76fd624..82283cd69 100644 --- a/gettext-tools/src/format-java-printf.c +++ b/gettext-tools/src/format-java-printf.c @@ -1,5 +1,5 @@ /* Java printf format strings. - Copyright (C) 2001-2004, 2006-2007, 2009-2010, 2018-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify @@ -118,12 +118,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -195,7 +189,7 @@ format_parse (const char *format, bool translated, char *fdi, number = last_arg_number; format++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -205,7 +199,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -265,9 +259,9 @@ format_parse (const char *format, bool translated, char *fdi, } /* Parse width. */ - if (isdigit (*format)) + if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); flags |= FAT_WIDTH; } @@ -276,7 +270,7 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (!isdigit (*format)) + if (!c_isdigit (*format)) { if (*format == '\0') { @@ -291,7 +285,7 @@ format_parse (const char *format, bool translated, char *fdi, goto bad_format; } - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); flags |= FAT_PRECISION; } diff --git a/gettext-tools/src/format-javascript.c b/gettext-tools/src/format-javascript.c index 79d87e1ae..810a98ce2 100644 --- a/gettext-tools/src/format-javascript.c +++ b/gettext-tools/src/format-javascript.c @@ -1,5 +1,5 @@ /* JavaScript format strings. - Copyright (C) 2001-2004, 2006-2010, 2013, 2016, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Andreas Stricker , 2010. It's based on python format module from Bruno Haible. @@ -77,12 +77,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -120,7 +114,7 @@ format_parse (const char *format, bool translated, char *fdi, FDI_SET (format - 1, FMTDIR_START); spec.directives++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -130,7 +124,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -151,14 +145,14 @@ format_parse (const char *format, bool translated, char *fdi, format++; /* Parse width. */ - while (isdigit (*format)) + while (c_isdigit (*format)) format++; if (*format == '.') { format++; - while (isdigit (*format)) + while (c_isdigit (*format)) format++; } diff --git a/gettext-tools/src/format-librep.c b/gettext-tools/src/format-librep.c index 66824c174..3d266e3f5 100644 --- a/gettext-tools/src/format-librep.c +++ b/gettext-tools/src/format-librep.c @@ -1,5 +1,5 @@ /* librep format strings. - Copyright (C) 2001-2004, 2006-2007, 2009, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify @@ -73,12 +73,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -114,7 +108,7 @@ format_parse (const char *format, bool translated, char *fdi, FDI_SET (format - 1, FMTDIR_START); spec.directives++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -124,7 +118,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$' && m > 0) { @@ -139,9 +133,9 @@ format_parse (const char *format, bool translated, char *fdi, format++; /* Parse width. */ - if (isdigit (*format)) + if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -149,9 +143,9 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } } diff --git a/gettext-tools/src/format-lua.c b/gettext-tools/src/format-lua.c index 98a9b20ea..1f0b8920f 100644 --- a/gettext-tools/src/format-lua.c +++ b/gettext-tools/src/format-lua.c @@ -1,5 +1,5 @@ /* Lua format strings. - Copyright (C) 2012-2023 Free Software Foundation, Inc. + Copyright (C) 2012-2025 Free Software Foundation, Inc. Written by Ľubomír Remák , 2012. This program is free software: you can redistribute it and/or modify @@ -72,12 +72,6 @@ struct spec enum format_arg_type *format_args; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static void format_free (void *descr); static void * @@ -108,7 +102,7 @@ format_parse (const char *format, bool translated, char *fdi, enum format_arg_type type; /* Remove width. */ - while (isdigit (*fatstr)) + while (c_isdigit (*fatstr)) fatstr++; if (*fatstr == '.') @@ -116,7 +110,7 @@ format_parse (const char *format, bool translated, char *fdi, fatstr++; /* Remove precision. */ - while (isdigit (*fatstr)) + while (c_isdigit (*fatstr)) fatstr++; } diff --git a/gettext-tools/src/format-pascal.c b/gettext-tools/src/format-pascal.c index 07b0021a4..855acc614 100644 --- a/gettext-tools/src/format-pascal.c +++ b/gettext-tools/src/format-pascal.c @@ -1,5 +1,5 @@ /* Object Pascal format strings. - Copyright (C) 2001-2004, 2006-2007, 2009-2010, 2018-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify @@ -87,12 +87,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -142,12 +136,12 @@ format_parse (const char *format, bool translated, char *fdi, unsigned int main_number = 0; enum format_arg_type type; - if (isdigit (*format) || *format == ':') + if (c_isdigit (*format) || *format == ':') { const char *f = format; unsigned int m = 0; - while (isdigit (*f)) + while (c_isdigit (*f)) { m = 10 * m + (*f - '0'); f++; @@ -174,11 +168,11 @@ format_parse (const char *format, bool translated, char *fdi, format++; /* Parse width. */ - if (isdigit (*format)) + if (c_isdigit (*format)) { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); } else if (*format == '*') { @@ -201,11 +195,11 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); } else if (*format == '*') { diff --git a/gettext-tools/src/format-perl.c b/gettext-tools/src/format-perl.c index 3e2d917af..6ffa05100 100644 --- a/gettext-tools/src/format-perl.c +++ b/gettext-tools/src/format-perl.c @@ -1,5 +1,5 @@ /* Perl format strings. - Copyright (C) 2004, 2006-2007, 2009, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2004-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or modify @@ -112,14 +112,8 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - /* Locale independent test for a nonzero decimal digit. */ -#define isnonzerodigit(c) ((unsigned int) ((c) - '1') < 9) +#define c_isnonzerodigit(c) ((unsigned int) ((c) - '1') < 9) static int @@ -161,7 +155,7 @@ format_parse (const char *format, bool translated, char *fdi, FDI_SET (format - 1, FMTDIR_START); directives++; - if (isnonzerodigit (*format)) + if (c_isnonzerodigit (*format)) { const char *f = format; unsigned int m = 0; @@ -171,7 +165,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -211,7 +205,7 @@ format_parse (const char *format, bool translated, char *fdi, numbered[numbered_arg_count].type = FAT_SCALAR_VECTOR; /* or FAT_STRING? */ numbered_arg_count++; } - else if (isnonzerodigit (*f)) + else if (c_isnonzerodigit (*f)) { unsigned int m = 0; @@ -220,7 +214,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -268,7 +262,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isnonzerodigit (*format)) + if (c_isnonzerodigit (*format)) { const char *f = format; unsigned int m = 0; @@ -278,7 +272,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -299,9 +293,9 @@ format_parse (const char *format, bool translated, char *fdi, numbered[numbered_arg_count].type = FAT_INTEGER; numbered_arg_count++; } - else if (isnonzerodigit (*format)) + else if (c_isnonzerodigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -315,7 +309,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; - if (isnonzerodigit (*format)) + if (c_isnonzerodigit (*format)) { const char *f = format; unsigned int m = 0; @@ -325,7 +319,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -346,7 +340,7 @@ format_parse (const char *format, bool translated, char *fdi, } else { - while (isdigit (*format)) format++; + while (c_isdigit (*format)) format++; } } diff --git a/gettext-tools/src/format-php.c b/gettext-tools/src/format-php.c index 8d941401d..b43fd5a99 100644 --- a/gettext-tools/src/format-php.c +++ b/gettext-tools/src/format-php.c @@ -1,5 +1,5 @@ /* PHP format strings. - Copyright (C) 2001-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify @@ -76,12 +76,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -124,7 +118,7 @@ format_parse (const char *format, bool translated, char *fdi, enum format_arg_type type; number = ++unnumbered_arg_count; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -134,7 +128,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -171,11 +165,11 @@ format_parse (const char *format, bool translated, char *fdi, } /* Parse width. */ - if (isdigit (*format)) + if (c_isdigit (*format)) { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); } /* Parse precision. */ @@ -183,11 +177,11 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { do format++; - while (isdigit (*format)); + while (c_isdigit (*format)); } else --format; /* will jump to bad_format */ diff --git a/gettext-tools/src/format-python.c b/gettext-tools/src/format-python.c index 79d118b37..9359abc3c 100644 --- a/gettext-tools/src/format-python.c +++ b/gettext-tools/src/format-python.c @@ -1,5 +1,5 @@ /* Python format strings. - Copyright (C) 2001-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify @@ -96,12 +96,6 @@ struct spec struct unnamed_arg *unnamed; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int named_arg_compare (const void *p1, const void *p2) @@ -199,9 +193,9 @@ format_parse (const char *format, bool translated, char *fdi, spec.unnamed[spec.unnamed_arg_count].type = FAT_INTEGER; spec.unnamed_arg_count++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } if (*format == '.') @@ -228,7 +222,7 @@ format_parse (const char *format, bool translated, char *fdi, spec.unnamed[spec.unnamed_arg_count].type = FAT_INTEGER; spec.unnamed_arg_count++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { zero_precision = true; do @@ -237,7 +231,7 @@ format_parse (const char *format, bool translated, char *fdi, zero_precision = false; format++; } - while (isdigit (*format)); + while (c_isdigit (*format)); } } diff --git a/gettext-tools/src/format-ruby.c b/gettext-tools/src/format-ruby.c index 88a5d8a75..b26922f64 100644 --- a/gettext-tools/src/format-ruby.c +++ b/gettext-tools/src/format-ruby.c @@ -104,12 +104,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int named_arg_compare (const void *p1, const void *p2) @@ -259,7 +253,7 @@ format_parse (const char *format, bool translated, char *fdi, continue; } - if (isdigit (*format)) + if (c_isdigit (*format)) { unsigned int m = 0; @@ -271,7 +265,7 @@ format_parse (const char *format, bool translated, char *fdi, m = UINT_MAX - 1; format++; } - while (isdigit (*format)); + while (c_isdigit (*format)); if (*format == '$') { @@ -322,7 +316,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Parse width. */ format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -335,7 +329,7 @@ format_parse (const char *format, bool translated, char *fdi, m = UINT_MAX - 1; f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -417,7 +411,7 @@ format_parse (const char *format, bool translated, char *fdi, { format++; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -430,7 +424,7 @@ format_parse (const char *format, bool translated, char *fdi, m = UINT_MAX - 1; f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -491,7 +485,7 @@ format_parse (const char *format, bool translated, char *fdi, continue; } - while (isdigit (*format)) + while (c_isdigit (*format)) format++; /* Seen a constant precision. */ diff --git a/gettext-tools/src/format-tcl.c b/gettext-tools/src/format-tcl.c index ff722b515..8dbdee2c1 100644 --- a/gettext-tools/src/format-tcl.c +++ b/gettext-tools/src/format-tcl.c @@ -1,5 +1,5 @@ /* Tcl format strings. - Copyright (C) 2001-2004, 2006-2007, 2009, 2019-2020, 2023 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify @@ -79,12 +79,6 @@ struct spec struct numbered_arg *numbered; }; -/* Locale independent test for a decimal digit. - Argument can be 'char' or 'unsigned char'. (Whereas the argument of - isdigit must be an 'unsigned char'.) */ -#undef isdigit -#define isdigit(c) ((unsigned int) ((c) - '0') < 10) - static int numbered_arg_compare (const void *p1, const void *p2) @@ -130,7 +124,7 @@ format_parse (const char *format, bool translated, char *fdi, enum format_arg_type type; is_numbered_arg = false; - if (isdigit (*format)) + if (c_isdigit (*format)) { const char *f = format; unsigned int m = 0; @@ -140,7 +134,7 @@ format_parse (const char *format, bool translated, char *fdi, m = 10 * m + (*f - '0'); f++; } - while (isdigit (*f)); + while (c_isdigit (*f)); if (*f == '$') { @@ -198,9 +192,9 @@ format_parse (const char *format, bool translated, char *fdi, number++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } /* Parse precision. */ @@ -223,9 +217,9 @@ format_parse (const char *format, bool translated, char *fdi, number++; } - else if (isdigit (*format)) + else if (c_isdigit (*format)) { - do format++; while (isdigit (*format)); + do format++; while (c_isdigit (*format)); } }