* 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'.
#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__
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;
};
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);
}
{
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;
if (*format++ == '%')
{
/* A directive. */
- unsigned int number = 0;
+ size_t number = 0;
enum format_arg_type type;
bool likely_intentional = true;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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
{
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
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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;
};
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);
}
{
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;
{
bool brackets = false;
bool done = false;
- unsigned int number = 0;
+ size_t number = 0;
enum format_arg_type type = FAT_NONE;
if (*format == '|')
if (c_isdigit (*format) && *format != '0')
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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
{
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
{
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);
}
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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.
struct spec
{
- unsigned int directives;
- unsigned int numbered_arg_count;
+ size_t directives;
+ size_t numbered_arg_count;
struct numbered_arg *numbered;
};
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);
}
{
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;
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;
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
*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;
}
/* 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,
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. */
{
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;
{
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;
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);
}
{
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;
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)
{
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)
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 '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;
};
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);
}
{
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;
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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
{
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
{
/* 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,
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)
#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 */
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
{
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;
}
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++)
{
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
/* C# format strings.
- Copyright (C) 2003-2023 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
struct spec
{
- unsigned int directives;
- unsigned int numbered_arg_count;
+ size_t directives;
+ size_t numbered_arg_count;
};
static void *
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;
}
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;
{
*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;
}
*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;
}
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
# include <config.h>
#endif
-#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include "format.h"
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
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
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;
};
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;
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]);
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);
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);
/* 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)
{
/* 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)
{
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. */
/* 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;
&& 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);
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];
static void
normalize_list (struct format_arg_list *list)
{
- unsigned int n, i;
+ size_t n, i;
VERIFY_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++)
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;
{
/* 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);
}
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;
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);
/* 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;
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);
/* 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);
{
/* 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];
}
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];
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);
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. */
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);
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);
{
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;
{
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;
/* 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;
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;
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)
/* 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)
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;
/* 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)
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)
{
/* ======================= 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 '%(...%)'."))
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() \
{
const char *format = *formatp;
const char *const format_start = format;
- unsigned int arg_count = 0;
+ size_t arg_count = 0;
for (; *format != '\0'; )
{
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
f++;
if (c_isdigit (*f))
{
- unsigned int m2 = 0;
+ size_t m2 = 0;
do
{
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
}
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);
}
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);
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);
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);
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
{
}
else
{
- if (arg_count == UINT_MAX)
+ if (arg_count == SIZE_MAX)
{
*invalid_reason = INVALID_ARG_PAST_LAST (spec->directives);
FDI_SET (format, FMTDIR_ERROR);
*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)
static void
print_list (struct format_arg_list *list)
{
- unsigned int i, j;
+ size_t i, j;
printf ("(");
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;
};
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);
}
{
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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;
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);
}
{
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;
{
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;
}
{
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;
}
{
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;
}
{
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;
}
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
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:
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;
}
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
{
}
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;
}
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;
}
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;
{
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;
}
{
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;
}
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;
}
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
struct numbered_arg
{
- unsigned int number;
+ size_t number;
format_arg_type_t type;
};
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;
};
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);
}
{
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
/* 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;
}
}
/* 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++)
if (spec.unnumbered_arg_count > 0)
{
- unsigned int j;
+ size_t j;
spec.unnumbered = XNMALLOC (spec.unnumbered_arg_count, struct unnumbered_arg);
j = 0;
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
{
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;
}
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
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,
{
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;
if (c_isdigit (format[1]))
{
const char *f = format + 1;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* Parse width. */
if (*format == '*')
{
- unsigned int width_number = number;
+ size_t width_number = number;
if (allocated == spec.numbered_arg_count)
{
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int width = 0;
+ size_t width = 0;
do
{
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;
}
else if (*format == '*')
{
- unsigned int width_number = number;
+ size_t width_number = number;
if (allocated == spec.numbered_arg_count)
{
if (c_isdigit (format[1]))
{
const char *f = format + 1;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* Finish parsing precision. */
if (*format == '*')
{
- unsigned int precision_number = number;
+ size_t precision_number = number;
if (allocated == spec.numbered_arg_count)
{
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int precision = 0;
+ size_t precision = 0;
do
{
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;
}
else if (*format == '*')
{
- unsigned int precision_number = number;
+ size_t precision_number = number;
if (allocated == spec.numbered_arg_count)
{
if (c_isdigit (format[1]))
{
const char *f = format + 1;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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)
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;
};
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,
{
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;
if (*format++ == '%')
{
/* A directive. */
- unsigned int number = 0;
+ size_t number = 0;
unsigned int flags;
format_arg_type_t type;
unsigned int invalid_flags;
else if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
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. */
{
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;
{
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;
{
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;
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
size_t n;
char *element_alloced;
char *element;
- unsigned int number;
+ size_t number;
enum format_arg_type type;
FDI_SET (format, FMTDIR_START);
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;
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;
*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;
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;
*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;
*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;
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;
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;
}
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;
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);
}
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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;
};
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);
}
{
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;
if (*format++ == '%')
{
/* A directive. */
- unsigned int number = 0;
+ size_t number = 0;
enum format_arg_type type;
bool likely_intentional = true;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
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. */
{
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;
{
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;
{
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;
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
{
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)
{
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 (" ");
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;
};
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);
}
{
const char *const format_start = format;
struct spec spec;
- unsigned int numbered_allocated;
+ size_t numbered_allocated;
struct spec *result;
spec.directives = 0;
if (*format > '0' && *format <= '9')
{
/* A directive. */
- unsigned int number;
+ size_t number;
FDI_SET (dir_start, FMTDIR_START);
spec.directives++;
/* 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);
{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;
}
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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;
};
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);
}
{
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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
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
struct spec
{
- unsigned int directives;
+ size_t directives;
struct format_arg_list *list;
};
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;
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]);
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);
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);
/* 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)
{
/* 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)
{
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. */
/* 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;
&& 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);
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];
static void
normalize_list (struct format_arg_list *list)
{
- unsigned int n, i;
+ size_t n, i;
VERIFY_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++)
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;
{
/* 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);
}
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;
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);
/* 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;
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);
/* 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);
{
/* 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];
}
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];
/* 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--)
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);
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. */
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);
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);
{
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;
{
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;
{
/* 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);
/* 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);
{
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;
{
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;
{
/* 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;
{
/* 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;
/* 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;
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;
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)
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;
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;
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);
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);
*/
/* 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);
{
/* 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;
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);
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);
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--)
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;
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;
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;
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;
{
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);
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;
{
/* 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;
}
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;
}
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;
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;
}
static void
print_list (struct format_arg_list *list)
{
- unsigned int i, j;
+ size_t i, j;
printf ("(");
struct spec
{
- unsigned int directives;
- unsigned int format_args_count;
+ size_t directives;
+ size_t format_args_count;
enum format_arg_type *format_args;
};
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;
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;
{
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;
}
{
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;
}
{
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;
}
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
struct spec
{
- unsigned int directives;
- unsigned int arg_count;
+ size_t directives;
+ size_t arg_count;
enum format_arg_type *args;
};
{
const char *const format_start = format;
struct spec spec;
- unsigned int args_allocated;
+ size_t args_allocated;
struct spec *result;
spec.directives = 0;
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;
}
{
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)
{
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;
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
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);
}
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
{
/* 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))
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
/* Perl brace format strings.
- Copyright (C) 2004-2023 Free Software Foundation, Inc.
+ Copyright (C) 2004-2025 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
struct spec
{
- unsigned int directives;
- unsigned int named_arg_count;
+ size_t directives;
+ size_t named_arg_count;
struct named_arg *named;
};
{
const char *const format_start = format;
struct spec spec;
- unsigned int named_allocated;
+ size_t named_allocated;
struct spec *result;
spec.directives = 0;
/* 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);
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);
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
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
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);
}
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;
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;
if (c_isnonzerodigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
}
else if (c_isnonzerodigit (*f))
{
- unsigned int m = 0;
+ size_t m = 0;
do
{
f++;
if (*f == 'v')
{
- unsigned int vector_number = m;
+ size_t vector_number = m;
format = ++f;
vectorize = true;
/* 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
{
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
{
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;
}
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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;
};
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);
}
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;
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
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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;
};
{
*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);
}
{
*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);
}
{
*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);
}
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;
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;
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;
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;
/* 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);
{
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);
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. */
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
{
const char *const format_start = format;
struct spec spec;
- unsigned int allocated;
+ size_t allocated;
struct spec *result;
spec.directives = 0;
if (*format == '(')
{
- unsigned int depth;
+ size_t depth;
const char *name_start;
const char *name_end;
size_t n;
/* 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),
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);
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);
{
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. */
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)
{
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;
}
};
-unsigned int
+size_t
get_python_format_unnamed_arg_count (const char *string)
{
/* Parse the format string. */
if (descr != NULL)
{
- unsigned int result = descr->unnamed_arg_count;
+ size_t result = descr->unnamed_arg_count;
format_free (descr);
return result;
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
/* Qt plural format strings.
- Copyright (C) 2003-2023 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify
struct spec
{
/* Number of format directives. */
- unsigned int directives;
+ size_t directives;
};
/* Qt format strings.
- Copyright (C) 2003-2023 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
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];
};
if (*format >= '0' && *format <= '9')
{
/* A directive. */
- unsigned int number;
+ size_t number;
FDI_SET (dir_start, FMTDIR_START);
spec.directives++;
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)
{
{
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;
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
# include <config.h>
#endif
-#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
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;
};
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);
}
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,
{
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;
{
/* 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;
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));
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));
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));
/* 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,
/* 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),
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);
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);
{
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. */
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)
{
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;
}
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
}
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 (" ");
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;
};
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);
}
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;
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;
}
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;
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;
/* 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);
/* 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);
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);
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);
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. */
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
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
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
struct spec
{
- unsigned int directives;
+ size_t directives;
struct format_arg_list *list;
};
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;
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]);
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);
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);
/* 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)
{
/* 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)
{
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. */
/* 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;
&& 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);
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];
static void
normalize_list (struct format_arg_list *list)
{
- unsigned int n, i;
+ size_t n, i;
VERIFY_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++)
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;
{
/* 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);
}
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;
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);
/* 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;
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);
/* 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);
{
/* 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];
}
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];
/* 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--)
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);
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. */
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);
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);
{
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;
{
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;
{
/* 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);
/* 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);
{
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;
{
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;
{
/* 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;
{
/* 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;
/* 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;
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;
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)
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;
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;
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);
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);
*/
/* 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);
{
/* 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;
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);
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);
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--)
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;
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;
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;
{
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);
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;
{
/* 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;
}
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;
}
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;
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;
}
static void
print_list (struct format_arg_list *list)
{
- unsigned int i, j;
+ size_t i, j;
printf ("(");
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;
};
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);
}
{
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;
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
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
/* Shell format strings.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software: you can redistribute it and/or modify
struct spec
{
- unsigned int directives;
- unsigned int named_arg_count;
+ size_t directives;
+ size_t named_arg_count;
struct named_arg *named;
};
{
const char *const format_start = format;
struct spec spec;
- unsigned int named_allocated;
+ size_t named_allocated;
struct spec *result;
spec.directives = 0;
/* 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);
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);
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);
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. */
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
/* 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 <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
struct spec
{
- unsigned int directives;
- unsigned int arg_count;
+ size_t directives;
+ size_t arg_count;
bool args_used[9];
};
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;
{
*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;
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++)
{
{
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;
format_print (void *descr)
{
struct spec *spec = (struct spec *) descr;
- unsigned int i;
+ size_t i;
if (spec == NULL)
{
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;
};
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);
}
{
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;
if (c_isdigit (*format))
{
const char *f = format;
- unsigned int m = 0;
+ size_t m = 0;
do
{
/* 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,
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. */
{
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;
{
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;
{
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;
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)
{
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 (" ");
/* 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).