* gnulib-local/lib/xerror.h: Include <stddef.h>.
(multiline_warning, multiline_error): Change return type to size_t. Don't
suggest to pass a NULL prefix.
(multiline_append): New declaration.
* gnulib-local/lib/xerror.c (multiline_internal): New function, extracted from
multiline_warning.
(multiline_warning, multiline_error): Reject a NULL prefix. Call
multiline_internal.
(multiline_append): New function.
* gettext-tools/src/msgl-charset.c (compare_po_locale_charsets): Invoke
multiline_append instead of multiline_warning with NULL argument.
* gettext-tools/src/msgfmt.c (msgfmt_parse_debrief): Invoke multiline_append
instead of multiline_error with NULL argument.
* gettext-tools/src/po-error.c (void_multiline_warning, void_multiline_error):
New functions.
(po_multiline_warning, po_multiline_error): Use them as initializer.
* gettext-tools/libgettextpo/gettext-po.c (void_multiline_warning,
void_multiline_error): New functions.
(po_file_read_v2, po_file_write): Use them as defaults for po_multiline_warning,
po_multiline_error.
int libgettextpo_version = LIBGETTEXTPO_VERSION;
+static void
+void_multiline_warning (char *prefix, char *message)
+{
+ multiline_warning (prefix, message);
+}
+
+static void
+void_multiline_error (char *prefix, char *message)
+{
+ multiline_error (prefix, message);
+}
+
+
/* Create an empty PO file representation in memory. */
po_file_t
/* Restore error handler. */
po_error = orig_error;
po_error_at_line = orig_error_at_line;
- po_multiline_warning = multiline_warning;
- po_multiline_error = multiline_error;
+ po_multiline_warning = void_multiline_warning;
+ po_multiline_error = void_multiline_error;
gram_max_allowed_errors = 20;
if (fp != stdin)
/* Restore error handler. */
po_error = orig_error;
po_error_at_line = orig_error_at_line;
- po_multiline_warning = multiline_warning;
- po_multiline_error = multiline_error;
+ po_multiline_warning = void_multiline_warning;
+ po_multiline_error = void_multiline_error;
return file;
}
{
if (!this->has_header_entry)
{
- multiline_error (xasprintf ("%s: ", this->file_name),
- xasprintf (_("warning: PO file header missing or invalid\n")));
- multiline_error (NULL,
- xasprintf (_("warning: charset conversion will not work\n")));
+ size_t prefix_width =
+ multiline_error (xasprintf ("%s: ", this->file_name),
+ xasprintf (_("warning: PO file header missing or invalid\n")));
+ multiline_append (prefix_width,
+ xasprintf (_("warning: charset conversion will not work\n")));
}
}
}
/* Message list charset and locale charset handling.
- Copyright (C) 2001-2003, 2005-2007, 2009, 2019-2020 Free Software Foundation, Inc.
+ Copyright (C) 2001-2023 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
freea (charset);
if (canon_locale_code != canon_charset)
{
- multiline_warning (xasprintf (_("warning: ")),
- xasprintf (_("\
+ size_t prefix_width =
+ multiline_warning (xasprintf (_("warning: ")),
+ xasprintf (_("\
Locale charset \"%s\" is different from\n\
input file charset \"%s\".\n\
Output of '%s' might be incorrect.\n\
Possible workarounds are:\n\
"), locale_code, canon_charset, last_component (program_name)));
- multiline_warning (NULL,
- xasprintf (_("\
+ multiline_append (prefix_width,
+ xasprintf (_("\
- Set LC_ALL to a locale with encoding %s.\n\
"), canon_charset));
if (canon_locale_code != NULL)
- multiline_warning (NULL,
- xasprintf (_("\
+ multiline_append (prefix_width,
+ xasprintf (_("\
- Convert the translation catalog to %s using 'msgconv',\n\
then apply '%s',\n\
then convert back to %s using 'msgconv'.\n\
if (strcmp (canon_charset, "UTF-8") != 0
&& (canon_locale_code == NULL
|| strcmp (canon_locale_code, "UTF-8") != 0))
- multiline_warning (NULL,
- xasprintf (_("\
+ multiline_append (prefix_width,
+ xasprintf (_("\
- Set LC_ALL to a locale with encoding %s,\n\
convert the translation catalog to %s using 'msgconv',\n\
then apply '%s',\n\
const char *format, ...)
= error_at_line;
+static void
+void_multiline_warning (char *prefix, char *message)
+{
+ multiline_warning (prefix, message);
+}
+
+static void
+void_multiline_error (char *prefix, char *message)
+{
+ multiline_error (prefix, message);
+}
+
void (*po_multiline_warning) (char *prefix, char *message)
- = multiline_warning;
+ = void_multiline_warning;
void (*po_multiline_error) (char *prefix, char *message)
- = multiline_error;
+ = void_multiline_error;
#endif
/* Emit a multiline warning to stderr, consisting of MESSAGE, with the
- first line prefixed with PREFIX and the remaining lines prefixed with
- the same amount of spaces. Reuse the spaces of the previous call if
- PREFIX is NULL. Free the PREFIX and MESSAGE when done. */
-void
-multiline_warning (char *prefix, char *message)
+ first line prefixed with PREFIX or, if that is NULL, with PREFIX_WIDTH
+ spaces, and the remaining lines prefixed with the same amount of spaces.
+ Free the PREFIX and MESSAGE when done. Return the amount of spaces. */
+static size_t
+multiline_internal (char *prefix, size_t prefix_width, char *message)
{
- static int width;
+ size_t width;
const char *cp;
- int i;
fflush (stdout);
free (prefix);
goto after_indent;
}
+ else
+ width = prefix_width;
for (;;)
{
const char *np;
- for (i = width; i > 0; i--)
- putc (' ', stderr);
+ {
+ size_t i;
+
+ for (i = width; i > 0; i--)
+ putc (' ', stderr);
+ }
after_indent:
np = strchr (cp, '\n');
}
free (message);
+
+ return width;
}
-/* Emit a multiline error to stderr, consisting of MESSAGE, with the
- first line prefixed with PREFIX and the remaining lines prefixed with
- the same amount of spaces. Reuse the spaces of the previous call if
- PREFIX is NULL. Free the PREFIX and MESSAGE when done. */
-void
+size_t
+multiline_warning (char *prefix, char *message)
+{
+ if (prefix == NULL)
+ /* Invalid argument. */
+ abort ();
+ return multiline_internal (prefix, 0, message);
+}
+
+size_t
multiline_error (char *prefix, char *message)
{
- if (prefix != NULL)
- ++error_message_count;
- multiline_warning (prefix, message);
+ if (prefix == NULL)
+ /* Invalid argument. */
+ abort ();
+ ++error_message_count;
+ return multiline_internal (prefix, 0, message);
+}
+
+void
+multiline_append (size_t prefix_width, char *message)
+{
+ multiline_internal (NULL, prefix_width, message);
}
/* Multiline error-reporting functions.
- Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2006, 2023 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
#ifndef _XERROR_H
#define _XERROR_H
+#include <stddef.h>
#ifdef __cplusplus
extern "C" {
/* Emit a multiline warning to stderr, consisting of MESSAGE, with the
first line prefixed with PREFIX and the remaining lines prefixed with
- the same amount of spaces. Reuse the spaces of the previous call if
- PREFIX is NULL. Free the PREFIX and MESSAGE when done. */
-extern void multiline_warning (char *prefix, char *message);
+ the same amount of spaces. Free the PREFIX and MESSAGE when done.
+ Return the width of PREFIX, for later uses of multiline_append. */
+extern size_t multiline_warning (char *prefix, char *message);
/* Emit a multiline error to stderr, consisting of MESSAGE, with the
first line prefixed with PREFIX and the remaining lines prefixed with
- the same amount of spaces. Reuse the spaces of the previous call if
- PREFIX is NULL. Free the PREFIX and MESSAGE when done. */
-extern void multiline_error (char *prefix, char *message);
+ the same amount of spaces. Free the PREFIX and MESSAGE when done.
+ Return the width of PREFIX, for later uses of multiline_append. */
+extern size_t multiline_error (char *prefix, char *message);
+
+/* Following a call to multiline_warning or multiline_error, append another
+ MESSAGE, with each line prefixed with PREFIX_WIDTH spaces.
+ Free the MESSAGE when done. */
+extern void multiline_append (size_t prefix_width, char *message);
#ifdef __cplusplus