From: Bruno Haible Date: Sat, 3 Aug 2024 12:28:32 +0000 (+0200) Subject: libgettextpo: Don't use static variable gram_max_allowed_errors. X-Git-Tag: v0.23~184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d862ba37a77979430593809d54d980292be18720;p=thirdparty%2Fgettext.git libgettextpo: Don't use static variable gram_max_allowed_errors. * gettext-tools/src/read-po.h (gram_max_allowed_errors): New declaration. * gettext-tools/src/read-po-lex.h (gram_max_allowed_errors): Remove declaration. * gettext-tools/src/read-po.c: Include . (gram_max_allowed_errors): Moved to here. Change initial value to UINT_MAX. * gettext-tools/src/read-po-lex.c: Include read-po.h. (gram_max_allowed_errors): Remove variable. * gettext-tools/libgettextpo/gettext-po.c: Don't include read-po-lex.h. (po_file_read): Don't assign gram_max_allowed_errors. * gettext-tools/src/msgattrib.c (main): Initialize gram_max_allowed_errors. * gettext-tools/src/msgcat.c (main): Likewise. * gettext-tools/src/msgcomm.c (main): Likewise. * gettext-tools/src/msgconv.c (main): Likewise. * gettext-tools/src/msgen.c (main): Likewise. * gettext-tools/src/msgexec.c (main): Likewise. * gettext-tools/src/msgfilter.c (main): Likewise. * gettext-tools/src/msggrep.c (main): Likewise. * gettext-tools/src/msginit.c (main): Likewise. * gettext-tools/src/msguniq.c (main): Likewise. * gettext-tools/src/xgettext.c (main): Likewise. * gettext-tools/src/msgcmp.c: Don't include read-po-lex.h. * gettext-tools/src/msgmerge.c: Likewise. * gettext-tools/src/msgfmt.c: Don't include read-po-lex.h. (main): Initialize gram_max_allowed_errors. --- diff --git a/gettext-tools/libgettextpo/gettext-po.c b/gettext-tools/libgettextpo/gettext-po.c index acbd4f37e..22a50c1df 100644 --- a/gettext-tools/libgettextpo/gettext-po.c +++ b/gettext-tools/libgettextpo/gettext-po.c @@ -31,7 +31,6 @@ #include "xalloc.h" #include "read-catalog.h" #include "read-po.h" -#include "read-po-lex.h" #include "write-catalog.h" #include "write-po.h" #include "xvasprintf.h" @@ -113,7 +112,6 @@ po_file_read (const char *filename, po_xerror_handler_t handler) handler->xerror2, &error_count }; - gram_max_allowed_errors = UINT_MAX; file = XMALLOC (struct po_file); file->real_filename = filename; @@ -123,9 +121,6 @@ po_file_read (const char *filename, po_xerror_handler_t handler) &local_xerror_handler); file->domains = NULL; - /* Restore. */ - gram_max_allowed_errors = 20; - if (fp != stdin) fclose (fp); return file; diff --git a/gettext-tools/src/msgattrib.c b/gettext-tools/src/msgattrib.c index 67407807a..3112622dd 100644 --- a/gettext-tools/src/msgattrib.c +++ b/gettext-tools/src/msgattrib.c @@ -154,6 +154,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgcat.c b/gettext-tools/src/msgcat.c index 2fb6ad356..eb7c44909 100644 --- a/gettext-tools/src/msgcat.c +++ b/gettext-tools/src/msgcat.c @@ -122,6 +122,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgcmp.c b/gettext-tools/src/msgcmp.c index 2b744397b..d0c345a10 100644 --- a/gettext-tools/src/msgcmp.c +++ b/gettext-tools/src/msgcmp.c @@ -37,7 +37,6 @@ #include "message.h" #include "read-catalog-file.h" #include "read-po.h" -#include "read-po-lex.h" #include "read-properties.h" #include "read-stringtable.h" #include "xmalloca.h" diff --git a/gettext-tools/src/msgcomm.c b/gettext-tools/src/msgcomm.c index a740a661b..23f939775 100644 --- a/gettext-tools/src/msgcomm.c +++ b/gettext-tools/src/msgcomm.c @@ -121,6 +121,7 @@ main (int argc, char *argv[]) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgconv.c b/gettext-tools/src/msgconv.c index a5a678794..5c4f34ae8 100644 --- a/gettext-tools/src/msgconv.c +++ b/gettext-tools/src/msgconv.c @@ -110,6 +110,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgen.c b/gettext-tools/src/msgen.c index c635b8f95..b8c2210b6 100644 --- a/gettext-tools/src/msgen.c +++ b/gettext-tools/src/msgen.c @@ -108,6 +108,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgexec.c b/gettext-tools/src/msgexec.c index 47707b855..762edecd4 100644 --- a/gettext-tools/src/msgexec.c +++ b/gettext-tools/src/msgexec.c @@ -110,6 +110,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c index 174498154..74b1ba3c6 100644 --- a/gettext-tools/src/msgfilter.c +++ b/gettext-tools/src/msgfilter.c @@ -144,6 +144,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index f7aa19bfb..e0819489e 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -57,7 +57,6 @@ #include "open-catalog.h" #include "read-catalog-file.h" #include "read-po.h" -#include "read-po-lex.h" #include "read-properties.h" #include "read-stringtable.h" #include "read-desktop.h" @@ -259,6 +258,7 @@ main (int argc, char *argv[]) error_print_progname = maybe_print_progname; error_one_per_line = 1; exit_status = EXIT_SUCCESS; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msggrep.c b/gettext-tools/src/msggrep.c index 7d773a4b8..08fa7ca2f 100644 --- a/gettext-tools/src/msggrep.c +++ b/gettext-tools/src/msggrep.c @@ -157,6 +157,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c index 1258fecc6..5a66f7fda 100644 --- a/gettext-tools/src/msginit.c +++ b/gettext-tools/src/msginit.c @@ -153,6 +153,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/msgmerge.c b/gettext-tools/src/msgmerge.c index 8cc278bec..7e1b770a3 100644 --- a/gettext-tools/src/msgmerge.c +++ b/gettext-tools/src/msgmerge.c @@ -44,7 +44,6 @@ #include "message.h" #include "read-catalog-file.h" #include "read-po.h" -#include "read-po-lex.h" #include "read-properties.h" #include "read-stringtable.h" #include "write-catalog.h" diff --git a/gettext-tools/src/msguniq.c b/gettext-tools/src/msguniq.c index 692af237e..457c7d27b 100644 --- a/gettext-tools/src/msguniq.c +++ b/gettext-tools/src/msguniq.c @@ -114,6 +114,7 @@ main (int argc, char **argv) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); diff --git a/gettext-tools/src/read-po-lex.c b/gettext-tools/src/read-po-lex.c index 3b2d14b62..6a6c3cb96 100644 --- a/gettext-tools/src/read-po-lex.c +++ b/gettext-tools/src/read-po-lex.c @@ -56,6 +56,7 @@ #include "pos.h" #include "message.h" #include "str-list.h" +#include "read-po.h" #include "read-po-internal.h" #include "read-po-gram.h" @@ -818,11 +819,6 @@ mbfile_ungetc (const mbchar_t mbc, mbfile_t mbf) } -/* Lexer variables. */ - -unsigned int gram_max_allowed_errors = 20; - - /* Prepare lexical analysis. */ void lex_start (struct po_parser_state *ps, diff --git a/gettext-tools/src/read-po-lex.h b/gettext-tools/src/read-po-lex.h index 57a2b68f5..ac4e6c092 100644 --- a/gettext-tools/src/read-po-lex.h +++ b/gettext-tools/src/read-po-lex.h @@ -52,12 +52,6 @@ extern "C" { struct po_parser_state; -/* Global variables from read-po-lex.c. */ - -/* Number of parse errors within a PO file that cause the program to - terminate. Cf. error_message_count, declared in . */ -extern DLL_VARIABLE unsigned int gram_max_allowed_errors; - /* Prepare lexical analysis. */ extern void lex_start (struct po_parser_state *ps, diff --git a/gettext-tools/src/read-po.c b/gettext-tools/src/read-po.c index 3b4cd1b5b..f817be9f7 100644 --- a/gettext-tools/src/read-po.c +++ b/gettext-tools/src/read-po.c @@ -21,6 +21,8 @@ /* Specification. */ #include "read-po.h" +#include + #include "read-po-lex.h" #include "read-po-internal.h" @@ -45,3 +47,8 @@ const struct catalog_input_format input_format_po = po_parse, /* parse */ false /* produces_utf8 */ }; + + +/* Lexer variables. */ + +unsigned int gram_max_allowed_errors = UINT_MAX; diff --git a/gettext-tools/src/read-po.h b/gettext-tools/src/read-po.h index 98fc893b2..baf6bbae5 100644 --- a/gettext-tools/src/read-po.h +++ b/gettext-tools/src/read-po.h @@ -1,5 +1,5 @@ /* Reading PO files. - Copyright (C) 2006, 2019 Free Software Foundation, Inc. + Copyright (C) 2006-2024 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -30,6 +30,13 @@ extern "C" { extern DLL_VARIABLE const struct catalog_input_format input_format_po; +/* Global variables. */ + +/* Number of parse errors within a PO file that cause the program to + terminate. Cf. error_message_count, declared in . */ +extern DLL_VARIABLE unsigned int gram_max_allowed_errors; + + #ifdef __cplusplus } #endif diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 5ae03e69e..25179ea89 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -351,6 +351,7 @@ main (int argc, char *argv[]) /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; + gram_max_allowed_errors = 20; /* Set locale via LC_ALL. */ setlocale (LC_ALL, "");