]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Tweak string control sequence parser.
authorBruno Haible <bruno@clisp.org>
Wed, 23 Aug 2000 21:06:21 +0000 (21:06 +0000)
committerBruno Haible <bruno@clisp.org>
Wed, 23 Aug 2000 21:06:21 +0000 (21:06 +0000)
src/ChangeLog
src/po-lex.c

index 6bd700bbcd778dd94b905bb4723ebfc533155c37..a956ef4d3a4236678761b0454ce8f1da88222743 100644 (file)
@@ -1,3 +1,8 @@
+2000-08-23  Bruno Haible  <haible@clisp.cons.org>
+
+       * po-lex.c (ALERT_CHAR): New constant macro.
+       (control_sequence): Accept \a. Don't accept \X.
+
 2000-08-23  Ulrich Drepper  <drepper@redhat.com>
 
        * po-lex.c (control_sequence): Unget character which ended \x..
index 549aa497119ec4a84059912045102208381bd27c..248ddc3a634de98166418601979909e97728dc94 100644 (file)
 #include "error.h"
 #include "po-gram-gen2.h"
 
+#if HAVE_C_BACKSLASH_A
+# define ALERT_CHAR '\a'
+#else
+# define ALERT_CHAR '\7'
+#endif
+
 
 static FILE *fp;
 lex_pos_ty gram_pos;
@@ -271,6 +277,9 @@ control_sequence ()
     case 'v':
       return '\v';
 
+    case 'a':
+      return ALERT_CHAR;
+
     case '\\':
     case '"':
       return c;
@@ -278,10 +287,13 @@ control_sequence ()
     case '0': case '1': case '2': case '3':
     case '4': case '5': case '6': case '7':
       val = 0;
-      for (max = 0; max < 3; ++max)
+      max = 0;
+      for (;;)
        {
          /* Warning: not portable, can't depend on '0'..'7' ordering.  */
-         val = val * 8 + c - '0';
+         val = val * 8 + (c - '0');
+         if (++max == 3)
+           break;
          c = lex_getc ();
          switch (c)
            {
@@ -292,12 +304,12 @@ control_sequence ()
            default:
              break;
            }
+         lex_ungetc (c);
          break;
        }
-      lex_ungetc (c);
       return val;
 
-    case 'x': case 'X':
+    case 'x':
       c = lex_getc ();
       if (c == EOF || !isxdigit (c))
        break;
@@ -328,10 +340,12 @@ control_sequence ()
            default:
              break;
            }
+         lex_ungetc (c);
          break;
        }
-      lex_ungetc (c);
       return val;
+
+    /* FIXME: \u and \U are not handled.  */
     }
   po_gram_error (_("invalid control sequence"));
   return ' ';
@@ -435,6 +449,7 @@ po_gram_lex ()
            }
          buf[bufpos] = 0;
 
+         /* FIXME: Treatment of embedded \000 chars is incorrect.  */
          po_gram_lval.string = xstrdup (buf);
          return STRING;