summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-05 22:59:56 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-05 22:59:56 +0000
commitd3fafebc837722c1b5ace30c8e990ae58bf91919 (patch)
treebf6dbca8e304c63e7ed2188aa9b3e0c9f5a21ebd /gcc
parente93eecf56b1325d7e16f05c2d303cf01b32fbe63 (diff)
downloadgcc-d3fafebc837722c1b5ace30c8e990ae58bf91919.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37267 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/java/ChangeLog6
-rw-r--r--gcc/java/lex.c36
2 files changed, 24 insertions, 18 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index ab5162ee553..5b77604a661 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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.
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 2c123ce87c1..14505708065 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 */