+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.
+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
| 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
| 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.
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 \
# (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
#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"
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. */
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. */
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)
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 16: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 17: /* --stringtable-output */
"--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);
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
/* 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);
#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"
__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
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]);
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'V':
break;
case CHAR_MAX + 1: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 2: /* --use-fuzzy */
}
/* compare the two files */
- compare (argv[optind], argv[optind + 1]);
+ compare (argv[optind], argv[optind + 1], input_syntax);
exit (EXIT_SUCCESS);
}
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;
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. */
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
/* 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);
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 2: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 3: /* --stringtable-output */
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)
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 2: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 3: /* --stringtable-output */
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)
#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"
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. */
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'V':
break;
case CHAR_MAX + 1: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
default:
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)
{
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 4: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 5: /* --stringtable-output */
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)
#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"
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
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;
output_file_name = optarg;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'r':
java_resource_name = optarg;
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;
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. */
/* 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);
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'S':
break;
case CHAR_MAX + 7: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 8: /* --stringtable-output */
}
/* 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
#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"
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. */
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'V':
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
}
/* 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);
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;
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 **));
/* 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
#include "message.h"
#include "str-list.h"
+#include "read-catalog-abstract.h"
#ifdef __cplusplus
extern msgdomain_list_ty *
catenate_msgdomain_list (string_list_ty *file_list,
+ catalog_input_format_ty input_syntax,
const char *to_code);
#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"
;
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);
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 'q':
break;
case CHAR_MAX + 5: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 6: /* --stringtable-output */
"--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)
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 ();
}
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;
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)
#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"
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;
break;
case 'P':
- input_syntax = syntax_properties;
+ input_syntax = &input_format_properties;
break;
case 's':
break;
case CHAR_MAX + 3: /* --stringtable-input */
- input_syntax = syntax_stringtable;
+ input_syntax = &input_format_stringtable;
break;
case CHAR_MAX + 4: /* --stringtable-output */
/* 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);
#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"
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)
};
+/* 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. */
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;
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,
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);
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
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "xalloc.h"
#include "pathname.h"
#include "error.h"
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);
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "error.h"
#include "exit.h"
#include "gettext.h"
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);
/* 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)
{
real_file_name = NULL;
gram_pos.line_number = 0;
}
+
+const struct catalog_input_format input_format_properties =
+{
+ properties_parse, /* parse */
+ true /* produces_utf8 */
+};
#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 */
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "message.h"
#include "pathname.h"
#include "error.h"
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);
/* 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)
{
real_file_name = NULL;
gram_pos.line_number = 0;
}
+
+const struct catalog_input_format input_format_stringtable =
+{
+ stringtable_parse, /* parse */
+ true /* produces_utf8 */
+};
#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 */
#include "pipe.h"
#include "wait-process.h"
#include "read-catalog.h"
+#include "read-po.h"
#include "xallocsa.h"
#include "error.h"
#include "exit.h"
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);
#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"
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;
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)
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);
}
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);
}
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);
}
#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"
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)
VARIABLE(formatstring_ycp)
VARIABLE(gram_max_allowed_errors)
VARIABLE(gram_pos)
-VARIABLE(input_syntax)
VARIABLE(less_than)
VARIABLE(line_comment)
VARIABLE(more_than)