From: Bruno Haible Date: Thu, 30 Nov 2023 07:34:51 +0000 (+0100) Subject: xgettext: Refactor. X-Git-Tag: v0.23~289 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e13883ab5734a1af1c356ec6302de9ef7475c01b;p=thirdparty%2Fgettext.git xgettext: Refactor. * gettext-tools/src/xg-formatstring.h: New file, extracted from xgettext.h. * gettext-tools/src/xg-formatstring.c: New file, extracted from xgettext.c. * gettext-tools/src/FILES: Mention them. * gettext-tools/src/Makefile.am (noinst_HEADERS): Add xg-formatstring.h. (xgettext_SOURCES): Add xg-formatstring.c. * gettext-tools/src/xgettext.h (current_formatstring_parser1, current_formatstring_parser2, current_formatstring_parser3, current_formatstring_parser4): Remove declarations. * gettext-tools/src/xgettext.c: Include xg-formatstring.h. (current_formatstring_parser1, current_formatstring_parser2, current_formatstring_parser3, current_formatstring_parser4): Remove variables. * gettext-tools/src/xg-message.c: Include xg-formatstring.h. --- diff --git a/gettext-tools/src/FILES b/gettext-tools/src/FILES index 34aa6f3b5..47b29bd12 100644 --- a/gettext-tools/src/FILES +++ b/gettext-tools/src/FILES @@ -308,6 +308,9 @@ msgl-check.c | xg-mixed-string.c | Handling strings that are given partially in the source | encoding and partially in Unicode. +| xg-formatstring.h +| xg-formatstring.c +| Recognizing language-dependent format strings. | xg-arglist-context.h | xg-arglist-context.c | Keeping track of the flags that apply to a string extracted diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index a71d5e26f..d95b08ed6 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -63,8 +63,9 @@ noinst_HEADERS = \ po-time.h plural-table.h lang-table.h format.h filters.h \ xgettext.h \ if-error.h \ - rc-str-list.h xg-pos.h xg-encoding.h xg-mixed-string.h xg-arglist-context.h \ - xg-arglist-callshape.h xg-arglist-parser.h xg-message.h xg-check.h \ + rc-str-list.h xg-pos.h xg-encoding.h xg-mixed-string.h xg-formatstring.h \ + xg-arglist-context.h xg-arglist-callshape.h xg-arglist-parser.h xg-message.h \ + xg-check.h \ x-po.h x-properties.h x-stringtable.h \ x-c.h \ x-python.h \ @@ -238,6 +239,7 @@ xgettext_SOURCES += \ xg-pos.c \ xg-encoding.c \ xg-mixed-string.c \ + xg-formatstring.c \ xg-arglist-context.c xg-arglist-callshape.c xg-arglist-parser.c \ xg-message.c \ xg-check.c \ diff --git a/gettext-tools/src/xg-formatstring.c b/gettext-tools/src/xg-formatstring.c new file mode 100644 index 000000000..ecc2ecbf4 --- /dev/null +++ b/gettext-tools/src/xg-formatstring.c @@ -0,0 +1,30 @@ +/* Language-dependent format strings. + Copyright (C) 2003-2023 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#include "xg-formatstring.h" + + +/* Language dependent format string parser. + NULL if the language has no notion of format strings. */ +struct formatstring_parser *current_formatstring_parser1; +struct formatstring_parser *current_formatstring_parser2; +struct formatstring_parser *current_formatstring_parser3; +struct formatstring_parser *current_formatstring_parser4; diff --git a/gettext-tools/src/xg-formatstring.h b/gettext-tools/src/xg-formatstring.h new file mode 100644 index 000000000..406bab953 --- /dev/null +++ b/gettext-tools/src/xg-formatstring.h @@ -0,0 +1,37 @@ +/* Language-dependent format strings. + Copyright (C) 2003-2023 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _XGETTEXT_FORMATSTRING_H +#define _XGETTEXT_FORMATSTRING_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Language dependent format string parser. + NULL if the language has no notion of format strings. */ +extern struct formatstring_parser *current_formatstring_parser1; +extern struct formatstring_parser *current_formatstring_parser2; +extern struct formatstring_parser *current_formatstring_parser3; +extern struct formatstring_parser *current_formatstring_parser4; + + +#ifdef __cplusplus +} +#endif + +#endif /* _XGETTEXT_FORMATSTRING_H */ diff --git a/gettext-tools/src/xg-message.c b/gettext-tools/src/xg-message.c index 895127d3d..53e64afd6 100644 --- a/gettext-tools/src/xg-message.c +++ b/gettext-tools/src/xg-message.c @@ -33,6 +33,7 @@ #include "verify.h" #include "xgettext.h" +#include "xg-formatstring.h" #include "gettext.h" #define _(str) gettext (str) diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 8abb61ba8..8ab5f9573 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -44,6 +44,7 @@ #include "noreturn.h" #include "rc-str-list.h" #include "xg-encoding.h" +#include "xg-formatstring.h" #include "xg-arglist-context.h" #include "xg-message.h" #include "closeout.h" @@ -1921,14 +1922,6 @@ xgettext_open (const char *fn, } -/* Language dependent format string parser. - NULL if the language has no notion of format strings. */ -struct formatstring_parser *current_formatstring_parser1; -struct formatstring_parser *current_formatstring_parser2; -struct formatstring_parser *current_formatstring_parser3; -struct formatstring_parser *current_formatstring_parser4; - - static void extract_from_file (const char *file_name, extractor_ty extractor, msgdomain_list_ty *mdlp) diff --git a/gettext-tools/src/xgettext.h b/gettext-tools/src/xgettext.h index c37f4a9ad..8d0af3bcc 100644 --- a/gettext-tools/src/xgettext.h +++ b/gettext-tools/src/xgettext.h @@ -55,13 +55,6 @@ extern int verbose; extern enum is_syntax_check default_syntax_check[NSYNTAXCHECKS]; -/* Language dependent format string parser. - NULL if the language has no notion of format strings. */ -extern struct formatstring_parser *current_formatstring_parser1; -extern struct formatstring_parser *current_formatstring_parser2; -extern struct formatstring_parser *current_formatstring_parser3; -extern struct formatstring_parser *current_formatstring_parser4; - /* Record a flag in the appropriate backend's table. OPTIONSTRING has the syntax WORD:ARG:FLAG (as documented)