]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
libgettextpo: Fix compilation error on Android.
authorBruno Haible <bruno@clisp.org>
Sat, 16 Sep 2023 15:49:23 +0000 (17:49 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Sep 2023 02:11:21 +0000 (04:11 +0200)
* gettext-tools/libgettextpo/gettext-po.c: Include error.h second.
(orig_error, orig_error_at_line): New variables.
(error, error_at_line): Undefine afterwards.
(po_file_read_v2, po_file_write, po_error_logger, po_message_check_format): Use
these variables instead of the error, error_at_line symbols.

gettext-tools/libgettextpo/gettext-po.c

index 3588fdb4b2c14a4b5f5cfb34324598aaa3315705..6f0b001c32cd4610b4ae9aa0fd165579cbfa7580 100644 (file)
 /* Avoid side effect of gnulib's error.h on 'struct po_error_handler'.  */
 #define _GL_NO_INLINE_ERROR
 
+/* Avoid side effect of config.h on 'struct po_error_handler'.  */
+#include "error.h"
+static void (*orig_error) (int status, int errnum,
+                           const char *format, ...)
+  = error;
+
+static void (*orig_error_at_line) (int status, int errnum,
+                                   const char *filename, unsigned int lineno,
+                                   const char *format, ...)
+  = error_at_line;
+#undef error
+#undef error_at_line
+
 /* Specification.  */
 #include "gettext-po.h"
 
@@ -37,7 +50,6 @@
 #include "read-po.h"
 #include "write-catalog.h"
 #include "write-po.h"
-#include "error.h"
 #include "xerror.h"
 #include "po-error.h"
 #include "po-xerror.h"
@@ -174,8 +186,8 @@ po_file_read_v2 (const char *filename, po_error_handler_t handler)
   file->domains = NULL;
 
   /* Restore error handler.  */
-  po_error             = error;
-  po_error_at_line     = error_at_line;
+  po_error             = orig_error;
+  po_error_at_line     = orig_error_at_line;
   po_multiline_warning = multiline_warning;
   po_multiline_error   = multiline_error;
   gram_max_allowed_errors = 20;
@@ -260,8 +272,8 @@ po_file_write (po_file_t file, const char *filename, po_error_handler_t handler)
   msgdomain_list_print (file->mdlp, filename, &output_format_po, true, false);
 
   /* Restore error handler.  */
-  po_error             = error;
-  po_error_at_line     = error_at_line;
+  po_error             = orig_error;
+  po_error_at_line     = orig_error_at_line;
   po_multiline_warning = multiline_warning;
   po_multiline_error   = multiline_error;
 
@@ -1325,7 +1337,7 @@ po_error_logger (const char *format, ...)
 
   va_start (args, format);
   if (vasprintf (&error_message, format, args) < 0)
-    error (EXIT_FAILURE, 0, _("memory exhausted"));
+    orig_error (EXIT_FAILURE, 0, _("memory exhausted"));
   va_end (args);
   po_error (0, 0, "%s", error_message);
   free (error_message);
@@ -1350,5 +1362,5 @@ po_message_check_format (po_message_t message, po_error_handler_t handler)
                              mp->is_format, mp->range, NULL, po_error_logger);
 
   /* Restore error handler.  */
-  po_error = error;
+  po_error = orig_error;
 }