]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Support for KDE format strings.
authorBruno Haible <bruno@clisp.org>
Mon, 1 Oct 2007 00:14:18 +0000 (00:14 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:06 +0000 (12:15 +0200)
13 files changed:
gettext-tools/ChangeLog
gettext-tools/libgettextpo/ChangeLog
gettext-tools/libgettextpo/Makefile.am
gettext-tools/src/ChangeLog
gettext-tools/src/FILES
gettext-tools/src/Makefile.am
gettext-tools/src/format.c
gettext-tools/src/format.h
gettext-tools/src/message.c
gettext-tools/src/message.h
gettext-tools/src/x-c.c
gettext-tools/src/xgettext.c
gettext-tools/woe32dll/gettextsrc-exports.c

index da735348396633af274198185b3a5e0dfb1b076c..34b9efd70814f8e804ee937543b53498a1b14992 100644 (file)
@@ -1,3 +1,7 @@
+2007-09-30  Bruno Haible  <bruno@clisp.org>
+
+       * woe32dll/gettextsrc-exports.c: Add formatstring_kde.
+
 2007-07-07  Bruno Haible  <bruno@clisp.org>
 
        * configure.ac: Don't create libuniname/Makefile.
index e2f573bcdc143f8daa97e6b2ea38ec7c6eb86faf..80711235ed3ae501915a17ccc623f7ef538ecc9a 100644 (file)
@@ -1,3 +1,7 @@
+2007-09-30  Bruno Haible  <bruno@clisp.org>
+
+       * Makefile.am (libgettextpo_la_AUXSOURCES): Add format-kde.c.
+
 2007-06-08  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (LDADD): Remove variable.
index f7026bb80cef1b6f9fa186e1f1287b7a11c16c8f..d0bb23ae39060ea651f038832fd3915af44ba347 100644 (file)
@@ -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 \
index e6e940e450afbcc05dfe321f13214683ab445ed9..de01dbc9ea11b11778b772edc5f8033878d3405e 100644 (file)
@@ -1,3 +1,27 @@
+2007-09-30  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        Add support for Qt 4 format strings.
index 49cf3faa3d5f92c90749540bd13e30b9c4338cff..53290b31ccf3d19e975cd17b05822c6a4a3e5506 100644 (file)
@@ -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.
 
index cebb5bc9a8311e150d54c62b90ec4602499bedbc..7f8cc4404edda8bae6c6ada92e91c8a9db90e819 100644 (file)
@@ -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 = \
index 2e4fbac6f73751dc69a184edeea6eceb5648e1e3..caa6cf883304726c8191faea82e2212ef0028069 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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
 };
 
index 6502325a4b98901bf02804e255e05bde7dd64d42..2015a9a06578b58588c3d7bbdb5334ab2b2bf3c4 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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.  */
index c608a9bea5f0d31ad93ab7ab8525b39f60104f85..9edcba3a28553149eb87858111679ce8f606ea28 100644 (file)
@@ -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"
 };
 
index 09648831e369342166546f6c12297c0f4d3136e4..35aa99ae1382c1f62486876c21ea34ceeaca4886 100644 (file)
@@ -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 <millerp@canb.auug.org.au>
 
@@ -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];
 
index fbbfb4a9dc8e8d2e18a15ca4a6cf552c6b98566a..05e163d50f3055ddf386bf9d0cdd19f2fc214f12 100644 (file)
@@ -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");
index 1075d8a2895b7a3288d79b287a85804f8bc3623d..e19c543f5389bb88ce7ae73c7d90185d2609f0cb 100644 (file)
@@ -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)
          {
index 64d41de9658400e28b265ad48f830c003d98b891..c3a86d4cd590a87cce1f3adfd32eeb365dbe6ed2 100644 (file)
@@ -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 <bruno@clisp.org>, 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)