]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add update_header argument to iconv_msgdomain_list.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Nov 2006 12:33:10 +0000 (12:33 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:23 +0000 (12:14 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/msgcmp.c
gettext-tools/src/msgconv.c
gettext-tools/src/msgfilter.c
gettext-tools/src/msgl-iconv.c
gettext-tools/src/msgl-iconv.h
gettext-tools/src/msgmerge.c
gettext-tools/src/xgettext.c

index 14535c22dd81f9f7aba3b7869dbc8c0e4106c924..2ebb8b1fc6b0ab4431a2747eb7f9c9a6167b4f88 100644 (file)
@@ -1,3 +1,16 @@
+2006-11-25  Bruno Haible  <bruno@clisp.org>
+
+       * msgl-iconv.h (iconv_msgdomain_list): Add update_header argument.
+       * msgl-iconv.c (iconv_message_list_internal): Renamed from
+       iconv_msgdomain_list. Add update_header argument.
+       (iconv_message_list): New function.
+       (iconv_msgdomain_list): Add update_header argument.
+       * msgcmp.c (compare): Update iconv_msgdomain_list call.
+       * msgconv.c (main): Likewise.
+       * msgfilter.c (main): Likewise.
+       * msgmerge.c (merge): Likewise.
+       * xgettext.c (main): Likewise.
+
 2006-11-23  Bruno Haible  <bruno@clisp.org>
 
        * write-catalog.h: Include ostream.h. Don't include <stdio.h>.
index b0e3104272e4f47f085ea763bc84cf011822ef22..12740c396b192200b9c8a154a6be3a178ce85b1b 100644 (file)
@@ -387,7 +387,7 @@ compare (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax)
            }
        }
     if (was_utf8)
-      def = iconv_msgdomain_list (def, "UTF-8", fn1);
+      def = iconv_msgdomain_list (def, "UTF-8", true, fn1);
   }
 
   empty_list = message_list_alloc (false);
index 2b7e0b73e08530f55f93ede891571f7617686469..2375f3407c22bea8dde99b1ba601977a8fdc674a 100644 (file)
@@ -264,7 +264,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
 
   /* Convert if and only if the output syntax supports different encodings.  */
   if (!output_syntax->requires_utf8)
-    result = iconv_msgdomain_list (result, to_code, input_file);
+    result = iconv_msgdomain_list (result, to_code, true, input_file);
 
   /* Sort the results.  */
   if (sort_by_filepos)
index d0b63394b8f6bbc605441531251a37e1459b5a85..c38e36cdcaf92a12d6f81b476f432382f65a2475 100644 (file)
@@ -354,7 +354,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
       filter = serbian_to_latin;
 
       /* Convert the input to UTF-8 first.  */
-      result = iconv_msgdomain_list (result, po_charset_utf8, input_file);
+      result = iconv_msgdomain_list (result, po_charset_utf8, true, input_file);
     }
   else
     {
index 24826334c523203f006f3b86201389ae0ba8bde0..83176ec0852719948aa8a5118056b3ef81390c26 100644 (file)
@@ -168,10 +168,12 @@ convert_msgstr (iconv_t cd, message_ty *mp,
 #endif
 
 
-bool
-iconv_message_list (message_list_ty *mlp,
-                   const char *canon_from_code, const char *canon_to_code,
-                   const char *from_filename)
+static bool
+iconv_message_list_internal (message_list_ty *mlp,
+                            const char *canon_from_code,
+                            const char *canon_to_code,
+                            bool update_header,
+                            const char *from_filename)
 {
   bool canon_from_code_overridden = (canon_from_code != NULL);
   bool msgids_changed;
@@ -196,8 +198,6 @@ iconv_message_list (message_list_ty *mlp,
                size_t len;
                char *charset;
                const char *canon_charset;
-               size_t len1, len2, len3;
-               char *new_header;
 
                charsetstr += strlen ("charset=");
                len = strcspn (charsetstr, " \t\n");
@@ -241,15 +241,22 @@ two different charsets \"%s\" and \"%s\" in input file"),
                  }
                freesa (charset);
 
-               len1 = charsetstr - header;
-               len2 = strlen (canon_to_code);
-               len3 = (header + strlen (header)) - (charsetstr + len);
-               new_header = XNMALLOC (len1 + len2 + len3 + 1, char);
-               memcpy (new_header, header, len1);
-               memcpy (new_header + len1, canon_to_code, len2);
-               memcpy (new_header + len1 + len2, charsetstr + len, len3 + 1);
-               mlp->item[j]->msgstr = new_header;
-               mlp->item[j]->msgstr_len = len1 + len2 + len3 + 1;
+               if (update_header)
+                 {
+                   size_t len1, len2, len3;
+                   char *new_header;
+
+                   len1 = charsetstr - header;
+                   len2 = strlen (canon_to_code);
+                   len3 = (header + strlen (header)) - (charsetstr + len);
+                   new_header = XNMALLOC (len1 + len2 + len3 + 1, char);
+                   memcpy (new_header, header, len1);
+                   memcpy (new_header + len1, canon_to_code, len2);
+                   memcpy (new_header + len1 + len2, charsetstr + len,
+                           len3 + 1);
+                   mlp->item[j]->msgstr = new_header;
+                   mlp->item[j]->msgstr_len = len1 + len2 + len3 + 1;
+                 }
              }
          }
       }
@@ -328,9 +335,20 @@ This version was built without iconv()."),
   return msgids_changed;
 }
 
+bool
+iconv_message_list (message_list_ty *mlp,
+                   const char *canon_from_code, const char *canon_to_code,
+                   const char *from_filename)
+{
+  return iconv_message_list_internal (mlp,
+                                     canon_from_code, canon_to_code, true,
+                                     from_filename);
+}
+
 msgdomain_list_ty *
 iconv_msgdomain_list (msgdomain_list_ty *mdlp,
                      const char *to_code,
+                     bool update_header,
                      const char *from_filename)
 {
   const char *canon_to_code;
@@ -345,8 +363,9 @@ target charset \"%s\" is not a portable encoding name."),
                          to_code));
 
   for (k = 0; k < mdlp->nitems; k++)
-    iconv_message_list (mdlp->item[k]->messages, mdlp->encoding, canon_to_code,
-                       from_filename);
+    iconv_message_list_internal (mdlp->item[k]->messages,
+                                mdlp->encoding, canon_to_code, update_header,
+                                from_filename);
 
   mdlp->encoding = canon_to_code;
   return mdlp;
index e56a27b9b07701185d00a7e6521536fdd28b4715..4eb69ee3a066b3101af6d2c0474bcf25e71c38b7 100644 (file)
@@ -60,10 +60,13 @@ extern bool
                           const char *canon_to_code,
                           const char *from_filename);
 
-/* Converts all the message lists in MDLP to the encoding TO_CODE.  */
+/* Converts all the message lists in MDLP to the encoding TO_CODE.
+   UPDATE_HEADER specifies whether to update the "charset=..." specification
+   in the header; it should normally be true.  */
 extern msgdomain_list_ty *
        iconv_msgdomain_list (msgdomain_list_ty *mdlp,
                             const char *to_code,
+                            bool update_header,
                             const char *from_filename);
 
 /* Tests whether the message list MLP could be converted to CANON_TO_CODE.
index be0b920d03504b511de889e0c8e97ff22e8c7d0f..e51a62e7e6492c4afb0ba6cb7ee46d95cd2f3bb8 100644 (file)
@@ -1415,7 +1415,7 @@ merge (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax,
        }
     if (was_utf8)
       {
-       def = iconv_msgdomain_list (def, "UTF-8", fn1);
+       def = iconv_msgdomain_list (def, "UTF-8", true, fn1);
        if (compendiums != NULL)
          for (k = 0; k < compendiums->nitems; k++)
            iconv_message_list (compendiums->item[k], NULL, po_charset_utf8,
@@ -1559,7 +1559,7 @@ merge (const char *fn1, const char *fn2, catalog_input_format_ty input_syntax,
              {
                /* It's too hairy to find out what would be the optimal target
                   encoding.  So, convert everything to UTF-8.  */
-               def = iconv_msgdomain_list (def, "UTF-8", fn1);
+               def = iconv_msgdomain_list (def, "UTF-8", true, fn1);
                if (compendiums != NULL)
                  for (k = 0; k < compendiums->nitems; k++)
                    iconv_message_list (compendiums->item[k],
index 4d09321a97529522deb31d75a4f8943634dce130..49bede3cfe014d01050d25c83ec5e7b3b9041ef6 100644 (file)
@@ -641,7 +641,7 @@ This version was built without iconv()."),
 
       extract_from_file (file_name, po_extractor, mdlp);
       if (!is_ascii_msgdomain_list (mdlp))
-       mdlp = iconv_msgdomain_list (mdlp, "UTF-8", file_name);
+       mdlp = iconv_msgdomain_list (mdlp, "UTF-8", true, file_name);
 
       dir_list_restore (saved_directory_list);
     }