]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Option --check-accelerators now takes an optional argument.
authorBruno Haible <bruno@clisp.org>
Mon, 19 Nov 2001 11:03:20 +0000 (11:03 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 21:20:43 +0000 (23:20 +0200)
doc/ChangeLog
doc/msgfmt.texi
src/ChangeLog
src/msgfmt.c

index 6cb40af371164f218daea4891f8139a95dfe4157..a040898ef70f94398c3319d77647a3e346f21f26 100644 (file)
@@ -1,3 +1,7 @@
+2001-11-17  Bruno Haible  <haible@clisp.cons.org>
+
+       * msgfmt.texi: --check-accelerators has optional argument.
+
 2001-11-11  Bruno Haible  <haible@clisp.cons.org>
 
        * msgfmt.texi: Document --check-accelerators option.
index 526b957bb13c55010b815333ee9574a26c46ba38..b0fa542a9ced29ba6fa1895ad6d09298b763daee 100644 (file)
@@ -119,13 +119,16 @@ option
 Check that GNU msgfmt behaves like X/Open msgfmt.  This will give an error
 when attempting to use the GNU extensions.
 
-@item --check-accelerators
+@item --check-accelerators[=@var{char}]
 Check presence of keyboard accelerators for menu items.  This is based on
 the convention used in some GUIs that a keyboard accelerator in a menu
 item string is designated by an immediately preceding @samp{&} character.
 Sometimes a keyboard accelerator is also called "keyboard mnemonic".
 This check verifies that if the untranslated string has exactly one
 @samp{&} character, the translated string has exactly one @samp{&} as well.
+If this option is given with a @var{char} argument, this @var{char} should
+be a non-alphanumeric character and is used as keyboard acceleator mark
+instead of @samp{&}.
 
 @item -f
 @itemx --use-fuzzy
index 1080549dd0ec4ed7c1debd1284e961008df9255d..e6f7847e63eaa8ba262d5f01ad67f3589b46d49f 100644 (file)
@@ -1,3 +1,11 @@
+2001-11-17  Bruno Haible  <haible@clisp.cons.org>
+
+       * msgfmt.c (accelerator_char): New variable.
+       (long_options): --check-accelerators has optional argument.
+       (main): Store --check-accelerators value in accelerator_char.
+       (usage): --check-accelerators has optional argument.
+       (check_pair): Use accelerator_char instead of hardwired '&'.
+
 2001-11-17  Bruno Haible  <haible@clisp.cons.org>
 
        * msginit.c (main): Print a blank line.
index 71016668bf16411ac3f285e98adcd418c0f1e712..ee143819dc519ec6ad9c3e56bdfd61fb272a8893 100644 (file)
@@ -129,6 +129,7 @@ static bool check_compatibility = false;
    the '&' designates a keyboard accelerator, and verify that the translations
    also have a keyboard accelerator.  */
 static bool check_accelerators = false;
+static char accelerator_char = '&';
 
 /* Counters for statistics on translations for the processed files.  */
 static int msgs_translated;
@@ -143,7 +144,7 @@ static const struct option long_options[] =
 {
   { "alignment", required_argument, NULL, 'a' },
   { "check", no_argument, NULL, 'c' },
-  { "check-accelerators", no_argument, NULL, CHAR_MAX + 1 },
+  { "check-accelerators", optional_argument, NULL, CHAR_MAX + 1 },
   { "check-compatibility", no_argument, NULL, 'C' },
   { "check-domain", no_argument, NULL, CHAR_MAX + 2 },
   { "check-format", no_argument, NULL, CHAR_MAX + 3 },
@@ -292,6 +293,16 @@ main (argc, argv)
        break;
       case CHAR_MAX + 1:
        check_accelerators = true;
+       if (optarg != NULL)
+         {
+           if (optarg[0] != '\0' && ispunct ((unsigned char) optarg[0])
+               && optarg[1] == '\0')
+             accelerator_char = optarg[0];
+           else
+             error (EXIT_FAILURE, 0,
+                    _("the argument to %s should be a single punctuation character"),
+                    "--check-accelerators");
+         }
        break;
       case CHAR_MAX + 2:
        check_domain = true;
@@ -525,7 +536,7 @@ Input file interpretation:\n\
       --check-domain          check for conflicts between domain directives\n\
                                 and the --output-file option\n\
   -C, --check-compatibility   check that GNU msgfmt behaves like X/Open msgfmt\n\
-      --check-accelerators    check presence of keyboard accelerators for\n\
+      --check-accelerators[=CHAR]  check presence of keyboard accelerators for\n\
                                 menu items\n\
   -f, --use-fuzzy             use fuzzy entries in output\n\
 "));
@@ -1086,27 +1097,29 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos,
       const char *p;
 
       /* We are only interested in msgids that contain exactly one '&'.  */
-      p = strchr (msgid, '&');
-      if (p != NULL && strchr (p + 1, '&') == NULL)
+      p = strchr (msgid, accelerator_char);
+      if (p != NULL && strchr (p + 1, accelerator_char) == NULL)
        {
          /* Count the number of '&' in msgstr.  */
          unsigned int count = 0;
 
-         for (p = msgstr; (p = strchr (p, '&')) != NULL; p++)
+         for (p = msgstr; (p = strchr (p, accelerator_char)) != NULL; p++)
            count++;
 
          if (count == 0)
            {
              error_with_progname = false;
              error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
-                            _("msgstr lacks the keyboard accelerator mark '&'"));
+                            _("msgstr lacks the keyboard accelerator mark '%c'"),
+                            accelerator_char);
              error_with_progname = true;
            }
          else if (count > 1)
            {
              error_with_progname = false;
              error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number,
-                            _("msgstr has too many keyboard accelerator marks '&'"));
+                            _("msgstr has too many keyboard accelerator marks '%c'"),
+                            accelerator_char);
              error_with_progname = true;
            }
        }