]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
scheme: Recognize GIMP script-fu extension _"abc"
authorDaiki Ueno <ueno@gnu.org>
Wed, 30 Apr 2014 08:29:04 +0000 (17:29 +0900)
committerDaiki Ueno <ueno@gnu.org>
Wed, 30 Apr 2014 09:02:51 +0000 (18:02 +0900)
* gettext-tools/src/x-scheme.c (read_object): Recognize _"abc".

gettext-tools/doc/ChangeLog
gettext-tools/doc/gettext.texi
gettext-tools/src/ChangeLog
gettext-tools/src/x-scheme.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-scheme-4 [new file with mode: 0644]

index f12e3dcd9b1ac485c25a9b9ffc0f17a705b12fff..5986b05d6db5e702e7f16525bd180b64d2953a4d 100644 (file)
@@ -1,3 +1,7 @@
+2014-04-30  Daiki Ueno  <ueno@gnu.org>
+
+       * gettext.texi (Scheme): Document gettext shorthand form _"abc".
+
 2014-04-22  Daiki Ueno  <ueno@gnu.org>
 
        build: Use git-version-gen intead of version.sh
index 9e2ac3925ed22bcfa0187016305167c74e9e4bd8..a35b7ac7025d9c94320d4195a719990154871791 100644 (file)
@@ -10034,7 +10034,7 @@ guile
 @code{"abc"}
 
 @item gettext shorthand
-@code{(_ "abc")}
+@code{(_ "abc")}, @code{_"abc"}
 
 @item gettext/ngettext functions
 @code{gettext}, @code{ngettext}
index 98a425fedc177d221d53b97ba3c60ce866c3ff3a..c7c953fff89cc73baf8df10f33b3592a5549fb85 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-30  Daiki Ueno  <ueno@gnu.org>
+
+       scheme: Recognize GIMP script-fu extension _"abc"
+       * x-scheme.c (read_object): Recognize _"abc".
+
 2014-04-30  Daiki Ueno  <ueno@gnu.org>
 
        format-python-brace: Limit acceptable format specifiers
index 1ddcb2db10f136fd2d7fb3b6b47ac49311b12829..361156ae558aa0fa05282718cd0db39dd69f4d53 100644 (file)
@@ -682,6 +682,7 @@ read_object (struct object *op, flag_context_ty outer_context)
   for (;;)
     {
       int c = do_getc ();
+      bool seen_underscore_prefix = false;
 
       switch (c)
         {
@@ -1167,6 +1168,33 @@ read_object (struct object *op, flag_context_ty outer_context)
             abort ();
           }
 
+        case '_':
+          /* GIMP script-fu extension: '_' before a string literal is
+             considered a gettext call on the string.  */
+          {
+            int c = do_getc ();
+            if (c == EOF)
+              /* Invalid input.  Be tolerant, no error message.  */
+              {
+                op->type = t_other;
+                return;
+              }
+            if (c != '"')
+              {
+                do_ungetc (c);
+
+                /* If '_' is not followed by a string literal,
+                   consider it a part of symbol.  */
+                op->token = XMALLOC (struct token);
+                read_token (op->token, '_');
+                op->type = t_symbol;
+                last_non_comment_line = line_number;
+                return;
+              }
+            seen_underscore_prefix = true;
+          }
+          /*FALLTHROUGH*/
+
         case '"':
           {
             op->token = XMALLOC (struct token);
@@ -1220,7 +1248,7 @@ read_object (struct object *op, flag_context_ty outer_context)
               }
             op->type = t_string;
 
-            if (extract_all)
+            if (seen_underscore_prefix || extract_all)
               {
                 lex_pos_ty pos;
 
index a82a5702f43b5d30210ac0588ac96038fd9fb45c..740bf5a7bfacfce099cba8f7b9d368fc9354d02f 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-30  Daiki Ueno  <ueno@gnu.org>
+
+       * xgettext-scheme-4: New file.
+       * Makefile.am (TESTS): Add new test.
+
 2014-04-30  Daiki Ueno  <ueno@gnu.org>
 
        format-python-brace: Limit acceptable format specifiers
index 490c2c821cca1dd0dd511422f6bbd7c05bd45e30..e6ef6b839e817ffecb8c5c627e43b0fac17ba77b 100644 (file)
@@ -95,6 +95,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        xgettext-python-1 xgettext-python-2 xgettext-python-3 \
        xgettext-python-4 \
        xgettext-scheme-1 xgettext-scheme-2 xgettext-scheme-3 \
+       xgettext-scheme-4 \
        xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 xgettext-sh-4 xgettext-sh-5 \
        xgettext-sh-6 \
        xgettext-smalltalk-1 xgettext-smalltalk-2 \
diff --git a/gettext-tools/tests/xgettext-scheme-4 b/gettext-tools/tests/xgettext-scheme-4
new file mode 100644 (file)
index 0000000..3566d6b
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test Scheme support: GIMP script-fu extension _"..."
+
+cat <<EOF > xg-sc-4.scm
+(script-fu-register "script-fu-paste-as-brush"
+  _"New _Brush..."
+  _"Paste the clipboard contents into a new brush"
+  "Michael Natterer <mitch@gimp.org>"
+  "Michael Natterer"
+  "2005-09-25"
+  ""
+  SF-STRING     _"Brush name" "My Brush"
+  SF-STRING     _"File name"  "mybrush"
+  SF-ADJUSTMENT _"Spacing"    '(25 0 1000 1 1 1 0)
+)
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} -k_ --omit-header --no-location --add-comments=TRANSLATORS: \
+  -d xg-sc-4.tmp xg-sc-4.scm || exit 1
+LC_ALL=C tr -d '\r' < xg-sc-4.tmp.po > xg-sc-4.po || exit 1
+
+cat <<EOF > xg-sc-4.ok
+msgid "New _Brush..."
+msgstr ""
+
+msgid "Paste the clipboard contents into a new brush"
+msgstr ""
+
+msgid "Brush name"
+msgstr ""
+
+msgid "File name"
+msgstr ""
+
+msgid "Spacing"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-sc-4.ok xg-sc-4.po
+result=$?
+
+exit $result