]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Create an object-oriented interface for the catalog input formats.
authorBruno Haible <bruno@clisp.org>
Wed, 18 Oct 2006 11:29:15 +0000 (11:29 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:09 +0000 (12:14 +0200)
35 files changed:
gettext-tools/ChangeLog
gettext-tools/src/ChangeLog
gettext-tools/src/FILES
gettext-tools/src/Makefile.am
gettext-tools/src/gettext-po.c
gettext-tools/src/msgattrib.c
gettext-tools/src/msgcat.c
gettext-tools/src/msgcmp.c
gettext-tools/src/msgcomm.c
gettext-tools/src/msgconv.c
gettext-tools/src/msgen.c
gettext-tools/src/msgexec.c
gettext-tools/src/msgfilter.c
gettext-tools/src/msgfmt.c
gettext-tools/src/msggrep.c
gettext-tools/src/msginit.c
gettext-tools/src/msgl-cat.c
gettext-tools/src/msgl-cat.h
gettext-tools/src/msgmerge.c
gettext-tools/src/msguniq.c
gettext-tools/src/read-catalog-abstract.c
gettext-tools/src/read-catalog-abstract.h
gettext-tools/src/read-catalog.c
gettext-tools/src/read-catalog.h
gettext-tools/src/read-csharp.c
gettext-tools/src/read-java.c
gettext-tools/src/read-properties.c
gettext-tools/src/read-properties.h
gettext-tools/src/read-resources.c
gettext-tools/src/read-stringtable.c
gettext-tools/src/read-stringtable.h
gettext-tools/src/read-tcl.c
gettext-tools/src/x-po.c
gettext-tools/src/xgettext.c
gettext-tools/woe32dll/gettextsrc-exports.c

index 97729f329aa0acca1de533130899ce4028f0a3cc..e3a5f101e37f9d66db0c9104e9fe1f475599609e 100644 (file)
@@ -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.
index 70a5234021315c8ee57ebf8ab9c1d26b8a250cd3..a12ef56e4e87636a26fd5883b52145c77fe2368d 100644 (file)
@@ -1,3 +1,92 @@
+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
index 7be1c047203a6e54210587c9ea8e89514512e356..1b3eac9f56bd844afe9c3382d535ad50cd3d977c 100644 (file)
@@ -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.
index e7d87ec073c0851def77b31058e450a344986d7f..14e8eef23eeaa6b03e3081c45b4e71283cd2c00e 100644 (file)
@@ -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
index fa7f0c1e9990faaab5a79886eaf4750a7ef6c51c..e23f6863ef7bedca4f3417d5477a061b0db16f96 100644 (file)
@@ -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)
index d3ff75aaf2ef1c0a9eb91d6811751a35a9fca294..a1275d03c4b7691627de26b42515215eff49ac54 100644 (file)
@@ -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);
index e0b31a3624a4b084d091e79d6a43018f2905b846..b50e30893a80051b14e59e91c421000a82472944 100644 (file)
@@ -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);
index a79d61a4d2a98976d2764c1038436df7348cbd8f..b0e3104272e4f47f085ea763bc84cf011822ef22 100644 (file)
@@ -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.  */
index 76596303356471932fc4556b0d1565d211687fe2..b38e5fd6b6516fc4dade27f3648292d3f3b2ad20 100644 (file)
@@ -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);
 
index 24cb9cb411b303f378802cf8ff76279d6dcd6fa9..2b7e0b73e08530f55f93ede891571f7617686469 100644 (file)
@@ -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)
index 248e54ca5cd85265f81ec5257c2a9f2b9454ad36..a748ba4e2ced17429df754b67d3575863532a7a5 100644 (file)
@@ -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)
index 38f27bc7d27d995ddaeea72b2f740058060559cc..3af467acd31f3be7d8ebfb878ae24d1b495f4d5b 100644 (file)
@@ -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)
     {
index fe20333e6ec62a4ecddb649a3b763401c99cbb19..8a15c7fcd4dc695a18a9144dab170e248007782e 100644 (file)
@@ -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)
index 5035a7c0622034ccc863b79a72b07cb910a5b6f5..642bbe4d521e7a4665540d970c608533ea1fc530 100644 (file)
@@ -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);
index 3dcaa93bbf3c1b443aac24bf0bf02a36f6dff14e..fa3b3f0dd539085154956cb67efcc6c4d9dc05d1 100644 (file)
@@ -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
index ebf3bbe14f3c1d4ee475390f307602300f81bf8c..1d44b3374571a50d00ca859251bfdb3922ad275f 100644 (file)
@@ -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);
index e600ffede6b7c7ac5a5195e4ef41a100978a0c73..7cd92c6d74cad6633c1e56062bfe5c6782735a2a 100644 (file)
@@ -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 **));
index 26749078c1b319b77f393d2ad52b096d26b46bae..55e777da168eeb5b1ccdb0a2235d007d51c32ce1 100644 (file)
@@ -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);
 
 
index 1f73e3701f1845b629f286bc00a8766b75b2d18a..1cf3fb415820b502ce74feba28f479cf7c0326fd 100644 (file)
@@ -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)
index e8dca9689bad805fc64a759bcafbc4ba3120e54b..6b270493836422ce109e89a78f6912d18e436cc5 100644 (file)
@@ -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);
 
index 9406596b4ee7005262a84d7f5c63faec48067773..0d88a2b1a4ffaf26c7849eff005f6a11f70b10d4 100644 (file)
@@ -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)
index ede334b2504e89a6d9b019347d92eb77f57efe61..5d4fde1467f82b005d8f355e8dd2bdaf2d63b44a 100644 (file)
@@ -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.  */
index 82a4d1e6ba9556a91e81eaec62bf862c9830e383..84fa5a0e5a6dd53ae3c8856c8a0957ed8517cd8b 100644 (file)
@@ -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);
index 2f944b552dbf083d1ac75f3fbee17d87298b9d42..b147fa29920c32eb6cc8fac1a6232106b00b02e7 100644 (file)
@@ -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
index 4968d7476c1085d45ed5de261fdc73f25821aed8..37da61c0d2d540a1dd612c8c7a2fc65c9fe64e79 100644 (file)
@@ -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);
 
index 1f7331c3d524730b2e904fe156ad64500cfca0a8..3c9239eac8e9faaca627772bd477d313c904a231 100644 (file)
@@ -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);
 
index e880f5a847dc7dd48ff755b6cc7cbe101c02e57a..fc20c1edcbd4ae411e9b988274dbb7782a0843f2 100644 (file)
@@ -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 */
+};
index 847bdab39462a09108a6253ec505e12d81118c86..993f97e6d1ac8d9352aa7358f43496988d97a9a0 100644 (file)
 
 #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 */
index fadae7aaad16172d0a509ebafa63dcc7c466001c..9a5b999cac501b828d60bf89cae555c4279527b4 100644 (file)
@@ -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);
 
index 135cb18236a9f47693cf578b9ac3401f30d9ad4f..771ce1988528ce28eab863bd83280cefb5df2c80 100644 (file)
@@ -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 */
+};
index 2c95444ffd29d881bb4e0a3f7caff06decba71ed..8f50ba831dc100af5954103096be863594aa9536 100644 (file)
 
 #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 */
index d1e70dee4cf13da95c399393853f1bdf231f604b..d9f6b890a6c8cdd00a627fba8e238264df5d122d 100644 (file)
@@ -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);
 
index c4e6eabf69727fdb05f1d2fc0cf65d760d219288..a33490eef9623cf3f91606e6eba4085a5d1039df 100644 (file)
@@ -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);
 }
index dbcfcf593090298befec6eea09192cef615f0744..97d42300484df353285ae9ec8e3964f897c10256 100644 (file)
@@ -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)
index cbd61287008c7092381d0c4a650c4fa28232d283..77504fd2cffec8e276ba4325d5f9c4b2a33f1e14 100644 (file)
@@ -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)