]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make it possible to use msgcat and msgconv on POT files.
authorBruno Haible <bruno@clisp.org>
Wed, 22 May 2002 12:37:46 +0000 (12:37 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:08:25 +0000 (12:08 +0200)
src/ChangeLog
src/msgconv.c
src/msgl-cat.c
src/msgl-iconv.c
src/msgl-iconv.h
src/write-java.c
src/write-tcl.c
src/x-glade.c
src/x-python.c
src/x-tcl.c

index 21d8e70c266cbb93da0910c0875b3956b73d4e34..fc498fd7d4df79d05a67109d73cea73237c236aa 100644 (file)
@@ -1,3 +1,20 @@
+2002-05-22  Bruno Haible  <bruno@clisp.org>
+
+       * msgl-iconv.h (iconv_message_list): Add from_filename argument.
+       (iconv_msgdomain_list): Likewise.
+       * msgl-iconv.c (iconv_message_list): Add from_filename argument.
+       Don't give an error for POT files containing charset=CHARSET.
+       (iconv_msgdomain_list): Add from_filename argument.
+       * msgl-cat.c (catenate_msgdomain_list): Don't give an error for
+       POT files containing charset=CHARSET. Pass input file name to
+       iconv_message_list.
+       * msgconv.c (main): Pass input file name to iconv_msgdomain_list.
+       * write-java.c (msgdomain_write_java): Update.
+       * write-tcl.c (msgdomain_write_tcl): Update.
+       * x-glade.c (do_extract_glade): Update.
+       * x-python.c (extract_python): Update.
+       * x-tcl.c (extract_tcl): Update.
+
 2002-05-18  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (RM): New variable.
index 49c2ccc08d7ffb39af2c326efcfa185b2a5822f9..4447aef509b0b3efe71a027115f1b1a3ba29785c 100644 (file)
@@ -223,7 +223,8 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     to_code = locale_charset ();
 
   /* Read input file and convert.  */
-  result = iconv_msgdomain_list (read_po_file (input_file), to_code);
+  result = iconv_msgdomain_list (read_po_file (input_file), to_code,
+                                input_file);
 
   /* Sort the results.  */
   if (sort_by_filepos)
index c0a23b98e7fbe8fb6dbd14c1461db321afda993d..d1807e3780744722ae3e53eaf3f6bafd367ddb59 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list concatenation and duplicate handling.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002 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
@@ -170,10 +170,24 @@ catenate_msgdomain_list (file_list, to_code)
 
                            canon_charset = po_charset_canonicalize (charset);
                            if (canon_charset == NULL)
-                             error (EXIT_FAILURE, 0,
-                                    _("\
+                             {
+                               /* Don't give an error for POT files, because
+                                  POT files usually contain only ASCII
+                                  msgids.  */
+                               const char *filename = files[n];
+                               size_t filenamelen = strlen (filename);
+
+                               if (filenamelen >= 4
+                                   && memcmp (filename + filenamelen - 4,
+                                              ".pot", 4) == 0
+                                   && strcmp (charset, "CHARSET") == 0)
+                                 canon_charset = po_charset_ascii;
+                               else
+                                 error (EXIT_FAILURE, 0,
+                                        _("\
 present charset \"%s\" is not a portable encoding name"),
-                                    charset);
+                                        charset);
+                             }
 
                            if (canon_from_code == NULL)
                              canon_from_code = canon_charset;
@@ -448,7 +462,7 @@ To select a different output encoding, use the --to-code option.\n\
               header entry with its canonical equivalent.  */
            if (!(to_code == NULL && canon_charsets[n][k] == canon_to_code))
              iconv_message_list (mdlp->item[k]->messages, canon_charsets[n][k],
-                                 canon_to_code);
+                                 canon_to_code, files[n]);
       }
 
   /* Fill the resulting messages.  */
index 28d1f1747482df81c7e9a65db55d598dd8b52cd8..6620cfdd2ba2ed02b691c0c04e5ce6d2a7e0d5a0 100644 (file)
@@ -260,10 +260,11 @@ convert_msgstr (cd, mp)
 
 
 void
-iconv_message_list (mlp, canon_from_code, canon_to_code)
+iconv_message_list (mlp, canon_from_code, canon_to_code, from_filename)
      message_list_ty *mlp;
      const char *canon_from_code;
      const char *canon_to_code;
+     const char *from_filename;
 {
   bool canon_from_code_overridden = (canon_from_code != NULL);
   size_t j;
@@ -300,10 +301,24 @@ iconv_message_list (mlp, canon_from_code, canon_to_code)
                if (canon_charset == NULL)
                  {
                    if (!canon_from_code_overridden)
-                     error (EXIT_FAILURE, 0,
-                            _("\
+                     {
+                       /* Don't give an error for POT files, because POT
+                          files usually contain only ASCII msgids.  */
+                       const char *filename = from_filename;
+                       size_t filenamelen;
+
+                       if (filename != NULL
+                           && (filenamelen = strlen (filename)) >= 4
+                           && memcmp (filename + filenamelen - 4, ".pot", 4)
+                              == 0
+                           && strcmp (charset, "CHARSET") == 0)
+                         canon_charset = po_charset_ascii;
+                       else
+                         error (EXIT_FAILURE, 0,
+                                _("\
 present charset \"%s\" is not a portable encoding name"),
-                            charset);
+                                charset);
+                     }
                  }
                else
                  {
@@ -376,9 +391,10 @@ This version was built without iconv()."),
 }
 
 msgdomain_list_ty *
-iconv_msgdomain_list (mdlp, to_code)
+iconv_msgdomain_list (mdlp, to_code, from_filename)
      msgdomain_list_ty *mdlp;
      const char *to_code;
+     const char *from_filename;
 {
   const char *canon_to_code;
   size_t k;
@@ -391,7 +407,8 @@ iconv_msgdomain_list (mdlp, to_code)
           to_code);
 
   for (k = 0; k < mdlp->nitems; k++)
-    iconv_message_list (mdlp->item[k]->messages, NULL, canon_to_code);
+    iconv_message_list (mdlp->item[k]->messages, NULL, canon_to_code,
+                       from_filename);
 
   return mdlp;
 }
index 66e9a15d9085deeb030de3636e1af0cde71d26c7..45cd5def32398d51414de3f885e9edb241726bff 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list character set conversion.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002 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
 extern void
        iconv_message_list PARAMS ((message_list_ty *mlp,
                                   const char *canon_from_code,
-                                  const char *canon_to_code));
+                                  const char *canon_to_code,
+                                  const char *from_filename));
 
 /* Converts all the message lists in MDLP to the encoding TO_CODE.  */
 extern msgdomain_list_ty *
        iconv_msgdomain_list PARAMS ((msgdomain_list_ty *mdlp,
-                                    const char *to_code));
+                                    const char *to_code,
+                                    const char *from_filename));
 
 #endif /* _MSGL_ICONV_H */
index 21a244a2c8d40ed2d3292a86d8eec3855ba95389..c53370ecd7e8ee0296b58cd4cda6aa5dd5ac3082 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing Java ResourceBundles.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002 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
@@ -1094,7 +1094,7 @@ msgdomain_write_java (mlp, resource_name, locale_name, directory, assume_java2)
   retval = 1;
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, NULL, po_charset_canonicalize ("UTF-8"));
+  iconv_message_list (mlp, NULL, po_charset_canonicalize ("UTF-8"), NULL);
 
   cleanup_list.tmpdir = NULL;
   cleanup_list.subdir_count = 0;
index 0ba0337e4dad7860832e880c13e8c8976f70de03..9533a1108767d52f0e293656172f930dd9481051 100644 (file)
@@ -174,7 +174,7 @@ but the Tcl message catalog format doesn't support plural handling\n")));
   }
 
   /* Convert the messages to Unicode.  */
-  iconv_message_list (mlp, NULL, po_charset_canonicalize ("UTF-8"));
+  iconv_message_list (mlp, NULL, po_charset_canonicalize ("UTF-8"), NULL);
 
   /* Now create the file.  */
   {
index 10d1f2fe96a1b1c22b72e89f736f6c4f7a3de055..715c0599da94a18802aa21e4088740e75ee867ed 100644 (file)
@@ -418,7 +418,7 @@ error while reading \"%s\""), real_filename);
   if (!is_ascii_message_list (mlp))
     {
       const char *canon_utf_8 = po_charset_canonicalize ("UTF-8");
-      iconv_message_list (mlp, canon_utf_8, canon_utf_8);
+      iconv_message_list (mlp, canon_utf_8, canon_utf_8, NULL);
     }
 
   /* Close scanner.  */
index da76b5200ed3a4f35bc8ca720d66f3b4a258b7d7..6f719ccd340defec0a5e1a812b1e820d01338aba 100644 (file)
@@ -1181,7 +1181,7 @@ extract_python (f, real_filename, logical_filename, mdlp)
   if (!is_ascii_message_list (mlp))
     {
       const char *canon_utf_8 = po_charset_canonicalize ("UTF-8");
-      iconv_message_list (mlp, canon_utf_8, canon_utf_8);
+      iconv_message_list (mlp, canon_utf_8, canon_utf_8, NULL);
     }
 
   fp = NULL;
index c23843b6769c7761e7fc8c89f76f8103e374d8cf..a942796de5e4dfcb433a4a388ddcaa079714c4fa 100644 (file)
@@ -1023,7 +1023,7 @@ extract_tcl (f, real_filename, logical_filename, mdlp)
   if (!is_ascii_message_list (mlp))
     {
       const char *canon_utf_8 = po_charset_canonicalize ("UTF-8");
-      iconv_message_list (mlp, canon_utf_8, canon_utf_8);
+      iconv_message_list (mlp, canon_utf_8, canon_utf_8, NULL);
     }
 
   fp = NULL;