lex.c (java_parse_escape_sequence): Only read two octal characters if the first one...
authorTom Tromey <tromey@cygnus.com>
Sun, 5 Nov 2000 22:59:56 +0000 (22:59 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Sun, 5 Nov 2000 22:59:56 +0000 (22:59 +0000)
* lex.c (java_parse_escape_sequence): Only read two octal
characters if the first one is greater than 3.  Don't allow
"octal" numbers to include the digits 8 or 9.

From-SVN: r37267

gcc/java/ChangeLog
gcc/java/lex.c

index ab5162ee55331d46655bfa8b0db0d54e1816a689..5b77604a661ee3cd5835a2bbee754789c7a3df53 100644 (file)
@@ -1,3 +1,9 @@
+2000-11-04  Tom Tromey  <tromey@cygnus.com>
+
+       * lex.c (java_parse_escape_sequence): Only read two octal
+       characters if the first one is greater than 3.  Don't allow
+       "octal" numbers to include the digits 8 or 9.
+
 2000-11-05  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * Make-lang.in (java.distdir): Remove.
index 2c123ce87c19391fd889deab544704dc7444f305..1450570806567dc0777240c33bfbf7afa6af3ff5 100644 (file)
@@ -727,32 +727,32 @@ java_parse_escape_sequence ()
     case '\\':
       return (unicode_t)0x5c;
     case '0': case '1': case '2': case '3': case '4':
-    case '5': case '6': case '7': case '8': case '9':
+    case '5': case '6': case '7':
       {
        int octal_escape[3];
        int octal_escape_index = 0;
-       
-       for (; octal_escape_index < 3 && RANGE (c, '0', '9');
+       int max = 3;
+       int i, shift;
+
+       for (; octal_escape_index < max && RANGE (c, '0', '7');
             c = java_get_unicode ())
-         octal_escape [octal_escape_index++] = c;
+         {
+           if (octal_escape_index == 0 && c > '3')
+             {
+               /* According to the grammar, `\477' has a well-defined
+                  meaning -- it is `\47' followed by `7'.  */
+               --max;
+             }
+           octal_escape [octal_escape_index++] = c;
+         }
 
        java_unget_unicode ();
 
-       if ((octal_escape_index == 3) && (octal_escape [0] > '3'))
-         {
-           java_lex_error ("Literal octal escape out of range", 0);
-           return JAVA_CHAR_ERROR;
-         }
-       else
-         {
-           int i, shift;
-           for (char_lit=0, i = 0, shift = 3*(octal_escape_index-1);
-                i < octal_escape_index; i++, shift -= 3)
-             char_lit |= (octal_escape [i] - '0') << shift;
+       for (char_lit=0, i = 0, shift = 3*(octal_escape_index-1);
+            i < octal_escape_index; i++, shift -= 3)
+         char_lit |= (octal_escape [i] - '0') << shift;
 
-           return (char_lit);
-         }
-       break;
+       return char_lit;
       }
     case '\n':
       return '\n';             /* ULT, caught latter as a specific error */