]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add an xerror_handler parameter to msgdomain_list_print.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Aug 2024 09:40:26 +0000 (11:40 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Aug 2024 23:03:39 +0000 (01:03 +0200)
* gettext-tools/src/write-catalog.h: Include xerror-handler.h.
(struct catalog_output_format): Add xerror_handler_ty parameter to the print
method.
(msgdomain_list_print): Add xerror_handler_ty parameter.
* gettext-tools/src/write-catalog.c: Include xerror-handler.h instead of
po-xerror.h.
(msgdomain_list_print): Add xerror_handler_ty parameter. Use it for error
handling.
* gettext-tools/src/write-po.c: Include xerror-handler.h instead of po-xerror.h.
(wrap, message_print, message_print_obsolete, msgdomain_list_print_po): Add
xerror_handler_ty parameter. Use it for error handling.
* gettext-tools/src/write-properties.c: Include xerror-handler.h.
(write_properties, msgdomain_list_print_properties): Add xerror_handler_ty
parameter. Use it for error handling.
* gettext-tools/src/write-stringtable.c: Include xerror-handler.h.
(write_stringtable, msgdomain_list_print_stringtable): Add xerror_handler_ty
parameter. Use it for error handling.
* gettext-tools/libgettextpo/gettext-po.c (po_file_write): Pass a
stack-allocated xerror_handler to msgdomain_list_print.
* gettext-tools/src/msgl-iconv.h: Include xerror-handler.h.
(iconv_message_list, iconv_msgdomain_list): Add xerror_handler_ty parameter.
* gettext-tools/src/msgl-iconv.c: Include xerror-handler.h instead of
po-xerror.h.
(conversion_error, convert_string, convert_string_list, convert_prev_msgid,
convert_msgid, convert_msgstr, iconv_message_list_internal, iconv_message_list,
iconv_msgdomain_list): Add xerror_handler_ty parameter. Use it for error
handling.
(convert_string_directly, convert_string_desc_directly): Use the default
xerror_handler.
* gettext-tools/src/msgattrib.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgcat.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgcmp.c: Include xerror-handler.h.
(compare): Use the default xerror_handler.
* gettext-tools/src/msgcomm.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgconv.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgen.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgfilter.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgfmt.c: Include xerror-handler.h.
(msgfmt_operand_list_add_from_directory): Use the default xerror_handler.
* gettext-tools/src/msggrep.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msginit.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msgl-cat.c: Include xerror-handler.h.
(catenate_msgdomain_list): Use the default xerror_handler.
* gettext-tools/src/msgmerge.c: Include xerror-handler.h.
(main, merge): Use the default xerror_handler.
* gettext-tools/src/msgunfmt.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/msguniq.c: Include xerror-handler.h.
(main): Use the default xerror_handler.
* gettext-tools/src/write-csharp.c: Include xerror-handler.h.
(msgdomain_write_csharp): Use the default xerror_handler.
* gettext-tools/src/write-desktop.c: Include xerror-handler.h.
(msgdomain_write_desktop): Use the default xerror_handler.
* gettext-tools/src/write-java.c: Include xerror-handler.h.
(msgdomain_write_java): Use the default xerror_handler.
* gettext-tools/src/write-mo.c: Include xerror-handler.h.
(msgdomain_write_mo): Use the default xerror_handler.
* gettext-tools/src/write-qt.c: Include xerror-handler.h.
(msgdomain_write_qt): Use the default xerror_handler.
* gettext-tools/src/write-resources.c: Include xerror-handler.h.
(msgdomain_write_csharp_resources): Use the default xerror_handler.
* gettext-tools/src/write-tcl.c: Include xerror-handler.h.
(msgdomain_write_tcl): Use the default xerror_handler.
* gettext-tools/src/write-xml.c: Include xerror-handler.h.
(msgdomain_write_xml): Use the default xerror_handler.
* gettext-tools/src/x-po.c (extract): Use the default xerror_handler.
* gettext-tools/src/xgettext.c: Include xerror-handler.h.
(main, finalize_header): Use the default xerror_handler.

32 files changed:
gettext-tools/libgettextpo/gettext-po.c
gettext-tools/src/msgattrib.c
gettext-tools/src/msgcat.c
gettext-tools/src/msgcmp.c
gettext-tools/src/msgcomm.c
gettext-tools/src/msgconv.c
gettext-tools/src/msgen.c
gettext-tools/src/msgfilter.c
gettext-tools/src/msgfmt.c
gettext-tools/src/msggrep.c
gettext-tools/src/msginit.c
gettext-tools/src/msgl-cat.c
gettext-tools/src/msgl-iconv.c
gettext-tools/src/msgl-iconv.h
gettext-tools/src/msgmerge.c
gettext-tools/src/msgunfmt.c
gettext-tools/src/msguniq.c
gettext-tools/src/write-catalog.c
gettext-tools/src/write-catalog.h
gettext-tools/src/write-csharp.c
gettext-tools/src/write-desktop.c
gettext-tools/src/write-java.c
gettext-tools/src/write-mo.c
gettext-tools/src/write-po.c
gettext-tools/src/write-properties.c
gettext-tools/src/write-qt.c
gettext-tools/src/write-resources.c
gettext-tools/src/write-stringtable.c
gettext-tools/src/write-tcl.c
gettext-tools/src/write-xml.c
gettext-tools/src/x-po.c
gettext-tools/src/xgettext.c

index 4cf51709d44b5761e7e5a64c4e83696509634ae3..43cea113630f99f97d1254e727e04c2bd591334d 100644 (file)
@@ -139,19 +139,19 @@ po_file_read (const char *filename, po_xerror_handler_t handler)
 po_file_t
 po_file_write (po_file_t file, const char *filename, po_xerror_handler_t handler)
 {
-  /* Establish error handler around msgdomain_list_print().  */
-  po_xerror =
-    (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *))
-    handler->xerror;
-  po_xerror2 =
-    (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *, const message_ty *, const char *, size_t, size_t, int, const char *))
-    handler->xerror2;
-
-  msgdomain_list_print (file->mdlp, filename, &output_format_po, true, false);
+  /* Establish error handler for msgdomain_list_print().  */
+  unsigned int error_count = 0;
+  struct xerror_handler local_xerror_handler =
+    {
+      (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *))
+      handler->xerror,
+      (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *, const message_ty *, const char *, size_t, size_t, int, const char *))
+      handler->xerror2,
+      &error_count
+    };
 
-  /* Restore error handler.  */
-  po_xerror  = textmode_xerror;
-  po_xerror2 = textmode_xerror2;
+  msgdomain_list_print (file->mdlp, filename, &output_format_po,
+                        &local_xerror_handler, true, false);
 
   return file;
 }
index 88ea68de1c8ce9545e418806f9228bced70444c4..67407807ad89be47eb15b7f375795d70a6c0d0a7 100644 (file)
@@ -45,6 +45,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "propername.h"
 #include "xalloc.h"
 #include "gettext.h"
@@ -400,7 +401,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 6554b8ce17fee92df6f16aea72be7fd346ce51cb..2fb6ad35675bd3db604b0bee9f4b527da8a9234a 100644 (file)
@@ -47,6 +47,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "msgl-cat.h"
 #include "msgl-header.h"
 #include "propername.h"
@@ -346,7 +347,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_set_header_field (result, "Language:", catalogname);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (error_message_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
 }
index 2d55ca33be67ba19d76fc58ef98c9f145c5cb1ff..2b744397b8572338227d9db3063fd3b0828c37c1 100644 (file)
@@ -42,6 +42,7 @@
 #include "read-stringtable.h"
 #include "xmalloca.h"
 #include "po-xerror.h"
+#include "xerror-handler.h"
 #include "xvasprintf.h"
 #include "po-charset.h"
 #include "msgl-iconv.h"
@@ -435,7 +436,8 @@ compare (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax)
             }
         }
     if (was_utf8)
-      def = iconv_msgdomain_list (def, po_charset_utf8, true, fn1);
+      def = iconv_msgdomain_list (def, po_charset_utf8, true, fn1,
+                                  textmode_xerror_handler);
   }
 
   /* Determine canonicalized encoding name of the definitions now, after
index 44287ad32b3b57a30ff0dba106c03235b7ad0d70..a740a661b699c4c5ec7becb2b6308b27493ea61f 100644 (file)
@@ -47,6 +47,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "msgl-cat.h"
 #include "propername.h"
 #include "gettext.h"
@@ -338,7 +339,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (error_message_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
 }
index fd1075e707d4edbfca339e4ade0977550a3d8e41..a5a6787940d32fa3680a9174215ea9e351489bf7 100644 (file)
@@ -46,6 +46,7 @@
 #include "write-properties.h"
 #include "write-stringtable.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "localcharset.h"
 #include "propername.h"
 #include "gettext.h"
@@ -277,7 +278,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
 
   /* Convert if and only if the output syntax supports different encodings.  */
   if (!output_syntax->requires_utf8)
-    result = iconv_msgdomain_list (result, to_code, true, input_file);
+    result = iconv_msgdomain_list (result, to_code, true, input_file,
+                                   textmode_xerror_handler);
 
   /* Sort the results.  */
   if (sort_by_filepos)
@@ -286,7 +288,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 6d975f1c8a8b7afb712812688abf9456a88ce68c..c635b8f950b87d075abd4ea7dc8ed3a0420a201c 100644 (file)
@@ -47,6 +47,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "propername.h"
 #include "gettext.h"
 
@@ -283,7 +284,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_set_header_field (result, "Language:", catalogname);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 151ff8d14441ea7ee42e74a46ddfe1e3ecf07539..174498154e15f56e498466c9891f0155b08771f9 100644 (file)
@@ -57,6 +57,7 @@
 #include "xsetenv.h"
 #include "filters.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "po-charset.h"
 #include "propername.h"
 #include "gettext.h"
@@ -351,21 +352,24 @@ There is NO WARRANTY, to the extent permitted by law.\n\
       filter = serbian_to_latin;
 
       /* Convert the input to UTF-8 first.  */
-      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file);
+      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file,
+                                     textmode_xerror_handler);
     }
   else if (strcmp (sub_name, "quot") == 0 && sub_argc == 1)
     {
       filter = ascii_quote_to_unicode;
 
       /* Convert the input to UTF-8 first.  */
-      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file);
+      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file,
+                                     textmode_xerror_handler);
     }
   else if (strcmp (sub_name, "boldquot") == 0 && sub_argc == 1)
     {
       filter = ascii_quote_to_unicode_bold;
 
       /* Convert the input to UTF-8 first.  */
-      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file);
+      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file,
+                                     textmode_xerror_handler);
     }
   else
     {
@@ -393,7 +397,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index eeeb13851529815844420e1051b4c761fb12482f..d1a275ec6086842ea195fb54af189bc905ca46b5 100644 (file)
@@ -62,6 +62,7 @@
 #include "read-stringtable.h"
 #include "read-desktop.h"
 #include "po-xerror.h"
+#include "xerror-handler.h"
 #include "po-charset.h"
 #include "msgl-check.h"
 #include "msgl-iconv.h"
@@ -1621,7 +1622,8 @@ msgfmt_operand_list_add_from_directory (msgfmt_operand_list_ty *operands,
         }
 
       /* Convert the messages to Unicode.  */
-      iconv_message_list (mlp, NULL, po_charset_utf8, NULL);
+      iconv_message_list (mlp, NULL, po_charset_utf8, NULL,
+                          textmode_xerror_handler);
 
       msgfmt_operand_list_append (operands, language, mlp);
     }
index 4082863169802bebdda12ba3a608edd8bb3391f8..7d773a4b8a91d923593a5d766fa9bc86e614af09 100644 (file)
@@ -56,6 +56,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "str-list.h"
 #include "msgl-charset.h"
 #include "xalloc.h"
@@ -481,7 +482,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 9cf0d997c2b7d457a6ff11c2801491437463a203..1258fecc601d376f7a1b3022bbb9a0be476f5870 100644 (file)
@@ -63,6 +63,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "po-charset.h"
 #include "localcharset.h"
 #include "localename.h"
@@ -378,7 +379,8 @@ the output .po file through the --output-file option.\n"),
     result = update_msgstr_plurals (result);
 
   /* Write the modified message list out.  */
-  msgdomain_list_print (result, output_file, output_syntax, true, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, true, false);
 
   if (!no_translator)
     fprintf (stderr, "\n");
index a3bba5f53cad21fd6f0df7b2dae50e9311d4ec90..afa01f6bf7ef2ea253f8e9135adc63d3745632f2 100644 (file)
@@ -40,6 +40,7 @@
 #include "msgl-ofn.h"
 #include "msgl-equal.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "xalloc.h"
 #include "xmalloca.h"
 #include "c-strstr.h"
@@ -532,7 +533,7 @@ Converting the output to %s.\n\
             if (!(to_code == NULL && canon_charsets[n][k] == canon_to_code))
               if (iconv_message_list (mdlp->item[k]->messages,
                                       canon_charsets[n][k], canon_to_code,
-                                      files[n]))
+                                      files[n], textmode_xerror_handler))
                 {
                   multiline_error (xstrdup (""),
                                    xasprintf (_("\
index 33b1aa88a289fe7c41df2c69f71370b4d0406897..05b09676d1625f6a66e86bd9ee865a99d3422879 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list charset and locale charset handling.
-   Copyright (C) 2001-2003, 2005-2009, 2019-2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2024 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
@@ -46,7 +46,7 @@
 #include "xmalloca.h"
 #include "c-strstr.h"
 #include "xvasprintf.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
 
 #if HAVE_ICONV
 
-_GL_NORETURN_FUNC static void conversion_error (const struct conversion_context* context);
+_GL_NORETURN_FUNC static void
+conversion_error (const struct conversion_context* context,
+                  xerror_handler_ty xeh);
 static void
-conversion_error (const struct conversion_context* context)
+conversion_error (const struct conversion_context* context,
+                  xerror_handler_ty xeh)
 {
   if (context->to_code == po_charset_utf8)
     /* If a conversion to UTF-8 fails, the problem lies in the input.  */
-    po_xerror (PO_SEVERITY_FATAL_ERROR, context->message, NULL, 0, 0, false,
-               xasprintf (_("%s: input is not valid in \"%s\" encoding"),
-                          context->from_filename, context->from_code));
+    xeh->xerror (CAT_SEVERITY_FATAL_ERROR, context->message, NULL, 0, 0, false,
+                 xasprintf (_("%s: input is not valid in \"%s\" encoding"),
+                            context->from_filename, context->from_code));
   else
-    po_xerror (PO_SEVERITY_FATAL_ERROR, context->message, NULL, 0, 0, false,
-               xasprintf (_("%s: error while converting from \"%s\" encoding to \"%s\" encoding"),
-                          context->from_filename, context->from_code,
-                          context->to_code));
+    xeh->xerror (CAT_SEVERITY_FATAL_ERROR, context->message, NULL, 0, 0, false,
+                 xasprintf (_("%s: error while converting from \"%s\" encoding to \"%s\" encoding"),
+                            context->from_filename, context->from_code,
+                            context->to_code));
   /* NOTREACHED */
   abort ();
 }
@@ -86,7 +89,7 @@ convert_string_directly (iconv_t cd, const char *string,
         && strlen (result) == resultlen - 1)
       return result;
 
-  conversion_error (context);
+  conversion_error (context, textmode_xerror_handler);
   /* NOTREACHED */
   return NULL;
 }
@@ -102,14 +105,15 @@ convert_string_desc_directly (iconv_t cd, string_desc_t string,
                      cd, &result, &resultlen) == 0)
     return string_desc_new_addr (resultlen, result);
 
-  conversion_error (context);
+  conversion_error (context, textmode_xerror_handler);
   /* NOTREACHED */
   return string_desc_new_empty ();
 }
 
 static char *
 convert_string (const iconveh_t *cd, const char *string,
-                const struct conversion_context* context)
+                const struct conversion_context* context,
+                xerror_handler_ty xeh)
 {
   size_t len = strlen (string) + 1;
   char *result = NULL;
@@ -122,48 +126,53 @@ convert_string (const iconveh_t *cd, const char *string,
         && strlen (result) == resultlen - 1)
       return result;
 
-  conversion_error (context);
+  conversion_error (context, xeh);
   /* NOTREACHED */
   return NULL;
 }
 
 static void
 convert_string_list (const iconveh_t *cd, string_list_ty *slp,
-                     const struct conversion_context* context)
+                     const struct conversion_context* context,
+                     xerror_handler_ty xeh)
 {
   size_t i;
 
   if (slp != NULL)
     for (i = 0; i < slp->nitems; i++)
-      slp->item[i] = convert_string (cd, slp->item[i], context);
+      slp->item[i] = convert_string (cd, slp->item[i], context, xeh);
 }
 
 static void
 convert_prev_msgid (const iconveh_t *cd, message_ty *mp,
-                    const struct conversion_context* context)
+                    const struct conversion_context* context,
+                    xerror_handler_ty xeh)
 {
   if (mp->prev_msgctxt != NULL)
-    mp->prev_msgctxt = convert_string (cd, mp->prev_msgctxt, context);
+    mp->prev_msgctxt = convert_string (cd, mp->prev_msgctxt, context, xeh);
   if (mp->prev_msgid != NULL)
-    mp->prev_msgid = convert_string (cd, mp->prev_msgid, context);
+    mp->prev_msgid = convert_string (cd, mp->prev_msgid, context, xeh);
   if (mp->prev_msgid_plural != NULL)
-    mp->prev_msgid_plural = convert_string (cd, mp->prev_msgid_plural, context);
+    mp->prev_msgid_plural =
+      convert_string (cd, mp->prev_msgid_plural, context, xeh);
 }
 
 static void
 convert_msgid (const iconveh_t *cd, message_ty *mp,
-               const struct conversion_context* context)
+               const struct conversion_context* context,
+               xerror_handler_ty xeh)
 {
   if (mp->msgctxt != NULL)
-    mp->msgctxt = convert_string (cd, mp->msgctxt, context);
-  mp->msgid = convert_string (cd, mp->msgid, context);
+    mp->msgctxt = convert_string (cd, mp->msgctxt, context, xeh);
+  mp->msgid = convert_string (cd, mp->msgid, context, xeh);
   if (mp->msgid_plural != NULL)
-    mp->msgid_plural = convert_string (cd, mp->msgid_plural, context);
+    mp->msgid_plural = convert_string (cd, mp->msgid_plural, context, xeh);
 }
 
 static void
 convert_msgstr (const iconveh_t *cd, message_ty *mp,
-                const struct conversion_context* context)
+                const struct conversion_context* context,
+                xerror_handler_ty xeh)
 {
   char *result = NULL;
   size_t resultlen = 0;
@@ -197,7 +206,7 @@ convert_msgstr (const iconveh_t *cd, message_ty *mp,
           }
       }
 
-  conversion_error (context);
+  conversion_error (context, xeh);
 }
 
 #endif
@@ -208,7 +217,8 @@ iconv_message_list_internal (message_list_ty *mlp,
                              const char *canon_from_code,
                              const char *canon_to_code,
                              bool update_header,
-                             const char *from_filename)
+                             const char *from_filename,
+                             xerror_handler_ty xeh)
 {
   bool canon_from_code_overridden = (canon_from_code != NULL);
   bool msgids_changed;
@@ -260,10 +270,10 @@ iconv_message_list_internal (message_list_ty *mlp,
                                 || is_ascii_message_list (mlp)))
                           canon_charset = po_charset_ascii;
                         else
-                          po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0,
-                                     false,
-                                     xasprintf (_("present charset \"%s\" is not a portable encoding name"),
-                                                charset));
+                          xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0,
+                                       false,
+                                       xasprintf (_("present charset \"%s\" is not a portable encoding name"),
+                                                  charset));
                       }
                   }
                 else
@@ -271,10 +281,10 @@ iconv_message_list_internal (message_list_ty *mlp,
                     if (canon_from_code == NULL)
                       canon_from_code = canon_charset;
                     else if (canon_from_code != canon_charset)
-                      po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0,  0,
-                                 false,
-                                 xasprintf (_("two different charsets \"%s\" and \"%s\" in input file"),
-                                            canon_from_code, canon_charset));
+                      xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0,  0,
+                                   false,
+                                   xasprintf (_("two different charsets \"%s\" and \"%s\" in input file"),
+                                              canon_from_code, canon_charset));
                   }
                 freea (charset);
 
@@ -302,8 +312,8 @@ iconv_message_list_internal (message_list_ty *mlp,
       if (is_ascii_message_list (mlp))
         canon_from_code = po_charset_ascii;
       else
-        po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                   _("input file doesn't contain a header entry with a charset specification"));
+        xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                     _("input file doesn't contain a header entry with a charset specification"));
     }
 
   msgids_changed = false;
@@ -316,10 +326,10 @@ iconv_message_list_internal (message_list_ty *mlp,
       struct conversion_context context;
 
       if (iconveh_open (canon_to_code, canon_from_code, &cd) < 0)
-        po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                   xasprintf (_("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(), and iconv() does not support this conversion."),
-                              canon_from_code, canon_to_code,
-                              last_component (program_name)));
+        xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                     xasprintf (_("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(), and iconv() does not support this conversion."),
+                                canon_from_code, canon_to_code,
+                                last_component (program_name)));
 
       context.from_code = canon_from_code;
       context.to_code = canon_to_code;
@@ -333,25 +343,25 @@ iconv_message_list_internal (message_list_ty *mlp,
               || !is_ascii_string (mp->msgid))
             msgids_changed = true;
           context.message = mp;
-          convert_string_list (&cd, mp->comment, &context);
-          convert_string_list (&cd, mp->comment_dot, &context);
-          convert_prev_msgid (&cd, mp, &context);
-          convert_msgid (&cd, mp, &context);
-          convert_msgstr (&cd, mp, &context);
+          convert_string_list (&cd, mp->comment, &context, xeh);
+          convert_string_list (&cd, mp->comment_dot, &context, xeh);
+          convert_prev_msgid (&cd, mp, &context, xeh);
+          convert_msgid (&cd, mp, &context, xeh);
+          convert_msgstr (&cd, mp, &context, xeh);
         }
 
       iconveh_close (&cd);
 
       if (msgids_changed)
         if (message_list_msgids_changed (mlp))
-          po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                     xasprintf (_("Conversion from \"%s\" to \"%s\" introduces duplicates: some different msgids become equal."),
-                                canon_from_code, canon_to_code));
+          xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                       xasprintf (_("Conversion from \"%s\" to \"%s\" introduces duplicates: some different msgids become equal."),
+                                  canon_from_code, canon_to_code));
 #else
-          po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                     xasprintf (_("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(). This version was built without iconv()."),
-                                canon_from_code, canon_to_code,
-                                last_component (program_name)));
+          xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                       xasprintf (_("Cannot convert from \"%s\" to \"%s\". %s relies on iconv(). This version was built without iconv()."),
+                                  canon_from_code, canon_to_code,
+                                  last_component (program_name)));
 #endif
     }
 
@@ -361,18 +371,19 @@ iconv_message_list_internal (message_list_ty *mlp,
 bool
 iconv_message_list (message_list_ty *mlp,
                     const char *canon_from_code, const char *canon_to_code,
-                    const char *from_filename)
+                    const char *from_filename, xerror_handler_ty xeh)
 {
   return iconv_message_list_internal (mlp,
                                       canon_from_code, canon_to_code, true,
-                                      from_filename);
+                                      from_filename, xeh);
 }
 
 msgdomain_list_ty *
 iconv_msgdomain_list (msgdomain_list_ty *mdlp,
                       const char *to_code,
                       bool update_header,
-                      const char *from_filename)
+                      const char *from_filename,
+                      xerror_handler_ty xeh)
 {
   const char *canon_to_code;
   size_t k;
@@ -380,23 +391,23 @@ iconv_msgdomain_list (msgdomain_list_ty *mdlp,
   /* Canonicalize target encoding.  */
   canon_to_code = po_charset_canonicalize (to_code);
   if (canon_to_code == NULL)
-    po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-               xasprintf (_("target charset \"%s\" is not a portable encoding name."),
-                          to_code));
+    xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                 xasprintf (_("target charset \"%s\" is not a portable encoding name."),
+                            to_code));
 
   /* Test whether the control characters required for escaping file names with
      spaces are present in the target encoding.  */
   if (msgdomain_list_has_filenames_with_spaces (mdlp)
       && !(canon_to_code == po_charset_utf8
            || strcmp (canon_to_code, "GB18030") == 0))
-    po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-               xasprintf (_("Cannot write the control characters that protect file names with spaces in the %s encoding"),
-                          canon_to_code));
+    xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                 xasprintf (_("Cannot write the control characters that protect file names with spaces in the %s encoding"),
+                            canon_to_code));
 
   for (k = 0; k < mdlp->nitems; k++)
     iconv_message_list_internal (mdlp->item[k]->messages,
                                  mdlp->encoding, canon_to_code, update_header,
-                                 from_filename);
+                                 from_filename, xeh);
 
   mdlp->encoding = canon_to_code;
   return mdlp;
index 13bed10be0fbceb06c648a51a2190fdc82a2211c..955b05779e34144864b966216e676133192fd6ba 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list character set conversion.
-   Copyright (C) 2001-2003, 2005-2006, 2009, 2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2024 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
@@ -26,6 +26,7 @@
 #include "string-desc.h"
 
 #include "message.h"
+#include "xerror-handler.h"
 
 
 #ifdef __cplusplus
@@ -63,7 +64,8 @@ extern bool
        iconv_message_list (message_list_ty *mlp,
                            const char *canon_from_code,
                            const char *canon_to_code,
-                           const char *from_filename);
+                           const char *from_filename,
+                           xerror_handler_ty xerror_handler);
 
 /* Converts all the message lists in MDLP to the encoding TO_CODE.
    UPDATE_HEADER specifies whether to update the "charset=..." specification
@@ -72,7 +74,8 @@ extern msgdomain_list_ty *
        iconv_msgdomain_list (msgdomain_list_ty *mdlp,
                              const char *to_code,
                              bool update_header,
-                             const char *from_filename);
+                             const char *from_filename,
+                             xerror_handler_ty xerror_handler);
 
 /* Tests whether the message list MLP could be converted to CANON_TO_CODE.
    The (already canonicalized) encoding before conversion can be passed as
index 1782bef8bc385bea45fb4e73a9d4171a020c2eb0..481b3ae87c1a8c60b2bfcfef83b346015ebad11b 100644 (file)
@@ -67,6 +67,7 @@
 #include "plural-count.h"
 #include "msgl-check.h"
 #include "po-xerror.h"
+#include "xerror-handler.h"
 #include "xvasprintf.h"
 #include "backupfile.h"
 #include "copy-file.h"
@@ -517,14 +518,15 @@ There is NO WARRANTY, to the extent permitted by law.\n\
             }
 
           /* Write the merged message list out.  */
-          msgdomain_list_print (result, output_file, output_syntax, true,
-                                false);
+          msgdomain_list_print (result, output_file, output_syntax,
+                                textmode_xerror_handler, true, false);
         }
     }
   else
     {
       /* Write the merged message list out.  */
       msgdomain_list_print (result, output_file, output_syntax,
+                            textmode_xerror_handler,
                             for_msgfmt || force_po, false);
     }
 
@@ -1827,11 +1829,13 @@ merge (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax,
         }
     if (was_utf8)
       {
-        def = iconv_msgdomain_list (def, po_charset_utf8, true, fn1);
+        def = iconv_msgdomain_list (def, po_charset_utf8, true, fn1,
+                                    textmode_xerror_handler);
         if (compendiums != NULL)
           for (k = 0; k < compendiums->nitems; k++)
             iconv_message_list (compendiums->item[k], NULL, po_charset_utf8,
-                                compendium_filenames->item[k]);
+                                compendium_filenames->item[k],
+                                textmode_xerror_handler);
       }
     else if (compendiums != NULL && compendiums->nitems > 0)
       {
@@ -1898,7 +1902,8 @@ merge (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax,
                         for (k = 0; k < compendiums->nitems; k++)
                           iconv_message_list (compendiums->item[k],
                                               NULL, canon_charset,
-                                              compendium_filenames->item[k]);
+                                              compendium_filenames->item[k],
+                                              textmode_xerror_handler);
                       conversion_done = true;
                     }
                 }
@@ -1971,12 +1976,14 @@ merge (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax,
               {
                 /* It's too hairy to find out what would be the optimal target
                    encoding.  So, convert everything to UTF-8.  */
-                def = iconv_msgdomain_list (def, po_charset_utf8, true, fn1);
+                def = iconv_msgdomain_list (def, po_charset_utf8, true, fn1,
+                                            textmode_xerror_handler);
                 if (compendiums != NULL)
                   for (k = 0; k < compendiums->nitems; k++)
                     iconv_message_list (compendiums->item[k],
                                         NULL, po_charset_utf8,
-                                        compendium_filenames->item[k]);
+                                        compendium_filenames->item[k],
+                                        textmode_xerror_handler);
               }
           }
       }
index 80955b375770ec58c9ec88daf38d4d1a0704cbab..4d8a9511d04385eb29734cf8145baee9dffc8ab4 100644 (file)
@@ -46,6 +46,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "propername.h"
 #include "gettext.h"
 
@@ -405,7 +406,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the resulting message list to the given .po file.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   /* No problems.  */
   exit (EXIT_SUCCESS);
index cbb067c20f703ef21e0594efa02d028aaa286974..692af237edb031f8248fc26a8ed3ffc794489ca2 100644 (file)
@@ -46,6 +46,7 @@
 #include "write-po.h"
 #include "write-properties.h"
 #include "write-stringtable.h"
+#include "xerror-handler.h"
 #include "msgl-cat.h"
 #include "propername.h"
 #include "gettext.h"
@@ -305,7 +306,8 @@ There is NO WARRANTY, to the extent permitted by law.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax,
+                        textmode_xerror_handler, force_po, false);
 
   exit (error_message_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
 }
index c25916d1b403dc57257b85771c256bf833448f58..b17f6a3e5045cc13acdbe86d80cefeed41396c68 100644 (file)
@@ -1,6 +1,5 @@
 /* GNU gettext - internationalization aids
-   Copyright (C) 1995-1998, 2000-2008, 2012, 2019-2020 Free Software
-   Foundation, Inc.
+   Copyright (C) 1995-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -39,7 +38,7 @@
 #include "fwriteerror.h"
 #include "error-progname.h"
 #include "xvasprintf.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
 #include "gettext.h"
 
 /* Our regular abbreviation.  */
@@ -90,6 +89,7 @@ message_page_width_set (size_t n)
 void
 msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
                       catalog_output_format_ty output_syntax,
+                      xerror_handler_ty xeh,
                       bool force, bool debug)
 {
   bool to_stdout;
@@ -121,11 +121,11 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
   if (!output_syntax->supports_multiple_domains && mdlp->nitems > 1)
     {
       if (output_syntax->alternative_is_po)
-        po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                   _("Cannot output multiple translation domains into a single file with the specified output format. Try using PO file syntax instead."));
+        xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                     _("Cannot output multiple translation domains into a single file with the specified output format. Try using PO file syntax instead."));
       else
-        po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                   _("Cannot output multiple translation domains into a single file with the specified output format."));
+        xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                     _("Cannot output multiple translation domains into a single file with the specified output format."));
     }
   else
     {
@@ -155,10 +155,10 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
           if (has_context != NULL)
             {
               error_with_progname = false;
-              po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
-                         has_context->file_name, has_context->line_number,
-                         (size_t)(-1), false,
-                         _("message catalog has context dependent translations, but the output format does not support them."));
+              xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL,
+                           has_context->file_name, has_context->line_number,
+                           (size_t)(-1), false,
+                           _("message catalog has context dependent translations, but the output format does not support them."));
               error_with_progname = true;
             }
         }
@@ -190,15 +190,15 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
             {
               error_with_progname = false;
               if (output_syntax->alternative_is_java_class)
-                po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
-                           has_plural->file_name, has_plural->line_number,
-                           (size_t)(-1), false,
-                           _("message catalog has plural form translations, but the output format does not support them. Try generating a Java class using \"msgfmt --java\", instead of a properties file."));
+                xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL,
+                             has_plural->file_name, has_plural->line_number,
+                             (size_t)(-1), false,
+                             _("message catalog has plural form translations, but the output format does not support them. Try generating a Java class using \"msgfmt --java\", instead of a properties file."));
               else
-                po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
-                           has_plural->file_name, has_plural->line_number,
-                           (size_t)(-1), false,
-                           _("message catalog has plural form translations, but the output format does not support them."));
+                xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL,
+                             has_plural->file_name, has_plural->line_number,
+                             (size_t)(-1), false,
+                             _("message catalog has plural form translations, but the output format does not support them."));
               error_with_progname = true;
             }
         }
@@ -226,11 +226,11 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
           if (fd < 0)
             {
               const char *errno_description = strerror (errno);
-              po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                         xasprintf ("%s: %s",
-                                    xasprintf (_("cannot create output file \"%s\""),
-                                               filename),
-                                    errno_description));
+              xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                           xasprintf ("%s: %s",
+                                      xasprintf (_("cannot create output file \"%s\""),
+                                                 filename),
+                                      errno_description));
             }
         }
       else
@@ -244,18 +244,18 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
                           "po-default.css");
       stream =
         styled_ostream_create (fd, filename, TTYCTL_AUTO, style_file_name);
-      output_syntax->print (mdlp, stream, page_width, debug);
+      output_syntax->print (mdlp, stream, page_width, xeh, debug);
       ostream_free (stream);
 
       /* Make sure nothing went wrong.  */
       if (close (fd) < 0)
         {
           const char *errno_description = strerror (errno);
-          po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                     xasprintf ("%s: %s",
-                                xasprintf (_("error while writing \"%s\" file"),
-                                           filename),
-                                errno_description));
+          xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                       xasprintf ("%s: %s",
+                                  xasprintf (_("error while writing \"%s\" file"),
+                                             filename),
+                                  errno_description));
         }
     }
   else
@@ -271,11 +271,11 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
           if (fp == NULL)
             {
               const char *errno_description = strerror (errno);
-              po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                         xasprintf ("%s: %s",
-                                    xasprintf (_("cannot create output file \"%s\""),
-                                               filename),
-                                    errno_description));
+              xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                           xasprintf ("%s: %s",
+                                      xasprintf (_("cannot create output file \"%s\""),
+                                                 filename),
+                                      errno_description));
             }
         }
       else
@@ -295,14 +295,15 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
           if (mdlp->encoding != po_charset_utf8)
             {
               mdlp = msgdomain_list_copy (mdlp, 0);
-              mdlp = iconv_msgdomain_list (mdlp, po_charset_utf8, false, NULL);
+              mdlp = iconv_msgdomain_list (mdlp, po_charset_utf8, false, NULL,
+                                           xeh);
             }
 
           style_file_prepare ("PO_STYLE",
                               "GETTEXTSTYLESDIR", relocate (GETTEXTSTYLESDIR),
                               "po-default.css");
           html_stream = html_styled_ostream_create (stream, style_file_name);
-          output_syntax->print (mdlp, html_stream, page_width, debug);
+          output_syntax->print (mdlp, html_stream, page_width, xeh, debug);
           ostream_free (html_stream);
         }
       else
@@ -310,11 +311,11 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
           noop_styled_ostream_t styled_stream;
 
           styled_stream = noop_styled_ostream_create (stream, false);
-          output_syntax->print (mdlp, styled_stream, page_width, debug);
+          output_syntax->print (mdlp, styled_stream, page_width, xeh, debug);
           ostream_free (styled_stream);
         }
 #else
-      output_syntax->print (mdlp, stream, page_width, debug);
+      output_syntax->print (mdlp, stream, page_width, xeh, debug);
       /* Don't call ostream_free if file_ostream_create is a dummy.  */
       if (stream != fp)
 #endif
@@ -324,11 +325,11 @@ msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
       if (fwriteerror (fp))
         {
           const char *errno_description = strerror (errno);
-          po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                     xasprintf ("%s: %s",
-                                xasprintf (_("error while writing \"%s\" file"),
-                                           filename),
-                                errno_description));
+          xeh->xerror (CAT_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
+                       xasprintf ("%s: %s",
+                                  xasprintf (_("error while writing \"%s\" file"),
+                                             filename),
+                                  errno_description));
         }
     }
 }
index d9bbece344b4c8760d8d7a5529164b6219af1829..9b3137188839152232045332d7bb3b336c9e73b6 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU gettext - internationalization aids
-   Copyright (C) 1995-1998, 2000-2003, 2006, 2008, 2019, 2021 Free Software Foundation, Inc.
+   Copyright (C) 1995-2024 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 #include <textstyle.h>
 
 #include "message.h"
+#include "xerror-handler.h"
 
 
 #ifdef __cplusplus
@@ -33,7 +34,8 @@ extern "C" {
 struct catalog_output_format
 {
   /* Outputs a list of domains of messages to a stream.  */
-  void (*print) (msgdomain_list_ty *mdlp, ostream_t stream, size_t page_width, bool debug);
+  void (*print) (msgdomain_list_ty *mdlp, ostream_t stream, size_t page_width,
+                 xerror_handler_ty xerror_handler, bool debug);
 
   /* Whether the print function requires the MDLP to be encoded in UTF-8
      encoding.  */
@@ -79,6 +81,7 @@ extern void
        msgdomain_list_print (msgdomain_list_ty *mdlp,
                              const char *filename,
                              catalog_output_format_ty output_syntax,
+                             xerror_handler_ty xerror_handler,
                              bool force, bool debug);
 
 /* Sort MDLP destructively according to the given criterion.  */
index c6415a6aee43bd4be3c4efc20b888e9277681fa5..dac983d8f20306562631d137549e41712c22ff23 100644 (file)
@@ -79,6 +79,7 @@
 #include "message.h"
 #include "msgfmt.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "plural-exp.h"
 #include "po-charset.h"
@@ -645,7 +646,8 @@ msgdomain_write_csharp (message_list_ty *mlp, const char *canon_encoding,
   retval = 1;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                      textmode_xerror_handler);
 
   /* Support for "reproducible builds": Delete information that may vary
      between builds in the same conditions.  */
index e63b8f516756f2e6dd9d476814823a261067494d..0c8f02eca3bc443d64414e654fb967f5559bac89 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <error.h>
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "po-charset.h"
 #include "read-catalog.h"
@@ -203,7 +204,8 @@ msgdomain_write_desktop (message_list_ty *mlp,
   msgfmt_operand_list_ty operands;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                      textmode_xerror_handler);
 
   /* Support for "reproducible builds": Delete information that may vary
      between builds in the same conditions.  */
index 8fca624069918ddbf486ace9dd71ff7056944c9c..02b0add95a9d9b9becd7868c7d715019873b1f02 100644 (file)
@@ -63,6 +63,7 @@
 #include "message.h"
 #include "msgfmt.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "plural-exp.h"
 #include "po-charset.h"
@@ -1067,7 +1068,8 @@ msgdomain_write_java (message_list_ty *mlp, const char *canon_encoding,
   retval = 1;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                      textmode_xerror_handler);
 
   /* Support for "reproducible builds": Delete information that may vary
      between builds in the same conditions.  */
index c345fce9c73c9e82967e48b400b5264f33e0ed8f..73e6a9ea761b34bdff59d9e949ed1410e855c020 100644 (file)
@@ -47,6 +47,7 @@
 #include "xmalloca.h"
 #include "po-charset.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "binary-io.h"
 #include "supersede.h"
@@ -1195,7 +1196,8 @@ msgdomain_write_mo (message_list_ty *mlp,
              It is also helpful for performance on glibc systems, since most
              locales nowadays have UTF-8 as locale encoding, whereas some PO
              files still are encoded in EUC-JP or so.  */
-          iconv_message_list (mlp, NULL, po_charset_utf8, input_file);
+          iconv_message_list (mlp, NULL, po_charset_utf8, input_file,
+                              textmode_xerror_handler);
         }
 
       /* Support for "reproducible builds": Delete information that may vary
index 1c03b2932f5a15828a5db62ea9c82de5db0d5fdb..eeb190a0ed0b7b908f797fb5343b8c5849629055 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU gettext - internationalization aids
-   Copyright (C) 1995-1998, 2000-2010, 2012, 2014-2015, 2018-2021, 2023 Free Software Foundation, Inc.
+   Copyright (C) 1995-2024 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -49,7 +49,7 @@
 #include "c-strstr.h"
 #include "xvasprintf.h"
 #include "verify.h"
-#include "po-xerror.h"
+#include "xerror-handler.h"
 #include "gettext.h"
 
 /* Our regular abbreviation.  */
@@ -654,7 +654,7 @@ wrap (const message_ty *mp, ostream_t stream,
       const char *line_prefix, int extra_indent, const char *css_class,
       const char *name, const char *value,
       enum is_wrap do_wrap, size_t page_width,
-      const char *charset)
+      const char *charset, xerror_handler_ty xeh)
 {
   const char *canon_charset;
   char *fmtdir;
@@ -845,8 +845,9 @@ wrap (const message_ty *mp, ostream_t stream,
                     {
                       if (errno == EILSEQ)
                         {
-                          po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
-                                     _("invalid multibyte sequence"));
+                          xeh->xerror (CAT_SEVERITY_ERROR, mp, NULL, 0, 0,
+                                       false,
+                                       _("invalid multibyte sequence"));
                           continue;
                         }
                       else if (errno == EINVAL)
@@ -854,8 +855,9 @@ wrap (const message_ty *mp, ostream_t stream,
                           /* This could happen if an incomplete
                              multibyte sequence at the end of input
                              bytes.  */
-                          po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
-                                     _("incomplete multibyte sequence"));
+                          xeh->xerror (CAT_SEVERITY_ERROR, mp, NULL, 0, 0,
+                                       false,
+                                       _("incomplete multibyte sequence"));
                           continue;
                         }
                       else
@@ -920,8 +922,8 @@ wrap (const message_ty *mp, ostream_t stream,
                   char *error_message =
                     xasprintf (_("internationalized messages should not contain the '\\%c' escape sequence"),
                                c);
-                  po_xerror (PO_SEVERITY_WARNING, mp, NULL, 0, 0, false,
-                             error_message);
+                  xeh->xerror (CAT_SEVERITY_WARNING, mp, NULL, 0, 0, false,
+                               error_message);
                   free (error_message);
                 }
             }
@@ -982,8 +984,8 @@ wrap (const message_ty *mp, ostream_t stream,
                     {
                       if (errno == EILSEQ)
                         {
-                          po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0,
-                                     false, _("invalid multibyte sequence"));
+                          xeh->xerror (CAT_SEVERITY_ERROR, mp, NULL, 0, 0,
+                                       false, _("invalid multibyte sequence"));
                           continue;
                         }
                       else
@@ -1304,7 +1306,7 @@ print_blank_line (ostream_t stream)
 static void
 message_print (const message_ty *mp, ostream_t stream,
                const char *charset, size_t page_width, bool blank_line,
-               bool debug)
+               xerror_handler_ty xeh, bool debug)
 {
   int extra_indent;
 
@@ -1346,13 +1348,13 @@ message_print (const message_ty *mp, ostream_t stream,
   begin_css_class (stream, class_previous_comment);
   if (mp->prev_msgctxt != NULL)
     wrap (mp, stream, "#| ", 0, class_previous, "msgctxt", mp->prev_msgctxt,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   if (mp->prev_msgid != NULL)
     wrap (mp, stream, "#| ", 0, class_previous, "msgid", mp->prev_msgid,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   if (mp->prev_msgid_plural != NULL)
     wrap (mp, stream, "#| ", 0, class_previous, "msgid_plural",
-          mp->prev_msgid_plural, mp->do_wrap, page_width, charset);
+          mp->prev_msgid_plural, mp->do_wrap, page_width, charset, xeh);
   end_css_class (stream, class_previous_comment);
   extra_indent = (mp->prev_msgctxt != NULL || mp->prev_msgid != NULL
                   || mp->prev_msgid_plural != NULL
@@ -1373,7 +1375,7 @@ The following msgctxt contains non-ASCII characters.\n\
 This will cause problems to translators who use a character encoding\n\
 different from yours. Consider using a pure ASCII msgctxt instead.\n\
 %s\n"), mp->msgctxt);
-      po_xerror (PO_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
+      xeh->xerror (CAT_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
       free (warning_message);
     }
   if (!is_ascii_string (mp->msgid)
@@ -1385,21 +1387,21 @@ The following msgid contains non-ASCII characters.\n\
 This will cause problems to translators who use a character encoding\n\
 different from yours. Consider using a pure ASCII msgid instead.\n\
 %s\n"), mp->msgid);
-      po_xerror (PO_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
+      xeh->xerror (CAT_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
       free (warning_message);
     }
   if (mp->msgctxt != NULL)
     wrap (mp, stream, NULL, extra_indent, class_msgid, "msgctxt", mp->msgctxt,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   wrap (mp, stream, NULL, extra_indent, class_msgid, "msgid", mp->msgid,
-        mp->do_wrap, page_width, charset);
+        mp->do_wrap, page_width, charset, xeh);
   if (mp->msgid_plural != NULL)
     wrap (mp, stream, NULL, extra_indent, class_msgid, "msgid_plural",
-          mp->msgid_plural, mp->do_wrap, page_width, charset);
+          mp->msgid_plural, mp->do_wrap, page_width, charset, xeh);
 
   if (mp->msgid_plural == NULL)
     wrap (mp, stream, NULL, extra_indent, class_msgstr, "msgstr", mp->msgstr,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   else
     {
       char prefix_buf[20];
@@ -1412,7 +1414,7 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
         {
           sprintf (prefix_buf, "msgstr[%u]", i);
           wrap (mp, stream, NULL, extra_indent, class_msgstr, prefix_buf, p,
-                mp->do_wrap, page_width, charset);
+                mp->do_wrap, page_width, charset, xeh);
         }
     }
 
@@ -1430,7 +1432,7 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
 static void
 message_print_obsolete (const message_ty *mp, ostream_t stream,
                         const char *charset, size_t page_width, bool blank_line,
-                        bool debug)
+                        xerror_handler_ty xeh, bool debug)
 {
   int extra_indent;
 
@@ -1517,13 +1519,13 @@ message_print_obsolete (const message_ty *mp, ostream_t stream,
   begin_css_class (stream, class_previous_comment);
   if (mp->prev_msgctxt != NULL)
     wrap (mp, stream, "#~| ", 0, class_previous, "msgctxt", mp->prev_msgctxt,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   if (mp->prev_msgid != NULL)
     wrap (mp, stream, "#~| ", 0, class_previous, "msgid", mp->prev_msgid,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   if (mp->prev_msgid_plural != NULL)
     wrap (mp, stream, "#~| ", 0, class_previous, "msgid_plural",
-          mp->prev_msgid_plural, mp->do_wrap, page_width, charset);
+          mp->prev_msgid_plural, mp->do_wrap, page_width, charset, xeh);
   end_css_class (stream, class_previous_comment);
   extra_indent = (mp->prev_msgctxt != NULL || mp->prev_msgid != NULL
                   || mp->prev_msgid_plural != NULL
@@ -1543,7 +1545,7 @@ The following msgctxt contains non-ASCII characters.\n\
 This will cause problems to translators who use a character encoding\n\
 different from yours. Consider using a pure ASCII msgctxt instead.\n\
 %s\n"), mp->msgctxt);
-      po_xerror (PO_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
+      xeh->xerror (CAT_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
       free (warning_message);
     }
   if (!is_ascii_string (mp->msgid)
@@ -1555,21 +1557,21 @@ The following msgid contains non-ASCII characters.\n\
 This will cause problems to translators who use a character encoding\n\
 different from yours. Consider using a pure ASCII msgid instead.\n\
 %s\n"), mp->msgid);
-      po_xerror (PO_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
+      xeh->xerror (CAT_SEVERITY_WARNING, mp, NULL, 0, 0, true, warning_message);
       free (warning_message);
     }
   if (mp->msgctxt != NULL)
     wrap (mp, stream, "#~ ", extra_indent, class_msgid, "msgctxt", mp->msgctxt,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   wrap (mp, stream, "#~ ", extra_indent, class_msgid, "msgid", mp->msgid,
-        mp->do_wrap, page_width, charset);
+        mp->do_wrap, page_width, charset, xeh);
   if (mp->msgid_plural != NULL)
     wrap (mp, stream, "#~ ", extra_indent, class_msgid, "msgid_plural",
-          mp->msgid_plural, mp->do_wrap, page_width, charset);
+          mp->msgid_plural, mp->do_wrap, page_width, charset, xeh);
 
   if (mp->msgid_plural == NULL)
     wrap (mp, stream, "#~ ", extra_indent, class_msgstr, "msgstr", mp->msgstr,
-          mp->do_wrap, page_width, charset);
+          mp->do_wrap, page_width, charset, xeh);
   else
     {
       char prefix_buf[20];
@@ -1582,7 +1584,7 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
         {
           sprintf (prefix_buf, "msgstr[%u]", i);
           wrap (mp, stream, "#~ ", extra_indent, class_msgstr, prefix_buf, p,
-                mp->do_wrap, page_width, charset);
+                mp->do_wrap, page_width, charset, xeh);
         }
     }
 
@@ -1592,7 +1594,7 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
 
 static void
 msgdomain_list_print_po (msgdomain_list_ty *mdlp, ostream_t stream,
-                         size_t page_width, bool debug)
+                         size_t page_width, xerror_handler_ty xeh, bool debug)
 {
   size_t j, k;
   bool blank_line;
@@ -1668,7 +1670,7 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, ostream_t stream,
         if (!mlp->item[j]->obsolete)
           {
             message_print (mlp->item[j], stream, charset, page_width,
-                           blank_line, debug);
+                           blank_line, xeh, debug);
             blank_line = true;
           }
 
@@ -1677,7 +1679,7 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, ostream_t stream,
         if (mlp->item[j]->obsolete)
           {
             message_print_obsolete (mlp->item[j], stream, charset, page_width,
-                                    blank_line, debug);
+                                    blank_line, xeh, debug);
             blank_line = true;
           }
 
index 706a388ba3f6a30976d824553552f16ab53846d5..43eb40fc21ed8abbdf6a74039eee4ca3c0db6cd3 100644 (file)
@@ -35,6 +35,7 @@
 #include "msgl-ascii.h"
 #include "msgl-iconv.h"
 #include "po-charset.h"
+#include "xerror-handler.h"
 #include "unistr.h"
 #include "write-po.h"
 #include "xalloc.h"
@@ -241,13 +242,14 @@ write_message (ostream_t stream, const message_ty *mp,
 /* Writes an entire message list to the stream.  */
 static void
 write_properties (ostream_t stream, message_list_ty *mlp,
-                  const char *canon_encoding, size_t page_width, bool debug)
+                  const char *canon_encoding, size_t page_width,
+                  xerror_handler_ty xeh, bool debug)
 {
   bool blank_line;
   size_t j, i;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL, xeh);
   for (j = 0; j < mlp->nitems; ++j)
     {
       message_ty *mp = mlp->item[j];
@@ -281,7 +283,8 @@ write_properties (ostream_t stream, message_list_ty *mlp,
 /* Output the contents of a PO file in Java .properties syntax.  */
 static void
 msgdomain_list_print_properties (msgdomain_list_ty *mdlp, ostream_t stream,
-                                 size_t page_width, bool debug)
+                                 size_t page_width, xerror_handler_ty xeh,
+                                 bool debug)
 {
   message_list_ty *mlp;
 
@@ -289,7 +292,7 @@ msgdomain_list_print_properties (msgdomain_list_ty *mdlp, ostream_t stream,
     mlp = mdlp->item[0]->messages;
   else
     mlp = message_list_alloc (false);
-  write_properties (stream, mlp, mdlp->encoding, page_width, debug);
+  write_properties (stream, mlp, mdlp->encoding, page_width, xeh, debug);
 }
 
 /* Describes a PO file in Java .properties syntax.  */
index 6b603b90a1a0fd1929dedd5c50e47f0ab4c004f4..5326c3fbee845a1f4443c551ac4714eac08a5d54 100644 (file)
@@ -35,6 +35,7 @@
 #include "message.h"
 #include "po-charset.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "hash-string.h"
 #include "unistr.h"
@@ -674,7 +675,8 @@ but the Qt message catalog format doesn't support plural handling\n")));
       }
 
       /* Convert the messages to Unicode.  */
-      iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+      iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                          textmode_xerror_handler);
 
       /* Determine whether mlp has non-ISO-8859-1 msgctxt entries.  */
       {
index a6fc2b423cd59f56f4f2b38785dc91ece46eb7a5..40aca4ec835b0d38073e6ad78af164a00c5ba8c6 100644 (file)
@@ -37,6 +37,7 @@
 #include "message.h"
 #include "msgfmt.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "po-charset.h"
 #include "xalloc.h"
@@ -156,7 +157,8 @@ but the C# .resources format doesn't support plural handling\n")));
       }
 
       /* Convert the messages to Unicode.  */
-      iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+      iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                          textmode_xerror_handler);
 
       /* Support for "reproducible builds": Delete information that may vary
          between builds in the same conditions.  */
index a86c9d9a78d4264dc739a3176a471a1950ada7a7..cfe59da6b1235204f3713c2b8442dd204cd3aa7a 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing NeXTstep/GNUstep .strings files.
-   Copyright (C) 2003-2023 Free Software Foundation, Inc.
+   Copyright (C) 2003-2024 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -32,6 +32,7 @@
 #include "msgl-ascii.h"
 #include "msgl-iconv.h"
 #include "po-charset.h"
+#include "xerror-handler.h"
 #include "c-strstr.h"
 #include "xvasprintf.h"
 #include "write-po.h"
@@ -279,13 +280,14 @@ write_message (ostream_t stream, const message_ty *mp,
 /* Writes an entire message list to the stream.  */
 static void
 write_stringtable (ostream_t stream, message_list_ty *mlp,
-                   const char *canon_encoding, size_t page_width, bool debug)
+                   const char *canon_encoding, size_t page_width,
+                   xerror_handler_ty xeh, bool debug)
 {
   bool blank_line;
   size_t j;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL, xeh);
 
   /* Output the BOM.  */
   if (!is_ascii_message_list (mlp))
@@ -312,7 +314,8 @@ write_stringtable (ostream_t stream, message_list_ty *mlp,
 /* Output the contents of a PO file in .strings syntax.  */
 static void
 msgdomain_list_print_stringtable (msgdomain_list_ty *mdlp, ostream_t stream,
-                                  size_t page_width, bool debug)
+                                  size_t page_width, xerror_handler_ty xeh,
+                                  bool debug)
 {
   message_list_ty *mlp;
 
@@ -320,7 +323,7 @@ msgdomain_list_print_stringtable (msgdomain_list_ty *mdlp, ostream_t stream,
     mlp = mdlp->item[0]->messages;
   else
     mlp = message_list_alloc (false);
-  write_stringtable (stream, mlp, mdlp->encoding, page_width, debug);
+  write_stringtable (stream, mlp, mdlp->encoding, page_width, xeh, debug);
 }
 
 /* Describes a PO file in .strings syntax.  */
index d5c039c09afcbe74d34c6170f68643ea290bdd16..581317976b7d02b17aa5f1b7174cd915d0a14a97 100644 (file)
@@ -33,6 +33,7 @@
 #include "xerror.h"
 #include "message.h"
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "po-charset.h"
 #include "xalloc.h"
@@ -183,7 +184,8 @@ but the Tcl message catalog format doesn't support plural handling\n")));
   }
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                      textmode_xerror_handler);
 
   /* Support for "reproducible builds": Delete information that may vary
      between builds in the same conditions.  */
index ae5f7c59a5e53644a828d2a9ae2dbaf4fbc49dfa..6c94d7cad9b7ef2bdfbe811f7bc1a0edf976753a 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <error.h>
 #include "msgl-iconv.h"
+#include "xerror-handler.h"
 #include "msgl-header.h"
 #include "po-charset.h"
 #include "read-catalog.h"
@@ -93,7 +94,8 @@ msgdomain_write_xml (message_list_ty *mlp,
   msgfmt_operand_list_ty operands;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
+  iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL,
+                      textmode_xerror_handler);
 
   /* Support for "reproducible builds": Delete information that may vary
      between builds in the same conditions.  */
index 8c610c3e0fe64fa9fc9654d6f4a6451787394681..7ddc052fea87b3d71ea4c166aa4b8bad604c6188 100644 (file)
@@ -212,7 +212,8 @@ extract (FILE *fp,
               /* Convert the messages to UTF-8.
                  finalize_header() expects this.  */
               message_list_ty *mlp = mdlp->item[0]->messages;
-              iconv_message_list (mlp, NULL, po_charset_utf8, logical_filename);
+              iconv_message_list (mlp, NULL, po_charset_utf8, logical_filename,
+                                  textmode_xerror_handler);
             }
         }
 
index aff0398336d3f8b4915400240c6a0a45e3857501..5ae03e69e67db6f52f62173b000f66f8531b01fd 100644 (file)
@@ -74,6 +74,7 @@
 #include "message.h"
 #include "pos.h"
 #include "po-xerror.h"
+#include "xerror-handler.h"
 #include "po-charset.h"
 #include "msgl-iconv.h"
 #include "msgl-ascii.h"
@@ -849,7 +850,8 @@ xgettext cannot work without keywords to look for"));
 
       extract_from_file (file_name, po_extractor, mdlp);
       if (!is_ascii_msgdomain_list (mdlp))
-        mdlp = iconv_msgdomain_list (mdlp, po_charset_utf8, true, file_name);
+        mdlp = iconv_msgdomain_list (mdlp, po_charset_utf8, true, file_name,
+                                     textmode_xerror_handler);
 
       dir_list_restore (saved_directory_list);
     }
@@ -1038,7 +1040,8 @@ xgettext cannot work without keywords to look for"));
   }
 
   /* Write the PO file.  */
-  msgdomain_list_print (mdlp, file_name, output_syntax, force_po, do_debug);
+  msgdomain_list_print (mdlp, file_name, output_syntax, textmode_xerror_handler,
+                        force_po, do_debug);
 
   if (its_locating_rules)
     locating_rule_list_free (its_locating_rules);
@@ -2191,7 +2194,8 @@ finalize_header (msgdomain_list_ty *mdlp)
       {
         message_list_ty *mlp = mdlp->item[0]->messages;
 
-        iconv_message_list (mlp, po_charset_utf8, po_charset_utf8, NULL);
+        iconv_message_list (mlp, po_charset_utf8, po_charset_utf8, NULL,
+                            textmode_xerror_handler);
       }
   }
 }