]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Ignore fuzziness of the header entry.
authorBruno Haible <bruno@clisp.org>
Mon, 30 Apr 2001 13:49:01 +0000 (13:49 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 30 Apr 2001 13:49:01 +0000 (13:49 +0000)
src/ChangeLog
src/msgfmt.c
src/po.c
src/po.h

index 45be1e5091b8e43e896cad4a1722819c65e7182b..989d517df9cf30790fc07c7a2a559d905992a0cd 100644 (file)
@@ -1,3 +1,13 @@
+2001-04-28  Bruno Haible  <haible@clisp.cons.org>
+
+       * po.h (PO_BASE_TY): Remove next_is_fuzzy field.
+       * po.c (po_alloc): Don't reset next_is_fuzzy.
+       (po_callback_message): Ignore fuzziness of the header entry. Don't
+       reset next_is_fuzzy.
+       (po_callback_comment): Don't set next_is_fuzzy.
+       * msgfmt.c (format_directive_message): Ignore fuzziness of the header
+       entry. Count fuzzy untranslated entries as untranslated.
+
 2001-04-19  Bruno Haible  <haible@clisp.cons.org>
 
        * gettext-0.10.37 released.
index 5d23dc2acde0bb19c7de539229c7b0bd1a0261c8..fd5c9d123f94f665ade3c8307e40c6c486aa20bc 100644 (file)
@@ -541,7 +541,10 @@ format_directive_message (that, msgid_string, msgid_pos, msgid_plural,
   msgfmt_class_ty *this = (msgfmt_class_ty *) that;
   struct hashtable_entry *entry;
 
-  if (msgstr_string[0] == '\0' || (!include_all && this->is_fuzzy))
+  /* Don't emit untranslated entries.  Also don't emit fuzzy entries, unless
+     --use-fuzzy was specified.  But ignore fuzziness of the header entry.  */
+  if (msgstr_string[0] == '\0'
+      || (!include_all && this->is_fuzzy && msgid_string[0] != '\0'))
     {
       if (verbose_level > 1)
        /* We don't change the exit status here because this is really
@@ -551,135 +554,135 @@ format_directive_message (that, msgid_string, msgid_pos, msgid_plural,
                        ? _("empty `msgstr' entry ignored")
                        : _("fuzzy `msgstr' entry ignored")));
 
-      /* Free strings allocated in po-gram.y.  */
-      free (msgstr_string);
-
       /* Increment counter for fuzzy/untranslated messages.  */
-      if (this->is_fuzzy)
-       ++msgs_fuzzy;
-      else
+      if (msgstr_string[0] == '\0')
        ++msgs_untranslated;
+      else
+       ++msgs_fuzzy;
 
-      goto prepare_next;
+      /* Free strings allocated in po-gram.y.  */
+      free (msgstr_string);
     }
-
-  /* Test for header entry.  */
-  if (msgid_string[0] == '\0')
+  else
     {
-      this->has_header_entry = 1;
-
-      /* Do some more tests on test contents of the header entry.  */
-      if (verbose_level > 0)
+      /* Test for header entry.  */
+      if (msgid_string[0] == '\0')
        {
-         static const char *required_fields[] =
-         {
-           "Project-Id-Version", "PO-Revision-Date",
-           "Last-Translator", "Language-Team", "MIME-Version",
-           "Content-Type", "Content-Transfer-Encoding"
-         };
-         static const char *default_values[] =
-         {
-           "PACKAGE VERSION", "YEAR-MO-DA", "FULL NAME", "LANGUAGE",
-           NULL, "text/plain; charset=CHARSET", "ENCODING"
-         };
-         const size_t nfields = SIZEOF (required_fields);
-         int initial = -1;
-         int cnt;
-
-         for (cnt = 0; cnt < nfields; ++cnt)
+         this->has_header_entry = 1;
+
+         /* Do some more tests on test contents of the header entry.  */
+         if (verbose_level > 0)
            {
-             char *endp = strstr (msgstr_string, required_fields[cnt]);
+             static const char *required_fields[] =
+             {
+               "Project-Id-Version", "PO-Revision-Date",
+               "Last-Translator", "Language-Team", "MIME-Version",
+               "Content-Type", "Content-Transfer-Encoding"
+             };
+             static const char *default_values[] =
+             {
+               "PACKAGE VERSION", "YEAR-MO-DA", "FULL NAME", "LANGUAGE",
+               NULL, "text/plain; charset=CHARSET", "ENCODING"
+             };
+             const size_t nfields = SIZEOF (required_fields);
+             int initial = -1;
+             int cnt;
+
+             for (cnt = 0; cnt < nfields; ++cnt)
+               {
+                 char *endp = strstr (msgstr_string, required_fields[cnt]);
 
-             if (endp == NULL)
-               error (0, 0, _("headerfield `%s' missing in header"),
-                      required_fields[cnt]);
-             else if (endp != msgstr_string && endp[-1] != '\n')
-               error (0, 0, _("\
+                 if (endp == NULL)
+                   error (0, 0, _("headerfield `%s' missing in header"),
+                          required_fields[cnt]);
+                 else if (endp != msgstr_string && endp[-1] != '\n')
+                   error (0, 0, _("\
 header field `%s' should start at beginning of line"),
-                      required_fields[cnt]);
-             else if (default_values[cnt] != NULL
-                      && strncmp (default_values[cnt],
-                                  endp + strlen (required_fields[cnt]) + 2,
-                                  strlen (default_values[cnt])) == 0)
-               {
-                 if (initial != -1)
+                          required_fields[cnt]);
+                 else if (default_values[cnt] != NULL
+                          && strncmp (default_values[cnt],
+                                      endp + strlen (required_fields[cnt]) + 2,
+                                      strlen (default_values[cnt])) == 0)
                    {
-                     error (0, 0, _("\
+                     if (initial != -1)
+                       {
+                         error (0, 0, _("\
 some header fields still have the initial default value"));
-                     initial = -1;
-                     break;
+                         initial = -1;
+                         break;
+                       }
+                     else
+                       initial = cnt;
                    }
-                 else
-                   initial = cnt;
                }
-           }
 
-         if (initial != -1)
-           error (0, 0, _("field `%s' still has initial default value"),
-                  required_fields[initial]);
+             if (initial != -1)
+               error (0, 0, _("field `%s' still has initial default value"),
+                      required_fields[initial]);
+           }
        }
-    }
-  else
-    /* We don't count the header entry in the statistic so place the
-       counter incrementation here.  */
-    if (this->is_fuzzy)
-      ++msgs_fuzzy;
-    else
-      ++msgs_translated;
-
-  /* We found a valid pair of msgid/msgstr.
-     Construct struct to describe msgstr definition.  */
-  entry = (struct hashtable_entry *) xmalloc (sizeof (*entry));
-
-  entry->msgid_plural = msgid_plural;
-  entry->msgstr = msgstr_string;
-  entry->msgstr_len = msgstr_len;
-  entry->pos = *msgstr_pos;
-
-  /* Do some more checks on both strings.  */
-  check_pair (msgid_string, msgid_pos, msgid_plural,
-             msgstr_string, msgstr_len, msgstr_pos,
-             do_check && possible_c_format_p (this->is_c_format));
-
-  /* Check whether already a domain is specified.  If not use default
-     domain.  */
-  if (current_domain == NULL)
-    current_domain = new_domain ("messages");
-
-  /* We insert the ID/string pair into the hashing table.  But we have
-     to take care for dublicates.  */
-  if (insert_entry (&current_domain->symbol_tab, msgid_string,
-                   strlen (msgid_string) + 1, entry))
-    {
-      /* We don't need the just constructed entry.  */
-      free (entry);
-
-      if (verbose_level > 0)
+      else
+       /* We don't count the header entry in the statistic so place the
+          counter incrementation here.  */
+       if (this->is_fuzzy)
+         ++msgs_fuzzy;
+       else
+         ++msgs_translated;
+
+      /* We found a valid pair of msgid/msgstr.
+        Construct struct to describe msgstr definition.  */
+      entry = (struct hashtable_entry *) xmalloc (sizeof (*entry));
+
+      entry->msgid_plural = msgid_plural;
+      entry->msgstr = msgstr_string;
+      entry->msgstr_len = msgstr_len;
+      entry->pos = *msgstr_pos;
+
+      /* Do some more checks on both strings.  */
+      check_pair (msgid_string, msgid_pos, msgid_plural,
+                 msgstr_string, msgstr_len, msgstr_pos,
+                 do_check && possible_c_format_p (this->is_c_format));
+
+      /* Check whether already a domain is specified.  If not use default
+        domain.  */
+      if (current_domain == NULL)
+       current_domain = new_domain ("messages");
+
+      /* We insert the ID/string pair into the hashing table.  But we have
+        to take care for duplicates.  */
+      if (insert_entry (&current_domain->symbol_tab, msgid_string,
+                       strlen (msgid_string) + 1, entry))
        {
-         /* We give a fatal error about this, but only if the
-            translations are different.  Tell the user the old
-            definition for reference.  */
-         find_entry (&current_domain->symbol_tab, msgid_string,
-                     strlen (msgid_string) + 1, (void **) &entry);
-         if (msgstr_len != entry->msgstr_len
-             || memcmp (msgstr_string, entry->msgstr, msgstr_len) != 0)
+         /* We don't need the just constructed entry.  */
+         free (entry);
+
+         if (verbose_level > 0)
            {
-             po_gram_error_at_line (msgid_pos, _("\
+             /* We give a fatal error about this, but only if the
+                translations are different.  Tell the user the old
+                definition for reference.  */
+             find_entry (&current_domain->symbol_tab, msgid_string,
+                         strlen (msgid_string) + 1, (void **) &entry);
+             if (msgstr_len != entry->msgstr_len
+                 || memcmp (msgstr_string, entry->msgstr, msgstr_len) != 0)
+               {
+                 po_gram_error_at_line (msgid_pos, _("\
 duplicate message definition"));
-             po_gram_error_at_line (&entry->pos, _("\
+                 po_gram_error_at_line (&entry->pos, _("\
 ...this is the location of the first definition"));
 
-             /* FIXME Should this be always a reason for an exit status != 0?  */
-             exit_status = EXIT_FAILURE;
+                 /* FIXME Should this be always a reason for an
+                    exit status != 0?  */
+                 exit_status = EXIT_FAILURE;
+               }
            }
-       }
 
-      /* We don't need the just constructed entries'
-         parameter string (allocated in po-gram.y).  */
-      free (msgstr_string);
-    }
+         /* We don't need the just constructed entries'
+            parameter string (allocated in po-gram.y).  */
+         free (msgstr_string);
+       }
+  }
 
-prepare_next:
   /* We do not need the msgid string in any case.  */
   free (msgid_string);
 
index 6917568287d07f1abd83c4c6c0b77fbffcbf0b52..2167d581f5e39b11b2e00ec9d9d8ff6e6d6d9384 100644 (file)
--- a/src/po.c
+++ b/src/po.c
@@ -67,7 +67,6 @@ po_alloc (pomp)
 
   pop = xmalloc (pomp->size);
   pop->method = pomp;
-  pop->next_is_fuzzy = 0;
   if (pomp->constructor)
     pomp->constructor (pop);
   return pop;
@@ -222,8 +221,8 @@ po_callback_message (msgid, msgid_pos, msgid_plural,
 {
   /* assert(callback_arg); */
 
-  /* Test for header entry.  */
-  if (msgid[0] == '\0' && !callback_arg->next_is_fuzzy)
+  /* Test for header entry.  Ignore fuzziness of the header entry.  */
+  if (msgid[0] == '\0')
     {
       /* Verify the validity of CHARSET.  It is necessary
         1. for the correct treatment of multibyte characters containing
@@ -448,9 +447,6 @@ Message conversion to user's charset will not work.\n"));
 
   po_directive_message (callback_arg, msgid, msgid_pos, msgid_plural,
                        msgstr, msgstr_len, msgstr_pos);
-
-  /* Prepare for next message.  */
-  callback_arg->next_is_fuzzy = 0;
 }
 
 
@@ -508,8 +504,6 @@ po_callback_comment (s)
   else if (*s == ',' || *s == '!')
     {
       /* Get all entries in the special comment line.  */
-      if (strstr (s + 1, "fuzzy") != NULL)
-       callback_arg->next_is_fuzzy = 1;
       po_comment_special (callback_arg, s + 1);
     }
   else
index e46e1db2b962ff46f9f15a8b3c24da826645607d..0b77f8e85bdb170838a3531e5cc5f2de9c6b498c 100644 (file)
--- a/src/po.h
+++ b/src/po.h
@@ -106,8 +106,7 @@ struct po_method_ty
    etc.  */
 
 #define PO_BASE_TY \
-  po_method_ty *method; \
-  int next_is_fuzzy;
+  po_method_ty *method;
 
 typedef struct po_ty po_ty;
 struct po_ty