summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-10-18 11:29:15 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:14:09 +0200
commitf1d3290e2043a85fcba1a7f6107c10fc16fcc508 (patch)
treea59c1050a91df71e29958b0ea4018bf785ced334
parent412d2b4a7ba134358d037fee01d986b5c3be3f20 (diff)
downloadexternal_gettext-f1d3290e2043a85fcba1a7f6107c10fc16fcc508.zip
external_gettext-f1d3290e2043a85fcba1a7f6107c10fc16fcc508.tar.gz
external_gettext-f1d3290e2043a85fcba1a7f6107c10fc16fcc508.tar.bz2
Create an object-oriented interface for the catalog input formats.
-rw-r--r--gettext-tools/ChangeLog4
-rw-r--r--gettext-tools/src/ChangeLog89
-rw-r--r--gettext-tools/src/FILES5
-rw-r--r--gettext-tools/src/Makefile.am7
-rw-r--r--gettext-tools/src/gettext-po.c13
-rw-r--r--gettext-tools/src/msgattrib.c18
-rw-r--r--gettext-tools/src/msgcat.c10
-rw-r--r--gettext-tools/src/msgcmp.c19
-rw-r--r--gettext-tools/src/msgcomm.c10
-rw-r--r--gettext-tools/src/msgconv.c10
-rw-r--r--gettext-tools/src/msgen.c15
-rw-r--r--gettext-tools/src/msgexec.c10
-rw-r--r--gettext-tools/src/msgfilter.c10
-rw-r--r--gettext-tools/src/msgfmt.c22
-rw-r--r--gettext-tools/src/msggrep.c10
-rw-r--r--gettext-tools/src/msginit.c10
-rw-r--r--gettext-tools/src/msgl-cat.c6
-rw-r--r--gettext-tools/src/msgl-cat.h4
-rw-r--r--gettext-tools/src/msgmerge.c24
-rw-r--r--gettext-tools/src/msguniq.c10
-rw-r--r--gettext-tools/src/read-catalog-abstract.c22
-rw-r--r--gettext-tools/src/read-catalog-abstract.h26
-rw-r--r--gettext-tools/src/read-catalog.c15
-rw-r--r--gettext-tools/src/read-catalog.h15
-rw-r--r--gettext-tools/src/read-csharp.c3
-rw-r--r--gettext-tools/src/read-java.c3
-rw-r--r--gettext-tools/src/read-properties.c8
-rw-r--r--gettext-tools/src/read-properties.h7
-rw-r--r--gettext-tools/src/read-resources.c3
-rw-r--r--gettext-tools/src/read-stringtable.c8
-rw-r--r--gettext-tools/src/read-stringtable.h7
-rw-r--r--gettext-tools/src/read-tcl.c3
-rw-r--r--gettext-tools/src/x-po.c15
-rw-r--r--gettext-tools/src/xgettext.c3
-rw-r--r--gettext-tools/woe32dll/gettextsrc-exports.c1
35 files changed, 305 insertions, 140 deletions
diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog
index 97729f3..e3a5f10 100644
--- a/gettext-tools/ChangeLog
+++ b/gettext-tools/ChangeLog
@@ -1,3 +1,7 @@
+2006-10-15 Bruno Haible <bruno@clisp.org>
+
+ * woe32dll/gettextsrc-exports.c: Remove input_syntax.
+
2006-10-02 Bruno Haible <bruno@clisp.org>
* Makefile.am (EXTRA_DIST): Add gnulib-m4/gnulib-cache.m4.
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 70a5234..a12ef56 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,5 +1,94 @@
2006-10-15 Bruno Haible <bruno@clisp.org>
+ * read-catalog-abstract.h (input_syntax_ty): Remove type.
+ (catalog_input_format): New structure type.
+ (catalog_input_format_ty): New type.
+ (catalog_reader_parse): Change type of input_syntax argument.
+ * read-catalog.h (input_syntax): Remove variable.
+ (read_catalog_stream, read_catalog_file): Add input_syntax argument.
+ * msgl-cat.h: Include read-catalog-abstract.h.
+ (catenate_msgdomain_list): Add input_syntax argument.
+ * read-po.h: New file.
+ * read-po.c: New file, extracted from read-catalog-abstract.c.
+ * msgattrib.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file calls.
+ * msgcat.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update catenate_msgdomain_list call.
+ * msgcmp.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update compare call.
+ (compare): Add input_syntax argument.
+ * msgcomm.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update catenate_msgdomain_list call.
+ * msgconv.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file call.
+ * msgen.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file call.
+ * msgexec.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file call.
+ * msgfilter.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file call.
+ * msgfmt.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file_msgfmt call.
+ (read_catalog_file_msgfmt): Add input_syntax argument.
+ * msggrep.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file call.
+ * msginit.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update read_catalog_file call.
+ * msgl-cat.c (catenate_msgdomain_list): Add input_syntax argument.
+ * msgmerge.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update merge call.
+ (compendium): Read it in PO syntax.
+ (merge): Add input_syntax argument.
+ * msguniq.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (main): Change handling of --properties-input, --stringtable-input
+ options. Update catenate_msgdomain_list call.
+ * read-catalog-abstract.c: Don't include po-gram.h, read-properties.h,
+ read-stringtable.h.
+ (catalog_reader_parse): Change type of input_syntax argument. Invoke
+ the parser indirectly.
+ * read-catalog.c (input_syntax): Remove variable.
+ (read_catalog_stream, read_catalog_file): Add input_syntax argument.
+ * read-csharp.c: Include read-po.h.
+ (execute_and_read_po_output): Update read_catalog_stream call.
+ * read-java.c: Include read-po.h.
+ (execute_and_read_po_output): Update read_catalog_stream call.
+ * read-properties.c (properties_parse): Make static.
+ (input_format_properties): New variable.
+ * read-properties.h (properties_parse): Remove declaration.
+ (input_format_properties): New declaration.
+ * read-resources.c: Include read-po.h.
+ (execute_and_read_po_output): Update read_catalog_stream call.
+ * read-stringtable.c (stringtable_parse): Make static.
+ (input_format_stringtable): New variable.
+ * read-stringtable.h (stringtable_parse): Remove declaration.
+ (input_format_stringtable): New declaration.
+ * read-tcl.c: Include read-po.h.
+ (msgdomain_read_tcl): Update read_catalog_stream call.
+ * x-po.c: Include read-po.h, read-properties.h, read-stringtable.h.
+ (extract): Change type of input_syntax argument.
+ (extract_po, extract_properties, extract_stringtable): Update.
+ * xgettext.c: Include read-po.h.
+ (read_exclusion_file): Read it in PO syntax.
+ * gettext-po.c: Include read-po.h.
+ (po_file_read_v3, po_file_read_v2, po_file_read): Update
+ read_catalog_stream call.
+ * Makefile.am (noinst_HEADERS): Add read-po.h.
+ (COMMON_SOURCE): Add read-po.c.
+
+2006-10-15 Bruno Haible <bruno@clisp.org>
+
* read-catalog-abstract.h (abstract_catalog_reader_ty): Renamed from
abstract_po_reader_ty.
(abstract_catalog_reader_class_ty): Renamed from
diff --git a/gettext-tools/src/FILES b/gettext-tools/src/FILES
index 7be1c04..1b3eac9 100644
--- a/gettext-tools/src/FILES
+++ b/gettext-tools/src/FILES
@@ -74,6 +74,8 @@ po-xerror.c
| read-catalog-abstract.h
| po-gram.h
| po-gram-gen.y
+| read-po.h
+| read-po.c
| read-properties.h
| read-properties.c
| read-stringtable.h
@@ -86,6 +88,9 @@ po-xerror.c
| po-gram.h
| po-gram-gen.y
| Parsing of PO files, based on po-lex.{h,c}.
+| read-po.h
+| read-po.c
+| Parsing of PO files.
| read-properties.h
| read-properties.c
| Parsing of Java .properties files.
diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am
index e7d87ec..14e8eef 100644
--- a/gettext-tools/src/Makefile.am
+++ b/gettext-tools/src/Makefile.am
@@ -37,8 +37,8 @@ lib_LTLIBRARIES = libgettextsrc.la libgettextpo.la
nodist_include_HEADERS = gettext-po.h
noinst_HEADERS = pos.h message.h po-error.h po-xerror.h po-gram.h po-charset.h \
-po-lex.h open-catalog.h \
-read-catalog-abstract.h read-catalog.h read-properties.h read-stringtable.h \
+po-lex.h open-catalog.h read-catalog-abstract.h read-catalog.h \
+read-po.h read-properties.h read-stringtable.h \
str-list.h \
write-catalog.h write-po.h write-properties.h write-stringtable.h \
dir-list.h file-list.h po-gram-gen.h po-gram-gen2.h \
@@ -107,7 +107,8 @@ endif
# (read-catalog-abstract.c <--> po-gram-gen.y <--> po-lex.c) -> message.c -> str-list.c.
COMMON_SOURCE = message.c po-error.c po-xerror.c \
read-catalog-abstract.c po-lex.c po-gram-gen.y po-charset.c \
-read-properties.c read-stringtable.c open-catalog.c dir-list.c str-list.c
+read-po.c read-properties.c read-stringtable.c open-catalog.c \
+dir-list.c str-list.c
# xgettext and msgfmt deal with format strings.
if !WOE32DLL
diff --git a/gettext-tools/src/gettext-po.c b/gettext-tools/src/gettext-po.c
index fa7f0c1..e23f686 100644
--- a/gettext-tools/src/gettext-po.c
+++ b/gettext-tools/src/gettext-po.c
@@ -33,6 +33,7 @@
#include "message.h"
#include "xalloc.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "write-catalog.h"
#include "write-po.h"
#include "error.h"
@@ -121,8 +122,8 @@ po_file_read (const char *filename, po_xerror_handler_t handler)
file = (struct po_file *) xmalloc (sizeof (struct po_file));
file->real_filename = filename;
file->logical_filename = filename;
- file->mdlp =
- read_catalog_stream (fp, file->real_filename, file->logical_filename);
+ file->mdlp = read_catalog_stream (fp, file->real_filename,
+ file->logical_filename, &input_format_po);
file->domains = NULL;
/* Restore error handler. */
@@ -164,8 +165,8 @@ po_file_read_v2 (const char *filename, po_error_handler_t handler)
file = (struct po_file *) xmalloc (sizeof (struct po_file));
file->real_filename = filename;
file->logical_filename = filename;
- file->mdlp =
- read_catalog_stream (fp, file->real_filename, file->logical_filename);
+ file->mdlp = read_catalog_stream (fp, file->real_filename,
+ file->logical_filename, &input_format_po);
file->domains = NULL;
/* Restore error handler. */
@@ -202,8 +203,8 @@ po_file_read (const char *filename)
file = (struct po_file *) xmalloc (sizeof (struct po_file));
file->real_filename = filename;
file->logical_filename = filename;
- file->mdlp =
- read_catalog_stream (fp, file->real_filename, file->logical_filename);
+ file->mdlp = read_catalog_stream (fp, file->real_filename,
+ file->logical_filename, &input_format_po);
file->domains = NULL;
if (fp != stdin)
diff --git a/gettext-tools/src/msgattrib.c b/gettext-tools/src/msgattrib.c
index d3ff75a..a1275d0 100644
--- a/gettext-tools/src/msgattrib.c
+++ b/gettext-tools/src/msgattrib.c
@@ -36,6 +36,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -138,6 +141,7 @@ main (int argc, char **argv)
msgdomain_list_ty *only_mdlp;
msgdomain_list_ty *ignore_mdlp;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_msgid = false;
bool sort_by_filepos = false;
@@ -211,7 +215,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -299,7 +303,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 16: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 17: /* --stringtable-output */
@@ -354,11 +358,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"--sort-output", "--sort-by-file");
/* Read input file. */
- result = read_catalog_file (input_file);
+ result = read_catalog_file (input_file, input_syntax);
/* Read optional files that limit the extent of the attribute changes. */
- only_mdlp = (only_file != NULL ? read_catalog_file (only_file) : NULL);
- ignore_mdlp = (ignore_file != NULL ? read_catalog_file (ignore_file) : NULL);
+ only_mdlp = (only_file != NULL
+ ? read_catalog_file (only_file, input_syntax)
+ : NULL);
+ ignore_mdlp = (ignore_file != NULL
+ ? read_catalog_file (ignore_file, input_syntax)
+ : NULL);
/* Filter the messages and manipulate the attributes. */
result = process_msgdomain_list (result, only_mdlp, ignore_mdlp);
diff --git a/gettext-tools/src/msgcat.c b/gettext-tools/src/msgcat.c
index e0b31a3..b50e308 100644
--- a/gettext-tools/src/msgcat.c
+++ b/gettext-tools/src/msgcat.c
@@ -38,6 +38,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -107,6 +110,7 @@ main (int argc, char **argv)
const char *files_from;
string_list_ty *file_list;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_msgid = false;
bool sort_by_filepos = false;
@@ -205,7 +209,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -247,7 +251,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
@@ -303,7 +307,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
/* Read input files, then filter, convert and merge messages. */
result =
- catenate_msgdomain_list (file_list,
+ catenate_msgdomain_list (file_list, input_syntax,
output_syntax->requires_utf8 ? "UTF-8" : to_code);
string_list_free (file_list);
diff --git a/gettext-tools/src/msgcmp.c b/gettext-tools/src/msgcmp.c
index a79d61a..b0e3104 100644
--- a/gettext-tools/src/msgcmp.c
+++ b/gettext-tools/src/msgcmp.c
@@ -37,6 +37,9 @@
#include "message.h"
#include "exit.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "msgl-iconv.h"
#include "c-strstr.h"
#include "c-strcase.h"
@@ -76,7 +79,8 @@ static void usage (int status)
__attribute__ ((noreturn))
#endif
;
-static void compare (const char *fn1, const char *fn2);
+static void compare (const char *fn1, const char *fn2,
+ catalog_input_format_ty input_syntax);
int
@@ -85,6 +89,7 @@ main (int argc, char *argv[])
int optchar;
bool do_help;
bool do_version;
+ catalog_input_format_ty input_syntax = &input_format_po;
/* Set program name for messages. */
set_program_name (argv[0]);
@@ -126,7 +131,7 @@ main (int argc, char *argv[])
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'V':
@@ -134,7 +139,7 @@ main (int argc, char *argv[])
break;
case CHAR_MAX + 1: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 2: /* --use-fuzzy */
@@ -181,7 +186,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
}
/* compare the two files */
- compare (argv[optind], argv[optind + 1]);
+ compare (argv[optind], argv[optind + 1], input_syntax);
exit (EXIT_SUCCESS);
}
@@ -336,7 +341,7 @@ this message is used but not defined in %s"), fn1);
static void
-compare (const char *fn1, const char *fn2)
+compare (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax)
{
msgdomain_list_ty *def;
msgdomain_list_ty *ref;
@@ -345,11 +350,11 @@ compare (const char *fn1, const char *fn2)
message_list_ty *empty_list;
/* This is the master file, created by a human. */
- def = remove_obsoletes (read_catalog_file (fn1));
+ def = remove_obsoletes (read_catalog_file (fn1, input_syntax));
/* This is the generated file, created by groping the sources with
the xgettext program. */
- ref = remove_obsoletes (read_catalog_file (fn2));
+ ref = remove_obsoletes (read_catalog_file (fn2, input_syntax));
/* The references file can be either in ASCII or in UTF-8. If it is
in UTF-8, we have to convert the definitions to UTF-8 as well. */
diff --git a/gettext-tools/src/msgcomm.c b/gettext-tools/src/msgcomm.c
index 7659630..b38e5fd 100644
--- a/gettext-tools/src/msgcomm.c
+++ b/gettext-tools/src/msgcomm.c
@@ -38,6 +38,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -107,6 +110,7 @@ main (int argc, char *argv[])
bool do_help = false;
bool do_version = false;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_msgid = false;
bool sort_by_filepos = false;
@@ -204,7 +208,7 @@ main (int argc, char *argv[])
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -246,7 +250,7 @@ main (int argc, char *argv[])
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
@@ -314,7 +318,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
/* Read input files, then filter, convert and merge messages. */
allow_duplicates = true;
msgcomm_mode = true;
- result = catenate_msgdomain_list (file_list, to_code);
+ result = catenate_msgdomain_list (file_list, input_syntax, to_code);
string_list_free (file_list);
diff --git a/gettext-tools/src/msgconv.c b/gettext-tools/src/msgconv.c
index 24cb9cb..2b7e0b7 100644
--- a/gettext-tools/src/msgconv.c
+++ b/gettext-tools/src/msgconv.c
@@ -36,6 +36,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -99,6 +102,7 @@ main (int argc, char **argv)
char *output_file;
const char *input_file;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_filepos = false;
bool sort_by_msgid = false;
@@ -167,7 +171,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -201,7 +205,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 2: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 3: /* --stringtable-output */
@@ -256,7 +260,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
to_code = locale_charset ();
/* Read input file. */
- result = read_catalog_file (input_file);
+ result = read_catalog_file (input_file, input_syntax);
/* Convert if and only if the output syntax supports different encodings. */
if (!output_syntax->requires_utf8)
diff --git a/gettext-tools/src/msgen.c b/gettext-tools/src/msgen.c
index 248e54c..a748ba4 100644
--- a/gettext-tools/src/msgen.c
+++ b/gettext-tools/src/msgen.c
@@ -36,6 +36,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "msgl-english.h"
#include "write-catalog.h"
#include "write-po.h"
@@ -93,6 +96,7 @@ main (int argc, char **argv)
bool do_version;
char *output_file;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_filepos = false;
bool sort_by_msgid = false;
@@ -159,7 +163,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -189,7 +193,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 2: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 3: /* --stringtable-output */
@@ -240,8 +244,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
"--sort-output", "--sort-by-file");
- /* Read input file and add English translations. */
- result = msgdomain_list_english (read_catalog_file (argv[optind]));
+ /* Read input file. */
+ result = read_catalog_file (argv[optind], input_syntax);
+
+ /* Add English translations. */
+ result = msgdomain_list_english (result);
/* Sort the results. */
if (sort_by_filepos)
diff --git a/gettext-tools/src/msgexec.c b/gettext-tools/src/msgexec.c
index 38f27bc..3af467a 100644
--- a/gettext-tools/src/msgexec.c
+++ b/gettext-tools/src/msgexec.c
@@ -41,6 +41,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "xalloc.h"
#include "exit.h"
#include "full-write.h"
@@ -101,6 +104,7 @@ main (int argc, char **argv)
bool do_version;
const char *input_file;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
size_t i;
/* Set program name for messages. */
@@ -152,7 +156,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'V':
@@ -160,7 +164,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 1: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
default:
@@ -203,7 +207,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
input_file = "-";
/* Read input file. */
- result = read_catalog_file (input_file);
+ result = read_catalog_file (input_file, input_syntax);
if (strcmp (sub_name, "0") != 0)
{
diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c
index fe20333..8a15c7f 100644
--- a/gettext-tools/src/msgfilter.c
+++ b/gettext-tools/src/msgfilter.c
@@ -54,6 +54,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -152,6 +155,7 @@ main (int argc, char **argv)
char *output_file;
const char *input_file;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_filepos = false;
bool sort_by_msgid = false;
@@ -224,7 +228,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -262,7 +266,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 4: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 5: /* --stringtable-output */
@@ -342,7 +346,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
input_file = "-";
/* Read input file. */
- result = read_catalog_file (input_file);
+ result = read_catalog_file (input_file, input_syntax);
/* Recognize special programs as built-ins. */
if (strcmp (sub_name, "recode-sr-latin") == 0 && sub_argc == 1)
diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c
index 5035a7c..642bbe4 100644
--- a/gettext-tools/src/msgfmt.c
+++ b/gettext-tools/src/msgfmt.c
@@ -51,6 +51,9 @@
#include "message.h"
#include "open-catalog.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "po-charset.h"
#include "msgl-check.h"
#include "gettext.h"
@@ -188,7 +191,8 @@ static void usage (int status)
static const char *add_mo_suffix (const char *);
static struct msg_domain *new_domain (const char *name, const char *file_name);
static bool is_nonobsolete (const message_ty *mp);
-static void read_catalog_file_msgfmt (char *filename);
+static void read_catalog_file_msgfmt (char *filename,
+ catalog_input_format_ty input_syntax);
int
@@ -198,6 +202,7 @@ main (int argc, char *argv[])
bool do_help = false;
bool do_version = false;
bool strict_uniforum = false;
+ catalog_input_format_ty input_syntax = &input_format_po;
const char *canon_encoding;
struct msg_domain *domain;
@@ -273,7 +278,7 @@ main (int argc, char *argv[])
output_file_name = optarg;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'r':
java_resource_name = optarg;
@@ -321,7 +326,7 @@ main (int argc, char *argv[])
tcl_mode = true;
break;
case CHAR_MAX + 8: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 9: /* --qt */
qt_mode = true;
@@ -506,17 +511,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
current_domain = NULL;
/* And process the input file. */
- read_catalog_file_msgfmt (argv[optind]);
+ read_catalog_file_msgfmt (argv[optind], input_syntax);
++optind;
}
- /* We know a priori that properties_parse() and stringtable_parse() convert
+ /* We know a priori that some input_syntax->parse() functions convert
strings to UTF-8. */
- canon_encoding =
- (input_syntax == syntax_properties || input_syntax == syntax_stringtable
- ? po_charset_utf8
- : NULL);
+ canon_encoding = (input_syntax->produces_utf8 ? po_charset_utf8 : NULL);
/* Remove obsolete messages. They were only needed for duplicate
checking. */
@@ -1067,7 +1069,7 @@ static default_catalog_reader_class_ty msgfmt_methods =
/* Read .po file FILENAME and store translation pairs. */
static void
-read_catalog_file_msgfmt (char *filename)
+read_catalog_file_msgfmt (char *filename, catalog_input_format_ty input_syntax)
{
char *real_filename;
FILE *fp = open_catalog_file (filename, &real_filename, true);
diff --git a/gettext-tools/src/msggrep.c b/gettext-tools/src/msggrep.c
index 3dcaa93..fa3b3f0 100644
--- a/gettext-tools/src/msggrep.c
+++ b/gettext-tools/src/msggrep.c
@@ -47,6 +47,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -149,6 +152,7 @@ main (int argc, char **argv)
const char *input_file;
int grep_pass;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_filepos = false;
bool sort_by_msgid = false;
@@ -318,7 +322,7 @@ error while reading \"%s\""), optarg);
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'S':
@@ -376,7 +380,7 @@ error while reading \"%s\""), optarg);
break;
case CHAR_MAX + 7: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 8: /* --stringtable-output */
@@ -446,7 +450,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
}
/* Read input file. */
- result = read_catalog_file (input_file);
+ result = read_catalog_file (input_file, input_syntax);
if (grep_task[0].pattern_count > 0
|| grep_task[1].pattern_count > 0
diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c
index ebf3bbe..1d44b33 100644
--- a/gettext-tools/src/msginit.c
+++ b/gettext-tools/src/msginit.c
@@ -60,6 +60,9 @@
#include "c-strcase.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -151,6 +154,7 @@ main (int argc, char **argv)
char *output_file;
const char *input_file;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
/* Set program name for messages. */
@@ -210,7 +214,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'V':
@@ -236,7 +240,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
@@ -315,7 +319,7 @@ the output .po file through the --output-file option.\n"),
}
/* Read input file. */
- result = read_catalog_file (input_file);
+ result = read_catalog_file (input_file, input_syntax);
/* Fill the header entry. */
result = fill_header (result);
diff --git a/gettext-tools/src/msgl-cat.c b/gettext-tools/src/msgl-cat.c
index e600ffe..7cd92c6 100644
--- a/gettext-tools/src/msgl-cat.c
+++ b/gettext-tools/src/msgl-cat.c
@@ -104,7 +104,9 @@ is_message_first_needed (const message_ty *mp)
msgdomain_list_ty *
-catenate_msgdomain_list (string_list_ty *file_list, const char *to_code)
+catenate_msgdomain_list (string_list_ty *file_list,
+ catalog_input_format_ty input_syntax,
+ const char *to_code)
{
const char * const *files = file_list->item;
size_t nfiles = file_list->nitems;
@@ -119,7 +121,7 @@ catenate_msgdomain_list (string_list_ty *file_list, const char *to_code)
mdlps =
(msgdomain_list_ty **) xmalloc (nfiles * sizeof (msgdomain_list_ty *));
for (n = 0; n < nfiles; n++)
- mdlps[n] = read_catalog_file (files[n]);
+ mdlps[n] = read_catalog_file (files[n], input_syntax);
/* Determine the canonical name of each input file's encoding. */
canon_charsets = (const char ***) xmalloc (nfiles * sizeof (const char **));
diff --git a/gettext-tools/src/msgl-cat.h b/gettext-tools/src/msgl-cat.h
index 2674907..55e777d 100644
--- a/gettext-tools/src/msgl-cat.h
+++ b/gettext-tools/src/msgl-cat.h
@@ -1,5 +1,5 @@
/* Message list concatenation and duplicate handling.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,7 @@
#include "message.h"
#include "str-list.h"
+#include "read-catalog-abstract.h"
#ifdef __cplusplus
@@ -48,6 +49,7 @@ extern DLL_VARIABLE bool omit_header;
extern msgdomain_list_ty *
catenate_msgdomain_list (string_list_ty *file_list,
+ catalog_input_format_ty input_syntax,
const char *to_code);
diff --git a/gettext-tools/src/msgmerge.c b/gettext-tools/src/msgmerge.c
index 1f73e37..1cf3fb4 100644
--- a/gettext-tools/src/msgmerge.c
+++ b/gettext-tools/src/msgmerge.c
@@ -38,6 +38,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -150,6 +153,7 @@ static void usage (int status)
;
static void compendium (const char *filename);
static msgdomain_list_ty *merge (const char *fn1, const char *fn2,
+ catalog_input_format_ty input_syntax,
msgdomain_list_ty **defp);
@@ -162,6 +166,7 @@ main (int argc, char **argv)
char *output_file;
msgdomain_list_ty *def;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_filepos = false;
bool sort_by_msgid = false;
@@ -244,7 +249,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'q':
@@ -294,7 +299,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 5: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 6: /* --stringtable-output */
@@ -374,14 +379,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"--sort-output", "--sort-by-file");
/* In update mode, --properties-input implies --properties-output. */
- if (update_mode && input_syntax == syntax_properties)
+ if (update_mode && input_syntax == &input_format_properties)
output_syntax = &output_format_properties;
/* In update mode, --stringtable-input implies --stringtable-output. */
- if (update_mode && input_syntax == syntax_stringtable)
+ if (update_mode && input_syntax == &input_format_stringtable)
output_syntax = &output_format_stringtable;
/* Merge the two files. */
- result = merge (argv[optind], argv[optind + 1], &def);
+ result = merge (argv[optind], argv[optind + 1], input_syntax, &def);
/* Sort the results. */
if (sort_by_filepos)
@@ -583,7 +588,7 @@ compendium (const char *filename)
msgdomain_list_ty *mdlp;
size_t k;
- mdlp = read_catalog_file (filename);
+ mdlp = read_catalog_file (filename, &input_format_po);
if (compendiums == NULL)
{
compendiums = message_list_list_alloc ();
@@ -1351,7 +1356,8 @@ this message should not define plural forms"));
}
static msgdomain_list_ty *
-merge (const char *fn1, const char *fn2, msgdomain_list_ty **defp)
+merge (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax,
+ msgdomain_list_ty **defp)
{
msgdomain_list_ty *def;
msgdomain_list_ty *ref;
@@ -1365,11 +1371,11 @@ merge (const char *fn1, const char *fn2, msgdomain_list_ty **defp)
stats.merged = stats.fuzzied = stats.missing = stats.obsolete = 0;
/* This is the definitions file, created by a human. */
- def = read_catalog_file (fn1);
+ def = read_catalog_file (fn1, input_syntax);
/* This is the references file, created by groping the sources with
the xgettext program. */
- ref = read_catalog_file (fn2);
+ ref = read_catalog_file (fn2, input_syntax);
/* Add a dummy header entry, if the references file contains none. */
for (k = 0; k < ref->nitems; k++)
if (message_list_search (ref->item[k]->messages, NULL, "") == NULL)
diff --git a/gettext-tools/src/msguniq.c b/gettext-tools/src/msguniq.c
index e8dca96..6b27049 100644
--- a/gettext-tools/src/msguniq.c
+++ b/gettext-tools/src/msguniq.c
@@ -37,6 +37,9 @@
#include "basename.h"
#include "message.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "write-catalog.h"
#include "write-po.h"
#include "write-properties.h"
@@ -103,6 +106,7 @@ main (int argc, char **argv)
const char *input_file;
string_list_ty *file_list;
msgdomain_list_ty *result;
+ catalog_input_format_ty input_syntax = &input_format_po;
catalog_output_format_ty output_syntax = &output_format_po;
bool sort_by_msgid = false;
bool sort_by_filepos = false;
@@ -182,7 +186,7 @@ main (int argc, char **argv)
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
@@ -225,7 +229,7 @@ main (int argc, char **argv)
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
@@ -281,7 +285,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
/* Read input files, then filter, convert and merge messages. */
allow_duplicates = true;
- result = catenate_msgdomain_list (file_list, to_code);
+ result = catenate_msgdomain_list (file_list, input_syntax, to_code);
string_list_free (file_list);
diff --git a/gettext-tools/src/read-catalog-abstract.c b/gettext-tools/src/read-catalog-abstract.c
index 9406596..0d88a2b 100644
--- a/gettext-tools/src/read-catalog-abstract.c
+++ b/gettext-tools/src/read-catalog-abstract.c
@@ -28,9 +28,6 @@
#include <stdlib.h>
#include <string.h>
-#include "po-gram.h"
-#include "read-properties.h"
-#include "read-stringtable.h"
#include "xalloc.h"
#include "xvasprintf.h"
#include "po-xerror.h"
@@ -171,26 +168,11 @@ parse_end (abstract_catalog_reader_ty *pop)
void
catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp,
const char *real_filename, const char *logical_filename,
- input_syntax_ty syntax)
+ catalog_input_format_ty input_syntax)
{
/* Parse the stream's content. */
parse_start (pop);
- switch (syntax)
- {
- case syntax_po:
- lex_start (fp, real_filename, logical_filename);
- po_gram_parse ();
- lex_end ();
- break;
- case syntax_properties:
- properties_parse (pop, fp, real_filename, logical_filename);
- break;
- case syntax_stringtable:
- stringtable_parse (pop, fp, real_filename, logical_filename);
- break;
- default:
- abort ();
- }
+ input_syntax->parse (pop, fp, real_filename, logical_filename);
parse_end (pop);
if (error_message_count > 0)
diff --git a/gettext-tools/src/read-catalog-abstract.h b/gettext-tools/src/read-catalog-abstract.h
index ede334b..5d4fde1 100644
--- a/gettext-tools/src/read-catalog-abstract.h
+++ b/gettext-tools/src/read-catalog-abstract.h
@@ -129,27 +129,33 @@ struct abstract_catalog_reader_ty
};
+/* This structure describes a textual catalog input format. */
+struct catalog_input_format
+{
+ /* Parses the contents of FP, invoking the appropriate callbacks. */
+ void (*parse) (abstract_catalog_reader_ty *pop, FILE *fp,
+ const char *real_filename, const char *logical_filename);
+
+ /* Whether the parse function always produces messages encoded in UTF-8
+ encoding. */
+ bool produces_utf8;
+};
+
+typedef const struct catalog_input_format * catalog_input_format_ty;
+
+
/* Allocate a fresh abstract_catalog_reader_ty (or derived class) instance and
call its constructor. */
extern abstract_catalog_reader_ty *
catalog_reader_alloc (abstract_catalog_reader_class_ty *method_table);
-/* Kinds of PO file input syntaxes. */
-enum input_syntax_ty
-{
- syntax_po,
- syntax_properties,
- syntax_stringtable
-};
-typedef enum input_syntax_ty input_syntax_ty;
-
/* Read a PO file from a stream, and dispatch to the various
abstract_catalog_reader_class_ty methods. */
extern void
catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp,
const char *real_filename,
const char *logical_filename,
- input_syntax_ty syntax);
+ catalog_input_format_ty input_syntax);
/* Call the destructor and deallocate a abstract_catalog_reader_ty (or derived
class) instance. */
diff --git a/gettext-tools/src/read-catalog.c b/gettext-tools/src/read-catalog.c
index 82a4d1e..84fa5a0 100644
--- a/gettext-tools/src/read-catalog.c
+++ b/gettext-tools/src/read-catalog.c
@@ -463,13 +463,11 @@ int line_comment = 1;
appropriately. Defaults to false. */
bool allow_duplicates = false;
-/* Expected syntax of the input files. */
-input_syntax_ty input_syntax = syntax_po;
-
msgdomain_list_ty *
read_catalog_stream (FILE *fp, const char *real_filename,
- const char *logical_filename)
+ const char *logical_filename,
+ catalog_input_format_ty input_syntax)
{
default_catalog_reader_ty *pop;
msgdomain_list_ty *mdlp;
@@ -482,9 +480,8 @@ read_catalog_stream (FILE *fp, const char *real_filename,
pop->allow_duplicates_if_same_msgstr = false;
pop->mdlp = msgdomain_list_alloc (!pop->allow_duplicates);
pop->mlp = msgdomain_list_sublist (pop->mdlp, pop->domain, true);
- if (input_syntax == syntax_properties || input_syntax == syntax_stringtable)
- /* We know a priori that properties_parse() and stringtable_parse()
- convert strings to UTF-8. */
+ if (input_syntax->produces_utf8)
+ /* We know a priori that input_syntax->parse convert strings to UTF-8. */
pop->mdlp->encoding = po_charset_utf8;
po_lex_pass_obsolete_entries (true);
catalog_reader_parse ((abstract_catalog_reader_ty *) pop, fp, real_filename,
@@ -496,13 +493,13 @@ read_catalog_stream (FILE *fp, const char *real_filename,
msgdomain_list_ty *
-read_catalog_file (const char *filename)
+read_catalog_file (const char *filename, catalog_input_format_ty input_syntax)
{
char *real_filename;
FILE *fp = open_catalog_file (filename, &real_filename, true);
msgdomain_list_ty *result;
- result = read_catalog_stream (fp, real_filename, filename);
+ result = read_catalog_stream (fp, real_filename, filename, input_syntax);
if (fp != stdin)
fclose (fp);
diff --git a/gettext-tools/src/read-catalog.h b/gettext-tools/src/read-catalog.h
index 2f944b5..b147fa2 100644
--- a/gettext-tools/src/read-catalog.h
+++ b/gettext-tools/src/read-catalog.h
@@ -173,19 +173,20 @@ extern DLL_VARIABLE int line_comment;
appropriately. Defaults to false. */
extern DLL_VARIABLE bool allow_duplicates;
-/* Expected syntax of the input files. */
-extern DLL_VARIABLE input_syntax_ty input_syntax;
-
/* Read the input file from a stream. Returns a list of messages. */
-extern msgdomain_list_ty *read_catalog_stream (FILE *fp,
- const char *real_filename,
- const char *logical_filename);
+extern msgdomain_list_ty *
+ read_catalog_stream (FILE *fp,
+ const char *real_filename,
+ const char *logical_filename,
+ catalog_input_format_ty input_syntax);
/* Read the input file with the name INPUT_NAME. The ending .po is added
if necessary. If INPUT_NAME is not an absolute file name and the file is
not found, the list of directories in "dir-list.h" is searched. Returns
a list of messages. */
-extern msgdomain_list_ty *read_catalog_file (const char *input_name);
+extern msgdomain_list_ty *
+ read_catalog_file (const char *input_name,
+ catalog_input_format_ty input_syntax);
#ifdef __cplusplus
diff --git a/gettext-tools/src/read-csharp.c b/gettext-tools/src/read-csharp.c
index 4968d74..37da61c 100644
--- a/gettext-tools/src/read-csharp.c
+++ b/gettext-tools/src/read-csharp.c
@@ -34,6 +34,7 @@
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "xalloc.h"
#include "pathname.h"
#include "error.h"
@@ -73,7 +74,7 @@ execute_and_read_po_output (const char *progname,
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)");
+ l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
fclose (fp);
diff --git a/gettext-tools/src/read-java.c b/gettext-tools/src/read-java.c
index 1f7331c..3c9239e 100644
--- a/gettext-tools/src/read-java.c
+++ b/gettext-tools/src/read-java.c
@@ -34,6 +34,7 @@
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "error.h"
#include "exit.h"
#include "gettext.h"
@@ -71,7 +72,7 @@ execute_and_read_po_output (const char *progname,
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)");
+ l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
fclose (fp);
diff --git a/gettext-tools/src/read-properties.c b/gettext-tools/src/read-properties.c
index e880f5a..fc20c1e 100644
--- a/gettext-tools/src/read-properties.c
+++ b/gettext-tools/src/read-properties.c
@@ -445,7 +445,7 @@ read_escaped_string (bool in_key)
/* Read a .properties file from a stream, and dispatch to the various
abstract_catalog_reader_class_ty methods. */
-void
+static void
properties_parse (abstract_catalog_reader_ty *this, FILE *file,
const char *real_filename, const char *logical_filename)
{
@@ -548,3 +548,9 @@ properties_parse (abstract_catalog_reader_ty *this, FILE *file,
real_file_name = NULL;
gram_pos.line_number = 0;
}
+
+const struct catalog_input_format input_format_properties =
+{
+ properties_parse, /* parse */
+ true /* produces_utf8 */
+};
diff --git a/gettext-tools/src/read-properties.h b/gettext-tools/src/read-properties.h
index 847bdab..993f97e 100644
--- a/gettext-tools/src/read-properties.h
+++ b/gettext-tools/src/read-properties.h
@@ -21,10 +21,7 @@
#include "read-catalog-abstract.h"
-/* Read a .properties file from a stream, and dispatch to the various
- abstract_catalog_reader_class_ty methods. */
-extern void properties_parse (abstract_catalog_reader_ty *pop, FILE *fp,
- const char *real_filename,
- const char *logical_filename);
+/* Describes a .properties file parser. */
+extern const struct catalog_input_format input_format_properties;
#endif /* _READ_PROPERTIES_H */
diff --git a/gettext-tools/src/read-resources.c b/gettext-tools/src/read-resources.c
index fadae7a..9a5b999 100644
--- a/gettext-tools/src/read-resources.c
+++ b/gettext-tools/src/read-resources.c
@@ -34,6 +34,7 @@
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "message.h"
#include "pathname.h"
#include "error.h"
@@ -74,7 +75,7 @@ execute_and_read_po_output (const char *progname,
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)");
+ l->mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
fclose (fp);
diff --git a/gettext-tools/src/read-stringtable.c b/gettext-tools/src/read-stringtable.c
index 135cb18..771ce19 100644
--- a/gettext-tools/src/read-stringtable.c
+++ b/gettext-tools/src/read-stringtable.c
@@ -827,7 +827,7 @@ read_string (lex_pos_ty *pos)
/* Read a .strings file from a stream, and dispatch to the various
abstract_catalog_reader_class_ty methods. */
-void
+static void
stringtable_parse (abstract_catalog_reader_ty *pop, FILE *file,
const char *real_filename, const char *logical_filename)
{
@@ -957,3 +957,9 @@ warning: syntax error, expected '=' or ';' after string"));
real_file_name = NULL;
gram_pos.line_number = 0;
}
+
+const struct catalog_input_format input_format_stringtable =
+{
+ stringtable_parse, /* parse */
+ true /* produces_utf8 */
+};
diff --git a/gettext-tools/src/read-stringtable.h b/gettext-tools/src/read-stringtable.h
index 2c95444..8f50ba8 100644
--- a/gettext-tools/src/read-stringtable.h
+++ b/gettext-tools/src/read-stringtable.h
@@ -21,10 +21,7 @@
#include "read-catalog-abstract.h"
-/* Read a .strings file from a stream, and dispatch to the various
- abstract_catalog_reader_class_ty methods. */
-extern void stringtable_parse (abstract_catalog_reader_ty *pop, FILE *fp,
- const char *real_filename,
- const char *logical_filename);
+/* Describes a .strings file parser. */
+extern const struct catalog_input_format input_format_stringtable;
#endif /* _READ_STRINGTABLE_H */
diff --git a/gettext-tools/src/read-tcl.c b/gettext-tools/src/read-tcl.c
index d1e70de..d9f6b89 100644
--- a/gettext-tools/src/read-tcl.c
+++ b/gettext-tools/src/read-tcl.c
@@ -35,6 +35,7 @@
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "xallocsa.h"
#include "error.h"
#include "exit.h"
@@ -111,7 +112,7 @@ msgdomain_read_tcl (const char *locale_name, const char *directory)
error (EXIT_FAILURE, errno, _("fdopen() failed"));
/* Read the message list. */
- mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)");
+ mdlp = read_catalog_stream (fp, "(pipe)", "(pipe)", &input_format_po);
fclose (fp);
diff --git a/gettext-tools/src/x-po.c b/gettext-tools/src/x-po.c
index c4e6eab..a33490e 100644
--- a/gettext-tools/src/x-po.c
+++ b/gettext-tools/src/x-po.c
@@ -33,6 +33,9 @@
#include "x-stringtable.h"
#include "xalloc.h"
#include "read-catalog.h"
+#include "read-po.h"
+#include "read-properties.h"
+#include "read-stringtable.h"
#include "po-lex.h"
#include "gettext.h"
@@ -140,7 +143,7 @@ static default_catalog_reader_class_ty extract_methods =
static void
extract (FILE *fp,
const char *real_filename, const char *logical_filename,
- input_syntax_ty syntax,
+ catalog_input_format_ty input_syntax,
msgdomain_list_ty *mdlp)
{
default_catalog_reader_ty *pop;
@@ -156,7 +159,7 @@ extract (FILE *fp,
pop->mdlp = NULL;
pop->mlp = mdlp->item[0]->messages;
catalog_reader_parse ((abstract_catalog_reader_ty *) pop, fp, real_filename,
- logical_filename, syntax);
+ logical_filename, input_syntax);
catalog_reader_free ((abstract_catalog_reader_ty *) pop);
if (header_charset != NULL)
@@ -208,7 +211,7 @@ extract_po (FILE *fp,
flag_context_list_table_ty *flag_table,
msgdomain_list_ty *mdlp)
{
- extract (fp, real_filename, logical_filename, syntax_po, mdlp);
+ extract (fp, real_filename, logical_filename, &input_format_po, mdlp);
}
@@ -218,7 +221,8 @@ extract_properties (FILE *fp,
flag_context_list_table_ty *flag_table,
msgdomain_list_ty *mdlp)
{
- extract (fp, real_filename, logical_filename, syntax_properties, mdlp);
+ extract (fp, real_filename, logical_filename, &input_format_properties,
+ mdlp);
}
@@ -228,5 +232,6 @@ extract_stringtable (FILE *fp,
flag_context_list_table_ty *flag_table,
msgdomain_list_ty *mdlp)
{
- extract (fp, real_filename, logical_filename, syntax_stringtable, mdlp);
+ extract (fp, real_filename, logical_filename, &input_format_stringtable,
+ mdlp);
}
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index dbcfcf5..97d4230 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -53,6 +53,7 @@
#include "c-strcase.h"
#include "open-catalog.h"
#include "read-catalog-abstract.h"
+#include "read-po.h"
#include "message.h"
#include "po-charset.h"
#include "msgl-iconv.h"
@@ -971,7 +972,7 @@ read_exclusion_file (char *filename)
abstract_catalog_reader_ty *pop;
pop = catalog_reader_alloc (&exclude_methods);
- catalog_reader_parse (pop, fp, real_filename, filename, input_syntax);
+ catalog_reader_parse (pop, fp, real_filename, filename, &input_format_po);
catalog_reader_free (pop);
if (fp != stdin)
diff --git a/gettext-tools/woe32dll/gettextsrc-exports.c b/gettext-tools/woe32dll/gettextsrc-exports.c
index cbd6128..77504fd 100644
--- a/gettext-tools/woe32dll/gettextsrc-exports.c
+++ b/gettext-tools/woe32dll/gettextsrc-exports.c
@@ -45,7 +45,6 @@ VARIABLE(formatstring_tcl)
VARIABLE(formatstring_ycp)
VARIABLE(gram_max_allowed_errors)
VARIABLE(gram_pos)
-VARIABLE(input_syntax)
VARIABLE(less_than)
VARIABLE(line_comment)
VARIABLE(more_than)