From: Bruno Haible Date: Mon, 1 Oct 2007 00:14:18 +0000 (+0000) Subject: Support for KDE format strings. X-Git-Tag: v0.17~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d5b22709b529153e4b95a837200b2f7c589e087;p=thirdparty%2Fgettext.git Support for KDE format strings. --- diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index da7353483..34b9efd70 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,7 @@ +2007-09-30 Bruno Haible + + * woe32dll/gettextsrc-exports.c: Add formatstring_kde. + 2007-07-07 Bruno Haible * configure.ac: Don't create libuniname/Makefile. diff --git a/gettext-tools/libgettextpo/ChangeLog b/gettext-tools/libgettextpo/ChangeLog index e2f573bcd..80711235e 100644 --- a/gettext-tools/libgettextpo/ChangeLog +++ b/gettext-tools/libgettextpo/ChangeLog @@ -1,3 +1,7 @@ +2007-09-30 Bruno Haible + + * Makefile.am (libgettextpo_la_AUXSOURCES): Add format-kde.c. + 2007-06-08 Bruno Haible * Makefile.am (LDADD): Remove variable. diff --git a/gettext-tools/libgettextpo/Makefile.am b/gettext-tools/libgettextpo/Makefile.am index f7026bb80..d0bb23ae3 100644 --- a/gettext-tools/libgettextpo/Makefile.am +++ b/gettext-tools/libgettextpo/Makefile.am @@ -80,6 +80,7 @@ libgettextpo_la_AUXSOURCES = \ ../src/format-php.c \ ../src/format-gcc-internal.c \ ../src/format-qt.c \ + ../src/format-kde.c \ ../src/format-boost.c \ ../src/format.c \ ../src/plural-exp.c \ diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index e6e940e45..de01dbc9e 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,27 @@ +2007-09-30 Bruno Haible + + * message.h (format_type): New enum value 'format_kde'. + (NFORMATS): Increment. + * message.c (format_language): Add format_kde entry. + (format_language_pretty): Likewise. + * format.h (formatstring_kde): New declaration. + * format-kde.c: New file. + * format.c (formatstring_parsers): Add formatstring_kde. + * x-c.c (init_flag_table_c): Also register flags for qt-format and + kde-format. + * xgettext.c (flag_table_cxx_kde): New variable. + (recognize_format_kde): New variable. + (main): Handle --kde option. + (usage): Document --kde option. + (xgettext_record_flag): Also fill flag_table_cxx_kde. + (remember_a_message, remember_a_message_plural): In the heuristics, + don't mark a string as c-format that is already known to be a + kde-format. + (language_to_extractor): Use a flag_table_cxx_kde that is different + from flag_table_c. + * Makefile.am (FORMAT_SOURCE): Add format-kde.c. + * FILES: Update. + 2007-09-09 Bruno Haible Add support for Qt 4 format strings. diff --git a/gettext-tools/src/FILES b/gettext-tools/src/FILES index 49cf3faa3..53290b31c 100644 --- a/gettext-tools/src/FILES +++ b/gettext-tools/src/FILES @@ -224,6 +224,7 @@ format-perl-brace.c Format string handling for Perl, braced syntax. format-php.c Format string handling for PHP. format-gcc-internal.c Format string handling GCC internal. format-qt.c Format string handling for Qt. +format-kde.c Format string handling for KDE. format-boost.c Format string handling for Boost. format.c Table of the language dependent format string handlers. diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index cebb5bc9a..7f8cc4404 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -114,7 +114,7 @@ FORMAT_SOURCE += format-invalid.h \ format-c.c format-sh.c format-python.c format-lisp.c format-elisp.c \ format-librep.c format-scheme.c format-java.c format-csharp.c format-awk.c \ format-pascal.c format-ycp.c format-tcl.c format-perl.c format-perl-brace.c \ -format-php.c format-gcc-internal.c format-qt.c format-boost.c +format-php.c format-gcc-internal.c format-qt.c format-kde.c format-boost.c # libgettextsrc contains all code that is needed by at least two programs. libgettextsrc_la_SOURCES = \ diff --git a/gettext-tools/src/format.c b/gettext-tools/src/format.c index 2e4fbac6f..caa6cf883 100644 --- a/gettext-tools/src/format.c +++ b/gettext-tools/src/format.c @@ -1,5 +1,5 @@ /* Format strings. - Copyright (C) 2001-2006 Free Software Foundation, Inc. + Copyright (C) 2001-2007 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -55,6 +55,7 @@ struct formatstring_parser *formatstring_parsers[NFORMATS] = /* format_php */ &formatstring_php, /* format_gcc_internal */ &formatstring_gcc_internal, /* format_qt */ &formatstring_qt, + /* format_kde */ &formatstring_kde, /* format_boost */ &formatstring_boost }; diff --git a/gettext-tools/src/format.h b/gettext-tools/src/format.h index 6502325a4..2015a9a06 100644 --- a/gettext-tools/src/format.h +++ b/gettext-tools/src/format.h @@ -1,5 +1,5 @@ /* Format strings. - Copyright (C) 2001-2006 Free Software Foundation, Inc. + Copyright (C) 2001-2007 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -115,6 +115,7 @@ extern DLL_VARIABLE struct formatstring_parser formatstring_perl_brace; extern DLL_VARIABLE struct formatstring_parser formatstring_php; extern DLL_VARIABLE struct formatstring_parser formatstring_gcc_internal; extern DLL_VARIABLE struct formatstring_parser formatstring_qt; +extern DLL_VARIABLE struct formatstring_parser formatstring_kde; extern DLL_VARIABLE struct formatstring_parser formatstring_boost; /* Table of all format string parsers. */ diff --git a/gettext-tools/src/message.c b/gettext-tools/src/message.c index c608a9bea..9edcba3a2 100644 --- a/gettext-tools/src/message.c +++ b/gettext-tools/src/message.c @@ -55,6 +55,7 @@ const char *const format_language[NFORMATS] = /* format_php */ "php", /* format_gcc_internal */ "gcc-internal", /* format_qt */ "qt", + /* format_kde */ "kde", /* format_boost */ "boost" }; @@ -80,6 +81,7 @@ const char *const format_language_pretty[NFORMATS] = /* format_php */ "PHP", /* format_gcc_internal */ "GCC internal", /* format_qt */ "Qt", + /* format_kde */ "KDE", /* format_boost */ "Boost" }; diff --git a/gettext-tools/src/message.h b/gettext-tools/src/message.h index 09648831e..35aa99ae1 100644 --- a/gettext-tools/src/message.h +++ b/gettext-tools/src/message.h @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2007 Free Software Foundation, Inc. This file was written by Peter Miller @@ -64,9 +64,10 @@ enum format_type format_php, format_gcc_internal, format_qt, + format_kde, format_boost }; -#define NFORMATS 21 /* Number of format_type enum values. */ +#define NFORMATS 22 /* Number of format_type enum values. */ extern DLL_VARIABLE const char *const format_language[NFORMATS]; extern DLL_VARIABLE const char *const format_language_pretty[NFORMATS]; diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index fbbfb4a9d..05e163d50 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -236,6 +236,46 @@ init_flag_table_c () xgettext_record_flag ("argp_failure:2:c-format"); #endif + xgettext_record_flag ("gettext:1:pass-qt-format"); + xgettext_record_flag ("dgettext:2:pass-qt-format"); + xgettext_record_flag ("dcgettext:2:pass-qt-format"); + xgettext_record_flag ("ngettext:1:pass-qt-format"); + xgettext_record_flag ("ngettext:2:pass-qt-format"); + xgettext_record_flag ("dngettext:2:pass-qt-format"); + xgettext_record_flag ("dngettext:3:pass-qt-format"); + xgettext_record_flag ("dcngettext:2:pass-qt-format"); + xgettext_record_flag ("dcngettext:3:pass-qt-format"); + xgettext_record_flag ("gettext_noop:1:pass-qt-format"); + xgettext_record_flag ("pgettext:2:pass-qt-format"); + xgettext_record_flag ("dpgettext:3:pass-qt-format"); + xgettext_record_flag ("dcpgettext:3:pass-qt-format"); + xgettext_record_flag ("npgettext:2:pass-qt-format"); + xgettext_record_flag ("npgettext:3:pass-qt-format"); + xgettext_record_flag ("dnpgettext:3:pass-qt-format"); + xgettext_record_flag ("dnpgettext:4:pass-qt-format"); + xgettext_record_flag ("dcnpgettext:3:pass-qt-format"); + xgettext_record_flag ("dcnpgettext:4:pass-qt-format"); + + xgettext_record_flag ("gettext:1:pass-kde-format"); + xgettext_record_flag ("dgettext:2:pass-kde-format"); + xgettext_record_flag ("dcgettext:2:pass-kde-format"); + xgettext_record_flag ("ngettext:1:pass-kde-format"); + xgettext_record_flag ("ngettext:2:pass-kde-format"); + xgettext_record_flag ("dngettext:2:pass-kde-format"); + xgettext_record_flag ("dngettext:3:pass-kde-format"); + xgettext_record_flag ("dcngettext:2:pass-kde-format"); + xgettext_record_flag ("dcngettext:3:pass-kde-format"); + xgettext_record_flag ("gettext_noop:1:pass-kde-format"); + xgettext_record_flag ("pgettext:2:pass-kde-format"); + xgettext_record_flag ("dpgettext:3:pass-kde-format"); + xgettext_record_flag ("dcpgettext:3:pass-kde-format"); + xgettext_record_flag ("npgettext:2:pass-kde-format"); + xgettext_record_flag ("npgettext:3:pass-kde-format"); + xgettext_record_flag ("dnpgettext:3:pass-kde-format"); + xgettext_record_flag ("dnpgettext:4:pass-kde-format"); + xgettext_record_flag ("dcnpgettext:3:pass-kde-format"); + xgettext_record_flag ("dcnpgettext:4:pass-kde-format"); + xgettext_record_flag ("gettext:1:pass-boost-format"); xgettext_record_flag ("dgettext:2:pass-boost-format"); xgettext_record_flag ("dcgettext:2:pass-boost-format"); diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 1075d8a28..e19c543f5 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -136,6 +136,7 @@ int xgettext_omit_header; /* Table of flag_context_list_ty tables. */ static flag_context_list_table_ty flag_table_c; static flag_context_list_table_ty flag_table_cxx_qt; +static flag_context_list_table_ty flag_table_cxx_kde; static flag_context_list_table_ty flag_table_cxx_boost; static flag_context_list_table_ty flag_table_objc; static flag_context_list_table_ty flag_table_gcc_internal; @@ -156,6 +157,9 @@ static flag_context_list_table_ty flag_table_php; /* If true, recognize Qt format strings. */ static bool recognize_format_qt; +/* If true, recognize KDE format strings. */ +static bool recognize_format_kde; + /* If true, recognize Boost format strings. */ static bool recognize_format_boost; @@ -182,7 +186,7 @@ static const struct option long_options[] = { { "add-comments", optional_argument, NULL, 'c' }, { "add-location", no_argument, &line_comment, 1 }, - { "boost", no_argument, NULL, CHAR_MAX + 10 }, + { "boost", no_argument, NULL, CHAR_MAX + 11 }, { "c++", no_argument, NULL, 'C' }, { "copyright-holder", required_argument, NULL, CHAR_MAX + 1 }, { "debug", no_argument, &do_debug, 1 }, @@ -199,6 +203,7 @@ static const struct option long_options[] = { "help", no_argument, NULL, 'h' }, { "indent", no_argument, NULL, 'i' }, { "join-existing", no_argument, NULL, 'j' }, + { "kde", no_argument, NULL, CHAR_MAX + 10 }, { "keyword", optional_argument, NULL, 'k' }, { "language", required_argument, NULL, 'L' }, { "msgid-bugs-address", required_argument, NULL, CHAR_MAX + 5 }, @@ -493,7 +498,10 @@ main (int argc, char *argv[]) case CHAR_MAX + 9: /* --qt */ recognize_format_qt = true; break; - case CHAR_MAX + 10: /* --boost */ + case CHAR_MAX + 10: /* --kde */ + recognize_format_kde = true; + break; + case CHAR_MAX + 11: /* --boost */ recognize_format_boost = true; break; default: @@ -529,12 +537,18 @@ There is NO WARRANTY, to the extent permitted by law.\n\ error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), "--sort-output", "--sort-by-file"); + /* We cannot support both Qt and KDE, or Qt and Boost, or KDE and Boost + format strings, because there are only two formatstring parsers per + language, and formatstring_c is the first one for C++. */ + if (recognize_format_qt && recognize_format_kde) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--qt", "--kde"); if (recognize_format_qt && recognize_format_boost) - /* We cannot support both Qt and Boost format strings, because there are - only two formatstring parsers per language, and formatstring_c is the - first one for C++. */ error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), "--qt", "--boost"); + if (recognize_format_kde && recognize_format_boost) + error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"), + "--kde", "--boost"); if (join_existing && strcmp (default_domain, "-") == 0) error (EXIT_FAILURE, 0, _("\ @@ -830,6 +844,10 @@ Language specific options:\n")); printf (_("\ (only language C++)\n")); printf (_("\ + --kde recognize KDE 4 format strings\n")); + printf (_("\ + (only language C++)\n")); + printf (_("\ --boost recognize Boost format strings\n")); printf (_("\ (only language C++)\n")); @@ -1527,6 +1545,9 @@ xgettext_record_flag (const char *optionstring) flag_context_list_table_insert (&flag_table_cxx_qt, 0, name_start, name_end, argnum, value, pass); + flag_context_list_table_insert (&flag_table_cxx_kde, 0, + name_start, name_end, + argnum, value, pass); flag_context_list_table_insert (&flag_table_cxx_boost, 0, name_start, name_end, argnum, value, pass); @@ -1623,6 +1644,11 @@ xgettext_record_flag (const char *optionstring) name_start, name_end, argnum, value, pass); break; + case format_kde: + flag_context_list_table_insert (&flag_table_cxx_kde, 1, + name_start, name_end, + argnum, value, pass); + break; case format_boost: flag_context_list_table_insert (&flag_table_cxx_boost, 1, name_start, name_end, @@ -2153,9 +2179,10 @@ meta information, not the empty string.\n"))); && !(i == format_c && possible_format_p (is_format[format_objc])) && !(i == format_objc && possible_format_p (is_format[format_c])) /* Avoid flagging a string as c-format when it's known to be a - qt-format or boost-format string. */ + qt-format or kde-format or boost-format string. */ && !(i == format_c && (possible_format_p (is_format[format_qt]) + || possible_format_p (is_format[format_kde]) || possible_format_p (is_format[format_boost])))) { struct formatstring_parser *parser = formatstring_parsers[i]; @@ -2268,6 +2295,7 @@ remember_a_message_plural (message_ty *mp, char *string, qt-format or boost-format string. */ && !(i == format_c && (possible_format_p (mp->is_format[format_qt]) + || possible_format_p (mp->is_format[format_kde]) || possible_format_p (mp->is_format[format_boost])))) { struct formatstring_parser *parser = formatstring_parsers[i]; @@ -2958,6 +2986,12 @@ language_to_extractor (const char *name) result.flag_table = &flag_table_cxx_qt; result.formatstring_parser2 = &formatstring_qt; } + /* Likewise for --kde. */ + if (recognize_format_kde && strcmp (tp->name, "C++") == 0) + { + result.flag_table = &flag_table_cxx_kde; + result.formatstring_parser2 = &formatstring_kde; + } /* Likewise for --boost. */ if (recognize_format_boost && strcmp (tp->name, "C++") == 0) { diff --git a/gettext-tools/woe32dll/gettextsrc-exports.c b/gettext-tools/woe32dll/gettextsrc-exports.c index 64d41de96..c3a86d4cd 100644 --- a/gettext-tools/woe32dll/gettextsrc-exports.c +++ b/gettext-tools/woe32dll/gettextsrc-exports.c @@ -1,5 +1,5 @@ /* List of exported symbols of libgettextsrc on Cygwin. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006-2007 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software; you can redistribute it and/or modify @@ -29,6 +29,7 @@ VARIABLE(formatstring_csharp) VARIABLE(formatstring_elisp) VARIABLE(formatstring_gcc_internal) VARIABLE(formatstring_java) +VARIABLE(formatstring_kde) VARIABLE(formatstring_librep) VARIABLE(formatstring_lisp) VARIABLE(formatstring_objc)