From: Bruno Haible Date: Mon, 23 Jun 2025 19:20:46 +0000 (+0200) Subject: Support format strings longer than 2 GiB on 64-bit platforms. X-Git-Tag: v0.26~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=baa77770778b3b7deb974f1da77cc7df947825e5;p=thirdparty%2Fgettext.git Support format strings longer than 2 GiB on 64-bit platforms. * gettext-tools/configure.ac: In config.h, define GCD_WORD_T. * gettext-tools/src/format-invalid.h: In format strings, use %zu instead of %u. * gettext-tools/src/format-awk.c: Use size_t instead of 'unsigned int'. In format strings, use %zu instead of %u. * gettext-tools/src/format-boost.c: Likewise. * gettext-tools/src/format-c.c: Likewise. * gettext-tools/src/format-c-parse.h: Likewise. * gettext-tools/src/format-c++-brace.c: Likewise. * gettext-tools/src/format-csharp.c: Likewise. * gettext-tools/src/format-d.c: Likewise. * gettext-tools/src/format-elisp.c: Likewise. * gettext-tools/src/format-gcc-internal.c: Likewise. * gettext-tools/src/format-gfc-internal.c: Likewise. * gettext-tools/src/format-go.c: Likewise. * gettext-tools/src/format-java.c: Likewise. * gettext-tools/src/format-java-printf.c: Likewise. * gettext-tools/src/format-javascript.c: Likewise. * gettext-tools/src/format-kde.c: Likewise. * gettext-tools/src/format-kde-kuit.c: Likewise. * gettext-tools/src/format-librep.c: Likewise. * gettext-tools/src/format-lisp.c: Likewise. * gettext-tools/src/format-lua.c: Likewise. * gettext-tools/src/format-modula2.c: Likewise. * gettext-tools/src/format-pascal.c: Likewise. * gettext-tools/src/format-perl.c: Likewise. * gettext-tools/src/format-perl-brace.c: Likewise. * gettext-tools/src/format-php.c: Likewise. * gettext-tools/src/format-python.c: Likewise. * gettext-tools/src/format-python-brace.c: Likewise. * gettext-tools/src/format-qt.c: Likewise. * gettext-tools/src/format-qt-plural.c: Likewise. * gettext-tools/src/format-ruby.c: Likewise. * gettext-tools/src/format-rust.c: Likewise. * gettext-tools/src/format-scheme.c: Likewise. * gettext-tools/src/format-sh.c: Likewise. * gettext-tools/src/format-sh-printf.c: Likewise. * gettext-tools/src/format-smalltalk.c: Likewise. * gettext-tools/src/format-tcl.c: Likewise. * gettext-tools/src/format.h (get_python_format_unnamed_arg_count): Return size_t instead of 'unsigned int'. --- diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index c440d1b1c..659e7e8c0 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -385,6 +385,9 @@ AH_TOP([ #define DEFAULT_OUTPUT_ALIGNMENT 1 ]) AH_BOTTOM([ +/* Parameterization of the 'gcd' module. */ +#define GCD_WORD_T size_t + /* A file name cannot consist of any character possible. INVALID_PATH_CHAR contains the characters not allowed. */ #if defined _MSC_VER || defined __MINGW32__ diff --git a/gettext-tools/src/format-awk.c b/gettext-tools/src/format-awk.c index 4ffb90106..adba4aca2 100644 --- a/gettext-tools/src/format-awk.c +++ b/gettext-tools/src/format-awk.c @@ -64,19 +64,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'awk-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -84,8 +84,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -96,8 +96,8 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; spec.directives = 0; @@ -112,7 +112,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format++ == '%') { /* A directive. */ - unsigned int number = 0; + size_t number = 0; enum format_arg_type type; bool likely_intentional = true; @@ -122,7 +122,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -156,14 +156,14 @@ format_parse (const char *format, bool translated, char *fdi, /* Parse width. */ if (*format == '*') { - unsigned int width_number = 0; + size_t width_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -241,14 +241,14 @@ format_parse (const char *format, bool translated, char *fdi, if (*format == '*') { - unsigned int precision_number = 0; + size_t precision_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -414,7 +414,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -505,9 +505,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -523,7 +523,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -535,7 +535,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -556,7 +556,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -594,8 +594,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -607,7 +607,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-boost.c b/gettext-tools/src/format-boost.c index a55b1a0c9..c8ca49883 100644 --- a/gettext-tools/src/format-boost.c +++ b/gettext-tools/src/format-boost.c @@ -85,19 +85,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'boost-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -105,8 +105,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -117,8 +117,8 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; spec.directives = 0; @@ -144,7 +144,7 @@ format_parse (const char *format, bool translated, char *fdi, { bool brackets = false; bool done = false; - unsigned int number = 0; + size_t number = 0; enum format_arg_type type = FAT_NONE; if (*format == '|') @@ -156,7 +156,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format) && *format != '0') { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -204,14 +204,14 @@ format_parse (const char *format, bool translated, char *fdi, /* Parse width. */ if (*format == '*') { - unsigned int width_number = 0; + size_t width_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -293,14 +293,14 @@ format_parse (const char *format, bool translated, char *fdi, if (*format == '*') { - unsigned int precision_number = 0; + size_t precision_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -454,7 +454,7 @@ format_parse (const char *format, bool translated, char *fdi, else { *invalid_reason = - xasprintf (_("The directive number %u starts with | but does not end with |."), + xasprintf (_("The directive number %zu starts with | but does not end with |."), spec.directives); FDI_SET (format, FMTDIR_ERROR); } @@ -522,7 +522,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -615,9 +615,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -633,7 +633,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -645,7 +645,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -666,7 +666,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -704,8 +704,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -717,7 +717,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-c++-brace.c b/gettext-tools/src/format-c++-brace.c index 28968af18..681f4930a 100644 --- a/gettext-tools/src/format-c++-brace.c +++ b/gettext-tools/src/format-c++-brace.c @@ -155,7 +155,7 @@ enum format_arg_type struct numbered_arg { /* The number of the argument, 0-based. */ - unsigned int number; + size_t number; /* The type is a bit mask that is the logical OR of the 'enum format_arg_type' values that represent each possible argument types for the argument. @@ -190,8 +190,8 @@ struct numbered_arg struct spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -199,8 +199,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -211,8 +211,8 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; spec.directives = 0; @@ -234,7 +234,7 @@ format_parse (const char *format, bool translated, char *fdi, else { /* A replacement field. */ - unsigned int arg_array_index; + size_t arg_array_index; bool have_sign = false; bool have_hash_flag = false; bool have_zero_flag = false; @@ -261,7 +261,7 @@ format_parse (const char *format, bool translated, char *fdi, if (arg_id >= UINT_MAX / 10) { *invalid_reason = - xasprintf (_("In the directive number %u, the arg-id is too large."), spec.directives); + xasprintf (_("In the directive number %zu, the arg-id is too large."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -374,7 +374,7 @@ format_parse (const char *format, bool translated, char *fdi, if (width_arg_id >= UINT_MAX / 10) { *invalid_reason = - xasprintf (_("In the directive number %u, the width's arg-id is too large."), spec.directives); + xasprintf (_("In the directive number %zu, the width's arg-id is too large."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -429,7 +429,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format != '}') { *invalid_reason = - xasprintf (_("In the directive number %u, the width's arg-id is not terminated through '}'."), spec.directives); + xasprintf (_("In the directive number %zu, the width's arg-id is not terminated through '}'."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; } @@ -468,7 +468,7 @@ format_parse (const char *format, bool translated, char *fdi, if (precision_arg_id >= UINT_MAX / 10) { *invalid_reason = - xasprintf (_("In the directive number %u, the width's arg-id is too large."), spec.directives); + xasprintf (_("In the directive number %zu, the width's arg-id is too large."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -523,7 +523,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format != '}') { *invalid_reason = - xasprintf (_("In the directive number %u, the precision's arg-id is not terminated through '}'."), spec.directives); + xasprintf (_("In the directive number %zu, the precision's arg-id is not terminated through '}'."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; } @@ -584,8 +584,8 @@ format_parse (const char *format, bool translated, char *fdi, default: *invalid_reason = (c_isprint (type_spec) - ? xasprintf (_("In the directive number %u, the character '%c' is not a standard type specifier."), spec.directives, type_spec) - : xasprintf (_("The character that terminates the directive number %u is not a standard type specifier."), spec.directives)); + ? xasprintf (_("In the directive number %zu, the character '%c' is not a standard type specifier."), spec.directives, type_spec) + : xasprintf (_("The character that terminates the directive number %zu is not a standard type specifier."), spec.directives)); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -593,7 +593,7 @@ format_parse (const char *format, bool translated, char *fdi, if (have_sign && (type & (FAT_INTEGER | FAT_FLOAT)) == 0) { *invalid_reason = - xasprintf (_("In the directive number %u, the sign specification is incompatible with the type specifier '%c'."), spec.directives, type_spec); + xasprintf (_("In the directive number %zu, the sign specification is incompatible with the type specifier '%c'."), spec.directives, type_spec); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -601,7 +601,7 @@ format_parse (const char *format, bool translated, char *fdi, if (have_hash_flag && (type & (FAT_INTEGER | FAT_FLOAT)) == 0) { *invalid_reason = - xasprintf (_("In the directive number %u, the '#' option is incompatible with the type specifier '%c'."), spec.directives, type_spec); + xasprintf (_("In the directive number %zu, the '#' option is incompatible with the type specifier '%c'."), spec.directives, type_spec); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -609,7 +609,7 @@ format_parse (const char *format, bool translated, char *fdi, if (have_zero_flag && (type & (FAT_INTEGER | FAT_FLOAT)) == 0) { *invalid_reason = - xasprintf (_("In the directive number %u, the '0' option is incompatible with the type specifier '%c'."), spec.directives, type_spec); + xasprintf (_("In the directive number %zu, the '0' option is incompatible with the type specifier '%c'."), spec.directives, type_spec); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -617,7 +617,7 @@ format_parse (const char *format, bool translated, char *fdi, if (have_precision && (type & (FAT_FLOAT | FAT_STRING)) == 0) { *invalid_reason = - xasprintf (_("In the directive number %u, the precision specification is incompatible with the type specifier '%c'."), spec.directives, type_spec); + xasprintf (_("In the directive number %zu, the precision specification is incompatible with the type specifier '%c'."), spec.directives, type_spec); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -625,7 +625,7 @@ format_parse (const char *format, bool translated, char *fdi, if (have_L_flag && (type & (FAT_INTEGER | FAT_FLOAT | FAT_CHARACTER | FAT_BOOL)) == 0) { *invalid_reason = - xasprintf (_("In the directive number %u, the 'L' option is incompatible with the type specifier '%c'."), spec.directives, type_spec); + xasprintf (_("In the directive number %zu, the 'L' option is incompatible with the type specifier '%c'."), spec.directives, type_spec); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -726,7 +726,7 @@ format_parse (const char *format, bool translated, char *fdi, if (type == FAT_NONE) { *invalid_reason = - xasprintf (_("The directive number %u, with all of its options, is not applicable to any type."), spec.directives); + xasprintf (_("The directive number %zu, with all of its options, is not applicable to any type."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; } @@ -738,7 +738,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format == '\0') { *invalid_reason = - xasprintf (_("The string ends in the middle of the directive number %u."), spec.directives); + xasprintf (_("The string ends in the middle of the directive number %zu."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; } @@ -746,7 +746,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format != '}') { *invalid_reason = - xasprintf (_("The directive number %u is not terminated through '}'."), spec.directives); + xasprintf (_("The directive number %zu is not terminated through '}'."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; } @@ -769,7 +769,7 @@ format_parse (const char *format, bool translated, char *fdi, *invalid_reason = (spec.directives == 0 ? xstrdup (_("The string starts in the middle of a directive: found '}' without matching '{'.")) - : xasprintf (_("The string contains a lone '}' after directive number %u."), spec.directives)); + : xasprintf (_("The string contains a lone '}' after directive number %zu."), spec.directives)); FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); goto bad_format; } @@ -787,7 +787,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -929,9 +929,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -947,7 +947,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -959,7 +959,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -985,7 +985,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, char buf[MAX_TYPE_DESCRIPTION_LEN]; get_type_description (buf, type_difference); error_logger (error_logger_data, - _("The format specification for argument %u in '%s' is applicable to the types %s, but the format specification for argument %u in '%s' is not."), + _("The format specification for argument %zu in '%s' is applicable to the types %s, but the format specification for argument %zu in '%s' is not."), spec1->numbered[i].number, pretty_msgid, buf, spec2->numbered[j].number, pretty_msgstr); } @@ -998,7 +998,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("The format specification for argument %u in '%s' uses a different presentation than the format specification for argument %u in '%s'."), + _("The format specification for argument %zu in '%s' uses a different presentation than the format specification for argument %zu in '%s'."), spec2->numbered[j].number, pretty_msgstr, spec1->numbered[i].number, pretty_msgid); err = true; @@ -1036,8 +1036,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -1049,7 +1049,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; char buf[MAX_TYPE_DESCRIPTION_LEN]; if (i > 0) diff --git a/gettext-tools/src/format-c-parse.h b/gettext-tools/src/format-c-parse.h index da9d22549..66cc808c9 100644 --- a/gettext-tools/src/format-c-parse.h +++ b/gettext-tools/src/format-c-parse.h @@ -130,7 +130,7 @@ typedef enum format_arg_type format_arg_type_t; struct numbered_arg { - unsigned int number; + size_t number; format_arg_type_t type; }; @@ -141,16 +141,16 @@ struct unnumbered_arg struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'c-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int unnumbered_arg_count; + size_t likely_intentional_directives; + size_t unnumbered_arg_count; struct unnumbered_arg *unnumbered; bool unlikely_intentional; - unsigned int sysdep_directives_count; + size_t sysdep_directives_count; const char **sysdep_directives; }; @@ -169,8 +169,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -182,9 +182,9 @@ format_parse_entrails (const char *format, bool translated, { const char *const format_start = format; struct spec spec; - unsigned int numbered_arg_count; + size_t numbered_arg_count; struct numbered_arg *numbered; - unsigned int allocated; + size_t allocated; spec.directives = 0; spec.likely_intentional_directives = 0; @@ -202,7 +202,7 @@ format_parse_entrails (const char *format, bool translated, if (*format++ == '%') { /* A directive. */ - unsigned int number = 0; + size_t number = 0; format_arg_type_t type; /* Relevant for the conversion characters d, i, b, o, u, x, X, n. */ format_arg_type_t integer_size; @@ -216,7 +216,7 @@ format_parse_entrails (const char *format, bool translated, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -270,14 +270,14 @@ format_parse_entrails (const char *format, bool translated, /* Parse width. */ if (*format == '*') { - unsigned int width_number = 0; + size_t width_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -356,14 +356,14 @@ format_parse_entrails (const char *format, bool translated, if (*format == '*') { - unsigned int precision_number = 0; + size_t precision_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -879,7 +879,7 @@ format_parse_entrails (const char *format, bool translated, /* Sort the numbered argument array, and eliminate duplicates. */ if (numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (numbered, numbered_arg_count, @@ -927,7 +927,7 @@ format_parse_entrails (const char *format, bool translated, numbered one. */ if (numbered_arg_count > 0) { - unsigned int i; + size_t i; for (i = 0; i < numbered_arg_count; i++) if (numbered[i].number != i + 1) diff --git a/gettext-tools/src/format-c.c b/gettext-tools/src/format-c.c index 7092b74bf..1529dddb6 100644 --- a/gettext-tools/src/format-c.c +++ b/gettext-tools/src/format-c.c @@ -33,16 +33,16 @@ #include "format-invalid.h" #define INVALID_C99_MACRO(directive_number) \ - xasprintf (_("In the directive number %u, the token after '<' is not the name of a format specifier macro. The valid macro names are listed in ISO C 99 section 7.8.1."), directive_number) + xasprintf (_("In the directive number %zu, the token after '<' is not the name of a format specifier macro. The valid macro names are listed in ISO C 99 section 7.8.1."), directive_number) #define INVALID_ANGLE_BRACKET(directive_number) \ - xasprintf (_("In the directive number %u, the token after '<' is not followed by '>'."), directive_number) + xasprintf (_("In the directive number %zu, the token after '<' is not followed by '>'."), directive_number) #define INVALID_SIZE_SPECIFIER(directive_number) \ - xasprintf (_("In the directive number %u, the argument size specifier is invalid."), directive_number) + xasprintf (_("In the directive number %zu, the argument size specifier is invalid."), directive_number) #define INVALID_IGNORED_ARGUMENT(referenced_arg, ignored_arg) \ - xasprintf (_("The string refers to argument number %u but ignores argument number %u."), referenced_arg, ignored_arg) + xasprintf (_("The string refers to argument number %zu but ignores argument number %zu."), referenced_arg, ignored_arg) /* Execute statement if memory allocation function returned NULL. */ #define IF_OOM(allocated_ptr, statement) /* nothing, since we use xalloc.h */ @@ -129,7 +129,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, struct spec *spec1 = (struct spec *) msgid_descr; struct spec *spec2 = (struct spec *) msgstr_descr; bool err = false; - unsigned int i; + size_t i; /* Check the argument types are the same. */ if (equality @@ -148,7 +148,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, i + 1); err = true; } @@ -191,9 +191,9 @@ get_sysdep_c_format_directives (const char *string, bool translated, if (descr != NULL && descr->sysdep_directives_count > 0) { - unsigned int n = descr->sysdep_directives_count; + size_t n = descr->sysdep_directives_count; struct interval *intervals = XNMALLOC (n, struct interval); - unsigned int i; + size_t i; for (i = 0; i < n; i++) { @@ -227,7 +227,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-csharp.c b/gettext-tools/src/format-csharp.c index 225418524..68d4cf479 100644 --- a/gettext-tools/src/format-csharp.c +++ b/gettext-tools/src/format-csharp.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 , 2003. This program is free software: you can redistribute it and/or modify @@ -48,8 +48,8 @@ struct spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; }; static void * @@ -75,14 +75,14 @@ format_parse (const char *format, bool translated, char *fdi, else { /* A directive. */ - unsigned int number; + size_t number; spec.directives++; if (!c_isdigit (*format)) { *invalid_reason = - xasprintf (_("In the directive number %u, '{' is not followed by an argument number."), spec.directives); + xasprintf (_("In the directive number %zu, '{' is not followed by an argument number."), spec.directives); FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); return NULL; } @@ -103,7 +103,7 @@ format_parse (const char *format, bool translated, char *fdi, if (!c_isdigit (*format)) { *invalid_reason = - xasprintf (_("In the directive number %u, ',' is not followed by a number."), spec.directives); + xasprintf (_("In the directive number %zu, ',' is not followed by a number."), spec.directives); FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); return NULL; @@ -133,8 +133,8 @@ format_parse (const char *format, bool translated, char *fdi, { *invalid_reason = (c_isprint (*format) - ? xasprintf (_("The directive number %u ends with an invalid character '%c' instead of '}'."), spec.directives, *format) - : xasprintf (_("The directive number %u ends with an invalid character instead of '}'."), spec.directives)); + ? xasprintf (_("The directive number %zu ends with an invalid character '%c' instead of '}'."), spec.directives, *format) + : xasprintf (_("The directive number %zu ends with an invalid character instead of '}'."), spec.directives)); FDI_SET (format, FMTDIR_ERROR); return NULL; } @@ -156,7 +156,7 @@ format_parse (const char *format, bool translated, char *fdi, *invalid_reason = (spec.directives == 0 ? xstrdup (_("The string starts in the middle of a directive: found '}' without matching '{'.")) - : xasprintf (_("The string contains a lone '}' after directive number %u."), spec.directives)); + : xasprintf (_("The string contains a lone '}' after directive number %zu."), spec.directives)); FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); return NULL; } @@ -231,7 +231,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-d.c b/gettext-tools/src/format-d.c index 52107641d..c26540e26 100644 --- a/gettext-tools/src/format-d.c +++ b/gettext-tools/src/format-d.c @@ -19,8 +19,8 @@ # include #endif -#include #include +#include #include #include "format.h" @@ -117,7 +117,7 @@ enum format_arg_type struct format_arg { - unsigned int repcount; /* Number of consecutive arguments this constraint + size_t repcount; /* Number of consecutive arguments this constraint applies to. Normally 1, but unconstrained arguments are often repeated. */ enum format_cdr_type presence; /* Can the argument list end right before @@ -128,11 +128,11 @@ struct format_arg struct segment { - unsigned int count; /* Number of format_arg records used. */ - unsigned int allocated; + size_t count; /* Number of format_arg records used. */ + size_t allocated; struct format_arg *element; /* Argument constraints. */ - unsigned int length; /* Number of arguments represented by this segment. - This is the sum of all repcounts in the segment. */ + size_t length; /* Number of arguments represented by this segment. + This is the sum of all repcounts in the segment. */ }; struct format_arg_list @@ -152,12 +152,12 @@ struct format_arg_list struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'd-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; + size_t likely_intentional_directives; struct format_arg_list *list; }; @@ -189,8 +189,8 @@ verify_element (const struct format_arg * e) static void verify_list (const struct format_arg_list *list) { - unsigned int i; - unsigned int total_repcount; + size_t i; + size_t total_repcount; ASSERT (list->initial.count <= list->initial.allocated); total_repcount = 0; @@ -230,7 +230,7 @@ free_element (struct format_arg *element) static void free_list (struct format_arg_list *list) { - unsigned int i; + size_t i; for (i = 0; i < list->initial.count; i++) free_element (&list->initial.element[i]); @@ -264,8 +264,8 @@ static struct format_arg_list * copy_list (const struct format_arg_list *list) { struct format_arg_list *newlist; - unsigned int length; - unsigned int i; + size_t length; + size_t i; VERIFY_LIST (list); @@ -332,7 +332,7 @@ static bool equal_list (const struct format_arg_list *list1, const struct format_arg_list *list2) { - unsigned int n, i; + size_t n, i; VERIFY_LIST (list1); VERIFY_LIST (list2); @@ -369,7 +369,7 @@ equal_list (const struct format_arg_list *list1, /* Ensure list->initial.allocated >= newcount. */ static inline void -ensure_initial_alloc (struct format_arg_list *list, unsigned int newcount) +ensure_initial_alloc (struct format_arg_list *list, size_t newcount) { if (newcount > list->initial.allocated) { @@ -399,7 +399,7 @@ grow_initial_alloc (struct format_arg_list *list) /* Ensure list->repeated.allocated >= newcount. */ static inline void -ensure_repeated_alloc (struct format_arg_list *list, unsigned int newcount) +ensure_repeated_alloc (struct format_arg_list *list, size_t newcount) { if (newcount > list->repeated.allocated) { @@ -436,7 +436,7 @@ grow_repeated_alloc (struct format_arg_list *list) static void normalize_outermost_list (struct format_arg_list *list) { - unsigned int n, i, j; + size_t n, i, j; /* Step 1: Combine adjacent elements. Copy from i to j, keeping 0 <= j <= i. */ @@ -480,7 +480,7 @@ normalize_outermost_list (struct format_arg_list *list) /* Nothing more to be done if the loop segment is empty. */ if (list->repeated.count > 0) { - unsigned int m, repcount0_extra; + size_t m, repcount0_extra; /* Step 2: Reduce the loop period. */ n = list->repeated.count; @@ -551,7 +551,7 @@ normalize_outermost_list (struct format_arg_list *list) && equal_element (&list->initial.element[list->initial.count-1], &list->repeated.element[list->repeated.count-1])) { - unsigned int moved_repcount = + size_t moved_repcount = MIN (list->initial.element[list->initial.count-1].repcount, list->repeated.element[list->repeated.count-1].repcount); @@ -561,7 +561,7 @@ normalize_outermost_list (struct format_arg_list *list) list->repeated.element[0].repcount += moved_repcount; else { - unsigned int newcount = list->repeated.count + 1; + size_t newcount = list->repeated.count + 1; ensure_repeated_alloc (list, newcount); for (i = newcount - 1; i > 0; i--) list->repeated.element[i] = list->repeated.element[i-1]; @@ -599,7 +599,7 @@ normalize_outermost_list (struct format_arg_list *list) static void normalize_list (struct format_arg_list *list) { - unsigned int n, i; + size_t n, i; VERIFY_LIST (list); @@ -690,13 +690,13 @@ is_empty_list (const struct format_arg_list *list) Assumes list->repeated.count > 0. */ /* Memory effects: list is destructively modified. */ static void -unfold_loop (struct format_arg_list *list, unsigned int m) +unfold_loop (struct format_arg_list *list, size_t m) { - unsigned int i, j, k; + size_t i, j, k; if (m > 1) { - unsigned int newcount = list->repeated.count * m; + size_t newcount = list->repeated.count * m; ensure_repeated_alloc (list, newcount); i = list->repeated.count; for (k = 1; k < m; k++) @@ -711,7 +711,7 @@ unfold_loop (struct format_arg_list *list, unsigned int m) Assumes list->repeated.count > 0. */ /* Memory effects: list is destructively modified. */ static void -rotate_loop (struct format_arg_list *list, unsigned int m) +rotate_loop (struct format_arg_list *list, size_t m) { if (m == list->initial.length) return; @@ -720,7 +720,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) { /* Instead of multiple copies of list->repeated.element[0], a single copy with higher repcount is appended to list->initial. */ - unsigned int i, newcount; + size_t i, newcount; newcount = list->initial.count + 1; ensure_initial_alloc (list, newcount); @@ -732,16 +732,16 @@ rotate_loop (struct format_arg_list *list, unsigned int m) } else { - unsigned int n = list->repeated.length; + size_t n = list->repeated.length; /* Write m = list->initial.length + q * n + r with 0 <= r < n. */ - unsigned int q = (m - list->initial.length) / n; - unsigned int r = (m - list->initial.length) % n; + size_t q = (m - list->initial.length) / n; + size_t r = (m - list->initial.length) % n; /* Determine how many entries of list->repeated are needed for length r. */ - unsigned int s; - unsigned int t; + size_t s; + size_t t; for (t = r, s = 0; s < list->repeated.count && t >= list->repeated.element[s].repcount; @@ -756,7 +756,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) plus the s first elements of list->repeated, plus, if t > 0, a splitoff of list->repeated.element[s]. */ { - unsigned int i, j, k, newcount; + size_t i, j, k, newcount; i = list->initial.count; newcount = i + q * list->repeated.count + s + (t > 0 ? 1 : 0); @@ -789,7 +789,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) /* And rotate list->repeated. */ if (r > 0) { - unsigned int i, j, oldcount, newcount; + size_t i, j, oldcount, newcount; struct format_arg *newelement; oldcount = list->repeated.count; @@ -818,14 +818,14 @@ rotate_loop (struct format_arg_list *list, unsigned int m) i.e. if 0 < n < list->initial.length, then n-1 and n are covered by two different adjacent elements. */ /* Memory effects: list is destructively modified. */ -static unsigned int -initial_splitelement (struct format_arg_list *list, unsigned int n) +static size_t +initial_splitelement (struct format_arg_list *list, size_t n) { - unsigned int s; - unsigned int t; - unsigned int oldrepcount; - unsigned int newcount; - unsigned int i; + size_t s; + size_t t; + size_t oldrepcount; + size_t newcount; + size_t i; VERIFY_LIST (list); @@ -866,15 +866,15 @@ initial_splitelement (struct format_arg_list *list, unsigned int n) /* Ensure index n in the initial segment is not shared. Return its index. */ /* Memory effects: list is destructively modified. */ -MAYBE_UNUSED static unsigned int -initial_unshare (struct format_arg_list *list, unsigned int n) +MAYBE_UNUSED static size_t +initial_unshare (struct format_arg_list *list, size_t n) { /* This does the same side effects as initial_splitelement (list, n); initial_splitelement (list, n + 1); */ - unsigned int s; - unsigned int t; + size_t s; + size_t t; VERIFY_LIST (list); @@ -898,13 +898,13 @@ initial_unshare (struct format_arg_list *list, unsigned int n) { /* Split the entry into at most three entries: for indices < n, for index n, and for indices > n. */ - unsigned int oldrepcount = list->initial.element[s].repcount; - unsigned int newcount = + size_t oldrepcount = list->initial.element[s].repcount; + size_t newcount = list->initial.count + (t == 0 || t == oldrepcount - 1 ? 1 : 2); ensure_initial_alloc (list, newcount); if (t == 0 || t == oldrepcount - 1) { - unsigned int i; + size_t i; for (i = list->initial.count - 1; i > s; i--) list->initial.element[i+1] = list->initial.element[i]; @@ -922,7 +922,7 @@ initial_unshare (struct format_arg_list *list, unsigned int n) } else { - unsigned int i; + size_t i; for (i = list->initial.count - 1; i > s; i--) list->initial.element[i+2] = list->initial.element[i]; @@ -1018,7 +1018,7 @@ append_repeated_to_initial (struct format_arg_list *list) if (list->repeated.count > 0) { /* Move list->repeated over to list->initial. */ - unsigned int i, j, newcount; + size_t i, j, newcount; newcount = list->initial.count + list->repeated.count; ensure_initial_alloc (list, newcount); @@ -1048,7 +1048,7 @@ backtrack_in_initial (struct format_arg_list *list) while (list->initial.count > 0) { - unsigned int i = list->initial.count - 1; + size_t i = list->initial.count - 1; if (list->initial.element[i].presence == FCT_REQUIRED) { /* Throw away this element. */ @@ -1093,11 +1093,11 @@ make_intersected_list (struct format_arg_list *list1, if (list1->repeated.length > 0 && list2->repeated.length > 0) /* Step 1: Ensure list1->repeated.length == list2->repeated.length. */ { - unsigned int n1 = list1->repeated.length; - unsigned int n2 = list2->repeated.length; - unsigned int g = gcd (n1, n2); - unsigned int m1 = n2 / g; /* = lcm(n1,n2) / n1 */ - unsigned int m2 = n1 / g; /* = lcm(n1,n2) / n2 */ + size_t n1 = list1->repeated.length; + size_t n2 = list2->repeated.length; + size_t g = gcd (n1, n2); + size_t m1 = n2 / g; /* = lcm(n1,n2) / n1 */ + size_t m2 = n1 / g; /* = lcm(n1,n2) / n2 */ unfold_loop (list1, m1); unfold_loop (list2, m2); @@ -1110,7 +1110,7 @@ make_intersected_list (struct format_arg_list *list1, repeated segment, this means to ensure list1->initial.length == list2->initial.length. */ { - unsigned int m = MAX (list1->initial.length, list2->initial.length); + size_t m = MAX (list1->initial.length, list2->initial.length); if (list1->repeated.length > 0) rotate_loop (list1, m); @@ -1139,8 +1139,8 @@ make_intersected_list (struct format_arg_list *list1, { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->initial.element; c1 = list1->initial.count; e2 = list2->initial.element; c2 = list2->initial.count; @@ -1227,8 +1227,8 @@ make_intersected_list (struct format_arg_list *list1, { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->repeated.element; c1 = list1->repeated.count; e2 = list2->repeated.element; c2 = list2->repeated.count; @@ -1374,10 +1374,10 @@ make_union_with_empty_list (struct format_arg_list *list) /* Test whether arguments 0..n are required arguments in a list. */ MAYBE_UNUSED static bool -is_required (const struct format_arg_list *list, unsigned int n) +is_required (const struct format_arg_list *list, size_t n) { - unsigned int s; - unsigned int t; + size_t s; + size_t t; /* We'll check whether the first n+1 presence flags are FCT_REQUIRED. */ t = n + 1; @@ -1432,9 +1432,9 @@ is_required (const struct format_arg_list *list, unsigned int n) present. NULL stands for an impossible situation, i.e. a contradiction. */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_required_constraint (struct format_arg_list *list, unsigned int n) +add_required_constraint (struct format_arg_list *list, size_t n) { - unsigned int i, rest; + size_t i, rest; if (list == NULL) return NULL; @@ -1469,9 +1469,9 @@ add_required_constraint (struct format_arg_list *list, unsigned int n) contradiction. */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_end_constraint (struct format_arg_list *list, unsigned int n) +add_end_constraint (struct format_arg_list *list, size_t n) { - unsigned int s, i; + size_t s, i; enum format_cdr_type n_presence; if (list == NULL) @@ -1519,11 +1519,11 @@ add_end_constraint (struct format_arg_list *list, unsigned int n) /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * add_type_constraint (struct format_arg_list *list, - unsigned int n1, unsigned int n2, + size_t n1, size_t n2, enum format_arg_type type, struct format_arg_list *sublist) { - unsigned int s; + size_t s; struct format_arg newconstraint; if (list == NULL) @@ -1540,7 +1540,7 @@ add_type_constraint (struct format_arg_list *list, newconstraint.list = sublist; /* Modify the elements that represent the indices n1..n2. */ - unsigned int n = n1; + size_t n = n1; while (n <= n2) { struct format_arg tmpelement; @@ -1571,12 +1571,12 @@ add_type_constraint (struct format_arg_list *list, /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * add_repeated_opt_type_constraint (struct format_arg_list *list, - unsigned int n, + size_t n, enum format_arg_type type, struct format_arg_list *sublist) { - unsigned int s; + size_t s; struct format_arg newconstraint; if (list == NULL) @@ -1633,7 +1633,7 @@ add_repeated_opt_type_constraint (struct format_arg_list *list, static void add_req_type_constraint (struct format_arg_list **listp, - unsigned int position1, unsigned int position2, + size_t position1, size_t position2, enum format_arg_type type, struct format_arg_list *sublist) { @@ -1655,13 +1655,13 @@ add_req_type_constraint (struct format_arg_list **listp, /* ======================= The format string parser ======================= */ #define INVALID_ARGNO_ORDER(directive_number) \ - xasprintf (_("In the directive number %u, the first argument number is greater than the second argument number."), directive_number) + xasprintf (_("In the directive number %zu, the first argument number is greater than the second argument number."), directive_number) #define INVALID_COMPOUND_VARARG(directive_number) \ - xasprintf (_("In the directive number %u, the compound specifier consumes a variable number of arguments."), directive_number) + xasprintf (_("In the directive number %zu, the compound specifier consumes a variable number of arguments."), directive_number) #define INVALID_COMPOUND_ARGCOUNT(directive_number, num_arguments) \ - xasprintf (_("In the directive number %u, the compound specifier consumes %u arguments."), directive_number, num_arguments) + xasprintf (_("In the directive number %zu, the compound specifier consumes %zu arguments."), directive_number, num_arguments) #define INVALID_BAR_OUTSIDE_COMPOUND() \ xstrdup (_("Found '%|' outside of '%(...%)'.")) @@ -1670,13 +1670,13 @@ add_req_type_constraint (struct format_arg_list **listp, xstrdup (_("The string ends in the middle of a compound specifier.")) #define INVALID_COMPOUND_DELIMITER(directive_number) \ - xasprintf (_("In the directive number %u, there is an invalid directive in the delimiter part of a compound specifier."), directive_number) + xasprintf (_("In the directive number %zu, there is an invalid directive in the delimiter part of a compound specifier."), directive_number) #define INVALID_NESTING(found_char, notfound_char) \ xasprintf (_("Found '%%%c' without matching '%%%c'."), found_char, notfound_char) #define INVALID_ARG_PAST_LAST(directive_number) \ - xasprintf (_("The directive number %u references an argument after the last argument."), directive_number) + xasprintf (_("The directive number %zu references an argument after the last argument."), directive_number) #undef INVALID_INCOMPATIBLE_ARG_TYPES #define INVALID_INCOMPATIBLE_ARG_TYPES() \ @@ -1698,7 +1698,7 @@ parse_upto (struct spec *spec, { const char *format = *formatp; const char *const format_start = format; - unsigned int arg_count = 0; + size_t arg_count = 0; for (; *format != '\0'; ) { @@ -1725,12 +1725,12 @@ parse_upto (struct spec *spec, else { /* A directive. */ - unsigned int first_number = 0; - unsigned int second_number = 0; + size_t first_number = 0; + size_t second_number = 0; bool second_is_last = false; - unsigned int width_number = 0; + size_t width_number = 0; bool width_from_arg = false; - unsigned int precision_number = 0; + size_t precision_number = 0; bool precision_from_arg = false; bool separator_digits_from_arg = false; bool separator_char_from_arg = false; @@ -1739,7 +1739,7 @@ parse_upto (struct spec *spec, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -1764,7 +1764,7 @@ parse_upto (struct spec *spec, f++; if (c_isdigit (*f)) { - unsigned int m2 = 0; + size_t m2 = 0; do { @@ -1821,7 +1821,7 @@ parse_upto (struct spec *spec, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -1861,7 +1861,7 @@ parse_upto (struct spec *spec, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -2037,7 +2037,7 @@ parse_upto (struct spec *spec, } else if (width_from_arg) { - if (arg_count == UINT_MAX) + if (arg_count == SIZE_MAX) { *invalid_reason = INVALID_ARG_PAST_LAST (spec->directives); FDI_SET (format, FMTDIR_ERROR); @@ -2057,7 +2057,7 @@ parse_upto (struct spec *spec, } else if (precision_from_arg) { - if (arg_count == UINT_MAX) + if (arg_count == SIZE_MAX) { *invalid_reason = INVALID_ARG_PAST_LAST (spec->directives); FDI_SET (format, FMTDIR_ERROR); @@ -2070,7 +2070,7 @@ parse_upto (struct spec *spec, if (separator_digits_from_arg) { - if (arg_count == UINT_MAX) + if (arg_count == SIZE_MAX) { *invalid_reason = INVALID_ARG_PAST_LAST (spec->directives); FDI_SET (format, FMTDIR_ERROR); @@ -2083,7 +2083,7 @@ parse_upto (struct spec *spec, if (separator_char_from_arg) { - if (arg_count == UINT_MAX) + if (arg_count == SIZE_MAX) { *invalid_reason = INVALID_ARG_PAST_LAST (spec->directives); FDI_SET (format, FMTDIR_ERROR); @@ -2109,7 +2109,7 @@ parse_upto (struct spec *spec, type, elementwise_list); spec->list = add_repeated_opt_type_constraint (spec->list, first_number, type, elementwise_list); - arg_count = UINT_MAX; + arg_count = SIZE_MAX; } else { @@ -2121,7 +2121,7 @@ parse_upto (struct spec *spec, } else { - if (arg_count == UINT_MAX) + if (arg_count == SIZE_MAX) { *invalid_reason = INVALID_ARG_PAST_LAST (spec->directives); FDI_SET (format, FMTDIR_ERROR); @@ -2154,7 +2154,7 @@ parse_upto (struct spec *spec, *formatp = format; /* Extra arguments at the end are not allowed. */ - if (arg_count != UINT_MAX) + if (arg_count != SIZE_MAX) { spec->list = add_end_constraint (spec->list, arg_count); if (spec->list == NULL) @@ -2362,7 +2362,7 @@ print_element (struct format_arg *element) static void print_list (struct format_arg_list *list) { - unsigned int i, j; + size_t i, j; printf ("("); diff --git a/gettext-tools/src/format-elisp.c b/gettext-tools/src/format-elisp.c index 819aa6c9f..237b7e9ac 100644 --- a/gettext-tools/src/format-elisp.c +++ b/gettext-tools/src/format-elisp.c @@ -65,19 +65,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'elisp-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -85,8 +85,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -97,9 +97,9 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; + size_t numbered_allocated; struct spec *result; - unsigned int number; + size_t number; spec.directives = 0; spec.likely_intentional_directives = 0; @@ -121,7 +121,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -252,7 +252,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -343,9 +343,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -361,7 +361,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -373,7 +373,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -394,7 +394,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -432,8 +432,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -445,7 +445,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-gcc-internal.c b/gettext-tools/src/format-gcc-internal.c index 7c9d3ca12..303b396b9 100644 --- a/gettext-tools/src/format-gcc-internal.c +++ b/gettext-tools/src/format-gcc-internal.c @@ -171,14 +171,14 @@ typedef enum format_arg_type format_arg_type_t; struct numbered_arg { - unsigned int number; + size_t number; format_arg_type_t type; }; struct spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct numbered_arg *numbered; bool uses_err_no; bool uses_current_locus; @@ -188,8 +188,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -200,11 +200,11 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; - unsigned int in_quote_group; - unsigned int in_color_group; - unsigned int in_url_group; + size_t numbered_allocated; + size_t unnumbered_arg_count; + size_t in_quote_group; + size_t in_color_group; + size_t in_url_group; struct spec *result; spec.directives = 0; @@ -232,7 +232,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (in_quote_group) { - *invalid_reason = xasprintf (_("The directive number %u opens a quote group, but the previous one is not terminated."), spec.directives); + *invalid_reason = xasprintf (_("The directive number %zu opens a quote group, but the previous one is not terminated."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -242,7 +242,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (!in_quote_group) { - *invalid_reason = xasprintf (_("The directive number %u does not match a preceding '%%%c'."), spec.directives, '<'); + *invalid_reason = xasprintf (_("The directive number %zu does not match a preceding '%%%c'."), spec.directives, '<'); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -252,7 +252,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (!in_color_group) { - *invalid_reason = xasprintf (_("The directive number %u does not match a preceding '%%%c'."), spec.directives, 'r'); + *invalid_reason = xasprintf (_("The directive number %zu does not match a preceding '%%%c'."), spec.directives, 'r'); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -262,7 +262,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (!in_url_group) { - *invalid_reason = xasprintf (_("The directive number %u does not match a preceding '%%%c'."), spec.directives, '{'); + *invalid_reason = xasprintf (_("The directive number %zu does not match a preceding '%%%c'."), spec.directives, '{'); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -274,7 +274,7 @@ format_parse (const char *format, bool translated, char *fdi, spec.uses_current_locus = true; else { - unsigned int number = 0; + size_t number = 0; unsigned int flag_q = 0; unsigned int flag_l = 0; unsigned int flag_w = 0; @@ -288,7 +288,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -351,7 +351,7 @@ format_parse (const char *format, bool translated, char *fdi, flag_sharp = 1; continue; invalid_flags: - *invalid_reason = xasprintf (_("In the directive number %u, the flags combination is invalid."), spec.directives); + *invalid_reason = xasprintf (_("In the directive number %zu, the flags combination is invalid."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; default: @@ -390,7 +390,7 @@ format_parse (const char *format, bool translated, char *fdi, else { *invalid_reason = - xasprintf (_("In the directive number %u, a precision is not allowed before '%c'."), spec.directives, *format); + xasprintf (_("In the directive number %zu, a precision is not allowed before '%c'."), spec.directives, *format); FDI_SET (format, FMTDIR_ERROR); } goto bad_format; @@ -400,14 +400,14 @@ format_parse (const char *format, bool translated, char *fdi, } else if (*format == '*') { - unsigned int precision_number = 0; + size_t precision_number = 0; format++; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -432,7 +432,7 @@ format_parse (const char *format, bool translated, char *fdi, } if (m != number - 1) { - *invalid_reason = xasprintf (_("In the directive number %u, the argument number for the precision must be equal to %u."), spec.directives, number - 1); + *invalid_reason = xasprintf (_("In the directive number %zu, the argument number for the precision must be equal to %zu."), spec.directives, number - 1); FDI_SET (f, FMTDIR_ERROR); goto bad_format; } @@ -496,7 +496,7 @@ format_parse (const char *format, bool translated, char *fdi, else { *invalid_reason = - xasprintf (_("In the directive number %u, a precision specification is not allowed before '%c'."), spec.directives, *format); + xasprintf (_("In the directive number %zu, a precision specification is not allowed before '%c'."), spec.directives, *format); FDI_SET (format, FMTDIR_ERROR); } goto bad_format; @@ -504,7 +504,7 @@ format_parse (const char *format, bool translated, char *fdi, } else { - *invalid_reason = xasprintf (_("In the directive number %u, the precision specification is invalid."), spec.directives); + *invalid_reason = xasprintf (_("In the directive number %zu, the precision specification is invalid."), spec.directives); FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); goto bad_format; @@ -530,7 +530,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (in_color_group) { - *invalid_reason = xasprintf (_("The directive number %u opens a color group, but the previous one is not terminated."), spec.directives); + *invalid_reason = xasprintf (_("The directive number %zu opens a color group, but the previous one is not terminated."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -541,7 +541,7 @@ format_parse (const char *format, bool translated, char *fdi, { if (in_url_group) { - *invalid_reason = xasprintf (_("The directive number %u opens a URL group, but the previous one is not terminated."), spec.directives); + *invalid_reason = xasprintf (_("The directive number %zu opens a URL group, but the previous one is not terminated."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -669,17 +669,17 @@ format_parse (const char *format, bool translated, char *fdi, if (in_quote_group) { - *invalid_reason = xasprintf (_("The quote group opened by the directive number %u is not terminated."), in_quote_group); + *invalid_reason = xasprintf (_("The quote group opened by the directive number %zu is not terminated."), in_quote_group); goto bad_format; } if (in_color_group) { - *invalid_reason = xasprintf (_("The color group opened by the directive number %u is not terminated."), in_color_group); + *invalid_reason = xasprintf (_("The color group opened by the directive number %zu is not terminated."), in_color_group); goto bad_format; } if (in_url_group) { - *invalid_reason = xasprintf (_("The URL group opened by the directive number %u is not terminated."), in_url_group); + *invalid_reason = xasprintf (_("The URL group opened by the directive number %zu is not terminated."), in_url_group); goto bad_format; } @@ -689,7 +689,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -772,9 +772,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -790,7 +790,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -802,7 +802,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -823,7 +823,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -895,8 +895,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -908,7 +908,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-gfc-internal.c b/gettext-tools/src/format-gfc-internal.c index b46602c6f..420e16061 100644 --- a/gettext-tools/src/format-gfc-internal.c +++ b/gettext-tools/src/format-gfc-internal.c @@ -86,7 +86,7 @@ typedef enum format_arg_type format_arg_type_t; struct numbered_arg { - unsigned int number; + size_t number; format_arg_type_t type; }; @@ -97,8 +97,8 @@ struct unnumbered_arg struct spec { - unsigned int directives; - unsigned int unnumbered_arg_count; + size_t directives; + size_t unnumbered_arg_count; struct unnumbered_arg *unnumbered; bool uses_currentloc; }; @@ -107,8 +107,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -119,11 +119,11 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_arg_count; - unsigned int numbered_allocated; + size_t numbered_arg_count; + size_t numbered_allocated; struct numbered_arg *numbered; struct spec *result; - unsigned int number; + size_t number; spec.directives = 0; numbered_arg_count = 0; @@ -146,7 +146,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -230,7 +230,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (numbered, numbered_arg_count, @@ -277,13 +277,13 @@ format_parse (const char *format, bool translated, char *fdi, /* Verify that the format string uses all arguments up to the highest numbered one. */ { - unsigned int i; + size_t i; for (i = 0; i < numbered_arg_count; i++) if (numbered[i].number != i + 1) { *invalid_reason = - xasprintf (_("The string refers to argument number %u but ignores argument number %u."), numbered[i].number, i + 1); + xasprintf (_("The string refers to argument number %zu but ignores argument number %zu."), numbered[i].number, i + 1); goto bad_format; } } @@ -291,7 +291,7 @@ format_parse (const char *format, bool translated, char *fdi, /* So now the numbered arguments array is equivalent to a sequence of unnumbered arguments. Eliminate the FAT_VOID placeholders. */ { - unsigned int i; + size_t i; spec.unnumbered_arg_count = 0; for (i = 0; i < numbered_arg_count; i++) @@ -300,7 +300,7 @@ format_parse (const char *format, bool translated, char *fdi, if (spec.unnumbered_arg_count > 0) { - unsigned int j; + size_t j; spec.unnumbered = XNMALLOC (spec.unnumbered_arg_count, struct unnumbered_arg); j = 0; @@ -349,7 +349,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, struct spec *spec1 = (struct spec *) msgid_descr; struct spec *spec2 = (struct spec *) msgstr_descr; bool err = false; - unsigned int i; + size_t i; /* Check the argument types are the same. */ if (equality @@ -368,7 +368,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, i + 1); err = true; } @@ -415,7 +415,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-go.c b/gettext-tools/src/format-go.c index 466d6cd62..4d1ef5d07 100644 --- a/gettext-tools/src/format-go.c +++ b/gettext-tools/src/format-go.c @@ -86,19 +86,19 @@ typedef unsigned int format_arg_type_t; struct numbered_arg { - unsigned int number; + size_t number; format_arg_type_t type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'go-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -106,14 +106,14 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } #define INVALID_ARGNO_TOO_LARGE(directive_number) \ - xasprintf (_("In the directive number %u, the argument number is too large."), directive_number) + xasprintf (_("In the directive number %zu, the argument number is too large."), directive_number) static void * format_parse (const char *format, bool translated, char *fdi, @@ -121,9 +121,9 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int allocated; + size_t allocated; struct spec *result; - unsigned int number; + size_t number; spec.directives = 0; spec.likely_intentional_directives = 0; @@ -156,7 +156,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (format[1])) { const char *f = format + 1; - unsigned int m = 0; + size_t m = 0; do { @@ -186,7 +186,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Parse width. */ if (*format == '*') { - unsigned int width_number = number; + size_t width_number = number; if (allocated == spec.numbered_arg_count) { @@ -211,7 +211,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int width = 0; + size_t width = 0; do { @@ -224,7 +224,7 @@ format_parse (const char *format, bool translated, char *fdi, if (width > 1000000) { *invalid_reason = - xasprintf (_("In the directive number %u, the width is too large."), + xasprintf (_("In the directive number %zu, the width is too large."), spec.directives); FDI_SET (f - 1, FMTDIR_ERROR); goto bad_format; @@ -233,7 +233,7 @@ format_parse (const char *format, bool translated, char *fdi, } else if (*format == '*') { - unsigned int width_number = number; + size_t width_number = number; if (allocated == spec.numbered_arg_count) { @@ -258,7 +258,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (format[1])) { const char *f = format + 1; - unsigned int m = 0; + size_t m = 0; do { @@ -288,7 +288,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Finish parsing precision. */ if (*format == '*') { - unsigned int precision_number = number; + size_t precision_number = number; if (allocated == spec.numbered_arg_count) { @@ -316,7 +316,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int precision = 0; + size_t precision = 0; do { @@ -329,7 +329,7 @@ format_parse (const char *format, bool translated, char *fdi, if (precision > 1000000) { *invalid_reason = - xasprintf (_("In the directive number %u, the precision is too large."), + xasprintf (_("In the directive number %zu, the precision is too large."), spec.directives); FDI_SET (f - 1, FMTDIR_ERROR); goto bad_format; @@ -338,7 +338,7 @@ format_parse (const char *format, bool translated, char *fdi, } else if (*format == '*') { - unsigned int precision_number = number; + size_t precision_number = number; if (allocated == spec.numbered_arg_count) { @@ -360,7 +360,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (format[1])) { const char *f = format + 1; - unsigned int m = 0; + size_t m = 0; do { @@ -474,7 +474,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -568,9 +568,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -586,7 +586,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -598,7 +598,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -619,7 +619,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -657,8 +657,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -670,7 +670,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-invalid.h b/gettext-tools/src/format-invalid.h index c38daf5ab..17826e95f 100644 --- a/gettext-tools/src/format-invalid.h +++ b/gettext-tools/src/format-invalid.h @@ -25,22 +25,22 @@ xstrdup (_("The string refers to arguments both through absolute argument numbers and through unnumbered argument specifications.")) #define INVALID_PRECISION_MISSING(directive_number) \ - xasprintf (_("In the directive number %u, the precision is missing."), directive_number) + xasprintf (_("In the directive number %zu, the precision is missing."), directive_number) #define INVALID_ARGNO_0(directive_number) \ - xasprintf (_("In the directive number %u, the argument number 0 is not a positive integer."), directive_number) + xasprintf (_("In the directive number %zu, the argument number 0 is not a positive integer."), directive_number) #define INVALID_WIDTH_ARGNO_0(directive_number) \ - xasprintf (_("In the directive number %u, the width's argument number 0 is not a positive integer."), directive_number) + xasprintf (_("In the directive number %zu, the width's argument number 0 is not a positive integer."), directive_number) #define INVALID_PRECISION_ARGNO_0(directive_number) \ - xasprintf (_("In the directive number %u, the precision's argument number 0 is not a positive integer."), directive_number) + xasprintf (_("In the directive number %zu, the precision's argument number 0 is not a positive integer."), directive_number) #define INVALID_CONVERSION_SPECIFIER(directive_number,conv_char) \ (c_isprint (conv_char) \ - ? xasprintf (_("In the directive number %u, the character '%c' is not a valid conversion specifier."), directive_number, conv_char) \ - : xasprintf (_("The character that terminates the directive number %u is not a valid conversion specifier."), directive_number)) + ? xasprintf (_("In the directive number %zu, the character '%c' is not a valid conversion specifier."), directive_number, conv_char) \ + : xasprintf (_("The character that terminates the directive number %zu is not a valid conversion specifier."), directive_number)) #define INVALID_FLAG_FOR(directive_number,flag_char,conv_char) \ - xasprintf (_("In the directive number %u, the flag '%c' is invalid for the conversion '%c'."), directive_number, flag_char, conv_char) + xasprintf (_("In the directive number %zu, the flag '%c' is invalid for the conversion '%c'."), directive_number, flag_char, conv_char) #define INVALID_INCOMPATIBLE_ARG_TYPES(arg_number) \ - xasprintf (_("The string refers to argument number %u in incompatible ways."), arg_number) + xasprintf (_("The string refers to argument number %zu in incompatible ways."), arg_number) diff --git a/gettext-tools/src/format-java-printf.c b/gettext-tools/src/format-java-printf.c index 99f476941..de2e5fe97 100644 --- a/gettext-tools/src/format-java-printf.c +++ b/gettext-tools/src/format-java-printf.c @@ -107,14 +107,14 @@ enum struct numbered_arg { - unsigned int number; + size_t number; format_arg_type_t type; }; struct spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -122,25 +122,25 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } #define INVALID_LAST_ARG(directive_number) \ - xasprintf (_("In the directive number %u, the reference to the argument of the previous directive is invalid."), directive_number) + xasprintf (_("In the directive number %zu, the reference to the argument of the previous directive is invalid."), directive_number) #define INVALID_WIDTH_FOR(directive_number,conv_char) \ - xasprintf (_("In the directive number %u, a width is invalid for the conversion '%c'."), directive_number, conv_char) + xasprintf (_("In the directive number %zu, a width is invalid for the conversion '%c'."), directive_number, conv_char) #define INVALID_PRECISION_FOR(directive_number,conv_char) \ - xasprintf (_("In the directive number %u, a precision is invalid for the conversion '%c'."), directive_number, conv_char) + xasprintf (_("In the directive number %zu, a precision is invalid for the conversion '%c'."), directive_number, conv_char) #define INVALID_DATETIME_CONVERSION_SUFFIX(directive_number,conv_char,suffix_char) \ (c_isprint (conv_char) \ - ? xasprintf (_("In the directive number %u, for the conversion '%c', the character '%c' is not a valid conversion suffix."), directive_number, conv_char, suffix_char) \ - : xasprintf (_("The character that terminates the directive number %u, for the conversion '%c', is not a valid conversion suffix."), directive_number, conv_char)) + ? xasprintf (_("In the directive number %zu, for the conversion '%c', the character '%c' is not a valid conversion suffix."), directive_number, conv_char, suffix_char) \ + : xasprintf (_("The character that terminates the directive number %zu, for the conversion '%c', is not a valid conversion suffix."), directive_number, conv_char)) static void * format_parse (const char *format, bool translated, char *fdi, @@ -148,10 +148,10 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; + size_t numbered_allocated; struct spec *result; - unsigned int unnumbered_arg_count; - unsigned int last_arg_number; + size_t unnumbered_arg_count; + size_t last_arg_number; spec.directives = 0; spec.numbered_arg_count = 0; @@ -164,7 +164,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format++ == '%') { /* A directive. */ - unsigned int number = 0; + size_t number = 0; unsigned int flags; format_arg_type_t type; unsigned int invalid_flags; @@ -186,7 +186,7 @@ format_parse (const char *format, bool translated, char *fdi, else if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -464,7 +464,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -547,9 +547,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -565,7 +565,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -577,7 +577,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -598,7 +598,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -636,7 +636,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-java.c b/gettext-tools/src/format-java.c index c957b06e5..022306dc0 100644 --- a/gettext-tools/src/format-java.c +++ b/gettext-tools/src/format-java.c @@ -114,15 +114,15 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; - unsigned int numbered_arg_count; - unsigned int allocated; + size_t directives; + size_t numbered_arg_count; + size_t allocated; struct numbered_arg *numbered; }; @@ -166,7 +166,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, size_t n; char *element_alloced; char *element; - unsigned int number; + size_t number; enum format_arg_type type; FDI_SET (format, FMTDIR_START); @@ -203,7 +203,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, if (!c_isdigit (*element)) { *invalid_reason = - xasprintf (_("In the directive number %u, '{' is not followed by an argument number."), spec->directives); + xasprintf (_("In the directive number %zu, '{' is not followed by an argument number."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -238,7 +238,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, else { *invalid_reason = - xasprintf (_("In the directive number %u, the substring \"%s\" is not a valid date/time style."), spec->directives, element); + xasprintf (_("In the directive number %zu, the substring \"%s\" is not a valid date/time style."), spec->directives, element); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -249,7 +249,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, *element = '\0'; element -= 4; *invalid_reason = - xasprintf (_("In the directive number %u, \"%s\" is not followed by a comma."), spec->directives, element); + xasprintf (_("In the directive number %zu, \"%s\" is not followed by a comma."), spec->directives, element); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -272,7 +272,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, else { *invalid_reason = - xasprintf (_("In the directive number %u, the substring \"%s\" is not a valid number style."), spec->directives, element); + xasprintf (_("In the directive number %zu, the substring \"%s\" is not a valid number style."), spec->directives, element); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -283,7 +283,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, *element = '\0'; element -= 6; *invalid_reason = - xasprintf (_("In the directive number %u, \"%s\" is not followed by a comma."), spec->directives, element); + xasprintf (_("In the directive number %zu, \"%s\" is not followed by a comma."), spec->directives, element); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -312,7 +312,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, *element = '\0'; element -= 6; *invalid_reason = - xasprintf (_("In the directive number %u, \"%s\" is not followed by a comma."), spec->directives, element); + xasprintf (_("In the directive number %zu, \"%s\" is not followed by a comma."), spec->directives, element); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -321,7 +321,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec, else { *invalid_reason = - xasprintf (_("In the directive number %u, the argument number is not followed by a comma and one of \"%s\", \"%s\", \"%s\", \"%s\"."), spec->directives, "time", "date", "number", "choice"); + xasprintf (_("In the directive number %zu, the argument number is not followed by a comma and one of \"%s\", \"%s\", \"%s\", \"%s\"."), spec->directives, "time", "date", "number", "choice"); FDI_SET (format - 1, FMTDIR_ERROR); freea (element_alloced); return false; @@ -570,7 +570,7 @@ choice_format_parse (const char *format, struct spec *spec, if (!number_nonempty) { *invalid_reason = - xasprintf (_("In the directive number %u, a choice contains no number."), spec->directives); + xasprintf (_("In the directive number %zu, a choice contains no number."), spec->directives); return false; } @@ -581,7 +581,7 @@ choice_format_parse (const char *format, struct spec *spec, else { *invalid_reason = - xasprintf (_("In the directive number %u, a choice contains a number that is not followed by '<', '#' or '%s'."), spec->directives, "\\u2264"); + xasprintf (_("In the directive number %zu, a choice contains a number that is not followed by '<', '#' or '%s'."), spec->directives, "\\u2264"); return false; } HANDLE_QUOTE; @@ -617,8 +617,8 @@ choice_format_parse (const char *format, struct spec *spec, static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -641,7 +641,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -726,9 +726,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -744,7 +744,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument {%u}, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument {%zu}, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -756,7 +756,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument {%u} doesn't exist in '%s'"), + _("a format specification for argument {%zu} doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -777,7 +777,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument {%u} are not the same"), + _("format specifications in '%s' and '%s' for argument {%zu} are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -815,8 +815,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -828,7 +828,7 @@ format_print (void *descr) last = 0; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-javascript.c b/gettext-tools/src/format-javascript.c index 01dc384d1..25348df3e 100644 --- a/gettext-tools/src/format-javascript.c +++ b/gettext-tools/src/format-javascript.c @@ -66,19 +66,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'javascript-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -86,8 +86,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -98,8 +98,8 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; spec.directives = 0; @@ -114,7 +114,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format++ == '%') { /* A directive. */ - unsigned int number = 0; + size_t number = 0; enum format_arg_type type; bool likely_intentional = true; @@ -124,7 +124,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -276,7 +276,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -367,9 +367,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -384,7 +384,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -396,7 +396,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -420,7 +420,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -458,7 +458,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-kde-kuit.c b/gettext-tools/src/format-kde-kuit.c index ab0bed121..784042466 100644 --- a/gettext-tools/src/format-kde-kuit.c +++ b/gettext-tools/src/format-kde-kuit.c @@ -342,13 +342,13 @@ struct formatstring_parser formatstring_kde_kuit = struct kde_numbered_arg { - unsigned int number; + size_t number; }; struct kde_spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct kde_numbered_arg *numbered; }; @@ -357,8 +357,8 @@ format_print (void *descr) { struct spec *spec = (struct spec *) descr; struct kde_spec *kspec; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -378,7 +378,7 @@ format_print (void *descr) last = 1; for (i = 0; i < kspec->numbered_arg_count; i++) { - unsigned int number = kspec->numbered[i].number; + size_t number = kspec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-kde.c b/gettext-tools/src/format-kde.c index 3b2423791..267b2fc87 100644 --- a/gettext-tools/src/format-kde.c +++ b/gettext-tools/src/format-kde.c @@ -47,13 +47,13 @@ struct numbered_arg { - unsigned int number; + size_t number; }; struct spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -61,8 +61,8 @@ static int numbered_arg_compare (const void *p1, const void *p2) { /* Subtract 1, because argument number 0 can only occur through overflow. */ - unsigned int n1 = ((const struct numbered_arg *) p1)->number - 1; - unsigned int n2 = ((const struct numbered_arg *) p2)->number - 1; + size_t n1 = ((const struct numbered_arg *) p1)->number - 1; + size_t n2 = ((const struct numbered_arg *) p2)->number - 1; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -73,7 +73,7 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; + size_t numbered_allocated; struct spec *result; spec.directives = 0; @@ -89,7 +89,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format > '0' && *format <= '9') { /* A directive. */ - unsigned int number; + size_t number; FDI_SET (dir_start, FMTDIR_START); spec.directives++; @@ -118,7 +118,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; qsort (spec.numbered, spec.numbered_arg_count, sizeof (struct numbered_arg), numbered_arg_compare); @@ -143,19 +143,19 @@ format_parse (const char *format, bool translated, char *fdi, {1,...,n} \ {m}. */ if (spec.numbered_arg_count > 0) { - unsigned int i; + size_t i; i = 0; for (; i < spec.numbered_arg_count; i++) if (spec.numbered[i].number > i + 1) { - unsigned int first_gap = i + 1; + size_t first_gap = i + 1; for (; i < spec.numbered_arg_count; i++) if (spec.numbered[i].number > i + 2) { - unsigned int second_gap = i + 2; + size_t second_gap = i + 2; *invalid_reason = - xasprintf (_("The string refers to argument number %u but ignores the arguments %u and %u."), + xasprintf (_("The string refers to argument number %zu but ignores the arguments %zu and %zu."), spec.numbered[i].number, first_gap, second_gap); goto bad_format; } @@ -202,10 +202,10 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; - unsigned int missing = 0; /* only used if !equality */ + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; + size_t missing = 0; /* only used if !equality */ /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -221,7 +221,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -233,7 +233,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -242,7 +242,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for arguments %u and %u doesn't exist in '%s', only one argument may be ignored"), + _("a format specification for arguments %zu and %zu doesn't exist in '%s', only one argument may be ignored"), missing, spec1->numbered[i].number, pretty_msgstr); err = true; @@ -284,8 +284,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -297,7 +297,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-librep.c b/gettext-tools/src/format-librep.c index 2e2025356..3ea286dfc 100644 --- a/gettext-tools/src/format-librep.c +++ b/gettext-tools/src/format-librep.c @@ -62,19 +62,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'librep-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -82,8 +82,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -94,9 +94,9 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; + size_t numbered_allocated; struct spec *result; - unsigned int number; + size_t number; spec.directives = 0; spec.likely_intentional_directives = 0; @@ -118,7 +118,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -216,7 +216,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -307,9 +307,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -325,7 +325,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -337,7 +337,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -358,7 +358,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -396,8 +396,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -409,7 +409,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-lisp.c b/gettext-tools/src/format-lisp.c index 69dd5b329..06eabe00e 100644 --- a/gettext-tools/src/format-lisp.c +++ b/gettext-tools/src/format-lisp.c @@ -68,7 +68,7 @@ enum format_arg_type struct format_arg { - unsigned int repcount; /* Number of consecutive arguments this constraint + size_t repcount; /* Number of consecutive arguments this constraint applies to. Normally 1, but unconstrained arguments are often repeated. */ enum format_cdr_type presence; /* Can the argument list end right before @@ -79,11 +79,11 @@ struct format_arg struct segment { - unsigned int count; /* Number of format_arg records used. */ - unsigned int allocated; + size_t count; /* Number of format_arg records used. */ + size_t allocated; struct format_arg *element; /* Argument constraints. */ - unsigned int length; /* Number of arguments represented by this segment. - This is the sum of all repcounts in the segment. */ + size_t length; /* Number of arguments represented by this segment. + This is the sum of all repcounts in the segment. */ }; struct format_arg_list @@ -104,7 +104,7 @@ struct format_arg_list struct spec { - unsigned int directives; + size_t directives; struct format_arg_list *list; }; @@ -159,8 +159,8 @@ verify_element (const struct format_arg * e) static void verify_list (const struct format_arg_list *list) { - unsigned int i; - unsigned int total_repcount; + size_t i; + size_t total_repcount; ASSERT (list->initial.count <= list->initial.allocated); total_repcount = 0; @@ -200,7 +200,7 @@ free_element (struct format_arg *element) static void free_list (struct format_arg_list *list) { - unsigned int i; + size_t i; for (i = 0; i < list->initial.count; i++) free_element (&list->initial.element[i]); @@ -234,8 +234,8 @@ static struct format_arg_list * copy_list (const struct format_arg_list *list) { struct format_arg_list *newlist; - unsigned int length; - unsigned int i; + size_t length; + size_t i; VERIFY_LIST (list); @@ -301,7 +301,7 @@ static bool equal_list (const struct format_arg_list *list1, const struct format_arg_list *list2) { - unsigned int n, i; + size_t n, i; VERIFY_LIST (list1); VERIFY_LIST (list2); @@ -338,7 +338,7 @@ equal_list (const struct format_arg_list *list1, /* Ensure list->initial.allocated >= newcount. */ static inline void -ensure_initial_alloc (struct format_arg_list *list, unsigned int newcount) +ensure_initial_alloc (struct format_arg_list *list, size_t newcount) { if (newcount > list->initial.allocated) { @@ -368,7 +368,7 @@ grow_initial_alloc (struct format_arg_list *list) /* Ensure list->repeated.allocated >= newcount. */ static inline void -ensure_repeated_alloc (struct format_arg_list *list, unsigned int newcount) +ensure_repeated_alloc (struct format_arg_list *list, size_t newcount) { if (newcount > list->repeated.allocated) { @@ -405,7 +405,7 @@ grow_repeated_alloc (struct format_arg_list *list) static void normalize_outermost_list (struct format_arg_list *list) { - unsigned int n, i, j; + size_t n, i, j; /* Step 1: Combine adjacent elements. Copy from i to j, keeping 0 <= j <= i. */ @@ -449,7 +449,7 @@ normalize_outermost_list (struct format_arg_list *list) /* Nothing more to be done if the loop segment is empty. */ if (list->repeated.count > 0) { - unsigned int m, repcount0_extra; + size_t m, repcount0_extra; /* Step 2: Reduce the loop period. */ n = list->repeated.count; @@ -520,7 +520,7 @@ normalize_outermost_list (struct format_arg_list *list) && equal_element (&list->initial.element[list->initial.count-1], &list->repeated.element[list->repeated.count-1])) { - unsigned int moved_repcount = + size_t moved_repcount = MIN (list->initial.element[list->initial.count-1].repcount, list->repeated.element[list->repeated.count-1].repcount); @@ -530,7 +530,7 @@ normalize_outermost_list (struct format_arg_list *list) list->repeated.element[0].repcount += moved_repcount; else { - unsigned int newcount = list->repeated.count + 1; + size_t newcount = list->repeated.count + 1; ensure_repeated_alloc (list, newcount); for (i = newcount - 1; i > 0; i--) list->repeated.element[i] = list->repeated.element[i-1]; @@ -568,7 +568,7 @@ normalize_outermost_list (struct format_arg_list *list) static void normalize_list (struct format_arg_list *list) { - unsigned int n, i; + size_t n, i; VERIFY_LIST (list); @@ -659,13 +659,13 @@ is_empty_list (const struct format_arg_list *list) Assumes list->repeated.count > 0. */ /* Memory effects: list is destructively modified. */ static void -unfold_loop (struct format_arg_list *list, unsigned int m) +unfold_loop (struct format_arg_list *list, size_t m) { - unsigned int i, j, k; + size_t i, j, k; if (m > 1) { - unsigned int newcount = list->repeated.count * m; + size_t newcount = list->repeated.count * m; ensure_repeated_alloc (list, newcount); i = list->repeated.count; for (k = 1; k < m; k++) @@ -680,7 +680,7 @@ unfold_loop (struct format_arg_list *list, unsigned int m) Assumes list->repeated.count > 0. */ /* Memory effects: list is destructively modified. */ static void -rotate_loop (struct format_arg_list *list, unsigned int m) +rotate_loop (struct format_arg_list *list, size_t m) { if (m == list->initial.length) return; @@ -689,7 +689,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) { /* Instead of multiple copies of list->repeated.element[0], a single copy with higher repcount is appended to list->initial. */ - unsigned int i, newcount; + size_t i, newcount; newcount = list->initial.count + 1; ensure_initial_alloc (list, newcount); @@ -701,16 +701,16 @@ rotate_loop (struct format_arg_list *list, unsigned int m) } else { - unsigned int n = list->repeated.length; + size_t n = list->repeated.length; /* Write m = list->initial.length + q * n + r with 0 <= r < n. */ - unsigned int q = (m - list->initial.length) / n; - unsigned int r = (m - list->initial.length) % n; + size_t q = (m - list->initial.length) / n; + size_t r = (m - list->initial.length) % n; /* Determine how many entries of list->repeated are needed for length r. */ - unsigned int s; - unsigned int t; + size_t s; + size_t t; for (t = r, s = 0; s < list->repeated.count && t >= list->repeated.element[s].repcount; @@ -725,7 +725,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) plus the s first elements of list->repeated, plus, if t > 0, a splitoff of list->repeated.element[s]. */ { - unsigned int i, j, k, newcount; + size_t i, j, k, newcount; i = list->initial.count; newcount = i + q * list->repeated.count + s + (t > 0 ? 1 : 0); @@ -758,7 +758,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) /* And rotate list->repeated. */ if (r > 0) { - unsigned int i, j, oldcount, newcount; + size_t i, j, oldcount, newcount; struct format_arg *newelement; oldcount = list->repeated.count; @@ -787,14 +787,14 @@ rotate_loop (struct format_arg_list *list, unsigned int m) i.e. if 0 < n < list->initial.length, then n-1 and n are covered by two different adjacent elements. */ /* Memory effects: list is destructively modified. */ -static unsigned int -initial_splitelement (struct format_arg_list *list, unsigned int n) +static size_t +initial_splitelement (struct format_arg_list *list, size_t n) { - unsigned int s; - unsigned int t; - unsigned int oldrepcount; - unsigned int newcount; - unsigned int i; + size_t s; + size_t t; + size_t oldrepcount; + size_t newcount; + size_t i; VERIFY_LIST (list); @@ -835,15 +835,15 @@ initial_splitelement (struct format_arg_list *list, unsigned int n) /* Ensure index n in the initial segment is not shared. Return its index. */ /* Memory effects: list is destructively modified. */ -static unsigned int -initial_unshare (struct format_arg_list *list, unsigned int n) +static size_t +initial_unshare (struct format_arg_list *list, size_t n) { /* This does the same side effects as initial_splitelement (list, n); initial_splitelement (list, n + 1); */ - unsigned int s; - unsigned int t; + size_t s; + size_t t; VERIFY_LIST (list); @@ -867,13 +867,13 @@ initial_unshare (struct format_arg_list *list, unsigned int n) { /* Split the entry into at most three entries: for indices < n, for index n, and for indices > n. */ - unsigned int oldrepcount = list->initial.element[s].repcount; - unsigned int newcount = + size_t oldrepcount = list->initial.element[s].repcount; + size_t newcount = list->initial.count + (t == 0 || t == oldrepcount - 1 ? 1 : 2); ensure_initial_alloc (list, newcount); if (t == 0 || t == oldrepcount - 1) { - unsigned int i; + size_t i; for (i = list->initial.count - 1; i > s; i--) list->initial.element[i+1] = list->initial.element[i]; @@ -891,7 +891,7 @@ initial_unshare (struct format_arg_list *list, unsigned int n) } else { - unsigned int i; + size_t i; for (i = list->initial.count - 1; i > s; i--) list->initial.element[i+2] = list->initial.element[i]; @@ -918,13 +918,13 @@ initial_unshare (struct format_arg_list *list, unsigned int n) /* Add n unconstrained elements at the front of the list. */ /* Memory effects: list is destructively modified. */ static void -shift_list (struct format_arg_list *list, unsigned int n) +shift_list (struct format_arg_list *list, size_t n) { VERIFY_LIST (list); if (n > 0) { - unsigned int i; + size_t i; grow_initial_alloc (list); for (i = list->initial.count; i > 0; i--) @@ -1055,7 +1055,7 @@ append_repeated_to_initial (struct format_arg_list *list) if (list->repeated.count > 0) { /* Move list->repeated over to list->initial. */ - unsigned int i, j, newcount; + size_t i, j, newcount; newcount = list->initial.count + list->repeated.count; ensure_initial_alloc (list, newcount); @@ -1085,7 +1085,7 @@ backtrack_in_initial (struct format_arg_list *list) while (list->initial.count > 0) { - unsigned int i = list->initial.count - 1; + size_t i = list->initial.count - 1; if (list->initial.element[i].presence == FCT_REQUIRED) { /* Throw away this element. */ @@ -1130,11 +1130,11 @@ make_intersected_list (struct format_arg_list *list1, if (list1->repeated.length > 0 && list2->repeated.length > 0) /* Step 1: Ensure list1->repeated.length == list2->repeated.length. */ { - unsigned int n1 = list1->repeated.length; - unsigned int n2 = list2->repeated.length; - unsigned int g = gcd (n1, n2); - unsigned int m1 = n2 / g; /* = lcm(n1,n2) / n1 */ - unsigned int m2 = n1 / g; /* = lcm(n1,n2) / n2 */ + size_t n1 = list1->repeated.length; + size_t n2 = list2->repeated.length; + size_t g = gcd (n1, n2); + size_t m1 = n2 / g; /* = lcm(n1,n2) / n1 */ + size_t m2 = n1 / g; /* = lcm(n1,n2) / n2 */ unfold_loop (list1, m1); unfold_loop (list2, m2); @@ -1147,7 +1147,7 @@ make_intersected_list (struct format_arg_list *list1, repeated segment, this means to ensure list1->initial.length == list2->initial.length. */ { - unsigned int m = MAX (list1->initial.length, list2->initial.length); + size_t m = MAX (list1->initial.length, list2->initial.length); if (list1->repeated.length > 0) rotate_loop (list1, m); @@ -1176,8 +1176,8 @@ make_intersected_list (struct format_arg_list *list1, { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->initial.element; c1 = list1->initial.count; e2 = list2->initial.element; c2 = list2->initial.count; @@ -1264,8 +1264,8 @@ make_intersected_list (struct format_arg_list *list1, { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->repeated.element; c1 = list1->repeated.count; e2 = list2->repeated.element; c2 = list2->repeated.count; @@ -1493,11 +1493,11 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { /* Step 1: Ensure list1->repeated.length == list2->repeated.length. */ { - unsigned int n1 = list1->repeated.length; - unsigned int n2 = list2->repeated.length; - unsigned int g = gcd (n1, n2); - unsigned int m1 = n2 / g; /* = lcm(n1,n2) / n1 */ - unsigned int m2 = n1 / g; /* = lcm(n1,n2) / n2 */ + size_t n1 = list1->repeated.length; + size_t n2 = list2->repeated.length; + size_t g = gcd (n1, n2); + size_t m1 = n2 / g; /* = lcm(n1,n2) / n1 */ + size_t m2 = n1 / g; /* = lcm(n1,n2) / n2 */ unfold_loop (list1, m1); unfold_loop (list2, m2); @@ -1506,7 +1506,7 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) /* Step 2: Ensure that list1->initial.length == list2->initial.length. */ { - unsigned int m = MAX (list1->initial.length, list2->initial.length); + size_t m = MAX (list1->initial.length, list2->initial.length); rotate_loop (list1, m); rotate_loop (list2, m); @@ -1553,8 +1553,8 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->initial.element; c1 = list1->initial.count; e2 = list2->initial.element; c2 = list2->initial.count; @@ -1675,8 +1675,8 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->repeated.element; c1 = list1->repeated.count; e2 = list2->repeated.element; c2 = list2->repeated.count; @@ -1714,7 +1714,7 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { /* Turning FCT_REQUIRED into FCT_OPTIONAL was already handled in the initial segment. Just copy the repeated segment of list1. */ - unsigned int i; + size_t i; result->repeated.count = list1->repeated.count; result->repeated.allocated = result->repeated.count; @@ -1729,7 +1729,7 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { /* Turning FCT_REQUIRED into FCT_OPTIONAL was already handled in the initial segment. Just copy the repeated segment of list2. */ - unsigned int i; + size_t i; result->repeated.count = list2->repeated.count; result->repeated.allocated = result->repeated.count; @@ -1812,10 +1812,10 @@ union (struct format_arg_list *list1, struct format_arg_list *list2) /* Test whether arguments 0..n are required arguments in a list. */ static bool -is_required (const struct format_arg_list *list, unsigned int n) +is_required (const struct format_arg_list *list, size_t n) { - unsigned int s; - unsigned int t; + size_t s; + size_t t; /* We'll check whether the first n+1 presence flags are FCT_REQUIRED. */ t = n + 1; @@ -1870,9 +1870,9 @@ is_required (const struct format_arg_list *list, unsigned int n) present. NULL stands for an impossible situation, i.e. a contradiction. */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_required_constraint (struct format_arg_list *list, unsigned int n) +add_required_constraint (struct format_arg_list *list, size_t n) { - unsigned int i, rest; + size_t i, rest; if (list == NULL) return NULL; @@ -1907,9 +1907,9 @@ add_required_constraint (struct format_arg_list *list, unsigned int n) contradiction. */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_end_constraint (struct format_arg_list *list, unsigned int n) +add_end_constraint (struct format_arg_list *list, size_t n) { - unsigned int s, i; + size_t s, i; enum format_cdr_type n_presence; if (list == NULL) @@ -1955,10 +1955,10 @@ add_end_constraint (struct format_arg_list *list, unsigned int n) contradiction. Assumes a preceding add_required_constraint (list, n). */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_type_constraint (struct format_arg_list *list, unsigned int n, +add_type_constraint (struct format_arg_list *list, size_t n, enum format_arg_type type) { - unsigned int s; + size_t s; struct format_arg newconstraint; struct format_arg tmpelement; @@ -1994,11 +1994,11 @@ add_type_constraint (struct format_arg_list *list, unsigned int n, contradiction. Assumes a preceding add_required_constraint (list, n). */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_listtype_constraint (struct format_arg_list *list, unsigned int n, +add_listtype_constraint (struct format_arg_list *list, size_t n, enum format_arg_type type, struct format_arg_list *sublist) { - unsigned int s; + size_t s; struct format_arg newconstraint; struct format_arg tmpelement; @@ -2034,7 +2034,7 @@ add_listtype_constraint (struct format_arg_list *list, unsigned int n, static void add_req_type_constraint (struct format_arg_list **listp, - unsigned int position, enum format_arg_type type) + size_t position, enum format_arg_type type) { *listp = add_required_constraint (*listp, position); *listp = add_type_constraint (*listp, position, type); @@ -2043,7 +2043,7 @@ add_req_type_constraint (struct format_arg_list **listp, static void add_req_listtype_constraint (struct format_arg_list **listp, - unsigned int position, enum format_arg_type type, + size_t position, enum format_arg_type type, struct format_arg_list *sublist) { *listp = add_required_constraint (*listp, position); @@ -2097,12 +2097,12 @@ make_repeated_list_of_lists (struct format_arg_list *sublist) */ /* Memory effects: sublist is freed. The result is freshly allocated. */ static struct format_arg_list * -make_repeated_list (struct format_arg_list *sublist, unsigned int period) +make_repeated_list (struct format_arg_list *sublist, size_t period) { struct segment tmp; struct segment *srcseg; struct format_arg_list *list; - unsigned int p, n, i, si, ti, j, sj, tj, splitindex, newcount; + size_t p, n, i, si, ti, j, sj, tj, splitindex, newcount; bool ended; VERIFY_LIST (sublist); @@ -2125,8 +2125,8 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) { /* L is an infinite list. */ /* p := lcm (period, period of L) */ - unsigned int Lp = sublist->repeated.length; - unsigned int m = period / gcd (period, Lp); /* = lcm(period,Lp) / Lp */ + size_t Lp = sublist->repeated.length; + size_t m = period / gcd (period, Lp); /* = lcm(period,Lp) / Lp */ unfold_loop (sublist, m); p = m * Lp; @@ -2183,7 +2183,7 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) i = 0, ti = 0, si = 0; while (i < p) { - unsigned int k = MIN (srcseg->element[si].repcount - ti, p - i); + size_t k = MIN (srcseg->element[si].repcount - ti, p - i); /* Ensure room in list->initial. */ grow_initial_alloc (list); @@ -2214,7 +2214,7 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) j = 0, tj = 0, sj = 0; while (i < n) { - unsigned int k = + size_t k = MIN (srcseg->element[si].repcount - ti, list->initial.element[sj].repcount - tj); @@ -2329,12 +2329,12 @@ static const enum format_arg_type THREE [3] = { invalid. */ static bool check_params (struct format_arg_list **listp, - unsigned int paramcount, struct param *params, - unsigned int t_count, const enum format_arg_type *t_types, - unsigned int directives, char **invalid_reason) + size_t paramcount, struct param *params, + size_t t_count, const enum format_arg_type *t_types, + size_t directives, char **invalid_reason) { - unsigned int orig_paramcount = paramcount; - unsigned int orig_t_count = t_count; + size_t orig_paramcount = paramcount; + size_t orig_t_count = t_count; for (; paramcount > 0 && t_count > 0; params++, paramcount--, t_types++, t_count--) @@ -2351,7 +2351,7 @@ check_params (struct format_arg_list **listp, case PT_INTEGER: case PT_ARGCOUNT: /* wrong param type */ *invalid_reason = - xasprintf (_("In the directive number %u, parameter %u is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "integer", "character"); + xasprintf (_("In the directive number %zu, parameter %zu is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "integer", "character"); return false; } break; @@ -2363,7 +2363,7 @@ check_params (struct format_arg_list **listp, case PT_CHARACTER: /* wrong param type */ *invalid_reason = - xasprintf (_("In the directive number %u, parameter %u is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "character", "integer"); + xasprintf (_("In the directive number %zu, parameter %zu is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "character", "integer"); return false; } break; @@ -2386,8 +2386,8 @@ check_params (struct format_arg_list **listp, case PT_CHARACTER: case PT_INTEGER: case PT_ARGCOUNT: /* too many params for directive */ *invalid_reason = - xasprintf (ngettext ("In the directive number %u, too many parameters are given; expected at most %u parameter.", - "In the directive number %u, too many parameters are given; expected at most %u parameters.", + xasprintf (ngettext ("In the directive number %zu, too many parameters are given; expected at most %zu parameter.", + "In the directive number %zu, too many parameters are given; expected at most %zu parameters.", orig_t_count), directives, orig_t_count); return false; @@ -2416,8 +2416,8 @@ check_params (struct format_arg_list **listp, invalid. */ static bool nocheck_params (struct format_arg_list **listp, - unsigned int paramcount, struct param *params, - unsigned int directives, char **invalid_reason) + size_t paramcount, struct param *params, + size_t directives, char **invalid_reason) { (void) directives; (void) invalid_reason; @@ -2472,7 +2472,7 @@ parse_upto (const char **formatp, { bool colon_p = false; bool atsign_p = false; - unsigned int paramcount = 0; + size_t paramcount = 0; struct param *params = NULL; FDI_SET (format - 1, FMTDIR_START); @@ -2511,7 +2511,7 @@ parse_upto (const char **formatp, else { *invalid_reason = - xasprintf (_("In the directive number %u, '%c' is not followed by a digit."), spec->directives, format[-1]); + xasprintf (_("In the directive number %zu, '%c' is not followed by a digit."), spec->directives, format[-1]); FDI_SET (format, FMTDIR_ERROR); } return false; @@ -2751,7 +2751,7 @@ parse_upto (const char **formatp, { /* invalid argument */ *invalid_reason = - xasprintf (_("In the directive number %u, the argument %d is negative."), spec->directives, n); + xasprintf (_("In the directive number %zu, the argument %d is negative."), spec->directives, n); FDI_SET (format - 1, FMTDIR_ERROR); return false; } @@ -2878,7 +2878,7 @@ parse_upto (const char **formatp, if (atsign_p && colon_p) { *invalid_reason = - xasprintf (_("In the directive number %u, both the @ and the : modifiers are given."), spec->directives); + xasprintf (_("In the directive number %zu, both the @ and the : modifiers are given."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; } @@ -2991,7 +2991,7 @@ parse_upto (const char **formatp, if (!sub_separator) { *invalid_reason = - xasprintf (_("In the directive number %u, '~:[' is not followed by two clauses, separated by '~;'."), spec->directives); + xasprintf (_("In the directive number %zu, '~:[' is not followed by two clauses, separated by '~;'."), spec->directives); FDI_SET (**formatp == '\0' ? *formatp - 1 : *formatp, FMTDIR_ERROR); return false; @@ -3341,7 +3341,7 @@ parse_upto (const char **formatp, if (!separator) { *invalid_reason = - xasprintf (_("In the directive number %u, '~;' is used in an invalid position."), spec->directives); + xasprintf (_("In the directive number %zu, '~;' is used in an invalid position."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; } @@ -3594,7 +3594,7 @@ print_element (struct format_arg *element) static void print_list (struct format_arg_list *list) { - unsigned int i, j; + size_t i, j; printf ("("); diff --git a/gettext-tools/src/format-lua.c b/gettext-tools/src/format-lua.c index 7f06d6711..3745e4226 100644 --- a/gettext-tools/src/format-lua.c +++ b/gettext-tools/src/format-lua.c @@ -68,8 +68,8 @@ enum format_arg_type struct spec { - unsigned int directives; - unsigned int format_args_count; + size_t directives; + size_t format_args_count; enum format_arg_type *format_args; }; @@ -82,7 +82,7 @@ format_parse (const char *format, bool translated, char *fdi, const char *fatstr = format; struct spec spec; struct spec *result; - unsigned int format_args_allocated; + size_t format_args_allocated; spec.directives = 0; spec.format_args_count = 0; @@ -218,7 +218,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->format_args_count + spec2->format_args_count > 0) { - unsigned int i, n1, n2; + size_t i, n1, n2; n1 = spec1->format_args_count; n2 = spec2->format_args_count; @@ -229,7 +229,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), i + 1, pretty_msgstr, pretty_msgid); return true; } @@ -237,7 +237,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), i + 1, pretty_msgstr); return true; } @@ -245,7 +245,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, i + 1); return true; } @@ -276,7 +276,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-modula2.c b/gettext-tools/src/format-modula2.c index c2b566499..eb7418873 100644 --- a/gettext-tools/src/format-modula2.c +++ b/gettext-tools/src/format-modula2.c @@ -63,8 +63,8 @@ enum format_arg_type struct spec { - unsigned int directives; - unsigned int arg_count; + size_t directives; + size_t arg_count; enum format_arg_type *args; }; @@ -74,7 +74,7 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int args_allocated; + size_t args_allocated; struct spec *result; spec.directives = 0; @@ -190,15 +190,15 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->arg_count + spec2->arg_count > 0) { - unsigned int n1 = spec1->arg_count; - unsigned int n2 = spec2->arg_count; + size_t n1 = spec1->arg_count; + size_t n2 = spec2->arg_count; /* Check that the argument counts are the same. */ if (n1 < n2) { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), n1 + 1, pretty_msgstr, pretty_msgid); err = true; } @@ -206,13 +206,13 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), n1 + 1, pretty_msgstr); err = true; } else { - unsigned int i; + size_t i; /* Check that the argument types are the same. */ if (!err) @@ -222,7 +222,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, i + 1); err = true; break; @@ -257,7 +257,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-pascal.c b/gettext-tools/src/format-pascal.c index 648597501..c9c8c3434 100644 --- a/gettext-tools/src/format-pascal.c +++ b/gettext-tools/src/format-pascal.c @@ -76,14 +76,14 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -91,8 +91,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -102,11 +102,11 @@ format_parse (const char *format, bool translated, char *fdi, char **invalid_reason) { const char *const format_start = format; - unsigned int directives; - unsigned int numbered_arg_count; + size_t directives; + size_t numbered_arg_count; struct numbered_arg *numbered; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; enum arg_index @@ -133,13 +133,13 @@ format_parse (const char *format, bool translated, char *fdi, { /* A complex directive. */ enum arg_index main_arg = index_unnumbered; - unsigned int main_number = 0; + size_t main_number = 0; enum format_arg_type type; if (c_isdigit (*format) || *format == ':') { const char *f = format; - unsigned int m = 0; + size_t m = 0; while (c_isdigit (*f)) { @@ -282,7 +282,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (numbered, numbered_arg_count, @@ -367,9 +367,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -385,7 +385,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -397,7 +397,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -418,7 +418,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -456,8 +456,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -469,7 +469,7 @@ format_print (void *descr) last = 0; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-perl-brace.c b/gettext-tools/src/format-perl-brace.c index 60613ac8b..355509ecc 100644 --- a/gettext-tools/src/format-perl-brace.c +++ b/gettext-tools/src/format-perl-brace.c @@ -1,5 +1,5 @@ /* Perl brace format strings. - Copyright (C) 2004-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 @@ -44,8 +44,8 @@ struct named_arg struct spec { - unsigned int directives; - unsigned int named_arg_count; + size_t directives; + size_t named_arg_count; struct named_arg *named; }; @@ -63,7 +63,7 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int named_allocated; + size_t named_allocated; struct spec *result; spec.directives = 0; @@ -118,7 +118,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the named argument array, and eliminate duplicates. */ if (spec.named_arg_count > 1) { - unsigned int i, j; + size_t i, j; qsort (spec.named, spec.named_arg_count, sizeof (struct named_arg), named_arg_compare); @@ -148,7 +148,7 @@ format_free (void *descr) if (spec->named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec->named_arg_count; i++) free (spec->named[i].name); free (spec->named); @@ -175,9 +175,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->named_arg_count + spec2->named_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->named_arg_count; - unsigned int n2 = spec2->named_arg_count; + size_t i, j; + size_t n1 = spec1->named_arg_count; + size_t n2 = spec2->named_arg_count; /* Check the argument names in spec1 are contained in those of spec2. Additional arguments in spec2 are allowed; they expand to themselves @@ -235,7 +235,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-perl.c b/gettext-tools/src/format-perl.c index 5e37a8334..f55a929e8 100644 --- a/gettext-tools/src/format-perl.c +++ b/gettext-tools/src/format-perl.c @@ -101,19 +101,19 @@ typedef enum format_arg_type format_arg_type_t; struct numbered_arg { - unsigned int number; + size_t number; format_arg_type_t type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'perl-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -124,8 +124,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -135,12 +135,12 @@ format_parse (const char *format, bool translated, char *fdi, char **invalid_reason) { const char *const format_start = format; - unsigned int directives; - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t directives; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; directives = 0; @@ -154,7 +154,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format++ == '%') { /* A directive. */ - unsigned int number = 0; + size_t number = 0; bool vectorize = false; format_arg_type_t type; format_arg_type_t size; @@ -166,7 +166,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isnonzerodigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -219,7 +219,7 @@ format_parse (const char *format, bool translated, char *fdi, } else if (c_isnonzerodigit (*f)) { - unsigned int m = 0; + size_t m = 0; do { @@ -233,7 +233,7 @@ format_parse (const char *format, bool translated, char *fdi, f++; if (*f == 'v') { - unsigned int vector_number = m; + size_t vector_number = m; format = ++f; vectorize = true; @@ -270,14 +270,14 @@ format_parse (const char *format, bool translated, char *fdi, /* Parse width. */ if (*format == '*') { - unsigned int width_number = 0; + size_t width_number = 0; format++; if (c_isnonzerodigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -317,14 +317,14 @@ format_parse (const char *format, bool translated, char *fdi, if (*format == '*') { - unsigned int precision_number = 0; + size_t precision_number = 0; format++; if (c_isnonzerodigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -435,7 +435,7 @@ format_parse (const char *format, bool translated, char *fdi, if (size == FAT_SIZE_SHORT || size == FAT_SIZE_LONG) { *invalid_reason = - xasprintf (_("In the directive number %u, the size specifier is incompatible with the conversion specifier '%c'."), directives, *format); + xasprintf (_("In the directive number %zu, the size specifier is incompatible with the conversion specifier '%c'."), directives, *format); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -485,7 +485,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (numbered, numbered_arg_count, @@ -579,9 +579,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -597,7 +597,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -609,7 +609,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -630,7 +630,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -668,8 +668,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -681,7 +681,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-php.c b/gettext-tools/src/format-php.c index c1ec3abbb..1e132594c 100644 --- a/gettext-tools/src/format-php.c +++ b/gettext-tools/src/format-php.c @@ -67,19 +67,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'php-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -87,8 +87,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -98,12 +98,12 @@ format_parse (const char *format, bool translated, char *fdi, char **invalid_reason) { const char *const format_start = format; - unsigned int directives; - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t directives; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; directives = 0; @@ -125,14 +125,14 @@ format_parse (const char *format, bool translated, char *fdi, if (*format != '%') { /* A complex directive. */ - unsigned int number; + size_t number; enum format_arg_type type; number = ++unnumbered_arg_count; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -256,7 +256,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (numbered, numbered_arg_count, @@ -350,9 +350,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -368,7 +368,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -380,7 +380,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -401,7 +401,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -439,8 +439,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -452,7 +452,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-python-brace.c b/gettext-tools/src/format-python-brace.c index 12a7af992..d66519616 100644 --- a/gettext-tools/src/format-python-brace.c +++ b/gettext-tools/src/format-python-brace.c @@ -70,9 +70,9 @@ struct named_arg struct spec { - unsigned int directives; - unsigned int named_arg_count; - unsigned int allocated; + size_t directives; + size_t named_arg_count; + size_t allocated; struct named_arg *named; }; @@ -165,9 +165,9 @@ parse_directive (struct spec *spec, { *invalid_reason = (c_isprint (*format) - ? xasprintf (_("In the directive number %u, '%c' cannot start a field name."), + ? xasprintf (_("In the directive number %zu, '%c' cannot start a field name."), spec->directives, *format) - : xasprintf (_("In the directive number %u, a field name starts with a character that is not alphanumerical or underscore."), + : xasprintf (_("In the directive number %zu, a field name starts with a character that is not alphanumerical or underscore."), spec->directives)); FDI_SET (format, FMTDIR_ERROR); } @@ -196,9 +196,9 @@ parse_directive (struct spec *spec, { *invalid_reason = (c_isprint (*format) - ? xasprintf (_("In the directive number %u, '%c' cannot start a getattr argument."), + ? xasprintf (_("In the directive number %zu, '%c' cannot start a getattr argument."), spec->directives, *format) - : xasprintf (_("In the directive number %u, a getattr argument starts with a character that is not alphabetical or underscore."), + : xasprintf (_("In the directive number %zu, a getattr argument starts with a character that is not alphabetical or underscore."), spec->directives)); FDI_SET (format, FMTDIR_ERROR); } @@ -222,9 +222,9 @@ parse_directive (struct spec *spec, { *invalid_reason = (c_isprint (*format) - ? xasprintf (_("In the directive number %u, '%c' cannot start a getitem argument."), + ? xasprintf (_("In the directive number %zu, '%c' cannot start a getitem argument."), spec->directives, *format) - : xasprintf (_("In the directive number %u, a getitem argument starts with a character that is not alphanumerical or underscore."), + : xasprintf (_("In the directive number %zu, a getitem argument starts with a character that is not alphanumerical or underscore."), spec->directives)); FDI_SET (format, FMTDIR_ERROR); } @@ -234,7 +234,7 @@ parse_directive (struct spec *spec, if (*format != ']') { *invalid_reason = - xasprintf (_("In the directive number %u, there is an unterminated getitem argument."), + xasprintf (_("In the directive number %zu, there is an unterminated getitem argument."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; @@ -251,7 +251,7 @@ parse_directive (struct spec *spec, if (!is_toplevel) { *invalid_reason = - xasprintf (_("In the directive number %u, no more nesting is allowed in a format specifier."), + xasprintf (_("In the directive number %zu, no more nesting is allowed in a format specifier."), spec->directives); FDI_SET (format, FMTDIR_ERROR); return false; @@ -290,7 +290,7 @@ parse_directive (struct spec *spec, if (c1 == '\0') { *invalid_reason = - xasprintf (_("The directive number %u is unterminated."), + xasprintf (_("The directive number %zu is unterminated."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; @@ -343,7 +343,7 @@ parse_directive (struct spec *spec, if (*format != '}') { *invalid_reason = - xasprintf (_("The directive number %u is unterminated."), + xasprintf (_("The directive number %zu is unterminated."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; @@ -428,7 +428,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the named argument array, and eliminate duplicates. */ if (spec.named_arg_count > 1) { - unsigned int i, j; + size_t i, j; qsort (spec.named, spec.named_arg_count, sizeof (struct named_arg), named_arg_compare); @@ -456,7 +456,7 @@ free_named_args (struct spec *spec) { if (spec->named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec->named_arg_count; i++) free (spec->named[i].name); free (spec->named); @@ -491,9 +491,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->named_arg_count + spec2->named_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->named_arg_count; - unsigned int n2 = spec2->named_arg_count; + size_t i, j; + size_t n1 = spec1->named_arg_count; + size_t n2 = spec2->named_arg_count; /* Check the argument names in spec2 are contained in those of spec1. Both arrays are sorted. We search for the first difference. */ @@ -557,7 +557,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-python.c b/gettext-tools/src/format-python.c index 5fce1397e..78b315430 100644 --- a/gettext-tools/src/format-python.c +++ b/gettext-tools/src/format-python.c @@ -89,14 +89,14 @@ struct unnamed_arg struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'python-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int named_arg_count; - unsigned int unnamed_arg_count; + size_t likely_intentional_directives; + size_t named_arg_count; + size_t unnamed_arg_count; struct named_arg *named; struct unnamed_arg *unnamed; }; @@ -118,7 +118,7 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int allocated; + size_t allocated; struct spec *result; spec.directives = 0; @@ -143,7 +143,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format == '(') { - unsigned int depth; + size_t depth; const char *name_start; const char *name_end; size_t n; @@ -333,7 +333,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the named argument array, and eliminate duplicates. */ if (spec.named_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.named, spec.named_arg_count, sizeof (struct named_arg), @@ -387,7 +387,7 @@ format_parse (const char *format, bool translated, char *fdi, bad_format: if (spec.named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec.named_arg_count; i++) free (spec.named[i].name); free (spec.named); @@ -404,7 +404,7 @@ format_free (void *descr) if (spec->named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec->named_arg_count; i++) free (spec->named[i].name); free (spec->named); @@ -459,9 +459,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (spec1->named_arg_count + spec2->named_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->named_arg_count; - unsigned int n2 = spec2->named_arg_count; + size_t i, j; + size_t n1 = spec1->named_arg_count; + size_t n2 = spec2->named_arg_count; /* Check the argument names in spec2 are contained in those of spec1. Both arrays are sorted. We search for the first difference. */ @@ -526,7 +526,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->unnamed_arg_count + spec2->unnamed_arg_count > 0) { - unsigned int i; + size_t i; /* Check the argument types are the same. */ if (spec1->unnamed_arg_count != spec2->unnamed_arg_count) @@ -546,7 +546,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, i + 1); err = true; } @@ -567,7 +567,7 @@ struct formatstring_parser formatstring_python = }; -unsigned int +size_t get_python_format_unnamed_arg_count (const char *string) { /* Parse the format string. */ @@ -577,7 +577,7 @@ get_python_format_unnamed_arg_count (const char *string) if (descr != NULL) { - unsigned int result = descr->unnamed_arg_count; + size_t result = descr->unnamed_arg_count; format_free (descr); return result; @@ -601,7 +601,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-qt-plural.c b/gettext-tools/src/format-qt-plural.c index eeb18d455..d056a3f8d 100644 --- a/gettext-tools/src/format-qt-plural.c +++ b/gettext-tools/src/format-qt-plural.c @@ -1,5 +1,5 @@ /* Qt plural 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 @@ -40,7 +40,7 @@ struct spec { /* Number of format directives. */ - unsigned int directives; + size_t directives; }; diff --git a/gettext-tools/src/format-qt.c b/gettext-tools/src/format-qt.c index f2912e373..e8c907694 100644 --- a/gettext-tools/src/format-qt.c +++ b/gettext-tools/src/format-qt.c @@ -1,5 +1,5 @@ /* Qt format strings. - Copyright (C) 2003-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 @@ -52,14 +52,14 @@ struct spec { /* Number of format directives. */ - unsigned int directives; + size_t directives; /* True if the string supports the multi-argument .arg() methods, i.e. if it contains no 'L' flags and only single-digit argument designators. */ bool simple; /* Booleans telling which %nn was seen. */ - unsigned int arg_count; + size_t arg_count; bool args_used[100]; }; @@ -90,7 +90,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format >= '0' && *format <= '9') { /* A directive. */ - unsigned int number; + size_t number; FDI_SET (dir_start, FMTDIR_START); spec.directives++; @@ -144,7 +144,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, struct spec *spec1 = (struct spec *) msgid_descr; struct spec *spec2 = (struct spec *) msgstr_descr; bool err = false; - unsigned int i; + size_t i; if (spec1->simple && !spec2->simple) { @@ -169,11 +169,11 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (arg_used1) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), i, pretty_msgstr); else error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), i, pretty_msgstr, pretty_msgid); } err = true; @@ -206,7 +206,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-ruby.c b/gettext-tools/src/format-ruby.c index 7e371fef9..017e3e365 100644 --- a/gettext-tools/src/format-ruby.c +++ b/gettext-tools/src/format-ruby.c @@ -19,8 +19,8 @@ # include #endif -#include #include +#include #include #include @@ -91,20 +91,20 @@ struct named_arg struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'ruby-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int named_arg_count; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t named_arg_count; + size_t numbered_arg_count; struct named_arg *named; struct numbered_arg *numbered; }; @@ -120,8 +120,8 @@ named_arg_compare (const void *p1, const void *p2) static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -130,25 +130,25 @@ numbered_arg_compare (const void *p1, const void *p2) xstrdup (_("The string refers to arguments both through argument names and through unnamed argument specifications.")) #define INVALID_TWO_ARG_NAMES(directive_number) \ - xasprintf (_("In the directive number %u, two names are given for the same argument."), directive_number) + xasprintf (_("In the directive number %zu, two names are given for the same argument."), directive_number) #define INVALID_TWO_ARG_NUMBERS(directive_number) \ - xasprintf (_("In the directive number %u, two numbers are given for the same argument."), directive_number) + xasprintf (_("In the directive number %zu, two numbers are given for the same argument."), directive_number) #define INVALID_FLAG_AFTER_WIDTH(directive_number) \ - xasprintf (_("In the directive number %u, a flag is given after the width."), directive_number) + xasprintf (_("In the directive number %zu, a flag is given after the width."), directive_number) #define INVALID_FLAG_AFTER_PRECISION(directive_number) \ - xasprintf (_("In the directive number %u, a flag is given after the precision."), directive_number) + xasprintf (_("In the directive number %zu, a flag is given after the precision."), directive_number) #define INVALID_WIDTH_AFTER_PRECISION(directive_number) \ - xasprintf (_("In the directive number %u, the width is given after the precision."), directive_number) + xasprintf (_("In the directive number %zu, the width is given after the precision."), directive_number) #define INVALID_WIDTH_TWICE(directive_number) \ - xasprintf (_("In the directive number %u, a width is given twice."), directive_number) + xasprintf (_("In the directive number %zu, a width is given twice."), directive_number) #define INVALID_PRECISION_TWICE(directive_number) \ - xasprintf (_("In the directive number %u, a precision is given twice."), directive_number) + xasprintf (_("In the directive number %zu, a precision is given twice."), directive_number) static void * format_parse (const char *format, bool translated, char *fdi, @@ -156,9 +156,9 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int unnumbered_arg_count; - unsigned int named_allocated; - unsigned int numbered_allocated; + size_t unnumbered_arg_count; + size_t named_allocated; + size_t numbered_allocated; struct spec *result; spec.directives = 0; @@ -177,14 +177,14 @@ format_parse (const char *format, bool translated, char *fdi, { /* A directive. */ char *name = NULL; - unsigned int number = 0; + size_t number = 0; bool seen_width = false; - unsigned int width_number = 0; + size_t width_number = 0; bool width_takenext = false; bool seen_precision = false; - unsigned int precision_number = 0; + size_t precision_number = 0; bool precision_takenext = false; enum format_arg_type type; @@ -265,14 +265,14 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { - unsigned int m = 0; + size_t m = 0; do { - if (m < UINT_MAX / 10) + if (m < SIZE_MAX / 10) m = 10 * m + (*format - '0'); else - m = UINT_MAX - 1; + m = SIZE_MAX - 1; format++; } while (c_isdigit (*format)); @@ -329,14 +329,14 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { - if (m < UINT_MAX / 10) + if (m < SIZE_MAX / 10) m = 10 * m + (*f - '0'); else - m = UINT_MAX - 1; + m = SIZE_MAX - 1; f++; } while (c_isdigit (*f)); @@ -424,14 +424,14 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { - if (m < UINT_MAX / 10) + if (m < SIZE_MAX / 10) m = 10 * m + (*f - '0'); else - m = UINT_MAX - 1; + m = SIZE_MAX - 1; f++; } while (c_isdigit (*f)); @@ -728,7 +728,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -775,7 +775,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the named argument array, and eliminate duplicates. */ if (spec.named_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.named, spec.named_arg_count, sizeof (struct named_arg), @@ -827,7 +827,7 @@ format_parse (const char *format, bool translated, char *fdi, bad_format: if (spec.named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec.named_arg_count; i++) free (spec.named[i].name); free (spec.named); @@ -844,7 +844,7 @@ format_free (void *descr) if (spec->named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec->named_arg_count; i++) free (spec->named[i].name); free (spec->named); @@ -899,9 +899,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (spec1->named_arg_count + spec2->named_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->named_arg_count; - unsigned int n2 = spec2->named_arg_count; + size_t i, j; + size_t n1 = spec1->named_arg_count; + size_t n2 = spec2->named_arg_count; /* Check the argument names in spec2 are contained in those of spec1. Both arrays are sorted. We search for the first difference. */ @@ -963,7 +963,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i; + size_t i; /* Check the argument types are the same. */ if (spec1->numbered_arg_count != spec2->numbered_arg_count) @@ -980,7 +980,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, i + 1); err = true; } @@ -1012,7 +1012,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { @@ -1056,13 +1056,13 @@ format_print (void *descr) } else { - unsigned int last; + size_t last; printf ("("); last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-rust.c b/gettext-tools/src/format-rust.c index 737835c91..f579a8bc7 100644 --- a/gettext-tools/src/format-rust.c +++ b/gettext-tools/src/format-rust.c @@ -91,14 +91,14 @@ struct named_arg struct numbered_arg { /* The number of the argument, 0-based. */ - unsigned int number; + size_t number; }; struct spec { - unsigned int directives; - unsigned int named_arg_count; - unsigned int numbered_arg_count; + size_t directives; + size_t named_arg_count; + size_t numbered_arg_count; struct named_arg *named; struct numbered_arg *numbered; }; @@ -114,8 +114,8 @@ named_arg_compare (const void *p1, const void *p2) static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -125,10 +125,10 @@ format_parse (const char *format, bool translated, char *fdi, char **invalid_reason) { struct spec spec; - unsigned int named_allocated; - unsigned int numbered_allocated; + size_t named_allocated; + size_t numbered_allocated; bool seen_numbered_args; - unsigned int unnumbered_arg_count; + size_t unnumbered_arg_count; struct spec *result; spec.directives = 0; @@ -176,7 +176,7 @@ format_parse (const char *format, bool translated, char *fdi, if (arg_id >= UINT_MAX / 10) { *invalid_reason = - xasprintf (_("In the directive number %u, the argument number is too large."), spec.directives); + xasprintf (_("In the directive number %zu, the argument number is too large."), spec.directives); FDI_SET (format, FMTDIR_ERROR); goto bad_format; } @@ -267,7 +267,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c1 == '\0') { *invalid_reason = - xasprintf (_("The directive number %u is unterminated."), + xasprintf (_("The directive number %zu is unterminated."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; @@ -324,7 +324,7 @@ format_parse (const char *format, bool translated, char *fdi, if (*format != '}') { *invalid_reason = - xasprintf (_("The directive number %u is unterminated."), + xasprintf (_("The directive number %zu is unterminated."), spec.directives); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; @@ -352,7 +352,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; qsort (spec.numbered, spec.numbered_arg_count, sizeof (struct numbered_arg), numbered_arg_compare); @@ -373,7 +373,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the named argument array, and eliminate duplicates. */ if (spec.named_arg_count > 1) { - unsigned int i, j; + size_t i, j; qsort (spec.named, spec.named_arg_count, sizeof (struct named_arg), named_arg_compare); @@ -398,7 +398,7 @@ format_parse (const char *format, bool translated, char *fdi, bad_format: if (spec.named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec.named_arg_count; i++) free (spec.named[i].name); free (spec.named); @@ -415,7 +415,7 @@ format_free (void *descr) if (spec->named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec->named_arg_count; i++) free (spec->named[i].name); free (spec->named); @@ -443,9 +443,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->named_arg_count + spec2->named_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->named_arg_count; - unsigned int n2 = spec2->named_arg_count; + size_t i, j; + size_t n1 = spec1->named_arg_count; + size_t n2 = spec2->named_arg_count; /* Check the argument names in spec2 are contained in those of spec1. Both arrays are sorted. We search for the first difference. */ @@ -486,10 +486,10 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; - unsigned int missing = 0; /* only used if !equality */ + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; + size_t missing = 0; /* only used if !equality */ /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -505,7 +505,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -517,7 +517,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -526,7 +526,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for arguments %u and %u doesn't exist in '%s', only one argument may be ignored"), + _("a format specification for arguments %zu and %zu doesn't exist in '%s', only one argument may be ignored"), missing, spec1->numbered[i].number, pretty_msgstr); err = true; @@ -568,8 +568,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i, j; + size_t last; + size_t i, j; if (spec == NULL) { @@ -581,7 +581,7 @@ format_print (void *descr) last = 0; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-scheme.c b/gettext-tools/src/format-scheme.c index 8017304ac..874013223 100644 --- a/gettext-tools/src/format-scheme.c +++ b/gettext-tools/src/format-scheme.c @@ -70,7 +70,7 @@ enum format_arg_type struct format_arg { - unsigned int repcount; /* Number of consecutive arguments this constraint + size_t repcount; /* Number of consecutive arguments this constraint applies to. Normally 1, but unconstrained arguments are often repeated. */ enum format_cdr_type presence; /* Can the argument list end right before @@ -81,11 +81,11 @@ struct format_arg struct segment { - unsigned int count; /* Number of format_arg records used. */ - unsigned int allocated; + size_t count; /* Number of format_arg records used. */ + size_t allocated; struct format_arg *element; /* Argument constraints. */ - unsigned int length; /* Number of arguments represented by this segment. - This is the sum of all repcounts in the segment. */ + size_t length; /* Number of arguments represented by this segment. + This is the sum of all repcounts in the segment. */ }; struct format_arg_list @@ -106,7 +106,7 @@ struct format_arg_list struct spec { - unsigned int directives; + size_t directives; struct format_arg_list *list; }; @@ -161,8 +161,8 @@ verify_element (const struct format_arg * e) static void verify_list (const struct format_arg_list *list) { - unsigned int i; - unsigned int total_repcount; + size_t i; + size_t total_repcount; ASSERT (list->initial.count <= list->initial.allocated); total_repcount = 0; @@ -202,7 +202,7 @@ free_element (struct format_arg *element) static void free_list (struct format_arg_list *list) { - unsigned int i; + size_t i; for (i = 0; i < list->initial.count; i++) free_element (&list->initial.element[i]); @@ -236,8 +236,8 @@ static struct format_arg_list * copy_list (const struct format_arg_list *list) { struct format_arg_list *newlist; - unsigned int length; - unsigned int i; + size_t length; + size_t i; VERIFY_LIST (list); @@ -303,7 +303,7 @@ static bool equal_list (const struct format_arg_list *list1, const struct format_arg_list *list2) { - unsigned int n, i; + size_t n, i; VERIFY_LIST (list1); VERIFY_LIST (list2); @@ -340,7 +340,7 @@ equal_list (const struct format_arg_list *list1, /* Ensure list->initial.allocated >= newcount. */ static inline void -ensure_initial_alloc (struct format_arg_list *list, unsigned int newcount) +ensure_initial_alloc (struct format_arg_list *list, size_t newcount) { if (newcount > list->initial.allocated) { @@ -370,7 +370,7 @@ grow_initial_alloc (struct format_arg_list *list) /* Ensure list->repeated.allocated >= newcount. */ static inline void -ensure_repeated_alloc (struct format_arg_list *list, unsigned int newcount) +ensure_repeated_alloc (struct format_arg_list *list, size_t newcount) { if (newcount > list->repeated.allocated) { @@ -407,7 +407,7 @@ grow_repeated_alloc (struct format_arg_list *list) static void normalize_outermost_list (struct format_arg_list *list) { - unsigned int n, i, j; + size_t n, i, j; /* Step 1: Combine adjacent elements. Copy from i to j, keeping 0 <= j <= i. */ @@ -451,7 +451,7 @@ normalize_outermost_list (struct format_arg_list *list) /* Nothing more to be done if the loop segment is empty. */ if (list->repeated.count > 0) { - unsigned int m, repcount0_extra; + size_t m, repcount0_extra; /* Step 2: Reduce the loop period. */ n = list->repeated.count; @@ -522,7 +522,7 @@ normalize_outermost_list (struct format_arg_list *list) && equal_element (&list->initial.element[list->initial.count-1], &list->repeated.element[list->repeated.count-1])) { - unsigned int moved_repcount = + size_t moved_repcount = MIN (list->initial.element[list->initial.count-1].repcount, list->repeated.element[list->repeated.count-1].repcount); @@ -532,7 +532,7 @@ normalize_outermost_list (struct format_arg_list *list) list->repeated.element[0].repcount += moved_repcount; else { - unsigned int newcount = list->repeated.count + 1; + size_t newcount = list->repeated.count + 1; ensure_repeated_alloc (list, newcount); for (i = newcount - 1; i > 0; i--) list->repeated.element[i] = list->repeated.element[i-1]; @@ -570,7 +570,7 @@ normalize_outermost_list (struct format_arg_list *list) static void normalize_list (struct format_arg_list *list) { - unsigned int n, i; + size_t n, i; VERIFY_LIST (list); @@ -661,13 +661,13 @@ is_empty_list (const struct format_arg_list *list) Assumes list->repeated.count > 0. */ /* Memory effects: list is destructively modified. */ static void -unfold_loop (struct format_arg_list *list, unsigned int m) +unfold_loop (struct format_arg_list *list, size_t m) { - unsigned int i, j, k; + size_t i, j, k; if (m > 1) { - unsigned int newcount = list->repeated.count * m; + size_t newcount = list->repeated.count * m; ensure_repeated_alloc (list, newcount); i = list->repeated.count; for (k = 1; k < m; k++) @@ -682,7 +682,7 @@ unfold_loop (struct format_arg_list *list, unsigned int m) Assumes list->repeated.count > 0. */ /* Memory effects: list is destructively modified. */ static void -rotate_loop (struct format_arg_list *list, unsigned int m) +rotate_loop (struct format_arg_list *list, size_t m) { if (m == list->initial.length) return; @@ -691,7 +691,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) { /* Instead of multiple copies of list->repeated.element[0], a single copy with higher repcount is appended to list->initial. */ - unsigned int i, newcount; + size_t i, newcount; newcount = list->initial.count + 1; ensure_initial_alloc (list, newcount); @@ -703,16 +703,16 @@ rotate_loop (struct format_arg_list *list, unsigned int m) } else { - unsigned int n = list->repeated.length; + size_t n = list->repeated.length; /* Write m = list->initial.length + q * n + r with 0 <= r < n. */ - unsigned int q = (m - list->initial.length) / n; - unsigned int r = (m - list->initial.length) % n; + size_t q = (m - list->initial.length) / n; + size_t r = (m - list->initial.length) % n; /* Determine how many entries of list->repeated are needed for length r. */ - unsigned int s; - unsigned int t; + size_t s; + size_t t; for (t = r, s = 0; s < list->repeated.count && t >= list->repeated.element[s].repcount; @@ -727,7 +727,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) plus the s first elements of list->repeated, plus, if t > 0, a splitoff of list->repeated.element[s]. */ { - unsigned int i, j, k, newcount; + size_t i, j, k, newcount; i = list->initial.count; newcount = i + q * list->repeated.count + s + (t > 0 ? 1 : 0); @@ -760,7 +760,7 @@ rotate_loop (struct format_arg_list *list, unsigned int m) /* And rotate list->repeated. */ if (r > 0) { - unsigned int i, j, oldcount, newcount; + size_t i, j, oldcount, newcount; struct format_arg *newelement; oldcount = list->repeated.count; @@ -789,14 +789,14 @@ rotate_loop (struct format_arg_list *list, unsigned int m) i.e. if 0 < n < list->initial.length, then n-1 and n are covered by two different adjacent elements. */ /* Memory effects: list is destructively modified. */ -static unsigned int -initial_splitelement (struct format_arg_list *list, unsigned int n) +static size_t +initial_splitelement (struct format_arg_list *list, size_t n) { - unsigned int s; - unsigned int t; - unsigned int oldrepcount; - unsigned int newcount; - unsigned int i; + size_t s; + size_t t; + size_t oldrepcount; + size_t newcount; + size_t i; VERIFY_LIST (list); @@ -837,15 +837,15 @@ initial_splitelement (struct format_arg_list *list, unsigned int n) /* Ensure index n in the initial segment is not shared. Return its index. */ /* Memory effects: list is destructively modified. */ -static unsigned int -initial_unshare (struct format_arg_list *list, unsigned int n) +static size_t +initial_unshare (struct format_arg_list *list, size_t n) { /* This does the same side effects as initial_splitelement (list, n); initial_splitelement (list, n + 1); */ - unsigned int s; - unsigned int t; + size_t s; + size_t t; VERIFY_LIST (list); @@ -869,13 +869,13 @@ initial_unshare (struct format_arg_list *list, unsigned int n) { /* Split the entry into at most three entries: for indices < n, for index n, and for indices > n. */ - unsigned int oldrepcount = list->initial.element[s].repcount; - unsigned int newcount = + size_t oldrepcount = list->initial.element[s].repcount; + size_t newcount = list->initial.count + (t == 0 || t == oldrepcount - 1 ? 1 : 2); ensure_initial_alloc (list, newcount); if (t == 0 || t == oldrepcount - 1) { - unsigned int i; + size_t i; for (i = list->initial.count - 1; i > s; i--) list->initial.element[i+1] = list->initial.element[i]; @@ -893,7 +893,7 @@ initial_unshare (struct format_arg_list *list, unsigned int n) } else { - unsigned int i; + size_t i; for (i = list->initial.count - 1; i > s; i--) list->initial.element[i+2] = list->initial.element[i]; @@ -920,13 +920,13 @@ initial_unshare (struct format_arg_list *list, unsigned int n) /* Add n unconstrained elements at the front of the list. */ /* Memory effects: list is destructively modified. */ static void -shift_list (struct format_arg_list *list, unsigned int n) +shift_list (struct format_arg_list *list, size_t n) { VERIFY_LIST (list); if (n > 0) { - unsigned int i; + size_t i; grow_initial_alloc (list); for (i = list->initial.count; i > 0; i--) @@ -1067,7 +1067,7 @@ append_repeated_to_initial (struct format_arg_list *list) if (list->repeated.count > 0) { /* Move list->repeated over to list->initial. */ - unsigned int i, j, newcount; + size_t i, j, newcount; newcount = list->initial.count + list->repeated.count; ensure_initial_alloc (list, newcount); @@ -1097,7 +1097,7 @@ backtrack_in_initial (struct format_arg_list *list) while (list->initial.count > 0) { - unsigned int i = list->initial.count - 1; + size_t i = list->initial.count - 1; if (list->initial.element[i].presence == FCT_REQUIRED) { /* Throw away this element. */ @@ -1142,11 +1142,11 @@ make_intersected_list (struct format_arg_list *list1, if (list1->repeated.length > 0 && list2->repeated.length > 0) /* Step 1: Ensure list1->repeated.length == list2->repeated.length. */ { - unsigned int n1 = list1->repeated.length; - unsigned int n2 = list2->repeated.length; - unsigned int g = gcd (n1, n2); - unsigned int m1 = n2 / g; /* = lcm(n1,n2) / n1 */ - unsigned int m2 = n1 / g; /* = lcm(n1,n2) / n2 */ + size_t n1 = list1->repeated.length; + size_t n2 = list2->repeated.length; + size_t g = gcd (n1, n2); + size_t m1 = n2 / g; /* = lcm(n1,n2) / n1 */ + size_t m2 = n1 / g; /* = lcm(n1,n2) / n2 */ unfold_loop (list1, m1); unfold_loop (list2, m2); @@ -1159,7 +1159,7 @@ make_intersected_list (struct format_arg_list *list1, repeated segment, this means to ensure list1->initial.length == list2->initial.length. */ { - unsigned int m = MAX (list1->initial.length, list2->initial.length); + size_t m = MAX (list1->initial.length, list2->initial.length); if (list1->repeated.length > 0) rotate_loop (list1, m); @@ -1188,8 +1188,8 @@ make_intersected_list (struct format_arg_list *list1, { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->initial.element; c1 = list1->initial.count; e2 = list2->initial.element; c2 = list2->initial.count; @@ -1276,8 +1276,8 @@ make_intersected_list (struct format_arg_list *list1, { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->repeated.element; c1 = list1->repeated.count; e2 = list2->repeated.element; c2 = list2->repeated.count; @@ -1515,11 +1515,11 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { /* Step 1: Ensure list1->repeated.length == list2->repeated.length. */ { - unsigned int n1 = list1->repeated.length; - unsigned int n2 = list2->repeated.length; - unsigned int g = gcd (n1, n2); - unsigned int m1 = n2 / g; /* = lcm(n1,n2) / n1 */ - unsigned int m2 = n1 / g; /* = lcm(n1,n2) / n2 */ + size_t n1 = list1->repeated.length; + size_t n2 = list2->repeated.length; + size_t g = gcd (n1, n2); + size_t m1 = n2 / g; /* = lcm(n1,n2) / n1 */ + size_t m2 = n1 / g; /* = lcm(n1,n2) / n2 */ unfold_loop (list1, m1); unfold_loop (list2, m2); @@ -1528,7 +1528,7 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) /* Step 2: Ensure that list1->initial.length == list2->initial.length. */ { - unsigned int m = MAX (list1->initial.length, list2->initial.length); + size_t m = MAX (list1->initial.length, list2->initial.length); rotate_loop (list1, m); rotate_loop (list2, m); @@ -1575,8 +1575,8 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->initial.element; c1 = list1->initial.count; e2 = list2->initial.element; c2 = list2->initial.count; @@ -1697,8 +1697,8 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { struct format_arg *e1; struct format_arg *e2; - unsigned int c1; - unsigned int c2; + size_t c1; + size_t c2; e1 = list1->repeated.element; c1 = list1->repeated.count; e2 = list2->repeated.element; c2 = list2->repeated.count; @@ -1736,7 +1736,7 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { /* Turning FCT_REQUIRED into FCT_OPTIONAL was already handled in the initial segment. Just copy the repeated segment of list1. */ - unsigned int i; + size_t i; result->repeated.count = list1->repeated.count; result->repeated.allocated = result->repeated.count; @@ -1751,7 +1751,7 @@ make_union_list (struct format_arg_list *list1, struct format_arg_list *list2) { /* Turning FCT_REQUIRED into FCT_OPTIONAL was already handled in the initial segment. Just copy the repeated segment of list2. */ - unsigned int i; + size_t i; result->repeated.count = list2->repeated.count; result->repeated.allocated = result->repeated.count; @@ -1834,10 +1834,10 @@ union (struct format_arg_list *list1, struct format_arg_list *list2) /* Test whether arguments 0..n are required arguments in a list. */ static bool -is_required (const struct format_arg_list *list, unsigned int n) +is_required (const struct format_arg_list *list, size_t n) { - unsigned int s; - unsigned int t; + size_t s; + size_t t; /* We'll check whether the first n+1 presence flags are FCT_REQUIRED. */ t = n + 1; @@ -1892,9 +1892,9 @@ is_required (const struct format_arg_list *list, unsigned int n) present. NULL stands for an impossible situation, i.e. a contradiction. */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_required_constraint (struct format_arg_list *list, unsigned int n) +add_required_constraint (struct format_arg_list *list, size_t n) { - unsigned int i, rest; + size_t i, rest; if (list == NULL) return NULL; @@ -1929,9 +1929,9 @@ add_required_constraint (struct format_arg_list *list, unsigned int n) contradiction. */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_end_constraint (struct format_arg_list *list, unsigned int n) +add_end_constraint (struct format_arg_list *list, size_t n) { - unsigned int s, i; + size_t s, i; enum format_cdr_type n_presence; if (list == NULL) @@ -1977,10 +1977,10 @@ add_end_constraint (struct format_arg_list *list, unsigned int n) contradiction. Assumes a preceding add_required_constraint (list, n). */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_type_constraint (struct format_arg_list *list, unsigned int n, +add_type_constraint (struct format_arg_list *list, size_t n, enum format_arg_type type) { - unsigned int s; + size_t s; struct format_arg newconstraint; struct format_arg tmpelement; @@ -2016,11 +2016,11 @@ add_type_constraint (struct format_arg_list *list, unsigned int n, contradiction. Assumes a preceding add_required_constraint (list, n). */ /* Memory effects: list is freed. The result is freshly allocated. */ static struct format_arg_list * -add_listtype_constraint (struct format_arg_list *list, unsigned int n, +add_listtype_constraint (struct format_arg_list *list, size_t n, enum format_arg_type type, struct format_arg_list *sublist) { - unsigned int s; + size_t s; struct format_arg newconstraint; struct format_arg tmpelement; @@ -2056,7 +2056,7 @@ add_listtype_constraint (struct format_arg_list *list, unsigned int n, static void add_req_type_constraint (struct format_arg_list **listp, - unsigned int position, enum format_arg_type type) + size_t position, enum format_arg_type type) { *listp = add_required_constraint (*listp, position); *listp = add_type_constraint (*listp, position, type); @@ -2065,7 +2065,7 @@ add_req_type_constraint (struct format_arg_list **listp, static void add_req_listtype_constraint (struct format_arg_list **listp, - unsigned int position, enum format_arg_type type, + size_t position, enum format_arg_type type, struct format_arg_list *sublist) { *listp = add_required_constraint (*listp, position); @@ -2119,12 +2119,12 @@ make_repeated_list_of_lists (struct format_arg_list *sublist) */ /* Memory effects: sublist is freed. The result is freshly allocated. */ static struct format_arg_list * -make_repeated_list (struct format_arg_list *sublist, unsigned int period) +make_repeated_list (struct format_arg_list *sublist, size_t period) { struct segment tmp; struct segment *srcseg; struct format_arg_list *list; - unsigned int p, n, i, si, ti, j, sj, tj, splitindex, newcount; + size_t p, n, i, si, ti, j, sj, tj, splitindex, newcount; bool ended; VERIFY_LIST (sublist); @@ -2147,8 +2147,8 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) { /* L is an infinite list. */ /* p := lcm (period, period of L) */ - unsigned int Lp = sublist->repeated.length; - unsigned int m = period / gcd (period, Lp); /* = lcm(period,Lp) / Lp */ + size_t Lp = sublist->repeated.length; + size_t m = period / gcd (period, Lp); /* = lcm(period,Lp) / Lp */ unfold_loop (sublist, m); p = m * Lp; @@ -2205,7 +2205,7 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) i = 0, ti = 0, si = 0; while (i < p) { - unsigned int k = MIN (srcseg->element[si].repcount - ti, p - i); + size_t k = MIN (srcseg->element[si].repcount - ti, p - i); /* Ensure room in list->initial. */ grow_initial_alloc (list); @@ -2236,7 +2236,7 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) j = 0, tj = 0, sj = 0; while (i < n) { - unsigned int k = + size_t k = MIN (srcseg->element[si].repcount - ti, list->initial.element[sj].repcount - tj); @@ -2355,12 +2355,12 @@ static const enum format_arg_type THREE [3] = { invalid. */ static bool check_params (struct format_arg_list **listp, - unsigned int paramcount, struct param *params, - unsigned int t_count, const enum format_arg_type *t_types, - unsigned int directives, char **invalid_reason) + size_t paramcount, struct param *params, + size_t t_count, const enum format_arg_type *t_types, + size_t directives, char **invalid_reason) { - unsigned int orig_paramcount = paramcount; - unsigned int orig_t_count = t_count; + size_t orig_paramcount = paramcount; + size_t orig_t_count = t_count; for (; paramcount > 0 && t_count > 0; params++, paramcount--, t_types++, t_count--) @@ -2377,7 +2377,7 @@ check_params (struct format_arg_list **listp, case PT_INTEGER: case PT_ARGCOUNT: /* wrong param type */ *invalid_reason = - xasprintf (_("In the directive number %u, parameter %u is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "integer", "character"); + xasprintf (_("In the directive number %zu, parameter %zu is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "integer", "character"); return false; } break; @@ -2389,7 +2389,7 @@ check_params (struct format_arg_list **listp, case PT_CHARACTER: /* wrong param type */ *invalid_reason = - xasprintf (_("In the directive number %u, parameter %u is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "character", "integer"); + xasprintf (_("In the directive number %zu, parameter %zu is of type '%s' but a parameter of type '%s' is expected."), directives, orig_paramcount - paramcount + 1, "character", "integer"); return false; } break; @@ -2412,8 +2412,8 @@ check_params (struct format_arg_list **listp, case PT_CHARACTER: case PT_INTEGER: case PT_ARGCOUNT: /* too many params for directive */ *invalid_reason = - xasprintf (ngettext ("In the directive number %u, too many parameters are given; expected at most %u parameter.", - "In the directive number %u, too many parameters are given; expected at most %u parameters.", + xasprintf (ngettext ("In the directive number %zu, too many parameters are given; expected at most %zu parameter.", + "In the directive number %zu, too many parameters are given; expected at most %zu parameters.", orig_t_count), directives, orig_t_count); return false; @@ -2474,7 +2474,7 @@ parse_upto (const char **formatp, { bool colon_p = false; bool atsign_p = false; - unsigned int paramcount = 0; + size_t paramcount = 0; struct param *params = NULL; FDI_SET (format - 1, FMTDIR_START); @@ -2513,7 +2513,7 @@ parse_upto (const char **formatp, else { *invalid_reason = - xasprintf (_("In the directive number %u, '%c' is not followed by a digit."), spec->directives, format[-1]); + xasprintf (_("In the directive number %zu, '%c' is not followed by a digit."), spec->directives, format[-1]); FDI_SET (format, FMTDIR_ERROR); } return false; @@ -2768,7 +2768,7 @@ parse_upto (const char **formatp, { /* invalid argument */ *invalid_reason = - xasprintf (_("In the directive number %u, the argument %d is negative."), spec->directives, n); + xasprintf (_("In the directive number %zu, the argument %d is negative."), spec->directives, n); FDI_SET (format - 1, FMTDIR_ERROR); return false; } @@ -2874,7 +2874,7 @@ parse_upto (const char **formatp, if (atsign_p && colon_p) { *invalid_reason = - xasprintf (_("In the directive number %u, both the @ and the : modifiers are given."), spec->directives); + xasprintf (_("In the directive number %zu, both the @ and the : modifiers are given."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; } @@ -2987,7 +2987,7 @@ parse_upto (const char **formatp, if (!sub_separator) { *invalid_reason = - xasprintf (_("In the directive number %u, '~:[' is not followed by two clauses, separated by '~;'."), spec->directives); + xasprintf (_("In the directive number %zu, '~:[' is not followed by two clauses, separated by '~;'."), spec->directives); FDI_SET (**formatp == '\0' ? *formatp - 1 : *formatp, FMTDIR_ERROR); return false; @@ -3277,7 +3277,7 @@ parse_upto (const char **formatp, if (!separator) { *invalid_reason = - xasprintf (_("In the directive number %u, '~;' is used in an invalid position."), spec->directives); + xasprintf (_("In the directive number %zu, '~;' is used in an invalid position."), spec->directives); FDI_SET (format - 1, FMTDIR_ERROR); return false; } @@ -3516,7 +3516,7 @@ print_element (struct format_arg *element) static void print_list (struct format_arg_list *list) { - unsigned int i, j; + size_t i, j; printf ("("); diff --git a/gettext-tools/src/format-sh-printf.c b/gettext-tools/src/format-sh-printf.c index feb2b9309..d2fb87ce2 100644 --- a/gettext-tools/src/format-sh-printf.c +++ b/gettext-tools/src/format-sh-printf.c @@ -90,19 +90,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'sh-printf-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -110,8 +110,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -122,8 +122,8 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; - unsigned int unnumbered_arg_count; + size_t numbered_allocated; + size_t unnumbered_arg_count; struct spec *result; spec.directives = 0; @@ -146,13 +146,13 @@ format_parse (const char *format, bool translated, char *fdi, if (*format != '%') { - unsigned int number = 0; + size_t number = 0; enum format_arg_type type; if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -366,7 +366,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ else if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -457,9 +457,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -475,7 +475,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -487,7 +487,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -508,7 +508,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -546,8 +546,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -559,7 +559,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format-sh.c b/gettext-tools/src/format-sh.c index ee50b3641..abd932b46 100644 --- a/gettext-tools/src/format-sh.c +++ b/gettext-tools/src/format-sh.c @@ -1,5 +1,5 @@ /* Shell format strings. - Copyright (C) 2003-2024 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 @@ -61,8 +61,8 @@ struct named_arg struct spec { - unsigned int directives; - unsigned int named_arg_count; + size_t directives; + size_t named_arg_count; struct named_arg *named; }; @@ -89,7 +89,7 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int named_allocated; + size_t named_allocated; struct spec *result; spec.directives = 0; @@ -212,7 +212,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the named argument array, and eliminate duplicates. */ if (spec.named_arg_count > 1) { - unsigned int i, j; + size_t i, j; qsort (spec.named, spec.named_arg_count, sizeof (struct named_arg), named_arg_compare); @@ -237,7 +237,7 @@ format_parse (const char *format, bool translated, char *fdi, bad_format: if (spec.named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec.named_arg_count; i++) free (spec.named[i].name); free (spec.named); @@ -252,7 +252,7 @@ format_free (void *descr) if (spec->named != NULL) { - unsigned int i; + size_t i; for (i = 0; i < spec->named_arg_count; i++) free (spec->named[i].name); free (spec->named); @@ -279,9 +279,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->named_arg_count + spec2->named_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->named_arg_count; - unsigned int n2 = spec2->named_arg_count; + size_t i, j; + size_t n1 = spec1->named_arg_count; + size_t n2 = spec2->named_arg_count; /* Check the argument names in spec2 are contained in those of spec1. Both arrays are sorted. We search for the first difference. */ @@ -345,7 +345,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-smalltalk.c b/gettext-tools/src/format-smalltalk.c index a6038ce03..c56c537a4 100644 --- a/gettext-tools/src/format-smalltalk.c +++ b/gettext-tools/src/format-smalltalk.c @@ -1,5 +1,5 @@ /* Smalltalk and YCP format strings. - Copyright (C) 2001-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 @@ -40,8 +40,8 @@ struct spec { - unsigned int directives; - unsigned int arg_count; + size_t directives; + size_t arg_count; bool args_used[9]; }; @@ -68,7 +68,7 @@ format_parse (const char *format, bool translated, char *fdi, format++; else if (*format >= '1' && *format <= '9') { - unsigned int number = *format - '1'; + size_t number = *format - '1'; while (spec.arg_count <= number) spec.args_used[spec.arg_count++] = false; @@ -87,8 +87,8 @@ format_parse (const char *format, bool translated, char *fdi, { *invalid_reason = (c_isprint (*format) - ? xasprintf (_("In the directive number %u, the character '%c' is not a digit between 1 and 9."), spec.directives, *format) - : xasprintf (_("The character that terminates the directive number %u is not a digit between 1 and 9."), spec.directives)); + ? xasprintf (_("In the directive number %zu, the character '%c' is not a digit between 1 and 9."), spec.directives, *format) + : xasprintf (_("The character that terminates the directive number %zu is not a digit between 1 and 9."), spec.directives)); FDI_SET (format, FMTDIR_ERROR); } goto bad_format; @@ -129,7 +129,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, struct spec *spec1 = (struct spec *) msgid_descr; struct spec *spec2 = (struct spec *) msgstr_descr; bool err = false; - unsigned int i; + size_t i; for (i = 0; i < spec1->arg_count || i < spec2->arg_count; i++) { @@ -142,11 +142,11 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (arg_used1) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), i + 1, pretty_msgstr); else error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), i + 1, pretty_msgstr, pretty_msgid); } err = true; @@ -189,7 +189,7 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int i; + size_t i; if (spec == NULL) { diff --git a/gettext-tools/src/format-tcl.c b/gettext-tools/src/format-tcl.c index 9702e32e6..3e985dab4 100644 --- a/gettext-tools/src/format-tcl.c +++ b/gettext-tools/src/format-tcl.c @@ -68,19 +68,19 @@ enum format_arg_type struct numbered_arg { - unsigned int number; + size_t number; enum format_arg_type type; }; struct spec { - unsigned int directives; + size_t directives; /* We consider a directive as "likely intentional" if it does not contain a space. This prevents xgettext from flagging strings like "100% complete" as 'tcl-format' if they don't occur in a context that requires a format string. */ - unsigned int likely_intentional_directives; - unsigned int numbered_arg_count; + size_t likely_intentional_directives; + size_t numbered_arg_count; struct numbered_arg *numbered; }; @@ -88,8 +88,8 @@ struct spec static int numbered_arg_compare (const void *p1, const void *p2) { - unsigned int n1 = ((const struct numbered_arg *) p1)->number; - unsigned int n2 = ((const struct numbered_arg *) p2)->number; + size_t n1 = ((const struct numbered_arg *) p1)->number; + size_t n2 = ((const struct numbered_arg *) p2)->number; return (n1 > n2 ? 1 : n1 < n2 ? -1 : 0); } @@ -100,11 +100,11 @@ format_parse (const char *format, bool translated, char *fdi, { const char *const format_start = format; struct spec spec; - unsigned int numbered_allocated; + size_t numbered_allocated; struct spec *result; bool seen_numbered_arg; bool seen_unnumbered_arg; - unsigned int number; + size_t number; spec.directives = 0; spec.likely_intentional_directives = 0; @@ -135,7 +135,7 @@ format_parse (const char *format, bool translated, char *fdi, if (c_isdigit (*format)) { const char *f = format; - unsigned int m = 0; + size_t m = 0; do { @@ -296,7 +296,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Sort the numbered argument array, and eliminate duplicates. */ if (spec.numbered_arg_count > 1) { - unsigned int i, j; + size_t i, j; bool err; qsort (spec.numbered, spec.numbered_arg_count, @@ -387,9 +387,9 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, if (spec1->numbered_arg_count + spec2->numbered_arg_count > 0) { - unsigned int i, j; - unsigned int n1 = spec1->numbered_arg_count; - unsigned int n2 = spec2->numbered_arg_count; + size_t i, j; + size_t n1 = spec1->numbered_arg_count; + size_t n2 = spec2->numbered_arg_count; /* Check that the argument numbers are the same. Both arrays are sorted. We search for the first difference. */ @@ -405,7 +405,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u, as in '%s', doesn't exist in '%s'"), + _("a format specification for argument %zu, as in '%s', doesn't exist in '%s'"), spec2->numbered[j].number, pretty_msgstr, pretty_msgid); err = true; @@ -417,7 +417,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("a format specification for argument %u doesn't exist in '%s'"), + _("a format specification for argument %zu doesn't exist in '%s'"), spec1->numbered[i].number, pretty_msgstr); err = true; break; @@ -438,7 +438,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality, { if (error_logger) error_logger (error_logger_data, - _("format specifications in '%s' and '%s' for argument %u are not the same"), + _("format specifications in '%s' and '%s' for argument %zu are not the same"), pretty_msgid, pretty_msgstr, spec2->numbered[j].number); err = true; @@ -476,8 +476,8 @@ static void format_print (void *descr) { struct spec *spec = (struct spec *) descr; - unsigned int last; - unsigned int i; + size_t last; + size_t i; if (spec == NULL) { @@ -489,7 +489,7 @@ format_print (void *descr) last = 1; for (i = 0; i < spec->numbered_arg_count; i++) { - unsigned int number = spec->numbered[i].number; + size_t number = spec->numbered[i].number; if (i > 0) printf (" "); diff --git a/gettext-tools/src/format.h b/gettext-tools/src/format.h index 7ab8d35cc..02e1531f1 100644 --- a/gettext-tools/src/format.h +++ b/gettext-tools/src/format.h @@ -156,7 +156,7 @@ extern void /* Returns the number of unnamed arguments consumed by a Python format string. */ -extern unsigned int get_python_format_unnamed_arg_count (const char *string); +extern size_t get_python_format_unnamed_arg_count (const char *string); /* Check whether both formats strings contain compatible format specifications for format type i (0 <= i < NFORMATS).