Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / src / x-scheme.c
index 1ddcb2d..abbe0e5 100644 (file)
@@ -1,5 +1,5 @@
 /* xgettext Scheme backend.
-   Copyright (C) 2004-2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2004-2009, 2011, 2015 Free Software Foundation, Inc.
 
    This file was written by Bruno Haible <bruno@clisp.org>, 2004-2005.
 
@@ -498,7 +498,6 @@ is_number (const struct token *tp)
 {
   const char *str = tp->chars;
   int len = tp->charcount;
-  int radix = 10;
   enum { unknown, exact, inexact } exactness = unknown;
   bool seen_radix_prefix = false;
   bool seen_exactness_prefix = false;
@@ -513,25 +512,21 @@ is_number (const struct token *tp)
         case 'B': case 'b':
           if (seen_radix_prefix)
             return false;
-          radix = 2;
           seen_radix_prefix = true;
           break;
         case 'O': case 'o':
           if (seen_radix_prefix)
             return false;
-          radix = 8;
           seen_radix_prefix = true;
           break;
         case 'D': case 'd':
           if (seen_radix_prefix)
             return false;
-          radix = 10;
           seen_radix_prefix = true;
           break;
         case 'X': case 'x':
           if (seen_radix_prefix)
             return false;
-          radix = 16;
           seen_radix_prefix = true;
           break;
         case 'E': case 'e':
@@ -682,6 +677,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 +1163,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 +1243,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;