diff options
author | Bruno Haible <bruno@clisp.org> | 2001-04-30 13:49:01 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2001-04-30 13:49:01 +0000 |
commit | bd962047e6e052371e7fb920579d72b534fb82b4 (patch) | |
tree | ffb2f45ba51315cf0395f4d54a8d975b6fbc379c /src | |
parent | 3622cd8108ba5caf2e3332640e50e342caa7d91b (diff) | |
download | external_gettext-bd962047e6e052371e7fb920579d72b534fb82b4.zip external_gettext-bd962047e6e052371e7fb920579d72b534fb82b4.tar.gz external_gettext-bd962047e6e052371e7fb920579d72b534fb82b4.tar.bz2 |
Ignore fuzziness of the header entry.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 10 | ||||
-rw-r--r-- | src/msgfmt.c | 217 | ||||
-rw-r--r-- | src/po.c | 10 | ||||
-rw-r--r-- | src/po.h | 3 |
4 files changed, 123 insertions, 117 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 45be1e5..989d517 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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. diff --git a/src/msgfmt.c b/src/msgfmt.c index 5d23dc2..fd5c9d1 100644 --- a/src/msgfmt.c +++ b/src/msgfmt.c @@ -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 (¤t_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 (¤t_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 (¤t_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 (¤t_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); @@ -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 @@ -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 |