]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Simplify code: The syntax-check flags are only used inside xgettext.
authorBruno Haible <bruno@clisp.org>
Mon, 30 Jun 2025 11:49:13 +0000 (13:49 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 30 Jun 2025 11:49:13 +0000 (13:49 +0200)
* gettext-tools/src/message.h: Improve comments regarding do_syntax_check.
* gettext-tools/src/msgl-cat.c (catenate_msgdomain_list): Don't manipulate
do_syntax_check field.
* gettext-tools/src/msgmerge.c (message_merge): Likewise.
* gettext-tools/src/read-catalog-special.h (parse_comment_special): Change 'scp'
parameter to a pointer.
* gettext-tools/src/read-catalog-special.c (parse_comment_special): Support a
null 'scp' argument.
* gettext-tools/src/read-catalog.h (DEFAULT_CATALOG_READER_TY): Remove
do_syntax_check field.
* gettext-tools/src/read-catalog.c (default_constructor,
default_copy_comment_state, default_reset_comment_state,
default_comment_special): Don't reference do_syntax_check field.

gettext-tools/src/message.h
gettext-tools/src/msgl-cat.c
gettext-tools/src/msgmerge.c
gettext-tools/src/read-catalog-special.c
gettext-tools/src/read-catalog-special.h
gettext-tools/src/read-catalog.c
gettext-tools/src/read-catalog.h

index ec386f734aced7a4728ad6fc8dd0e30f33752bd1..5790295cd40f10da8dc518137ce7c255f9ea90d0 100644 (file)
@@ -123,7 +123,7 @@ enum is_wrap
 #endif
 
 
-/* Kinds of syntax checks which apply to strings.  */
+/* Kinds of syntax checks which apply to an msgid.  */
 enum syntax_check_type
 {
   sc_ellipsis_unicode,
@@ -208,7 +208,8 @@ struct message_ty
   /* Do we want the string to be wrapped in the emitted PO file?  */
   enum is_wrap do_wrap;
 
-  /* Do we want to apply extra syntax checks on the string?  */
+  /* Do we want to apply or inhibit extra syntax checks on the string?
+     This is only relevant within xgettext.  */
   enum is_syntax_check do_syntax_check[NSYNTAXCHECKS];
 
   /* The prev_msgctxt, prev_msgid and prev_msgid_plural strings appearing
index afa01f6bf7ef2ea253f8e9135adc63d3745632f2..a477285ebadb3d665f4e1ad988d9cf468d490c1b 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list concatenation and duplicate handling.
-   Copyright (C) 2001-2024 Free Software Foundation, Inc.
+   Copyright (C) 2001-2025 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
@@ -322,8 +322,6 @@ catenate_msgdomain_list (string_list_ty *file_list,
                   tmp->range.min = - INT_MAX;
                   tmp->range.max = - INT_MAX;
                   tmp->do_wrap = yes; /* may be set to no later */
-                  for (i = 0; i < NSYNTAXCHECKS; i++)
-                    tmp->do_syntax_check[i] = undecided; /* may be set to yes/no later */
                   tmp->obsolete = true; /* may be set to false later */
                   tmp->alternative_count = 0;
                   tmp->alternative = NULL;
@@ -586,8 +584,6 @@ UTF-8 encoded from the beginning, i.e. already in your source code files.\n"),
                     tmp->is_format[i] = mp->is_format[i];
                   tmp->range = mp->range;
                   tmp->do_wrap = mp->do_wrap;
-                  for (i = 0; i < NSYNTAXCHECKS; i++)
-                    tmp->do_syntax_check[i] = mp->do_syntax_check[i];
                   tmp->prev_msgctxt = mp->prev_msgctxt;
                   tmp->prev_msgid = mp->prev_msgid;
                   tmp->prev_msgid_plural = mp->prev_msgid_plural;
@@ -636,9 +632,6 @@ UTF-8 encoded from the beginning, i.e. already in your source code files.\n"),
                     }
                   if (tmp->do_wrap == undecided)
                     tmp->do_wrap = mp->do_wrap;
-                  for (i = 0; i < NSYNTAXCHECKS; i++)
-                    if (tmp->do_syntax_check[i] == undecided)
-                      tmp->do_syntax_check[i] = mp->do_syntax_check[i];
                   tmp->obsolete = false;
                 }
               else
@@ -691,12 +684,6 @@ UTF-8 encoded from the beginning, i.e. already in your source code files.\n"),
                     }
                   if (mp->do_wrap == no)
                     tmp->do_wrap = no;
-                  for (i = 0; i < NSYNTAXCHECKS; i++)
-                    if (mp->do_syntax_check[i] == yes)
-                      tmp->do_syntax_check[i] = yes;
-                    else if (mp->do_syntax_check[i] == no
-                             && tmp->do_syntax_check[i] == undecided)
-                      tmp->do_syntax_check[i] = no;
                   /* Don't fill tmp->prev_msgid in this case.  */
                   if (!mp->obsolete)
                     tmp->obsolete = false;
index 6e8afce04d2efc607990eca281efe3d4dfc02f76..df4a89ea900eaf67e2266f2cf8245bc779455652 100644 (file)
@@ -1410,12 +1410,6 @@ message_merge (message_ty *def, message_ty *ref, bool force_fuzzy,
 
   result->do_wrap = ref->do_wrap;
 
-  {
-    size_t i;
-    for (i = 0; i < NSYNTAXCHECKS; i++)
-      result->do_syntax_check[i] = ref->do_syntax_check[i];
-  }
-
   /* Insert previous msgid, commented out with "#|".
      Do so only when --previous is specified, for backward compatibility.
      Since the "previous msgid" represents the original msgid that led to
index dc61b0a3f3aa6a152cb2148bee1da1bef97747c3..487d453bb84d930b850ab9aa2a502594ca54f312 100644 (file)
@@ -1,5 +1,5 @@
 /* Parsing of special comments (#, comments) in textual message catalogs.
-   Copyright (C) 1995-2024 Free Software Foundation, Inc.
+   Copyright (C) 1995-2025 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
 
 
 /* Parse a special comment and put the result in *fuzzyp, formatp, *rangep,
-   *wrapp, scp.  */
+   *wrapp, and, if scp != NULL, scp[0..NSYNTAXCHECKS-1].  */
 void
 parse_comment_special (const char *s,
                        bool *fuzzyp, enum is_format formatp[NFORMATS],
                        struct argument_range *rangep, enum is_wrap *wrapp,
-                       enum is_syntax_check scp[NSYNTAXCHECKS])
+                       enum is_syntax_check *scp)
 {
   size_t i;
 
@@ -44,8 +44,11 @@ parse_comment_special (const char *s,
   rangep->min = -1;
   rangep->max = -1;
   *wrapp = undecided;
-  for (i = 0; i < NSYNTAXCHECKS; i++)
-    scp[i] = undecided;
+  if (scp != NULL)
+    {
+      for (i = 0; i < NSYNTAXCHECKS; i++)
+        scp[i] = undecided;
+    }
 
   while (*s != '\0')
     {
@@ -180,7 +183,7 @@ parse_comment_special (const char *s,
             }
 
           /* Accept syntax check description.  */
-          if (len >= 6 && memcmp (t + len - 6, "-check", 6) == 0)
+          if (scp != NULL && len >= 6 && memcmp (t + len - 6, "-check", 6) == 0)
             {
               const char *p;
               size_t n;
index 37778a5972683a2cdf85eec949b87b0c0cd3b2ab..51cb7d71e2322d4ae224e588e4b40b5067e4448d 100644 (file)
@@ -1,5 +1,5 @@
 /* Parsing of special comments (#, comments) in textual message catalogs.
-   Copyright (C) 1995-2024 Free Software Foundation, Inc.
+   Copyright (C) 1995-2025 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -30,12 +30,12 @@ extern "C" {
 
 
 /* Parse a special comment and put the result in *fuzzyp, formatp, *rangep,
-   *wrapp, scp.  */
+   *wrapp, and, if scp != NULL, scp[0..NSYNTAXCHECKS-1].  */
 extern void parse_comment_special (const char *s, bool *fuzzyp,
                                    enum is_format formatp[NFORMATS],
                                    struct argument_range *rangep,
                                    enum is_wrap *wrapp,
-                                   enum is_syntax_check scp[NSYNTAXCHECKS]);
+                                   enum is_syntax_check *scp);
 
 
 #ifdef __cplusplus
index 8364ef67eb719e8789fefd454311059a7a9e32e9..1fd37910d50c581c557b0fe5de6be0f3be91c4d6 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading textual message catalogs (such as PO files).
-   Copyright (C) 1995-2024 Free Software Foundation, Inc.
+   Copyright (C) 1995-2025 Free Software Foundation, Inc.
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
    This program is free software: you can redistribute it and/or modify
@@ -107,8 +107,6 @@ default_constructor (abstract_catalog_reader_ty *catr)
   dcatr->range.min = -1;
   dcatr->range.max = -1;
   dcatr->do_wrap = undecided;
-  for (i = 0; i < NSYNTAXCHECKS; i++)
-    dcatr->do_syntax_check[i] = undecided;
 }
 
 
@@ -176,8 +174,6 @@ default_copy_comment_state (default_catalog_reader_ty *dcatr, message_ty *mp)
     mp->is_format[i] = dcatr->is_format[i];
   mp->range = dcatr->range;
   mp->do_wrap = dcatr->do_wrap;
-  for (i = 0; i < NSYNTAXCHECKS; i++)
-    mp->do_syntax_check[i] = dcatr->do_syntax_check[i];
 }
 
 
@@ -211,8 +207,6 @@ default_reset_comment_state (default_catalog_reader_ty *dcatr)
   dcatr->range.min = -1;
   dcatr->range.max = -1;
   dcatr->do_wrap = undecided;
-  for (i = 0; i < NSYNTAXCHECKS; i++)
-    dcatr->do_syntax_check[i] = undecided;
 }
 
 
@@ -308,7 +302,7 @@ default_comment_special (abstract_catalog_reader_ty *catr, const char *s)
   default_catalog_reader_ty *dcatr = (default_catalog_reader_ty *) catr;
 
   parse_comment_special (s, &dcatr->is_fuzzy, dcatr->is_format, &dcatr->range,
-                         &dcatr->do_wrap, dcatr->do_syntax_check);
+                         &dcatr->do_wrap, NULL);
 }
 
 
index 3b25295f1a68f0b7e7dcca38a87f238857836f96..875b19137b413e89b5c86d0ae3133edbeda27699 100644 (file)
@@ -116,7 +116,6 @@ struct default_catalog_reader_class_ty
   enum is_format is_format[NFORMATS];                                   \
   struct argument_range range;                                          \
   enum is_wrap do_wrap;                                                 \
-  enum is_syntax_check do_syntax_check[NSYNTAXCHECKS];                  \
 
 typedef struct default_catalog_reader_ty default_catalog_reader_ty;
 struct default_catalog_reader_ty