From: Bruno Haible Date: Sun, 4 Nov 2018 19:20:24 +0000 (+0100) Subject: xgettext: Share some more code among extractors. X-Git-Tag: v0.20~265 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72e9af3b95448f2844102e83d11c8f298df97842;p=thirdparty%2Fgettext.git xgettext: Share some more code among extractors. * gettext-tools/src/xg-pos.h: New file. * gettext-tools/src/xg-pos.c: New file. * gettext-tools/src/Makefile.am (noinst_HEADERS): Add xg-pos.h. (xgettext_SOURCES): Add xg-pos.c. * gettext-tools/src/FILES: Update. * gettext-tools/src/x-awk.c: Include xg-pos.h. (real_file_name, logical_file_name, line_number): Remove variables. * gettext-tools/src/x-c.c: Likewise. * gettext-tools/src/x-csharp.c: Likewise. * gettext-tools/src/x-elisp.c: Likewise. * gettext-tools/src/x-java.c: Likewise. * gettext-tools/src/x-javascript.c: Likewise. * gettext-tools/src/x-librep.c: Likewise. * gettext-tools/src/x-lisp.c: Likewise. * gettext-tools/src/x-lua.c: Likewise. * gettext-tools/src/x-perl.c: Likewise. * gettext-tools/src/x-php.c: Likewise. * gettext-tools/src/x-python.c: Likewise. * gettext-tools/src/x-rst.c: Likewise. * gettext-tools/src/x-scheme.c: Likewise. * gettext-tools/src/x-sh.c: Likewise. * gettext-tools/src/x-smalltalk.c: Likewise. * gettext-tools/src/x-tcl.c: Likewise. * gettext-tools/src/x-vala.c: Likewise. * gettext-tools/src/x-ycp.c: Likewise. --- diff --git a/gettext-tools/src/FILES b/gettext-tools/src/FILES index 0a9bee97a..c88750388 100644 --- a/gettext-tools/src/FILES +++ b/gettext-tools/src/FILES @@ -287,6 +287,9 @@ msgl-check.c | Declarations used by the backends. | rc-str-list.h | A reference-counted list-of-immutable-strings type. +| xg-pos.h +| xg-pos.c +| The source file position. | xg-encoding.h | xg-encoding.c | Keeping track of the encoding of strings to be extracted. diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index bf5ea0e88..7d0c7d821 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -53,7 +53,7 @@ read-desktop.h write-desktop.h \ write-xml.h \ po-time.h plural-table.h lang-table.h format.h filters.h \ xgettext.h \ -rc-str-list.h xg-encoding.h xg-mixed-string.h xg-arglist-context.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 \ x-c.h x-po.h x-sh.h x-python.h x-lisp.h x-elisp.h x-librep.h \ x-scheme.h x-smalltalk.h x-java.h x-properties.h x-csharp.h x-awk.h x-ycp.h \ @@ -180,6 +180,7 @@ else xgettext_SOURCES = ../woe32dll/c++xgettext.cc endif xgettext_SOURCES += \ + xg-pos.c \ xg-encoding.c \ xg-mixed-string.c \ xg-arglist-context.c xg-arglist-callshape.c xg-arglist-parser.c \ diff --git a/gettext-tools/src/x-awk.c b/gettext-tools/src/x-awk.c index b918b1b17..b97e29806 100644 --- a/gettext-tools/src/x-awk.c +++ b/gettext-tools/src/x-awk.c @@ -31,6 +31,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -114,13 +115,6 @@ init_flag_table_awk () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index b13d77e7c..3b4509955 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -33,6 +33,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-mixed-string.h" #include "xg-arglist-context.h" @@ -555,13 +556,6 @@ init_flag_table_kde () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-csharp.c b/gettext-tools/src/x-csharp.c index 8a2686601..4656e5459 100644 --- a/gettext-tools/src/x-csharp.c +++ b/gettext-tools/src/x-csharp.c @@ -31,6 +31,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-mixed-string.h" #include "xg-arglist-context.h" @@ -131,13 +132,6 @@ init_flag_table_csharp () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-elisp.c b/gettext-tools/src/x-elisp.c index 50582f22c..75360eeed 100644 --- a/gettext-tools/src/x-elisp.c +++ b/gettext-tools/src/x-elisp.c @@ -31,6 +31,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -126,13 +127,6 @@ init_flag_table_elisp () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-java.c b/gettext-tools/src/x-java.c index 3f65a5c1d..972cf3228 100644 --- a/gettext-tools/src/x-java.c +++ b/gettext-tools/src/x-java.c @@ -31,6 +31,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" @@ -141,13 +142,6 @@ init_flag_table_java () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-javascript.c b/gettext-tools/src/x-javascript.c index fc144a036..ed0a09857 100644 --- a/gettext-tools/src/x-javascript.c +++ b/gettext-tools/src/x-javascript.c @@ -34,6 +34,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-mixed-string.h" #include "xg-arglist-context.h" @@ -142,13 +143,6 @@ init_flag_table_javascript () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-librep.c b/gettext-tools/src/x-librep.c index fb5601004..4fbc30732 100644 --- a/gettext-tools/src/x-librep.c +++ b/gettext-tools/src/x-librep.c @@ -32,6 +32,7 @@ #include "c-ctype.h" #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -128,13 +129,6 @@ init_flag_table_librep () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-lisp.c b/gettext-tools/src/x-lisp.c index fd2802d6f..ec6fadf49 100644 --- a/gettext-tools/src/x-lisp.c +++ b/gettext-tools/src/x-lisp.c @@ -31,6 +31,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -193,13 +194,6 @@ init_flag_table_lisp () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-lua.c b/gettext-tools/src/x-lua.c index bd98adf25..0d5ce6dc1 100644 --- a/gettext-tools/src/x-lua.c +++ b/gettext-tools/src/x-lua.c @@ -31,6 +31,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -123,15 +124,8 @@ init_flag_table_lua () xgettext_record_flag ("string.format:1:lua-format"); } -/* ======================== Reading of characters. ======================== */ - - -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; +/* ======================== Reading of characters. ======================== */ /* The input file stream. */ static FILE *fp; @@ -389,6 +383,7 @@ phase2_getc () return c; } + /* ========================== Reading of tokens. ========================== */ enum token_type_ty diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index ebae6d16b..59b8df055 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -32,6 +32,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" @@ -211,13 +212,6 @@ init_flag_table_perl () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c index dee1da4a4..211943247 100644 --- a/gettext-tools/src/x-php.c +++ b/gettext-tools/src/x-php.c @@ -31,6 +31,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -134,14 +135,6 @@ init_flag_table_php () /* ======================== Reading of characters. ======================== */ - -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-python.c b/gettext-tools/src/x-python.c index 86e1b355b..3cf8cb1c9 100644 --- a/gettext-tools/src/x-python.c +++ b/gettext-tools/src/x-python.c @@ -33,6 +33,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-mixed-string.h" #include "xg-arglist-context.h" @@ -157,13 +158,6 @@ init_flag_table_python () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-rst.c b/gettext-tools/src/x-rst.c index 512618d88..886163cc1 100644 --- a/gettext-tools/src/x-rst.c +++ b/gettext-tools/src/x-rst.c @@ -33,6 +33,7 @@ #include "po-charset.h" #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-mixed-string.h" #include "xg-message.h" @@ -277,13 +278,6 @@ extract_rst (FILE *f, /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-scheme.c b/gettext-tools/src/x-scheme.c index 3faec32c3..262d650a4 100644 --- a/gettext-tools/src/x-scheme.c +++ b/gettext-tools/src/x-scheme.c @@ -31,6 +31,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -152,13 +153,6 @@ init_flag_table_scheme () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 43cfdfda3..a072f03a6 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -31,6 +31,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" #include "xg-arglist-parser.h" @@ -144,13 +145,6 @@ init_flag_table_sh () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-smalltalk.c b/gettext-tools/src/x-smalltalk.c index 628a5aac8..a2c6bd658 100644 --- a/gettext-tools/src/x-smalltalk.c +++ b/gettext-tools/src/x-smalltalk.c @@ -29,6 +29,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-message.h" #include "error.h" #include "xalloc.h" @@ -67,14 +68,6 @@ /* ======================== Reading of characters. ======================== */ - -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-tcl.c b/gettext-tools/src/x-tcl.c index 5517bc7ac..78784e9aa 100644 --- a/gettext-tools/src/x-tcl.c +++ b/gettext-tools/src/x-tcl.c @@ -33,6 +33,7 @@ #include "message.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-arglist-context.h" #include "xg-arglist-callshape.h" @@ -132,13 +133,6 @@ init_flag_table_tcl () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-vala.c b/gettext-tools/src/x-vala.c index b74b834de..a33c48827 100644 --- a/gettext-tools/src/x-vala.c +++ b/gettext-tools/src/x-vala.c @@ -33,6 +33,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-encoding.h" #include "xg-mixed-string.h" #include "xg-arglist-context.h" @@ -149,13 +150,6 @@ init_flag_table_vala () /* ======================== Reading of characters. ======================== */ -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; - /* The input file stream. */ static FILE *fp; diff --git a/gettext-tools/src/x-ycp.c b/gettext-tools/src/x-ycp.c index 3dc7b50a6..0392718a8 100644 --- a/gettext-tools/src/x-ycp.c +++ b/gettext-tools/src/x-ycp.c @@ -32,6 +32,7 @@ #include "message.h" #include "rc-str-list.h" #include "xgettext.h" +#include "xg-pos.h" #include "xg-arglist-context.h" #include "xg-message.h" #include "error.h" @@ -63,13 +64,7 @@ init_flag_table_ycp () /* ======================== Reading of characters. ======================== */ - -/* Real filename, used in error messages about the input file. */ -static const char *real_file_name; - -/* Logical filename and line number, used to label the extracted messages. */ -static char *logical_file_name; -static int line_number; +/* Position in the current line. */ static int char_in_line; /* The input file stream. */ diff --git a/gettext-tools/src/xg-pos.c b/gettext-tools/src/xg-pos.c new file mode 100644 index 000000000..7eb06e9c8 --- /dev/null +++ b/gettext-tools/src/xg-pos.c @@ -0,0 +1,28 @@ +/* The source file position. + Copyright (C) 2001-2018 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-pos.h" + + +const char *real_file_name; + +char *logical_file_name; +int line_number; diff --git a/gettext-tools/src/xg-pos.h b/gettext-tools/src/xg-pos.h new file mode 100644 index 000000000..e875a04ee --- /dev/null +++ b/gettext-tools/src/xg-pos.h @@ -0,0 +1,43 @@ +/* The source file position. + Copyright (C) 1995-2018 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_POS_H +#define _XGETTEXT_POS_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/* These variables are set by the extractor and used by the extractor and + its auxiliary functions. They are *not* meant to be used by xgettext.c. */ + + +/* Real filename, used in error messages about the input file. */ +extern const char *real_file_name; + +/* Logical filename and line number, used to label the extracted messages. */ +extern char *logical_file_name; +extern int line_number; + + + +#ifdef __cplusplus +} +#endif + + +#endif /* _XGETTEXT_POS_H */