]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Simplify calling convention of arglist_parser_remember.
authorBruno Haible <bruno@clisp.org>
Sun, 4 Nov 2018 23:02:54 +0000 (00:02 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Nov 2018 23:25:34 +0000 (00:25 +0100)
* gettext-tools/src/xg-arglist-parser.h (struct partial_call): Add
'msgid_comment_is_utf8' field.
(arglist_parser_remember): Add comment_is_utf8 argument.
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_alloc,
arglist_parser_clone): Update.
(arglist_parser_remember): Add comment_is_utf8 argument.
(arglist_parser_done): Pass comment_is_utf8 value down to remember_a_message.
* gettext-tools/src/x-c.c (extract_parenthesized): Update callers. Don't set
xgettext_current_source_encoding around arglist_parser_remember calls.
* gettext-tools/src/x-csharp.c (extract_parenthesized): Likewise.
* gettext-tools/src/x-java.c (extract_parenthesized): Likewise.
* gettext-tools/src/x-javascript.c (extract_balanced): Likewise.
* gettext-tools/src/x-perl.c (extract_balanced): Likewise.
* gettext-tools/src/x-python.c (extract_balanced): Likewise.
* gettext-tools/src/x-vala.c (extract_balanced): Likewise.
* gettext-tools/src/x-awk.c (extract_parenthesized): Update callers.
* gettext-tools/src/x-elisp.c (read_object): Likewise.
* gettext-tools/src/x-librep.c (read_object): Likewise.
* gettext-tools/src/x-lisp.c (read_object): Likewise.
* gettext-tools/src/x-lua.c (extract_balanced): Likewise.
* gettext-tools/src/x-php.c (extract_balanced): Likewise.
* gettext-tools/src/x-scheme.c (read_object): Likewise.
* gettext-tools/src/x-sh.c (read_command): Likewise.
* gettext-tools/src/x-tcl.c (read_command): Likewise.

18 files changed:
gettext-tools/src/x-awk.c
gettext-tools/src/x-c.c
gettext-tools/src/x-csharp.c
gettext-tools/src/x-elisp.c
gettext-tools/src/x-java.c
gettext-tools/src/x-javascript.c
gettext-tools/src/x-librep.c
gettext-tools/src/x-lisp.c
gettext-tools/src/x-lua.c
gettext-tools/src/x-perl.c
gettext-tools/src/x-php.c
gettext-tools/src/x-python.c
gettext-tools/src/x-scheme.c
gettext-tools/src/x-sh.c
gettext-tools/src/x-tcl.c
gettext-tools/src/x-vala.c
gettext-tools/src/xg-arglist-parser.c
gettext-tools/src/xg-arglist-parser.h

index 0cc16186fe4bdf0358b4e5844ae40559a592ae1e..da74c004245a63ccebe34f8dfb5cd85d0850ef44 100644 (file)
@@ -800,7 +800,7 @@ extract_parenthesized (message_list_ty *mlp,
                 arglist_parser_remember (argparser, arg, ms,
                                          inner_context,
                                          pos.file_name, pos.line_number,
-                                         savable_comment);
+                                         savable_comment, false);
               }
           }
           next_is_argument = false;
index 00f076ffd93e17c1f6321b244b0eecf66406e5ad..0d43fc8d2c4885c28959283b2d1ade89d7a0cf0e 100644 (file)
@@ -2304,15 +2304,11 @@ extract_parenthesized (message_list_ty *mlp,
                                     &token.pos, NULL, token.comment, false);
               }
             else
-              {
-                xgettext_current_source_encoding = po_charset_utf8;
-                arglist_parser_remember (argparser, arg, token.mixed_string,
-                                         inner_context,
-                                         token.pos.file_name,
-                                         token.pos.line_number,
-                                         token.comment);
-                xgettext_current_source_encoding = xgettext_global_source_encoding;
-              }
+              arglist_parser_remember (argparser, arg, token.mixed_string,
+                                       inner_context,
+                                       token.pos.file_name,
+                                       token.pos.line_number,
+                                       token.comment, false);
             drop_reference (token.comment);
           }
           next_context_iter = null_context_list_iterator;
index 963dda2daf48fd750eef007cec96808eef24c8a6..85fb833973bba52c2260b433e39867d380ae3467 100644 (file)
@@ -2014,14 +2014,10 @@ extract_parenthesized (message_list_ty *mlp, token_type_ty terminator,
                                     &pos, NULL, token.comment, true);
               }
             else
-              {
-                xgettext_current_source_encoding = po_charset_utf8;
-                arglist_parser_remember (argparser, arg, token.mixed_string,
-                                         inner_context,
-                                         pos.file_name, pos.line_number,
-                                         token.comment);
-                xgettext_current_source_encoding = xgettext_global_source_encoding;
-              }
+              arglist_parser_remember (argparser, arg, token.mixed_string,
+                                       inner_context,
+                                       pos.file_name, pos.line_number,
+                                       token.comment, true);
           }
           drop_reference (token.comment);
           next_context_iter = null_context_list_iterator;
index b1077406107fe0486d26e3c0f4a99250df9b81ef..b661c0c4def75b3fdb52a0c70c224e698d99cafc 100644 (file)
@@ -720,7 +720,7 @@ read_object (struct object *op, bool first_in_list, bool new_backquote_flag,
                                                  inner_context,
                                                  logical_file_name,
                                                  inner.line_number_at_start,
-                                                 savable_comment);
+                                                 savable_comment, false);
                       }
                   }
 
index cd57c30560dcf63fc566faee5c6ebabbf83ea4b7..9b75915888d0e702537190daeadd06a3070e785e 100644 (file)
@@ -1213,14 +1213,10 @@ extract_parenthesized (message_list_ty *mlp, token_type_ty terminator,
                                     &pos, NULL, token.comment, true);
               }
             else
-              {
-                xgettext_current_source_encoding = po_charset_utf8;
-                arglist_parser_remember (argparser, arg, token.mixed_string,
-                                         inner_context,
-                                         pos.file_name, pos.line_number,
-                                         token.comment);
-                xgettext_current_source_encoding = xgettext_global_source_encoding;
-              }
+              arglist_parser_remember (argparser, arg, token.mixed_string,
+                                       inner_context,
+                                       pos.file_name, pos.line_number,
+                                       token.comment, true);
           }
           drop_reference (token.comment);
           next_context_iter = null_context_list_iterator;
index 27b87d4f72d9f0d4ce3b43d5632974d6493fbe9c..85c9ad3280e8658c1494618cfe8970cf6926720a 100644 (file)
@@ -1514,14 +1514,10 @@ extract_balanced (message_list_ty *mlp,
                                     &pos, NULL, token.comment, true);
               }
             else
-              {
-                xgettext_current_source_encoding = po_charset_utf8;
-                arglist_parser_remember (argparser, arg, token.mixed_string,
-                                         inner_context,
-                                         pos.file_name, pos.line_number,
-                                         token.comment);
-                xgettext_current_source_encoding = xgettext_current_file_source_encoding;
-              }
+              arglist_parser_remember (argparser, arg, token.mixed_string,
+                                       inner_context,
+                                       pos.file_name, pos.line_number,
+                                       token.comment, true);
           }
           drop_reference (token.comment);
           next_context_iter = null_context_list_iterator;
index 1739e6f7cf14f321a187e03317e81616cb8cff22..f660808c76dc49c08569f387ff7c701feb3bad07 100644 (file)
@@ -694,7 +694,7 @@ read_object (struct object *op, flag_context_ty outer_context)
                                                  inner_context,
                                                  logical_file_name,
                                                  inner.line_number_at_start,
-                                                 savable_comment);
+                                                 savable_comment, false);
                       }
                   }
 
index 41402e24dd9d9fb071ff51634d60b30e92438123..7604325f87d4e146d941f826944fac455c9d382e 100644 (file)
@@ -1097,7 +1097,7 @@ read_object (struct object *op, flag_context_ty outer_context)
                                                      inner_context,
                                                      logical_file_name,
                                                      inner.line_number_at_start,
-                                                     savable_comment);
+                                                     savable_comment, false);
                           }
                       }
 
index 55b46ad4ab2441f6f9f6ccf428d959cfdb854a42..3a2296f3649080df5f18c856109c98d6febf0dc4 100644 (file)
@@ -1161,14 +1161,16 @@ extract_balanced (message_list_ty *mlp, token_type_ty delim,
                     tmp_argparser = arglist_parser_alloc (mlp, next_shapes);
 
                     arglist_parser_remember (tmp_argparser, 1, ms,
-                                             inner_context, pos.file_name,
-                                             pos.line_number, token.comment);
+                                             inner_context,
+                                             pos.file_name, pos.line_number,
+                                             token.comment, false);
                     arglist_parser_done (tmp_argparser, 1);
                   }
                 else
                   arglist_parser_remember (argparser, arg, ms,
-                                           inner_context, pos.file_name,
-                                           pos.line_number, token.comment);
+                                           inner_context,
+                                           pos.file_name, pos.line_number,
+                                           token.comment, false);
               }
           }
           drop_reference (token.comment);
index 818ad27ca55595570edc3642ee01c25d84a96817..50b87bc12a076751b842410640c072f3327271bf 100644 (file)
@@ -3332,11 +3332,9 @@ extract_balanced (message_list_ty *mlp,
                     mixed_string_alloc_utf8 (string, lc_string,
                                              logical_file_name, tp->line_number);
                   free (string);
-                  xgettext_current_source_encoding = po_charset_utf8;
                   arglist_parser_remember (argparser, arg, ms, inner_context,
                                            logical_file_name, tp->line_number,
-                                           tp->comment);
-                  xgettext_current_source_encoding = xgettext_global_source_encoding;
+                                           tp->comment, true);
                 }
             }
 
index ecb689bdb90d3f53f3f26e13b2a7700be4cdab4d..de9b89f54447e9f67fb7a9ce113ba4c98809e782 100644 (file)
@@ -1542,7 +1542,7 @@ extract_balanced (message_list_ty *mlp,
                 free (token.string);
                 arglist_parser_remember (argparser, arg, ms, inner_context,
                                          pos.file_name, pos.line_number,
-                                         token.comment);
+                                         token.comment, false);
               }
             drop_reference (token.comment);
           }
index fb1a4f1d9e437fa5200b33758eeb3429c64517e6..a37a1e8b09f7796d9bad5188830399ae56757f90 100644 (file)
@@ -1629,14 +1629,10 @@ extract_balanced (message_list_ty *mlp,
                                     &pos, NULL, token.comment, true);
               }
             else
-              {
-                xgettext_current_source_encoding = po_charset_utf8;
-                arglist_parser_remember (argparser, arg, token.mixed_string,
-                                         inner_context,
-                                         pos.file_name, pos.line_number,
-                                         token.comment);
-                xgettext_current_source_encoding = xgettext_current_file_source_encoding;
-              }
+              arglist_parser_remember (argparser, arg, token.mixed_string,
+                                       inner_context,
+                                       pos.file_name, pos.line_number,
+                                       token.comment, true);
           }
           drop_reference (token.comment);
           next_context_iter = null_context_list_iterator;
index 955ca7468fed8c8a5eef6eecb4cd5ca860949f4c..fc4b7853d21782ff665b56dd853f58b4b68f8ddf 100644 (file)
@@ -801,7 +801,7 @@ read_object (struct object *op, flag_context_ty outer_context)
                                                  inner_context,
                                                  logical_file_name,
                                                  inner.line_number_at_start,
-                                                 savable_comment);
+                                                 savable_comment, false);
                       }
                   }
 
index 6980a4222fa8f946093d7e8aa42e59266973a8ba..653d8ab6c410cecd91a89cd02dada853609684c1 100644 (file)
@@ -1370,7 +1370,7 @@ read_command (int looking_for, flag_context_ty outer_context)
                                                inner_context,
                                                logical_file_name,
                                                inner.line_number_at_start,
-                                               savable_comment);
+                                               savable_comment, false);
                     }
                 }
 
index e67d94a57d0bb8f2297a097383499a991de4c157..8980739fca9a6ecde80add0d40ea1021d8258409 100644 (file)
@@ -942,7 +942,7 @@ read_command (int looking_for, flag_context_ty outer_context)
                                          inner_context,
                                          logical_file_name,
                                          inner.line_number_at_start,
-                                         savable_comment);
+                                         savable_comment, false);
               }
           }
 
index 2c5f34509e4dfaf40cf631b1367a8fd947d0a3bb..0fadd6af5610328aebfda418ccf40f839a7fccaa 100644 (file)
@@ -1335,21 +1335,17 @@ extract_balanced (message_list_ty *mlp, token_type_ty delim,
                     struct arglist_parser *tmp_argparser;
                     tmp_argparser = arglist_parser_alloc (mlp, next_shapes);
 
-                    xgettext_current_source_encoding = po_charset_utf8;
-                    arglist_parser_remember (tmp_argparser, 1, token.mixed_string,
-                                             inner_context, pos.file_name,
-                                             pos.line_number, token.comment);
-                    xgettext_current_source_encoding = xgettext_global_source_encoding;
+                    arglist_parser_remember (tmp_argparser, 1,
+                                             token.mixed_string, inner_context,
+                                             pos.file_name, pos.line_number,
+                                             token.comment, false);
                     arglist_parser_done (tmp_argparser, 1);
                   }
                 else
-                  {
-                    xgettext_current_source_encoding = po_charset_utf8;
-                    arglist_parser_remember (argparser, arg, token.mixed_string,
-                                             inner_context, pos.file_name,
-                                             pos.line_number, token.comment);
-                    xgettext_current_source_encoding = xgettext_global_source_encoding;
-                  }
+                  arglist_parser_remember (argparser, arg,
+                                           token.mixed_string, inner_context,
+                                           pos.file_name, pos.line_number,
+                                           token.comment, false);
               }
           }
           drop_reference (token.comment);
index 37647d7e4b2486cd207ccae4124c8f0dc260556c..a99dc5fc5d38ab7f2a82db8ba19ce85298a0cae1 100644 (file)
@@ -87,6 +87,7 @@ arglist_parser_alloc (message_list_ty *mlp, const struct callshapes *shapes)
           ap->alternative[i].msgid_pos.file_name = NULL;
           ap->alternative[i].msgid_pos.line_number = (size_t)(-1);
           ap->alternative[i].msgid_comment = NULL;
+          ap->alternative[i].msgid_comment_is_utf8 = false;
           ap->alternative[i].msgid_plural = NULL;
           ap->alternative[i].msgid_plural_context = null_context;
           ap->alternative[i].msgid_plural_pos.file_name = NULL;
@@ -131,6 +132,7 @@ arglist_parser_clone (struct arglist_parser *ap)
       ccp->msgid_context = cp->msgid_context;
       ccp->msgid_pos = cp->msgctxt_pos;
       ccp->msgid_comment = add_reference (cp->msgid_comment);
+      ccp->msgid_comment_is_utf8 = cp->msgid_comment_is_utf8;
       ccp->msgid_plural =
         (cp->msgid_plural != NULL ? mixed_string_clone (cp->msgid_plural) : NULL);
       ccp->msgid_plural_context = cp->msgid_plural_context;
@@ -146,7 +148,8 @@ arglist_parser_remember (struct arglist_parser *ap,
                          int argnum, mixed_string_ty *string,
                          flag_context_ty context,
                          char *file_name, size_t line_number,
-                         refcounted_string_list_ty *comment)
+                         refcounted_string_list_ty *comment,
+                         bool comment_is_utf8)
 {
   bool stored_string = false;
   size_t nalternatives = ap->nalternatives;
@@ -176,6 +179,7 @@ arglist_parser_remember (struct arglist_parser *ap,
               cp->msgid_pos.file_name = file_name;
               cp->msgid_pos.line_number = line_number;
               cp->msgid_comment = add_reference (comment);
+              cp->msgid_comment_is_utf8 = comment_is_utf8;
               stored_string = true;
               /* Mark msgid as done.  */
               cp->argnum1 = 0;
@@ -501,7 +505,8 @@ arglist_parser_done (struct arglist_parser *ap, int argnum)
           mp = remember_a_message (ap->mlp, best_msgctxt, best_msgid, true,
                                    msgid_context,
                                    &best_cp->msgid_pos,
-                                   NULL, best_cp->msgid_comment, false);
+                                   NULL, best_cp->msgid_comment,
+                                   best_cp->msgid_comment_is_utf8);
           if (mp != NULL && best_msgid_plural != NULL)
             remember_a_message_plural (mp, best_msgid_plural, true,
                                        msgid_plural_context,
index b6d31145cd3c796c3670e102deb2cbcc8d44f9d2..e2f754e45f9f30b72f666c15861467799785234f 100644 (file)
@@ -51,6 +51,7 @@ struct partial_call
   flag_context_ty msgid_context;
   lex_pos_ty msgid_pos;
   refcounted_string_list_ty *msgid_comment;
+  bool msgid_comment_is_utf8;
   mixed_string_ty *msgid_plural; /* msgid_plural - owned mixed_string, or NULL */
   flag_context_ty msgid_plural_context;
   lex_pos_ty msgid_plural_pos;
@@ -79,12 +80,15 @@ extern struct arglist_parser * arglist_parser_clone (struct arglist_parser *ap);
    FILE_NAME must be allocated with indefinite extent.
    COMMENT may be savable_comment, or it may be a saved copy of savable_comment
    (then add_reference must be used when saving it, and drop_reference while
-   dropping it).  Clear savable_comment.  */
+   dropping it).  Clear savable_comment.
+   COMMENT_IS_UTF8 must be true if COMMENT has already been converted to UTF-8.
+ */
 extern void arglist_parser_remember (struct arglist_parser *ap,
                                      int argnum, mixed_string_ty *string,
                                      flag_context_ty context,
                                      char *file_name, size_t line_number,
-                                     refcounted_string_list_ty *comment);
+                                     refcounted_string_list_ty *comment,
+                                     bool comment_is_utf8);
 /* Adds a string argument as msgctxt to an arglist_parser, without incrementing
    the current argument number.
    STRING must be a mixed_string; its ownership is passed to the callee.