]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Simplify code that emits diagnostics with error number.
authorBruno Haible <bruno@clisp.org>
Thu, 5 Oct 2023 21:04:32 +0000 (23:04 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Oct 2023 12:55:58 +0000 (14:55 +0200)
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add xstrerror.
(GNULIB_MODULES_LIBGETTEXTPO_OTHER): Add strerror_r-posix.
* gettext-tools/src/x-csharp.c: Include xstrerror.h.
(phase2_getc): Invoke 'xstrerror' and 'if_error' instead of 'error'.
* gettext-tools/src/x-javascript.c: Include xstrerror.h.
(phase2_getc): Invoke 'xstrerror' and 'if_error' instead of 'error'.
* gettext-tools/src/x-python.c: Include xstrerror.h.
(phase2_getc): Invoke 'xstrerror' and 'if_error' instead of 'error'.

autogen.sh
gettext-tools/src/x-csharp.c
gettext-tools/src/x-javascript.c
gettext-tools/src/x-python.c

index 094fe9756a5b44e252bd799f78b287881594adb2..5db7e7c24bdd4481e3dc7c892c0316ca728aec0b 100755 (executable)
@@ -250,6 +250,7 @@ if ! $skip_gnulib; then
     xmalloca
     xmemdup0
     xsetenv
+    xstrerror
     xstriconv
     xstriconveh
     xvasprintf
@@ -379,19 +380,26 @@ if ! $skip_gnulib; then
     xstriconv
     xvasprintf
   '
-  # Module 'fdopen' is enabled in gettext-tools/config.status, because
-  # it occurs as dependency of some module ('supersede') in
+  # Module 'fdopen' is enabled in gettext-tools/config.status,
+  # because it occurs as dependency of some module ('supersede') in
   # GNULIB_MODULES_TOOLS_FOR_SRC. Therefore on mingw, libgettextpo/stdio.h
   # contains '#define fdopen rpl_fdopen'. Therefore we need to include
   # fdopen.lo in libgettextpo.la.
-  # Module 'realloc-posix' is enabled in gettext-tools/config.status, because
-  # it occurs as dependency of some module ('read-file') in
+  # Module 'realloc-posix' is enabled in gettext-tools/config.status,
+  # because it occurs as dependency of some module ('read-file') in
   # GNULIB_MODULES_TOOLS_FOR_SRC. Therefore on mingw, libgettextpo/stdlib.h
   # contains '#define realloc rpl_realloc'. Therefore we need to include
   # realloc.lo in libgettextpo.la.
+  # Module 'strerror_r-posix' is enabled in gettext-tools/config.status,
+  # because it occurs as dependency of some module ('xstrerror') in
+  # GNULIB_MODULES_TOOLS_FOR_SRC. Therefore gettext-tools/config.h contains
+  # '#define GNULIB_STRERROR_R_POSIX 1'. Therefore on mingw,
+  # libgettextpo/error.o references strerror_r. Therefore we need to include
+  # strerror_r.lo in libgettextpo.la.
   GNULIB_MODULES_LIBGETTEXTPO_OTHER='
     fdopen
     realloc-posix
+    strerror_r-posix
   '
   $GNULIB_TOOL --dir=gettext-tools --source-base=libgettextpo --m4-base=libgettextpo/gnulib-m4 --macro-prefix=gtpo --makefile-name=Makefile.gnulib --libtool --local-dir=gnulib-local --local-symlink \
     --import --avoid=progname $GNULIB_MODULES_LIBGETTEXTPO $GNULIB_MODULES_LIBGETTEXTPO_OTHER || exit $?
index 81552c93a5674b77124b8145b052122237e6f26c..9dd385ca6db29e1e8923ccf66e937fa2773cefb1 100644 (file)
@@ -42,6 +42,7 @@
 #include "c-ctype.h"
 #include "error.h"
 #include "if-error.h"
+#include "xstrerror.h"
 #include "xalloc.h"
 #include "xerror.h"
 #include "xvasprintf.h"
@@ -316,8 +317,9 @@ Please specify the correct source encoding through --from-code.\n"),
                   buf[bufcount++] = (unsigned char) c;
                 }
               else
-                error (EXIT_FAILURE, errno, _("%s:%d: error: iconv failure"),
-                       real_file_name, line_number);
+                if_error (IF_SEVERITY_FATAL_ERROR,
+                          real_file_name, line_number, (size_t)(-1), false,
+                          "%s", xstrerror (_("iconv failure"), errno));
             }
           else
             {
index 644f9db3396b41f1db7a7b79be262c5ba65da3a7..8c6883fc2c4145533e7bcf77edb09d973310986e 100644 (file)
@@ -44,6 +44,7 @@
 #include "xg-message.h"
 #include "error.h"
 #include "if-error.h"
+#include "xstrerror.h"
 #include "progname.h"
 #include "xerror.h"
 #include "xvasprintf.h"
@@ -328,8 +329,9 @@ Please specify the correct source encoding through --from-code\n"),
                   buf[bufcount++] = (unsigned char) c;
                 }
               else
-                error (EXIT_FAILURE, errno, _("%s:%d: error: iconv failure"),
-                       real_file_name, line_number);
+                if_error (IF_SEVERITY_FATAL_ERROR,
+                          real_file_name, line_number, (size_t)(-1), false,
+                          "%s", xstrerror (_("iconv failure"), errno));
             }
           else
             {
index 4946b0b772613b0588a1732d5f9c4c66f4f193e3..38f6f82a5eb00e22f7d6f916c1654155135d1097 100644 (file)
@@ -43,6 +43,7 @@
 #include "xg-message.h"
 #include "error.h"
 #include "if-error.h"
+#include "xstrerror.h"
 #include "progname.h"
 #include "basename-lgpl.h"
 #include "xerror.h"
@@ -355,8 +356,9 @@ comment as specified in https://www.python.org/peps/pep-0263.html.\n"),
                   buf[bufcount++] = (unsigned char) c;
                 }
               else
-                error (EXIT_FAILURE, errno, _("%s:%d: error: iconv failure"),
-                       real_file_name, line_number);
+                if_error (IF_SEVERITY_FATAL_ERROR,
+                          real_file_name, line_number, (size_t)(-1), false,
+                          "%s", xstrerror (_("iconv failure"), errno));
             }
           else
             {