]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Share some more code among extractors.
authorBruno Haible <bruno@clisp.org>
Sun, 4 Nov 2018 19:20:24 +0000 (20:20 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Nov 2018 23:25:34 +0000 (00:25 +0100)
* 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.

23 files changed:
gettext-tools/src/FILES
gettext-tools/src/Makefile.am
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-rst.c
gettext-tools/src/x-scheme.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
gettext-tools/src/xg-pos.c [new file with mode: 0644]
gettext-tools/src/xg-pos.h [new file with mode: 0644]

index 0a9bee97a4aac326430c0984e9899e436fec2a1c..c88750388fb624567330be41be48903ae2f841f2 100644 (file)
@@ -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.
index bf5ea0e883dffc4702ad0edc71e4df4ee044a591..7d0c7d8217e579f5094a4bb074b6350be66ab89b 100644 (file)
@@ -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 \
index b918b1b1777af7ca3a7faee5d3d83f1236665104..b97e298068f93ba282b1f29eb56976f7ac6f4f7c 100644 (file)
@@ -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;
 
index b13d77e7c2e819889bf104ad927b2348016646b8..3b4509955ac3a6a21b78bc29cf3080a6e88e5f60 100644 (file)
@@ -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;
 
index 8a26866010bc2f301a723c04be5e99180de5ed84..4656e5459844943c5763659cbf341b32c44d8130 100644 (file)
@@ -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;
 
index 50582f22c7f857aa73dfcf965c32faebf64a956d..75360eeedfe0ef03926f7dba69793acd154c6a34 100644 (file)
@@ -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;
 
index 3f65a5c1dcae9430c4ccd540feec715a1ebdb076..972cf32284aef944ff38c33c6f71ea072c319055 100644 (file)
@@ -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;
 
index fc144a0364919c7944c6959cfbd49b3c73578b42..ed0a09857e52911e1e08aa3fa7da787508dce9f3 100644 (file)
@@ -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;
 
index fb5601004334498102dfc97a9e919e04ac78669d..4fbc3073225b39b4dfc6d5eb8e7b742c7724662a 100644 (file)
@@ -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;
 
index fd2802d6f9124e0fb5a850b1946f73c398386c2d..ec6fadf4928b8c82af41e15aaa0f4ad9a8b2442d 100644 (file)
@@ -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;
 
index bd98adf25ef3441c2cc683e1a7b250263e5e2bb3..0d5ce6dc1775b38c2e9dffcbab7b7543582f00b5 100644 (file)
@@ -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
index ebae6d16bba200b88ee0487aa9785ca3a1a03f33..59b8df0558d9a5e9292c4ec9ef23f2a28393ef59 100644 (file)
@@ -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;
 
index dee1da4a4d3814ecc926bf5518951e0cb565e981..211943247e960f11a89142c294866ec3c12953f2 100644 (file)
@@ -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;
 
index 86e1b355b7ba65625b8f1b329d68a1027c3622e9..3cf8cb1c988b82c88ee0118eda3fd80ea9352745 100644 (file)
@@ -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;
 
index 512618d88a96d4295566af33fa26190b02cd548a..886163cc17fa6ef5d4175b50f8538737d7b40bc3 100644 (file)
@@ -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;
 
index 3faec32c3f0d7294cb21e3d2429017acf5644f7f..262d650a42fbc265884e59aa159cb9084fdae4ce 100644 (file)
@@ -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;
 
index 43cfdfda3b8a2be2d2f664378ba372e71e4f1689..a072f03a6fa741a7eeebcb97624fd299f361d38f 100644 (file)
@@ -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;
 
index 628a5aac83e52080fa6105a134622fed072310ed..a2c6bd658f813aef1f58f1a79f87aa77469d21a6 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "message.h"
 #include "xgettext.h"
+#include "xg-pos.h"
 #include "xg-message.h"
 #include "error.h"
 #include "xalloc.h"
 
 /* ======================== 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;
 
index 5517bc7ace8c517877f542dbe97362d5ad328724..78784e9aa74adfee6486ad1c741553195d09945c 100644 (file)
@@ -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;
 
index b74b834de334b576538a2b1ecbf4ef444aa88c4f..a33c48827dff879a742c9fef1a643131d351e65a 100644 (file)
@@ -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;
 
index 3dc7b50a66a94cb3c5106a990b3298e22cf739cb..0392718a812f7fe65f4c4ac80dbd903e4fb72188 100644 (file)
@@ -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 (file)
index 0000000..7eb06e9
--- /dev/null
@@ -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 <https://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#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 (file)
index 0000000..e875a04
--- /dev/null
@@ -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 <https://www.gnu.org/licenses/>.  */
+
+#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 */