aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/lex.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-11-05 22:59:56 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-11-05 22:59:56 +0000
commitcbf53a1d5e052958d1581083c65de96bebef10ce (patch)
treebf6dbca8e304c63e7ed2188aa9b3e0c9f5a21ebd /gcc/java/lex.c
parent35f93a1e2d5c15959d2de3d4233c69b0f87c8f2b (diff)
downloadgcc-cbf53a1d5e052958d1581083c65de96bebef10ce.zip
gcc-cbf53a1d5e052958d1581083c65de96bebef10ce.tar.gz
gcc-cbf53a1d5e052958d1581083c65de96bebef10ce.tar.bz2
lex.c (java_parse_escape_sequence): Only read two octal characters if the first one is greater than 3.
* 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
Diffstat (limited to 'gcc/java/lex.c')
-rw-r--r--gcc/java/lex.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 2c123ce..1450570 100644
--- a/gcc/java/lex.c
+++ b/gcc/java/lex.c
@@ -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 */