]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgfmt: Fix python-brace-format checking.
authorBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2024 23:49:01 +0000 (00:49 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 31 Dec 2024 23:49:01 +0000 (00:49 +0100)
Reported at <https://savannah.gnu.org/bugs/index.php?48872>.

* gettext-tools/src/format-python-brace.c (format_check): Fix comment. Do the
cmp > 0 check also if equality==false.
* gettext-tools/src/format-python.c (format_check): Fix comment.
* gettext-tools/src/format-ruby.c (format_check): Likewise.
* gettext-tools/src/format-sh.c (format_check): Likewise.

gettext-tools/src/format-python-brace.c
gettext-tools/src/format-python.c
gettext-tools/src/format-ruby.c
gettext-tools/src/format-sh.c

index 692422075779f95a53e814290583b3e7a4be2acd..a0306f61f214e69e6ede4fbe70eb0d58e4b168d4 100644 (file)
@@ -1,5 +1,5 @@
 /* Python brace format strings.
-   Copyright (C) 2004, 2006-2007, 2013-2014, 2016, 2019, 2023 Free Software Foundation, Inc.
+   Copyright (C) 2004-2024 Free Software Foundation, Inc.
    Written by Daiki Ueno <ueno@gnu.org>, 2013.
 
    This program is free software: you can redistribute it and/or modify
@@ -462,8 +462,8 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
       unsigned int n1 = spec1->named_arg_count;
       unsigned int n2 = spec2->named_arg_count;
 
-      /* Check the argument names in spec1 are contained in those of spec2.
-         Both arrays are sorted.  We search for the differences.  */
+      /* Check the argument names in spec2 are contained in those of spec1.
+         Both arrays are sorted.  We search for the first difference.  */
       for (i = 0, j = 0; i < n1 || j < n2; )
         {
           int cmp = (i >= n1 ? 1 :
@@ -472,17 +472,13 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
 
           if (cmp > 0)
             {
-              if (equality)
-                {
-                  if (error_logger)
-                    error_logger (error_logger_data,
-                                  _("a format specification for argument '%s' doesn't exist in '%s'"),
-                                  spec2->named[i].name, pretty_msgid);
-                  err = true;
-                  break;
-                }
-              else
-                j++;
+              if (error_logger)
+                error_logger (error_logger_data,
+                              _("a format specification for argument '%s', as in '%s', doesn't exist in '%s'"),
+                              spec2->named[j].name, pretty_msgstr,
+                              pretty_msgid);
+              err = true;
+              break;
             }
           else if (cmp < 0)
             {
index ebe18d046135bb4abdea82eb67bd3e9a08bc954f..79d118b37b85b1ce18fe9d88a684c315a750535a 100644 (file)
@@ -1,5 +1,5 @@
 /* Python format strings.
-   Copyright (C) 2001-2004, 2006-2009, 2019-2020, 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
@@ -448,7 +448,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
           unsigned int n1 = spec1->named_arg_count;
           unsigned int n2 = spec2->named_arg_count;
 
-          /* Check that the argument names are the same.
+          /* Check the argument names in spec2 are contained in those of spec1.
              Both arrays are sorted.  We search for the first difference.  */
           for (i = 0, j = 0; i < n1 || j < n2; )
             {
index 1648c8d2b694eb606262559609b208f7bdb5e0d7..8fd277c05f1e0a737c9e096287b2a26118eff198 100644 (file)
@@ -1,5 +1,5 @@
 /* Ruby format strings.
-   Copyright (C) 2001-2004, 2006-2009, 2019-2020, 2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2024 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2020.
 
    This program is free software: you can redistribute it and/or modify
@@ -887,7 +887,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
           unsigned int n1 = spec1->named_arg_count;
           unsigned int n2 = spec2->named_arg_count;
 
-          /* Check that the argument names are the same.
+          /* Check the argument names in spec2 are contained in those of spec1.
              Both arrays are sorted.  We search for the first difference.  */
           for (i = 0, j = 0; i < n1 || j < n2; )
             {
index d20f58bc3d397966ed8816177f9b255b68748cc1..ee50b3641d816d4acef115fd867cda642503f219 100644 (file)
@@ -1,5 +1,5 @@
 /* Shell format strings.
-   Copyright (C) 2003-2004, 2006-2007, 2009, 2019-2020, 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
@@ -283,7 +283,7 @@ format_check (void *msgid_descr, void *msgstr_descr, bool equality,
       unsigned int n1 = spec1->named_arg_count;
       unsigned int n2 = spec2->named_arg_count;
 
-      /* Check that the argument names are the same.
+      /* Check the argument names in spec2 are contained in those of spec1.
          Both arrays are sorted.  We search for the first difference.  */
       for (i = 0, j = 0; i < n1 || j < n2; )
         {