]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Create an object-oriented interface for the catalog output formats.
authorBruno Haible <bruno@clisp.org>
Mon, 16 Oct 2006 12:28:26 +0000 (12:28 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:07 +0000 (12:14 +0200)
24 files changed:
gettext-tools/po/ChangeLog
gettext-tools/po/POTFILES.in
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/msgcomm.c
gettext-tools/src/msgconv.c
gettext-tools/src/msgen.c
gettext-tools/src/msgfilter.c
gettext-tools/src/msggrep.c
gettext-tools/src/msginit.c
gettext-tools/src/msgmerge.c
gettext-tools/src/msgunfmt.c
gettext-tools/src/msguniq.c
gettext-tools/src/write-po.c
gettext-tools/src/write-po.h
gettext-tools/src/write-properties.c
gettext-tools/src/write-properties.h
gettext-tools/src/write-stringtable.c
gettext-tools/src/write-stringtable.h
gettext-tools/src/xgettext.c

index 27e8b0ec00f6caf30df561b72013e42552a1b6b5..01887182a7ad15aef144540b86047a238af84a53 100644 (file)
@@ -1,3 +1,7 @@
+2006-10-15  Bruno Haible  <bruno@clisp.org>
+
+       * POTFILES.in: Add src/write-catalog.c.
+
 2006-10-02  Bruno Haible  <bruno@clisp.org>
 
        * fr.po: Update from Christophe Combelles <ccomb@free.fr>.
index b3a6fdbf5fddfd782b836d7ed3202e92d1d5c862..755bba6e3b607e233238a369513357ce39ff4d77 100644 (file)
@@ -83,6 +83,7 @@ src/read-stringtable.c
 src/read-tcl.c
 src/recode-sr-latin.c
 src/urlget.c
+src/write-catalog.c
 src/write-csharp.c
 src/write-java.c
 src/write-mo.c
index 31ade88261baa9c9ec73765114656dfb0debcf60..116e89ea41c55c679b18d8dc44413ee134cb5d2a 100644 (file)
@@ -1,3 +1,95 @@
+2006-10-15  Bruno Haible  <bruno@clisp.org>
+
+       * write-catalog.h: New file.
+       * write-catalog.c: New file, mostly extracted from write-po.c.
+       * write-po.h (message_page_width_set): Move declaration to
+       write-catalog.h.
+       (message_print_syntax_properties, message_print_syntax_stringtable):
+       Remove declarations.
+       (msgdomain_list_print): Move out to write-catalog.h, adding a
+       catalog_output_format_ty argument.
+       (msgdomain_list_sort_by_msgid, msgdomain_list_sort_by_filepos): Move
+       out to write-catalog.h.
+       (output_format_po): New declaration.
+       * write-po.c: Don't include fwriteerror.h, error-progname.h.
+       (page_width, message_page_width_set): Move out to write-catalog.c.
+       (use_syntax_properties): Remove variable.
+       (message_print_syntax_properties): Remove function.
+       (use_syntax_stringtable): Remove variable.
+       (message_print_syntax_stringtable): Remove function.
+       (wrap, message_print, message_print_obsolete, msgdomain_list_print_po):
+       Add page_width argument.
+       (msgdomain_list_print): Move out to write-catalog.c, adding a
+       catalog_output_format_ty argument.
+       (cmp_by_msgid, msgdomain_list_sort_by_msgid,
+       cmp_filepos, msgdomain_list_sort_filepos,
+       cmp_by_filepos, msgdomain_list_sort_by_filepos): Move out to
+       write-catalog.c.
+       (output_format_po): New variable.
+       * write-properties.h (msgdomain_list_print_properties): Remove
+       declaration.
+       (output_format_properties): New declaration.
+       * write-properties.c (msgdomain_list_print_properties): Make static.
+       (output_format_properties): New variable.
+       * write-stringtable.h (msgdomain_list_print_stringtable): Remove
+       declaration.
+       (output_format_stringtable): New declaration.
+       * write-stringtable.c (msgdomain_list_print_stringtable): Make static.
+       (output_format_stringtable): New variable.
+       * msgattrib.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgcat.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgcomm.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgconv.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgen.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgfilter.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msggrep.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msginit.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgmerge.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msgunfmt.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * msguniq.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (main): Change handling of --properties-output, --stringtable-output
+       options. Pass the output_syntax to msgdomain_list_print.
+       * xgettext.c: Include write-catalog.h, write-properties.h,
+       write-stringtable.h.
+       (output_syntax): Change type to catalog_output_format_ty.
+       (main): Update. Pass the output_syntax to msgdomain_list_print.
+       (finalize_header): Update.
+       * gettext-po.c: Include write-catalog.h.
+       (po_file_write): Specify PO syntax.
+       * Makefile.am (noinst_HEADERS): Add write-catalog.h.
+       (libgettextsrc_la_SOURCES): Add write.catalog.c.
+
 2006-10-05  Bruno Haible  <bruno@clisp.org>
 
        * lang-table.c (language_table): Add Adangme, Kashubian. Fix the
index 3fbd06142c7516dd6c9599179678786ba7deef16..905de77ef3058a01091056e6025bde7dc9bc4df4 100644 (file)
@@ -42,16 +42,21 @@ po-xerror.h
 po-xerror.c
                 Error handling during writing and reading of PO files.
 
-write-po.h
-write-po.c
-                Output of a list-of-messages to a PO file.
-write-properties.h
-write-properties.c
-                Output of a list-of-messages to a Java .properties file.
-write-stringtable.h
-write-stringtable.c
-                Output of a list-of-messages to a NeXTstep/GNUstep .strings
-                file.
++-------------- Writing PO files
+| write-catalog.h
+| write-catalog.c
+|               Output of a list-of-messages.
+| write-po.h
+| write-po.c
+|               Output of a list-of-messages to a PO file.
+| write-properties.h
+| write-properties.c
+|               Output of a list-of-messages to a Java .properties file.
+| write-stringtable.h
+| write-stringtable.c
+|               Output of a list-of-messages to a NeXTstep/GNUstep .strings
+|               file.
++-------------- Writing PO files
 
 +-------------- Reading PO files
 | open-po.h
index 6f0addec246803b27349d653f2a69c1c8247d117..613f537cdcf34fe5b1f021de0e529f9504d4f748 100644 (file)
@@ -40,7 +40,7 @@ noinst_HEADERS = pos.h message.h po-error.h po-xerror.h po-gram.h po-charset.h \
 po-lex.h open-po.h \
 read-po-abstract.h read-po.h read-properties.h read-stringtable.h \
 str-list.h \
-write-po.h write-properties.h write-stringtable.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 \
 msgl-charset.h msgl-equal.h msgl-iconv.h msgl-ascii.h msgl-cat.h \
 msgl-english.h msgl-check.h msgl-fsearch.h msgfmt.h msgunfmt.h \
@@ -123,7 +123,8 @@ format-php.c format-gcc-internal.c format-qt.c format-boost.c
 
 # libgettextsrc contains all code that is needed by at least two programs.
 libgettextsrc_la_SOURCES = \
-$(COMMON_SOURCE) read-po.c write-properties.c write-stringtable.c write-po.c \
+$(COMMON_SOURCE) read-po.c \
+write-catalog.c write-properties.c write-stringtable.c write-po.c \
 msgl-ascii.c msgl-iconv.c msgl-equal.c msgl-cat.c msgl-english.c msgl-check.c \
 file-list.c msgl-charset.c po-time.c plural-exp.c plural-eval.c plural-table.c \
 $(FORMAT_SOURCE)
index 597f14852fe9a7bd4937557e6ffcd73603894d99..1982c3d26382222f81a916227cd9580a78d713d7 100644 (file)
@@ -33,6 +33,7 @@
 #include "message.h"
 #include "xalloc.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
 #include "error.h"
 #include "xerror.h"
@@ -222,7 +223,7 @@ po_file_write (po_file_t file, const char *filename, po_xerror_handler_t handler
     (void (*) (int, const message_ty *, const char *, size_t, size_t, int, const char *, const message_ty *, const char *, size_t, size_t, int, const char *))
     handler->xerror2;
 
-  msgdomain_list_print (file->mdlp, filename, true, false);
+  msgdomain_list_print (file->mdlp, filename, &output_format_po, true, false);
 
   /* Restore error handler.  */
   po_xerror  = textmode_xerror;
index 276ff098b32b8fe58aad00e26af216fa5956b3db..aefbcd0642160eda254c75db2575ba130f8d9cb0 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "exit.h"
 #include "propername.h"
 #include "gettext.h"
@@ -135,6 +138,7 @@ main (int argc, char **argv)
   msgdomain_list_ty *only_mdlp;
   msgdomain_list_ty *ignore_mdlp;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_msgid = false;
   bool sort_by_filepos = false;
 
@@ -203,7 +207,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -299,7 +303,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 17: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       case CHAR_MAX + 18: /* --clear-previous */
@@ -366,7 +370,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 26b9f69fa3158b4a2d131c249029c8bbdaeaeb0e..60346fff5b27948577ee47276d83d0eb0eaa96f2 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "msgl-cat.h"
 #include "exit.h"
 #include "propername.h"
@@ -104,7 +107,7 @@ main (int argc, char **argv)
   const char *files_from;
   string_list_ty *file_list;
   msgdomain_list_ty *result;
-  input_syntax_ty output_syntax = syntax_po;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_msgid = false;
   bool sort_by_filepos = false;
 
@@ -198,8 +201,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
-       output_syntax = syntax_properties;
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -249,7 +251,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 4: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -300,11 +302,9 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     string_list_append_unique (file_list, argv[cnt]);
 
   /* Read input files, then filter, convert and merge messages.  */
-  result = catenate_msgdomain_list (file_list,
-                                   output_syntax != syntax_properties
-                                   && output_syntax != syntax_stringtable
-                                   ? to_code
-                                   : "UTF-8");
+  result =
+    catenate_msgdomain_list (file_list,
+                            output_syntax->requires_utf8 ? "UTF-8" : to_code);
 
   string_list_free (file_list);
 
@@ -315,7 +315,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 933abb95d5e897dc0207e13d892d90df2348743d..6303cc3aa99d40e4dba20727a8df0519616b5dbb 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "msgl-cat.h"
 #include "exit.h"
 #include "propername.h"
@@ -104,6 +107,7 @@ main (int argc, char *argv[])
   bool do_help = false;
   bool do_version = false;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_msgid = false;
   bool sort_by_filepos = false;
   const char *files_from = NULL;
@@ -196,7 +200,7 @@ main (int argc, char *argv[])
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -246,7 +250,7 @@ main (int argc, char *argv[])
        break;
 
       case CHAR_MAX + 4: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -321,7 +325,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 89767a0ac390ff32322f2a5ce98111456863868f..f98f4cc2d43db20e3e4fa602a7edd0b2b74b8c85 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "msgl-iconv.h"
 #include "localcharset.h"
 #include "exit.h"
@@ -96,7 +99,7 @@ main (int argc, char **argv)
   char *output_file;
   const char *input_file;
   msgdomain_list_ty *result;
-  input_syntax_ty output_syntax = syntax_po;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_filepos = false;
   bool sort_by_msgid = false;
 
@@ -160,8 +163,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
-       output_syntax = syntax_properties;
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -203,7 +205,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 3: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -257,8 +259,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
   result = read_po_file (input_file);
 
   /* Convert if and only if the output syntax supports different encodings.  */
-  if (output_syntax != syntax_properties
-      && output_syntax != syntax_stringtable)
+  if (!output_syntax->requires_utf8)
     result = iconv_msgdomain_list (result, to_code, input_file);
 
   /* Sort the results.  */
@@ -268,7 +269,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 9280e590f714723811bf9914afa36499a49b0003..3b8a4890e585624ee370a16e2ea39674b9c0aeb9 100644 (file)
 #include "message.h"
 #include "read-po.h"
 #include "msgl-english.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "exit.h"
 #include "propername.h"
 #include "gettext.h"
@@ -90,6 +93,7 @@ main (int argc, char **argv)
   bool do_version;
   char *output_file;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_filepos = false;
   bool sort_by_msgid = false;
 
@@ -151,7 +155,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -189,7 +193,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 3: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -246,7 +250,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 1407b8f779062e971d5f0421a7540f1e1f56a498..2120a6d7d7828e90c314a8c0b21e42fba4e0220c 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "msgl-charset.h"
 #include "xalloc.h"
 #include "exit.h"
@@ -149,6 +152,7 @@ main (int argc, char **argv)
   char *output_file;
   const char *input_file;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_filepos = false;
   bool sort_by_msgid = false;
   int i;
@@ -216,7 +220,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -262,7 +266,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 5: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -374,7 +378,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index f9ca9657d291d541a5068c8608a728bfb0399125..f6823ce259b40ed59c39456a77ba885b5efb9481 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "str-list.h"
 #include "msgl-charset.h"
 #include "xalloc.h"
@@ -146,6 +149,7 @@ main (int argc, char **argv)
   const char *input_file;
   int grep_pass;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_filepos = false;
   bool sort_by_msgid = false;
   size_t i;
@@ -310,7 +314,7 @@ error while reading \"%s\""), optarg);
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -376,7 +380,7 @@ error while reading \"%s\""), optarg);
        break;
 
       case CHAR_MAX + 8: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -464,7 +468,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the merged message list out.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index 9d462cebcba780b3e361c7814699d4e11bf8feb0..05595a4c6dfb569647e1cebfe3a702c439d674f3 100644 (file)
 #include "c-strcase.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "po-charset.h"
 #include "localcharset.h"
 #include "po-time.h"
@@ -148,6 +151,7 @@ main (int argc, char **argv)
   char *output_file;
   const char *input_file;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
 
   /* Set program name for messages.  */
   set_program_name (argv[0]);
@@ -202,7 +206,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -236,7 +240,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 4: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -323,7 +327,7 @@ the output .po file through the --output-file option.\n"),
     result = update_msgstr_plurals (result);
 
   /* Write the modified message list out.  */
-  msgdomain_list_print (result, output_file, true, false);
+  msgdomain_list_print (result, output_file, output_syntax, true, false);
 
   if (!no_translator)
     fprintf (stderr, "\n");
index 12725879a16a9e27745af14177c038881a5b863d..181bde660d724d185cb9890d9ec9509cff06bfee 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "format.h"
 #include "xalloc.h"
 #include "xallocsa.h"
@@ -159,6 +162,7 @@ main (int argc, char **argv)
   char *output_file;
   msgdomain_list_ty *def;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_filepos = false;
   bool sort_by_msgid = false;
 
@@ -236,7 +240,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -294,7 +298,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 6: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       case CHAR_MAX + 7: /* --previous */
@@ -371,10 +375,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
 
   /* In update mode, --properties-input implies --properties-output.  */
   if (update_mode && input_syntax == syntax_properties)
-    message_print_syntax_properties ();
+    output_syntax = &output_format_properties;
   /* In update mode, --stringtable-input implies --stringtable-output.  */
   if (update_mode && input_syntax == syntax_stringtable)
-    message_print_syntax_stringtable ();
+    output_syntax = &output_format_stringtable;
 
   /* Merge the two files.  */
   result = merge (argv[optind], argv[optind + 1], &def);
@@ -417,13 +421,15 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
            }
 
          /* Write the merged message list out.  */
-         msgdomain_list_print (result, output_file, true, false);
+         msgdomain_list_print (result, output_file, output_syntax, true,
+                               false);
        }
     }
   else
     {
       /* Write the merged message list out.  */
-      msgdomain_list_print (result, output_file, force_po, false);
+      msgdomain_list_print (result, output_file, output_syntax, force_po,
+                           false);
     }
 
   exit (EXIT_SUCCESS);
index b82602efb413d308f7cf76dd61495bb034357d08..2e0cf236eb84d73a8a94fef5894d19e7d109b7e6 100644 (file)
 #include "read-csharp.h"
 #include "read-resources.h"
 #include "read-tcl.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "propername.h"
 #include "gettext.h"
 
@@ -117,6 +120,7 @@ main (int argc, char **argv)
   bool do_version = false;
   const char *output_file = "-";
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_msgid = false;
 
   /* Set program name for messages.  */
@@ -181,7 +185,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'r':
@@ -224,7 +228,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 3: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       case CHAR_MAX + 4: /* --csharp */
@@ -393,7 +397,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the resulting message list to the given .po file.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   /* No problems.  */
   exit (EXIT_SUCCESS);
index 379bbdfa7bdf2260936826b00f4194c24ccb065a..fe6e1fdddbc5af62b578279156e6fb62c9abb7aa 100644 (file)
 #include "basename.h"
 #include "message.h"
 #include "read-po.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "msgl-cat.h"
 #include "exit.h"
 #include "propername.h"
@@ -100,6 +103,7 @@ main (int argc, char **argv)
   const char *input_file;
   string_list_ty *file_list;
   msgdomain_list_ty *result;
+  catalog_output_format_ty output_syntax = &output_format_po;
   bool sort_by_msgid = false;
   bool sort_by_filepos = false;
 
@@ -174,7 +178,7 @@ main (int argc, char **argv)
        break;
 
       case 'p':
-       message_print_syntax_properties ();
+       output_syntax = &output_format_properties;
        break;
 
       case 'P':
@@ -225,7 +229,7 @@ main (int argc, char **argv)
        break;
 
       case CHAR_MAX + 4: /* --stringtable-output */
-       message_print_syntax_stringtable ();
+       output_syntax = &output_format_stringtable;
        break;
 
       default:
@@ -288,7 +292,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     msgdomain_list_sort_by_msgid (result);
 
   /* Write the PO file.  */
-  msgdomain_list_print (result, output_file, force_po, false);
+  msgdomain_list_print (result, output_file, output_syntax, force_po, false);
 
   exit (EXIT_SUCCESS);
 }
index de35b7b9f2190618649e2c06fa61a5e196ec249b..631f2047bf44db84655cb01c47004388cc32970b 100644 (file)
@@ -44,8 +44,6 @@
 #include "xalloc.h"
 #include "xallocsa.h"
 #include "c-strstr.h"
-#include "fwriteerror.h"
-#include "error-progname.h"
 #include "xvasprintf.h"
 #include "po-xerror.h"
 #include "gettext.h"
@@ -317,28 +315,7 @@ message_print_comment_flags (const message_ty *mp, FILE *fp, bool debug)
 }
 
 
-/* =========== Some parameters for use by 'msgdomain_list_print'. ========== */
-
-
-/* This variable controls the page width when printing messages.
-   Defaults to PAGE_WIDTH if not set.  Zero (0) given to message_page_-
-   width_set will result in no wrapping being performed.  */
-static size_t page_width = PAGE_WIDTH;
-
-void
-message_page_width_set (size_t n)
-{
-  if (n == 0)
-    {
-      page_width = INT_MAX;
-      return;
-    }
-
-  if (n < 20)
-    n = 20;
-
-  page_width = n;
-}
+/* ========= Some parameters for use by 'msgdomain_list_print_po'. ========= */
 
 
 /* This variable controls the extent to which the page width applies.
@@ -378,27 +355,7 @@ message_print_style_escape (bool flag)
 }
 
 
-/* Whether to output a file in Java .properties syntax.  */
-static bool use_syntax_properties = false;
-
-void
-message_print_syntax_properties ()
-{
-  use_syntax_properties = true;
-}
-
-
-/* Whether to output a file in NeXTstep/GNUstep .strings syntax.  */
-static bool use_syntax_stringtable = false;
-
-void
-message_print_syntax_stringtable ()
-{
-  use_syntax_stringtable = true;
-}
-
-
-/* ================ msgdomain_list_print() and subroutines. ================ */
+/* =============== msgdomain_list_print_po() and subroutines. =============== */
 
 
 /* A version of memcpy optimized for the case n <= 1.  */
@@ -419,7 +376,8 @@ memcpy_small (void *dst, const void *src, size_t n)
 
 static void
 wrap (const message_ty *mp, FILE *fp, const char *line_prefix, int extra_indent,
-      const char *name, const char *value, enum is_wrap do_wrap,
+      const char *name, const char *value,
+      enum is_wrap do_wrap, size_t page_width,
       const char *charset)
 {
   const char *canon_charset;
@@ -838,7 +796,7 @@ print_blank_line (FILE *fp)
 
 static void
 message_print (const message_ty *mp, FILE *fp, const char *charset,
-              bool blank_line, bool debug)
+              size_t page_width, bool blank_line, bool debug)
 {
   int extra_indent;
 
@@ -867,12 +825,14 @@ message_print (const message_ty *mp, FILE *fp, const char *charset,
   /* Print the previous msgid.  This helps the translator when the msgid has
      only slightly changed.  */
   if (mp->prev_msgctxt != NULL)
-    wrap (mp, fp, "#| ", 0, "msgctxt", mp->prev_msgctxt, mp->do_wrap, charset);
+    wrap (mp, fp, "#| ", 0, "msgctxt", mp->prev_msgctxt, mp->do_wrap,
+         page_width, charset);
   if (mp->prev_msgid != NULL)
-    wrap (mp, fp, "#| ", 0, "msgid", mp->prev_msgid, mp->do_wrap, charset);
+    wrap (mp, fp, "#| ", 0, "msgid", mp->prev_msgid, mp->do_wrap, page_width,
+         charset);
   if (mp->prev_msgid_plural != NULL)
     wrap (mp, fp, "#| ", 0, "msgid_plural", mp->prev_msgid_plural, mp->do_wrap,
-         charset);
+         page_width, charset);
   extra_indent = (mp->prev_msgctxt != NULL || mp->prev_msgid != NULL
                  || mp->prev_msgid_plural != NULL
                  ? 3
@@ -907,15 +867,16 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
     }
   if (mp->msgctxt != NULL)
     wrap (mp, fp, NULL, extra_indent, "msgctxt", mp->msgctxt, mp->do_wrap,
-         charset);
-  wrap (mp, fp, NULL, extra_indent, "msgid", mp->msgid, mp->do_wrap, charset);
+         page_width, charset);
+  wrap (mp, fp, NULL, extra_indent, "msgid", mp->msgid, mp->do_wrap,
+         page_width, charset);
   if (mp->msgid_plural != NULL)
     wrap (mp, fp, NULL, extra_indent, "msgid_plural", mp->msgid_plural,
-         mp->do_wrap, charset);
+         mp->do_wrap, page_width, charset);
 
   if (mp->msgid_plural == NULL)
     wrap (mp, fp, NULL, extra_indent, "msgstr", mp->msgstr, mp->do_wrap,
-         charset);
+         page_width, charset);
   else
     {
       char prefix_buf[20];
@@ -928,7 +889,7 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
        {
          sprintf (prefix_buf, "msgstr[%u]", i);
          wrap (mp, fp, NULL, extra_indent, prefix_buf, p, mp->do_wrap,
-               charset);
+               page_width, charset);
        }
     }
 }
@@ -936,7 +897,7 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
 
 static void
 message_print_obsolete (const message_ty *mp, FILE *fp, const char *charset,
-                       bool blank_line)
+                       size_t page_width, bool blank_line)
 {
   int extra_indent;
 
@@ -978,12 +939,14 @@ message_print_obsolete (const message_ty *mp, FILE *fp, const char *charset,
   /* Print the previous msgid.  This helps the translator when the msgid has
      only slightly changed.  */
   if (mp->prev_msgctxt != NULL)
-    wrap (mp, fp, "#~| ", 0, "msgctxt", mp->prev_msgctxt, mp->do_wrap, charset);
+    wrap (mp, fp, "#~| ", 0, "msgctxt", mp->prev_msgctxt, mp->do_wrap,
+         page_width, charset);
   if (mp->prev_msgid != NULL)
-    wrap (mp, fp, "#~| ", 0, "msgid", mp->prev_msgid, mp->do_wrap, charset);
+    wrap (mp, fp, "#~| ", 0, "msgid", mp->prev_msgid, mp->do_wrap, page_width,
+         charset);
   if (mp->prev_msgid_plural != NULL)
     wrap (mp, fp, "#~| ", 0, "msgid_plural", mp->prev_msgid_plural, mp->do_wrap,
-         charset);
+         page_width, charset);
   extra_indent = (mp->prev_msgctxt != NULL || mp->prev_msgid != NULL
                  || mp->prev_msgid_plural != NULL
                  ? 1
@@ -1017,15 +980,16 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
     }
   if (mp->msgctxt != NULL)
     wrap (mp, fp, "#~ ", extra_indent, "msgctxt", mp->msgctxt, mp->do_wrap,
-         charset);
-  wrap (mp, fp, "#~ ", extra_indent, "msgid", mp->msgid, mp->do_wrap, charset);
+         page_width, charset);
+  wrap (mp, fp, "#~ ", extra_indent, "msgid", mp->msgid, mp->do_wrap,
+       page_width, charset);
   if (mp->msgid_plural != NULL)
     wrap (mp, fp, "#~ ", extra_indent, "msgid_plural", mp->msgid_plural,
-         mp->do_wrap, charset);
+         mp->do_wrap, page_width, charset);
 
   if (mp->msgid_plural == NULL)
     wrap (mp, fp, "#~ ", extra_indent, "msgstr", mp->msgstr, mp->do_wrap,
-         charset);
+         page_width, charset);
   else
     {
       char prefix_buf[20];
@@ -1038,14 +1002,15 @@ different from yours. Consider using a pure ASCII msgid instead.\n\
        {
          sprintf (prefix_buf, "msgstr[%u]", i);
          wrap (mp, fp, "#~ ", extra_indent, prefix_buf, p, mp->do_wrap,
-               charset);
+               page_width, charset);
        }
     }
 }
 
 
 static void
-msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
+msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, size_t page_width,
+                        bool debug)
 {
   size_t j, k;
   bool blank_line;
@@ -1108,7 +1073,8 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
       for (j = 0; j < mlp->nitems; ++j)
        if (!mlp->item[j]->obsolete)
          {
-           message_print (mlp->item[j], fp, charset, blank_line, debug);
+           message_print (mlp->item[j], fp, charset, page_width, blank_line,
+                          debug);
            blank_line = true;
          }
 
@@ -1116,7 +1082,8 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
       for (j = 0; j < mlp->nitems; ++j)
        if (mlp->item[j]->obsolete)
          {
-           message_print_obsolete (mlp->item[j], fp, charset, blank_line);
+           message_print_obsolete (mlp->item[j], fp, charset, page_width,
+                                   blank_line);
            blank_line = true;
          }
 
@@ -1126,265 +1093,14 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
 }
 
 
-void
-msgdomain_list_print (msgdomain_list_ty *mdlp, const char *filename,
-                     bool force, bool debug)
-{
-  FILE *fp;
-
-  /* We will not write anything if, for every domain, we have no message
-     or only the header entry.  */
-  if (!force)
-    {
-      bool found_nonempty = false;
-      size_t k;
-
-      for (k = 0; k < mdlp->nitems; k++)
-       {
-         message_list_ty *mlp = mdlp->item[k]->messages;
-
-         if (!(mlp->nitems == 0
-               || (mlp->nitems == 1 && is_header (mlp->item[0]))))
-           {
-             found_nonempty = true;
-             break;
-           }
-       }
-
-      if (!found_nonempty)
-       return;
-    }
-
-  /* Check whether the output format can accomodate all messages.  */
-  if (use_syntax_properties || use_syntax_stringtable)
-    {
-      if (mdlp->nitems > 1)
-       {
-         if (use_syntax_properties)
-           po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false, _("\
-Cannot output multiple translation domains into a single file with Java .properties syntax. Try using PO file syntax instead."));
-         if (use_syntax_stringtable)
-           po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false, _("\
-Cannot output multiple translation domains into a single file with NeXTstep/GNUstep .strings syntax."));
-       }
-      if (mdlp->nitems == 1)
-       {
-         message_list_ty *mlp = mdlp->item[0]->messages;
-         const lex_pos_ty *has_context;
-         const lex_pos_ty *has_plural;
-         size_t j;
-
-         has_context = NULL;
-         for (j = 0; j < mlp->nitems; j++)
-           {
-             message_ty *mp = mlp->item[j];
-
-             if (mp->msgctxt != NULL)
-               {
-                 has_context = &mp->pos;
-                 break;
-               }
-           }
-
-         if (has_context != NULL)
-           {
-             error_with_progname = false;
-             po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
-                        has_context->file_name, has_context->line_number,
-                        (size_t)(-1), false, _("\
-message catalog has context dependent translations, but the output format does not support them."));
-             error_with_progname = true;
-           }
-
-         has_plural = NULL;
-         for (j = 0; j < mlp->nitems; j++)
-           {
-             message_ty *mp = mlp->item[j];
-
-             if (mp->msgid_plural != NULL)
-               {
-                 has_plural = &mp->pos;
-                 break;
-               }
-           }
-
-         if (has_plural != NULL)
-           {
-             error_with_progname = false;
-             if (use_syntax_properties)
-               po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
-                          has_plural->file_name, has_plural->line_number,
-                          (size_t)(-1), false, _("\
-message catalog has plural form translations, but the output format does not support them. Try generating a Java class using \"msgfmt --java\", instead of a properties file."));
-             if (use_syntax_stringtable)
-               po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
-                          has_plural->file_name, has_plural->line_number,
-                          (size_t)(-1), false, _("\
-message catalog has plural form translations, but the output format does not support them."));
-             error_with_progname = true;
-           }
-       }
-    }
-
-  /* Open the output file.  */
-  if (filename != NULL && strcmp (filename, "-") != 0
-      && strcmp (filename, "/dev/stdout") != 0)
-    {
-      fp = fopen (filename, "w");
-      if (fp == NULL)
-       {
-         const char *errno_description = strerror (errno);
-         po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                    xasprintf ("%s: %s",
-                               xasprintf (_("cannot create output file \"%s\""),
-                                          filename),
-                               errno_description));
-       }
-    }
-  else
-    {
-      fp = stdout;
-      /* xgettext:no-c-format */
-      filename = _("standard output");
-    }
-
-  if (use_syntax_properties)
-    msgdomain_list_print_properties (mdlp, fp, page_width, debug);
-  else if (use_syntax_stringtable)
-    msgdomain_list_print_stringtable (mdlp, fp, page_width, debug);
-  else
-    msgdomain_list_print_po (mdlp, fp, debug);
-
-  /* Make sure nothing went wrong.  */
-  if (fwriteerror (fp))
-    {
-      const char *errno_description = strerror (errno);
-      po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false,
-                xasprintf ("%s: %s",
-                           xasprintf (_("error while writing \"%s\" file"),
-                                      filename),
-                           errno_description));
-    }
-}
-
-
-/* =============================== Sorting. ================================ */
-
-
-static int
-cmp_by_msgid (const void *va, const void *vb)
-{
-  const message_ty *a = *(const message_ty **) va;
-  const message_ty *b = *(const message_ty **) vb;
-  /* Because msgids normally contain only ASCII characters, it is OK to
-     sort them as if we were in the C locale. And strcoll() in the C locale
-     is the same as strcmp().  */
-  return strcmp (a->msgid, b->msgid);
-}
-
-
-void
-msgdomain_list_sort_by_msgid (msgdomain_list_ty *mdlp)
-{
-  size_t k;
-
-  for (k = 0; k < mdlp->nitems; k++)
-    {
-      message_list_ty *mlp = mdlp->item[k]->messages;
-
-      if (mlp->nitems > 0)
-       qsort (mlp->item, mlp->nitems, sizeof (mlp->item[0]), cmp_by_msgid);
-    }
-}
-
-
-/* Sort the file positions of every message.  */
-
-static int
-cmp_filepos (const void *va, const void *vb)
-{
-  const lex_pos_ty *a = (const lex_pos_ty *) va;
-  const lex_pos_ty *b = (const lex_pos_ty *) vb;
-  int cmp;
-
-  cmp = strcmp (a->file_name, b->file_name);
-  if (cmp == 0)
-    cmp = (int) a->line_number - (int) b->line_number;
-
-  return cmp;
-}
-
-static void
-msgdomain_list_sort_filepos (msgdomain_list_ty *mdlp)
-{
-  size_t j, k;
-
-  for (k = 0; k < mdlp->nitems; k++)
-    {
-      message_list_ty *mlp = mdlp->item[k]->messages;
-
-      for (j = 0; j < mlp->nitems; j++)
-       {
-         message_ty *mp = mlp->item[j];
-
-         if (mp->filepos_count > 0)
-           qsort (mp->filepos, mp->filepos_count, sizeof (mp->filepos[0]),
-                  cmp_filepos);
-       }
-    }
-}
-
-
-/* Sort the messages according to the file position.  */
-
-static int
-cmp_by_filepos (const void *va, const void *vb)
+/* Describes a PO file in .po syntax.  */
+const struct catalog_output_format output_format_po =
 {
-  const message_ty *a = *(const message_ty **) va;
-  const message_ty *b = *(const message_ty **) vb;
-  int cmp;
-
-  /* No filepos is smaller than any other filepos.  */
-  if (a->filepos_count == 0)
-    {
-      if (b->filepos_count != 0)
-       return -1;
-    }
-  if (b->filepos_count == 0)
-    return 1;
-
-  /* Compare on the file names...  */
-  cmp = strcmp (a->filepos[0].file_name, b->filepos[0].file_name);
-  if (cmp != 0)
-    return cmp;
-
-  /* If they are equal, compare on the line numbers...  */
-  cmp = a->filepos[0].line_number - b->filepos[0].line_number;
-  if (cmp != 0)
-    return cmp;
-
-  /* If they are equal, compare on the msgid strings.  */
-  /* Because msgids normally contain only ASCII characters, it is OK to
-     sort them as if we were in the C locale. And strcoll() in the C locale
-     is the same as strcmp().  */
-  return strcmp (a->msgid, b->msgid);
-}
-
-
-void
-msgdomain_list_sort_by_filepos (msgdomain_list_ty *mdlp)
-{
-  size_t k;
-
-  /* It makes sense to compare filepos[0] of different messages only after
-     the filepos[] array of each message has been sorted.  Sort it now.  */
-  msgdomain_list_sort_filepos (mdlp);
-
-  for (k = 0; k < mdlp->nitems; k++)
-    {
-      message_list_ty *mlp = mdlp->item[k]->messages;
-
-      if (mlp->nitems > 0)
-       qsort (mlp->item, mlp->nitems, sizeof (mlp->item[0]), cmp_by_filepos);
-    }
-}
+  msgdomain_list_print_po,             /* print */
+  false,                               /* requires_utf8 */
+  true,                                        /* supports_multiple_domains */
+  true,                                        /* supports_contexts */
+  true,                                        /* supports_plurals */
+  false,                               /* alternative_is_po */
+  false                                        /* alternative_is_java_class */
+};
index ef947c75a6ffed65a237a670904f920ee5b2c29f..1095047a89e9d3c8d40ad1936e0096edea9a050f 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU gettext - internationalization aids
-   Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2003, 2006 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -51,9 +51,7 @@ extern void
        message_print_comment_flags (const message_ty *mp, FILE *fp,
                                    bool debug);
 
-/* These functions set some parameters for use by 'msgdomain_list_print'.  */
-extern void
-       message_page_width_set (size_t width);
+/* These functions set some parameters for use by 'output_format_po.print'.  */
 extern void
        message_page_width_ignore (void);
 extern void
@@ -62,23 +60,9 @@ extern void
        message_print_style_uniforum (void);
 extern void
        message_print_style_escape (bool flag);
-extern void
-       message_print_syntax_properties (void);
-extern void
-       message_print_syntax_stringtable (void);
 
-/* Output MDLP into a PO file with the given FILENAME, according to the
-   parameters set by the functions above.  */
-extern void
-       msgdomain_list_print (msgdomain_list_ty *mdlp,
-                            const char *filename,
-                            bool force, bool debug);
-
-/* Sort MDLP destructively according to the given criterion.  */
-extern void
-       msgdomain_list_sort_by_msgid (msgdomain_list_ty *mdlp);
-extern void
-       msgdomain_list_sort_by_filepos (msgdomain_list_ty *mdlp);
+/* Describes a PO file in .po syntax.  */
+extern const struct catalog_output_format output_format_po;
 
 
 #ifdef __cplusplus
index 0e74f20532b28f6a65d31c0ea0b022aae41bdb9a..8406a92628e3aa1641f1c7abafa3c1ef871195cd 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing Java .properties files.
-   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
@@ -273,7 +273,7 @@ write_properties (FILE *fp, message_list_ty *mlp, const char *canon_encoding,
 }
 
 /* Output the contents of a PO file in Java .properties syntax.  */
-void
+static void
 msgdomain_list_print_properties (msgdomain_list_ty *mdlp, FILE *fp,
                                 size_t page_width, bool debug)
 {
@@ -285,3 +285,15 @@ msgdomain_list_print_properties (msgdomain_list_ty *mdlp, FILE *fp,
     mlp = message_list_alloc (false);
   write_properties (fp, mlp, mdlp->encoding, page_width, debug);
 }
+
+/* Describes a PO file in Java .properties syntax.  */
+const struct catalog_output_format output_format_properties =
+{
+  msgdomain_list_print_properties,     /* print */
+  true,                                        /* requires_utf8 */
+  false,                               /* supports_multiple_domains */
+  false,                               /* supports_contexts */
+  false,                               /* supports_plurals */
+  true,                                        /* alternative_is_po */
+  true                                 /* alternative_is_java_class */
+};
index a866a6987192e7b1bbc380e91c56b6a0df36a3f8..def010a2feec8ad59ed3021ad51dd0bf169f720a 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing Java .properties files.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
 #ifndef _WRITE_PROPERTIES_H
 #define _WRITE_PROPERTIES_H
 
-#include <stdbool.h>
-#include <stdio.h>
-#include <stddef.h>
+#include "write-catalog.h"
 
-#include "message.h"
-
-/* Output the contents of a PO file in Java .properties syntax.  */
-extern void
-       msgdomain_list_print_properties (msgdomain_list_ty *mdlp, FILE *fp,
-                                       size_t page_width, bool debug);
+/* Describes a PO file in Java .properties syntax.  */
+extern const struct catalog_output_format output_format_properties;
 
 #endif /* _WRITE_PROPERTIES_H */
index 7a5fa5f0e0e049aaefc07e0929b6ec651d00ccf8..619a282bc6d9c22fa4647d66276ee3b173c91e4e 100644 (file)
@@ -297,7 +297,7 @@ write_stringtable (FILE *fp, message_list_ty *mlp, const char *canon_encoding,
 }
 
 /* Output the contents of a PO file in .strings syntax.  */
-void
+static void
 msgdomain_list_print_stringtable (msgdomain_list_ty *mdlp, FILE *fp,
                                  size_t page_width, bool debug)
 {
@@ -309,3 +309,15 @@ msgdomain_list_print_stringtable (msgdomain_list_ty *mdlp, FILE *fp,
     mlp = message_list_alloc (false);
   write_stringtable (fp, mlp, mdlp->encoding, page_width, debug);
 }
+
+/* Describes a PO file in .strings syntax.  */
+const struct catalog_output_format output_format_stringtable =
+{
+  msgdomain_list_print_stringtable,    /* print */
+  true,                                        /* requires_utf8 */
+  false,                               /* supports_multiple_domains */
+  false,                               /* supports_contexts */
+  false,                               /* supports_plurals */
+  false,                               /* alternative_is_po */
+  false                                        /* alternative_is_java_class */
+};
index 07dad168952471a2d2d0af9b1faec8b84fccae0f..e2fd6b9a67b711b74afeacaa3e9dd334c4b5334a 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing NeXTstep/GNUstep .strings files.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
 #ifndef _WRITE_STRINGTABLE_H
 #define _WRITE_STRINGTABLE_H
 
-#include <stdbool.h>
-#include <stdio.h>
-#include <stddef.h>
+#include "write-catalog.h"
 
-#include "message.h"
-
-/* Output the contents of a PO file in .strings syntax.  */
-extern void
-       msgdomain_list_print_stringtable (msgdomain_list_ty *mdlp, FILE *fp,
-                                        size_t page_width, bool debug);
+/* Describes a PO file in .strings syntax.  */
+extern const struct catalog_output_format output_format_stringtable;
 
 #endif /* _WRITE_STRINGTABLE_H */
index 6c0c81c24a04b777ca1d48112b1a478293074d6d..ac0a46f3300fbdbe87415284df5f272a09bd793c 100644 (file)
 #include "msgl-iconv.h"
 #include "msgl-ascii.h"
 #include "po-time.h"
+#include "write-catalog.h"
 #include "write-po.h"
+#include "write-properties.h"
+#include "write-stringtable.h"
 #include "format.h"
 #include "propername.h"
 #include "gettext.h"
@@ -132,7 +135,7 @@ static const char *msgstr_suffix;
 static char *output_dir;
 
 /* The output syntax: .pot or .properties or .strings.  */
-static input_syntax_ty output_syntax = syntax_po;
+static catalog_output_format_ty output_syntax = &output_format_po;
 
 /* If nonzero omit header with information about this run.  */
 int xgettext_omit_header;
@@ -486,12 +489,10 @@ main (int argc, char *argv[])
        msgid_bugs_address = optarg;
        break;
       case CHAR_MAX + 6:       /* --properties-output */
-       message_print_syntax_properties ();
-       output_syntax = syntax_properties;
+       output_syntax = &output_format_properties;
        break;
       case CHAR_MAX + 7:       /* --stringtable-output */
-       message_print_syntax_stringtable ();
-       output_syntax = syntax_stringtable;
+       output_syntax = &output_format_stringtable;
        break;
       case CHAR_MAX + 8:       /* --flag */
        xgettext_record_flag (optarg);
@@ -722,7 +723,7 @@ warning: file `%s' extension `%s' is unknown; will try C"), filename, extension)
     msgdomain_list_sort_by_msgid (mdlp);
 
   /* Write the PO file.  */
-  msgdomain_list_print (mdlp, file_name, force_po, do_debug);
+  msgdomain_list_print (mdlp, file_name, output_syntax, force_po, do_debug);
 
   exit (EXIT_SUCCESS);
 }
@@ -2888,9 +2889,7 @@ finalize_header (msgdomain_list_ty *mdlp)
          has_nonascii = true;
       }
 
-    if (has_nonascii
-       || output_syntax == syntax_properties
-       || output_syntax == syntax_stringtable)
+    if (has_nonascii || output_syntax->requires_utf8)
       {
        message_list_ty *mlp = mdlp->item[0]->messages;