]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Polish the last commit.
authorBruno Haible <bruno@clisp.org>
Thu, 15 Dec 2016 21:51:00 +0000 (22:51 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 15 Dec 2016 21:51:00 +0000 (22:51 +0100)
gettext-tools/src/msgl-header.c
gettext-tools/src/msgl-header.h
gettext-tools/src/write-csharp.c
gettext-tools/src/write-desktop.c
gettext-tools/src/write-java.c
gettext-tools/src/write-mo.c
gettext-tools/src/write-qt.c
gettext-tools/src/write-resources.c
gettext-tools/src/write-tcl.c
gettext-tools/src/write-xml.c
gettext-tools/tests/msgfmt-19

index 25ae33af3f1c7f6cb738fedc31af0105689d6ffa..219b412ab5e53d77eb4bb6ad04b4a8c710212d82 100644 (file)
@@ -36,20 +36,20 @@ static const struct
   const char *name;
   size_t len;
 }
-  known_fields[] =
-    {
-      { "Project-Id-Version:", sizeof ("Project-Id-Version:") - 1 },
-      { "Report-Msgid-Bugs-To:", sizeof ("Report-Msgid-Bugs-To:") - 1 },
-      { "POT-Creation-Date:", sizeof ("POT-Creation-Date:") - 1 },
-      { "PO-Revision-Date:", sizeof ("PO-Revision-Date:") - 1 },
-      { "Last-Translator:", sizeof ("Last-Translator:") - 1 },
-      { "Language-Team:", sizeof ("Language-Team:") - 1 },
-      { "Language:", sizeof ("Language:") - 1 },
-      { "MIME-Version:", sizeof ("MIME-Version:") - 1 },
-      { "Content-Type:", sizeof ("Content-Type:") - 1 },
-      { "Content-Transfer-Encoding:",
-        sizeof ("Content-Transfer-Encoding:") - 1 }
-    };
+known_fields[] =
+  {
+    { "Project-Id-Version:", sizeof ("Project-Id-Version:") - 1 },
+    { "Report-Msgid-Bugs-To:", sizeof ("Report-Msgid-Bugs-To:") - 1 },
+    { "POT-Creation-Date:", sizeof ("POT-Creation-Date:") - 1 },
+    { "PO-Revision-Date:", sizeof ("PO-Revision-Date:") - 1 },
+    { "Last-Translator:", sizeof ("Last-Translator:") - 1 },
+    { "Language-Team:", sizeof ("Language-Team:") - 1 },
+    { "Language:", sizeof ("Language:") - 1 },
+    { "MIME-Version:", sizeof ("MIME-Version:") - 1 },
+    { "Content-Type:", sizeof ("Content-Type:") - 1 },
+    { "Content-Transfer-Encoding:", sizeof ("Content-Transfer-Encoding:") - 1 }
+  };
+
 
 void
 msgdomain_list_set_header_field (msgdomain_list_ty *mdlp,
@@ -175,21 +175,8 @@ void
 message_list_delete_header_field (message_list_ty *mlp,
                                   const char *field)
 {
+  size_t field_len = strlen (field);
   size_t j;
-  int field_index;
-  size_t k;
-
-  /* Search the field in known_fields[].  */
-  field_index = -1;
-  for (k = 0; k < SIZEOF (known_fields); k++)
-    if (strcmp (known_fields[k].name, field) == 0)
-      {
-        field_index = k;
-        break;
-      }
-
-  size_t field_len;
-  field_len = strlen (field);
 
   /* Search the header entry.  */
   for (j = 0; j < mlp->nitems; j++)
@@ -199,11 +186,8 @@ message_list_delete_header_field (message_list_ty *mlp,
 
         /* Modify the header entry.  */
         const char *header = mp->msgstr;
-        char *new_header =
-          XCALLOC (strlen (header) + 1,
-                    char);
 
-        /* Test whether the field already occurs in the header entry.  */
+        /* Test whether the field occurs in the header entry.  */
         const char *h;
 
         for (h = header; *h != '\0'; )
@@ -217,7 +201,9 @@ message_list_delete_header_field (message_list_ty *mlp,
           }
         if (h != NULL && *h != '\0')
           {
-            /* Replace the field.  */
+            /* Delete the field.  */
+            char *new_header = XCALLOC (strlen (header) + 1, char);
+
             char *p = new_header;
             memcpy (p, header, h - header);
             p += h - header;
@@ -225,15 +211,12 @@ message_list_delete_header_field (message_list_ty *mlp,
             if (h != NULL)
               {
                 h++;
-                stpcpy (p, h);
+                strcpy (p, h);
               }
+            else
+              *p = '\0';
+
+            mp->msgstr = new_header;
           }
-        else
-          {
-            char *p = new_header;
-            p = stpcpy (p, header);
-          }
-        
-        mp->msgstr = new_header;
       }
 }
index 34726e7b0da16160e925ffd5d883e2a6b4fe1d22..35524a37f42aa1526b9bd59dc023f23cf1303faf 100644 (file)
@@ -34,8 +34,11 @@ extern void
        msgdomain_list_set_header_field (msgdomain_list_ty *mdlp,
                                         const char *field, const char *value);
 
+/* Remove the given field from the header.
+   The FIELD name ends in a colon.  */
 extern void
-       message_list_delete_header_field (message_list_ty *mlp, const char *field);
+       message_list_delete_header_field (message_list_ty *mlp,
+                                         const char *field);
 
 
 #ifdef __cplusplus
index 30e8411ccbab2dcf35db53a1ece29a69924ecb82..161cd4f456031583c8010f8be746af5cdcd44b58 100644 (file)
@@ -646,8 +646,10 @@ msgdomain_write_csharp (message_list_ty *mlp, const char *canon_encoding,
   /* Convert the messages to Unicode.  */
   iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
 
+  /* Support for "reproducible builds": Delete information that may vary
+     between builds in the same conditions.  */
   message_list_delete_header_field (mlp, "POT-Creation-Date:");
-  
+
   /* Create a temporary directory where we can put the C# file.
      A simple temporary file would also be possible but would require us to
      define our own variant of mkstemp(): On one hand the functions mktemp(),
index e568d47fb7c431ecc0710c9cff4efc5e32e01c44..657620dcbcaec835977075b8a5b62655a4035015 100644 (file)
@@ -204,8 +204,10 @@ msgdomain_write_desktop (message_list_ty *mlp,
   /* Convert the messages to Unicode.  */
   iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
 
+  /* Support for "reproducible builds": Delete information that may vary
+     between builds in the same conditions.  */
   message_list_delete_header_field (mlp, "POT-Creation-Date:");
-  
+
   /* Create a single-element operands and run the bulk operation on it.  */
   operand.language = (char *) locale_name;
   operand.mlp = mlp;
index 039ed94d938663c1daa3b6d07d4e9a5b02e6a7ae..9ddfac868aca76f7c954baf997c7fbb89f464159 100644 (file)
@@ -1067,6 +1067,8 @@ msgdomain_write_java (message_list_ty *mlp, const char *canon_encoding,
   /* Convert the messages to Unicode.  */
   iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
 
+  /* Support for "reproducible builds": Delete information that may vary
+     between builds in the same conditions.  */
   message_list_delete_header_field (mlp, "POT-Creation-Date:");
 
   if (output_source)
index b99dece021d52d01f7199ed430d83da0747ce6ad..69196550c43625a9b981d48bf4020ca761bed5d0 100644 (file)
 #include "xsize.h"
 #include "xalloc.h"
 #include "xmalloca.h"
+#include "msgl-header.h"
 #include "binary-io.h"
 #include "fwriteerror.h"
 #include "gettext.h"
-#include "read-catalog.h"
-#include "read-stringtable.h"
-#include "msgl-header.h"
 
 #define _(str) gettext (str)
 
@@ -789,6 +787,10 @@ msgdomain_write_mo (message_list_ty *mlp,
   /* If no entry for this domain don't even create the file.  */
   if (mlp->nitems != 0)
     {
+      /* Support for "reproducible builds": Delete information that may vary
+         between builds in the same conditions.  */
+      message_list_delete_header_field (mlp, "POT-Creation-Date:");
+
       if (strcmp (domain_name, "-") == 0)
         {
           output_file = stdout;
@@ -807,7 +809,6 @@ msgdomain_write_mo (message_list_ty *mlp,
 
       if (output_file != NULL)
         {
-          message_list_delete_header_field (mlp, "POT-Creation-Date:");
           write_table (output_file, mlp);
 
           /* Make sure nothing went wrong.  */
index 4a47d241fc7c2c7fe4fb127619adf4bd3140dd03..b3cca5a8e52aecf9638674e99777f1f14255c25b 100644 (file)
@@ -725,6 +725,10 @@ strings, not in the untranslated strings\n")));
           }
       }
 
+      /* Support for "reproducible builds": Delete information that may vary
+         between builds in the same conditions.  */
+      message_list_delete_header_field (mlp, "POT-Creation-Date:");
+
       if (strcmp (domain_name, "-") == 0)
         {
           output_file = stdout;
@@ -743,7 +747,6 @@ strings, not in the untranslated strings\n")));
 
       if (output_file != NULL)
         {
-          message_list_delete_header_field (mlp, "POT-Creation-Date:");
           write_qm (output_file, mlp);
 
           /* Make sure nothing went wrong.  */
index ec74eadcdc1a0e46de21a3185509950eadac3fed..8cc33cc13c5a2e1558b7969c51be8b82fce41307 100644 (file)
@@ -115,8 +115,6 @@ msgdomain_write_csharp_resources (message_list_ty *mlp,
                                   const char *domain_name,
                                   const char *file_name)
 {
-  message_list_delete_header_field (mlp, "POT-Creation-Date:");
-  
   /* If no entry for this domain don't even create the file.  */
   if (mlp->nitems != 0)
     {
@@ -161,6 +159,10 @@ but the C# .resources format doesn't support plural handling\n")));
       /* Convert the messages to Unicode.  */
       iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
 
+      /* Support for "reproducible builds": Delete information that may vary
+         between builds in the same conditions.  */
+      message_list_delete_header_field (mlp, "POT-Creation-Date:");
+
       /* Execute the WriteResource program.  */
       {
         const char *args[2];
index 04b62d9c84baa786861a985efe0ff4754616d5cc..b61608e769151746314e3d91e5d682c5dc61d32a 100644 (file)
@@ -185,6 +185,10 @@ but the Tcl message catalog format doesn't support plural handling\n")));
   /* Convert the messages to Unicode.  */
   iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
 
+  /* Support for "reproducible builds": Delete information that may vary
+     between builds in the same conditions.  */
+  message_list_delete_header_field (mlp, "POT-Creation-Date:");
+
   /* Now create the file.  */
   {
     size_t len;
@@ -217,7 +221,6 @@ but the Tcl message catalog format doesn't support plural handling\n")));
         return 1;
       }
 
-    message_list_delete_header_field (mlp, "POT-Creation-Date:");
     write_msg (output_file, mlp, frobbed_locale_name);
 
     /* Make sure nothing went wrong.  */
index f6cd6c003d8a6638923cdaa31c716ed45bba6eca..5c719f92e3423737a2598d966232c742a30a58b7 100644 (file)
@@ -95,8 +95,10 @@ msgdomain_write_xml (message_list_ty *mlp,
   /* Convert the messages to Unicode.  */
   iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
 
+  /* Support for "reproducible builds": Delete information that may vary
+     between builds in the same conditions.  */
   message_list_delete_header_field (mlp, "POT-Creation-Date:");
-  
+
   /* Create a single-element operands and run the bulk operation on it.  */
   operand.language = (char *) locale_name;
   operand.mlp = mlp;
index 88574c8172dc58cac144446b2f3b01a2a61cb73b..76d4a739d5c4d6027340567d6455f83c17c9898b 100755 (executable)
@@ -1,7 +1,8 @@
 #! /bin/sh
 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
 
-# Test accelerators.
+# Test that PO files that differ only in the POT-Creation-Date yield the
+# exact same .mo file.
 
 cat <<\EOF > mf-19-1.po
 # SOME DESCRIPTIVE TITLE.
@@ -20,14 +21,13 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "pen &File"
-msgstr "pen File"
+msgid "Open &File"
+msgstr "Open File"
 
-msgid "how _Help"
-msgstr "how Help"
+msgid "Show _Help"
+msgstr "Show Help"
 EOF
 
-
 cat <<\EOF > mf-19-2.po
 # SOME DESCRIPTIVE TITLE.
 # Copyright (C) YEAR Free Software Foundation, Inc.
@@ -45,14 +45,13 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "pen &File"
-msgstr "pen File"
+msgid "Open &File"
+msgstr "Open File"
 
-msgid "how _Help"
-msgstr "how Help"
+msgid "Show _Help"
+msgstr "Show Help"
 EOF
 
-
 : ${MSGFMT=msgfmt}
 ${MSGFMT} -o mf-19-1.mo mf-19-1.po 2>/dev/null
 test $? = 0 || { Exit 1; }