From 038fb35b351ddbe3bbbc28f3a06abdf8209635d7 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Nov 2010 14:46:10 +0100 Subject: [PATCH] format-c.c: Prepare for sharing code with libintlext. --- gettext-tools/src/ChangeLog | 7 +++++++ gettext-tools/src/format-c.c | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 87202d3f5..f3a767d43 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2010-11-07 Bruno Haible + + format-c.c: Prepare for sharing code with libintlext. + * format-c.c (INVALID_ANGLE_BRACKET, INVALID_IGNORED_ARGUMENT): New + macros. + (format_parse): Use them. + 2011-06-07 Bruno Haible Rely more on libtool. diff --git a/gettext-tools/src/format-c.c b/gettext-tools/src/format-c.c index 929e835c0..a9cf5c696 100644 --- a/gettext-tools/src/format-c.c +++ b/gettext-tools/src/format-c.c @@ -180,6 +180,12 @@ numbered_arg_compare (const void *p1, const void *p2) #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) +#define INVALID_ANGLE_BRACKET(directive_number) \ + xasprintf (_("In the directive number %u, the token after '<' is not followed by '>'."), 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) + static void * format_parse (const char *format, bool translated, bool objc_extensions, char *fdi, char **invalid_reason) @@ -584,8 +590,7 @@ format_parse (const char *format, bool translated, bool objc_extensions, if (*format != '>') { - *invalid_reason = - xasprintf (_("In the directive number %u, the token after '<' is not followed by '>'."), spec.directives); + *invalid_reason = INVALID_ANGLE_BRACKET (spec.directives); FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); goto bad_format; } @@ -810,8 +815,7 @@ format_parse (const char *format, bool translated, bool objc_extensions, 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); + *invalid_reason = INVALID_IGNORED_ARGUMENT (numbered[i].number, i + 1); goto bad_format; } -- 2.47.2