]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Freshly initialize all static variables for each input file.
authorBruno Haible <bruno@clisp.org>
Mon, 6 Apr 2020 12:07:01 +0000 (14:07 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 6 Apr 2020 12:07:01 +0000 (14:07 +0200)
* gettext-tools/src/x-c.c (extract_whole_file): Initialize
phase1_pushback_length, phase2_pushback_length, phase3_pushback_length,
phase5_pushback_length, phase6_pushback_length.
* gettext-tools/src/x-csharp.c (extract_csharp): Initialize
phase1_pushback_length, phase2_pushback_length, phase3_pushback_length,
phase5_pushback_length, phase6_pushback_length, phase7_pushback_length.
* gettext-tools/src/x-java.c (extract_java): Initialize phase1_pushback_length,
phase2_pushback_length, phase3_pushback_length, phase5_pushback_length,
phase6_pushback_length.
* gettext-tools/src/x-javascript.c (continuation_or_nonblank_line,
last_token_type): Remove static initialization.
(extract_javascript): Initialize phase1_pushback_length, phase2_pushback_length,
phase5_pushback_length, last_token_type.
* gettext-tools/src/x-lua.c (first_character): Change type to 'bool'. Remove
static initialization.
(extract_lua): Initialize phase1_pushback_length, first_character,
phase3_pushback_length, phase4_last, phase4_pushback_length.
* gettext-tools/src/x-perl.c (extract_perl): Reorder initializations.
* gettext-tools/src/x-php.c (extract_php): Initialize phase1_pushback_length,
phase3_pushback_length, phase4_pushback_length.
* gettext-tools/src/x-python.c (continuation_or_nonblank_line): Remove static
initialization.
(extract_python): Initialize phase1_pushback_length, phase2_pushback_length,
phase5_pushback_length.
* gettext-tools/src/x-sh.c (extract_sh): Initialize phase1_pushback_length,
phase2_pushback_length.
* gettext-tools/src/x-smalltalk.c (extract_smalltalk): Initialize
phase2_pushback_length, phase3_pushback_length.
* gettext-tools/src/x-tcl.c (extract_tcl): Initialize phase1_pushback_length,
phase2_pushback_length.
* gettext-tools/src/x-vala.c (last_token_type): Remove static initialization.
(extract_vala): Initialize phase1_pushback_length, phase3_pushback_length,
last_token_type.
* gettext-tools/src/x-ycp.c (extract_ycp): Initialize phase2_pushback_length,
phase5_pushback_length, phase8_pushback_length.

13 files changed:
gettext-tools/src/x-c.c
gettext-tools/src/x-csharp.c
gettext-tools/src/x-java.c
gettext-tools/src/x-javascript.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-sh.c
gettext-tools/src/x-smalltalk.c
gettext-tools/src/x-tcl.c
gettext-tools/src/x-vala.c
gettext-tools/src/x-ycp.c

index de99a707cedec7b9fd884eae74dba12859b9df0c..f4e6522ab6e788592e73c162799db163ad936f25 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext C/C++/ObjectiveC backend.
-   Copyright (C) 1995-1998, 2000-2009, 2012-2015, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2009, 2012-2015, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -2344,9 +2344,16 @@ extract_whole_file (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
-  newline_count = 0;
+  phase1_pushback_length = 0;
+  phase2_pushback_length = 0;
+  phase3_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
+  newline_count = 0;
+
+  phase5_pushback_length = 0;
+  phase6_pushback_length = 0;
 
   flag_context_list_table = flag_table;
 
index 71678b3ef9b32fe799fc09a04323b3e5e81f87f9..2fb48f98c5813bd46ae3be870170ed6b6bc67808 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext C# backend.
-   Copyright (C) 2003-2009, 2011, 2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2009, 2011, 2014, 2018-2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -2056,12 +2056,23 @@ extract_csharp (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+
   lexical_context = lc_outside;
 
+  phase2_pushback_length = 0;
+
   logical_line_number = 1;
+
+  phase3_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase5_pushback_length = 0;
+  phase6_pushback_length = 0;
+  phase7_pushback_length = 0;
+
   flag_context_list_table = flag_table;
 
   init_keywords ();
index 64a7f2b6492800c5cfd809bda84d1b2af87c5c57..577304f6a11b512f2c4bf9ee40c6167b28d72562 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Java backend.
-   Copyright (C) 2003, 2005-2009, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005-2009, 2018-2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -1694,9 +1694,15 @@ extract_java (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+  phase2_pushback_length = 0;
+  phase3_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase5_pushback_length = 0;
+  phase6_pushback_length = 0;
   phase6_last = token_type_eof;
 
   flag_context_list_table = flag_table;
index 4823b295c6e38b3349d754ac95e141b004d17e3b..564abd3a95eab8ceb92b78a93775edb95e1e237c 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext JavaScript backend.
-   Copyright (C) 2002-2003, 2005-2009, 2013-2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2009, 2013-2014, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Andreas Stricker <andy@knitter.ch>, 2010
    It's based on x-python from Bruno Haible.
@@ -512,7 +512,7 @@ static iconv_t xgettext_current_file_source_iconv;
 
 /* Tracking whether the current line is a continuation line or contains a
    non-blank character.  */
-static bool continuation_or_nonblank_line = false;
+static bool continuation_or_nonblank_line;
 
 
 /* Phase 3: Outside strings, replace backslash-newline with nothing and a
@@ -892,7 +892,7 @@ phase7_getuc (int quote_char)
 static token_ty phase5_pushback[2];
 static int phase5_pushback_length;
 
-static token_type_ty last_token_type = token_type_other;
+static token_type_ty last_token_type;
 
 static void
 phase5_scan_regexp (void)
@@ -1713,16 +1713,15 @@ extract_javascript (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+
   lexical_context = lc_outside;
 
+  phase2_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
-  template_literal_depth = 0;
-  new_brace_depth_level ();
-  xml_element_depth = 0;
-  inside_embedded_js_in_xml = false;
-
   xgettext_current_file_source_encoding =
     (xgettext_global_source_encoding != NULL ? xgettext_global_source_encoding :
      po_charset_ascii);
@@ -1737,6 +1736,14 @@ extract_javascript (FILE *f,
 
   continuation_or_nonblank_line = false;
 
+  phase5_pushback_length = 0;
+  last_token_type = token_type_other;
+
+  template_literal_depth = 0;
+  new_brace_depth_level ();
+  xml_element_depth = 0;
+  inside_embedded_js_in_xml = false;
+
   flag_context_list_table = flag_table;
 
   init_keywords ();
index 25970fea949a12e9a53d98b4c11e15d960590424..5dbc94c689e04c9d68ed385e896d9161ebb081d2 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Lua backend.
-   Copyright (C) 2012-2013, 2016, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2012-2013, 2016, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Ľubomír Remák <lubomirr@lubomirr.eu>, 2012.
 
@@ -138,7 +138,7 @@ static FILE *fp;
 static unsigned char phase1_pushback[2];
 static int phase1_pushback_length;
 
-static int first_character = 1;
+static bool first_character;
 
 static int
 phase1_getc ()
@@ -153,7 +153,7 @@ phase1_getc ()
 
       if (first_character)
         {
-          first_character = 0;
+          first_character = false;
 
           /* Ignore shebang line.  No pushback required in this case.  */
           if (c == '#')
@@ -1213,9 +1213,17 @@ extract_lua (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+  first_character = true;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase3_pushback_length = 0;
+
+  phase4_last = token_type_eof;
+  phase4_pushback_length = 0;
+
   flag_context_list_table = flag_table;
 
   init_keywords ();
index e16f9b60866f3b5a127884ae8277ffcef2a3b54c..58892cddf3ba514c96f555f753ca2b3bf3222122 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Perl backend.
-   Copyright (C) 2002-2010, 2013, 2016, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2010, 2013, 2016, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Guido Flohr <guido@imperia.net>, 2002-2010.
 
@@ -218,6 +218,8 @@ static FILE *fp;
 
 /* The current line buffer.  */
 static char *linebuf;
+/* The size of the input buffer.  */
+static size_t linebuf_size;
 
 /* The size of the current line.  */
 static int linesize;
@@ -225,9 +227,6 @@ static int linesize;
 /* The position in the current line.  */
 static int linepos;
 
-/* The size of the input buffer.  */
-static size_t linebuf_size;
-
 /* Number of lines eaten for here documents.  */
 static int eaten_here;
 
@@ -3553,23 +3552,24 @@ extract_perl (FILE *f, const char *real_filename, const char *logical_filename,
   logical_file_name = xstrdup (logical_filename);
   line_number = 0;
 
+  linesize = 0;
+  linepos = 0;
+  eaten_here = 0;
+  end_of_file = false;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
   flag_context_list_table = flag_table;
 
-  init_keywords ();
+  /* Safe assumption.  */
+  last_token_type = token_type_semicolon;
 
   token_stack.items = NULL;
   token_stack.nitems = 0;
   token_stack.nitems_max = 0;
-  linesize = 0;
-  linepos = 0;
-  eaten_here = 0;
-  end_of_file = false;
 
-  /* Safe assumption.  */
-  last_token_type = token_type_semicolon;
+  init_keywords ();
 
   /* Eat tokens until eof is seen.  When extract_balanced returns
      due to an unbalanced closing brace, just restart it.  */
index cccb9dc2d29bbea10be733eec8cd8d91e2d1006a..410790961f31cc0d9599431ce0119ae5cbc5a58a 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext PHP backend.
-   Copyright (C) 2001-2003, 2005-2010, 2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2010, 2014, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <bruno@clisp.org>, 2002.
 
@@ -1583,9 +1583,17 @@ extract_php (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+#if 0
+  phase2_pushback_length = 0;
+#endif
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase3_pushback_length = 0;
+  phase4_pushback_length = 0;
+
   phase5_last = token_type_eof;
 
   flag_context_list_table = flag_table;
index a27669eeccd4f97fa0f1882fa861fb409f4ed961..ed319f13a0d7608965d3aef2441f49475db7f725 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Python backend.
-   Copyright (C) 2002-2003, 2005-2011, 2013-2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2011, 2013-2014, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
@@ -695,7 +695,7 @@ try_to_extract_coding (const char *comment)
 
 /* Tracking whether the current line is a continuation line or contains a
    non-blank character.  */
-static bool continuation_or_nonblank_line = false;
+static bool continuation_or_nonblank_line;
 
 
 /* Phase 3: Outside strings, replace backslash-newline with nothing and a
@@ -1693,8 +1693,12 @@ extract_python (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+
   lexical_context = lc_outside;
 
+  phase2_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
@@ -1716,6 +1720,8 @@ extract_python (FILE *f,
 
   open_pbb = 0;
 
+  phase5_pushback_length = 0;
+
   flag_context_list_table = flag_table;
 
   init_keywords ();
index 341f7027f0b3435785c5fddc2acfbbe1402ebb2c..2868e4031ea5bdafdee2351f19d3ddf9d70e4878 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext sh backend.
-   Copyright (C) 2003, 2005-2009, 2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005-2009, 2014, 2018-2020 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -1516,6 +1516,8 @@ extract_sh (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
@@ -1524,6 +1526,8 @@ extract_sh (FILE *f,
   open_doublequote = false;
   open_singlequote = false;
 
+  phase2_pushback_length = 0;
+
   flag_context_list_table = flag_table;
 
   init_keywords ();
index 1a2b60998e221294186a3e0fc32e99a2368a6978..d84b307eb3c73ada271f3273674c8bc3230a8a6a 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Smalltalk backend.
-   Copyright (C) 2002-2003, 2005-2009, 2011, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2009, 2011, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
@@ -517,6 +517,9 @@ extract_smalltalk (FILE *f,
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase2_pushback_length = 0;
+  phase3_pushback_length = 0;
+
   /* Eat tokens until eof is seen.  */
   {
     /* 0 when no "NLS" has been seen.
index 1be2bcbfa8b36e099c1be9d576a8ff204434c5c1..6c347a7cbe7a2adde99219445eaa7a9239a906f1 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Tcl backend.
-   Copyright (C) 2002-2003, 2005-2009, 2013, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2009, 2013, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
 
@@ -986,6 +986,9 @@ extract_tcl (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+  phase2_pushback_length = 0;
+
   /* Initially, no brace is open.  */
   brace_depth = 1000000;
 
index 49e822d7adfacabf4428f9247bb6aaddb2803d5f..1e8b26bfeae34f802645f330325d15b9ef30ff7c 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Vala backend.
-   Copyright (C) 2013-2014, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2013-2014, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Daiki Ueno <ueno@gnu.org>, 2013.
 
@@ -591,7 +591,7 @@ static token_ty phase3_pushback[2];
 static int phase3_pushback_length;
 
 
-static token_type_ty last_token_type = token_type_other;
+static token_type_ty last_token_type;
 
 static void
 phase3_scan_regex ()
@@ -1392,9 +1392,14 @@ extract_vala (FILE *f,
   logical_file_name = xstrdup (logical_filename);
   line_number = 1;
 
+  phase1_pushback_length = 0;
+
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase3_pushback_length = 0;
+  last_token_type = token_type_other;
+
   flag_context_list_table = flag_table;
 
   init_keywords ();
index 51c4cb3b32295d111e26f202a017f215865ac0d4..5097b574827988f7ccb127eec5f4843b1a74d715 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext YCP backend.
-   Copyright (C) 2001-2003, 2005-2009, 2011, 2018-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2009, 2011, 2018-2020 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
@@ -805,6 +805,10 @@ extract_ycp (FILE *f,
   last_comment_line = -1;
   last_non_comment_line = -1;
 
+  phase2_pushback_length = 0;
+  phase5_pushback_length = 0;
+  phase8_pushback_length = 0;
+
   flag_context_list_table = flag_table;
 
   /* Eat tokens until eof is seen.  When extract_parenthesized returns