aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-01-28 18:47:52 +0000
committerTom Tromey <tromey@gcc.gnu.org>2003-01-28 18:47:52 +0000
commit82b22c42f92a4fe76e4cd83ba9ab3cce5ccf6dc3 (patch)
treec39ef1d10cdd0034ca01bb377913fcd770b6873b /gcc
parentbffcd064da34369768a4b20dbbcbd1211e55032d (diff)
downloadgcc-82b22c42f92a4fe76e4cd83ba9ab3cce5ccf6dc3.zip
gcc-82b22c42f92a4fe76e4cd83ba9ab3cce5ccf6dc3.tar.gz
gcc-82b22c42f92a4fe76e4cd83ba9ab3cce5ccf6dc3.tar.bz2
lex.c (java_lex): Don't include UEOF as part of token.
* lex.c (java_lex): Don't include UEOF as part of token. (java_read_unicode): Error if \u sequence prematurely terminated. From-SVN: r61993
Diffstat (limited to 'gcc')
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/lex.c37
2 files changed, 28 insertions, 14 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index ed7106b..042b7db 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,8 @@
+2003-01-28 Tom Tromey <tromey@redhat.com>
+
+ * lex.c (java_lex): Don't include UEOF as part of token.
+ (java_read_unicode): Error if \u sequence prematurely terminated.
+
2003-01-27 Tom Tromey <tromey@redhat.com>
* parse.y (java_check_regular_methods): Check for construct after
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 0aded3f..370217e 100644
--- a/gcc/java/lex.c
+++ b/gcc/java/lex.c
@@ -542,23 +542,31 @@ java_read_unicode (java_lexer *lex, int *unicode_escape_p)
while ((c = java_read_char (lex)) == 'u')
;
- /* Unget the most recent character as it is not a `u'. */
- if (c == UEOF)
- return UEOF;
- lex->unget_value = c;
-
- /* Next should be 4 hex digits, otherwise it's an error.
- The hex value is converted into the unicode, pushed into
- the Unicode stream. */
- for (shift = 12; shift >= 0; shift -= 4)
+ shift = 12;
+ do
{
- if ((c = java_read_char (lex)) == UEOF)
- return UEOF;
+ if (c == UEOF)
+ {
+ java_lex_error ("prematurely terminated \\u sequence", 0);
+ return UEOF;
+ }
+
if (hex_p (c))
unicode |= (unicode_t)(hex_value (c) << shift);
else
- java_lex_error ("Non hex digit in Unicode escape sequence", 0);
+ {
+ java_lex_error ("non-hex digit in \\u sequence", 0);
+ break;
+ }
+
+ c = java_read_char (lex);
+ shift -= 4;
}
+ while (shift >= 0);
+
+ if (c != UEOF)
+ lex->unget_value = c;
+
lex->bs_count = 0;
*unicode_escape_p = 1;
return unicode;
@@ -1514,7 +1522,7 @@ java_lex (YYSTYPE *java_lval)
/* Keyword, boolean literal or null literal. */
for (first_unicode = c, all_ascii = 1, ascii_index = 0;
- JAVA_PART_CHAR_P (c); c = java_get_unicode ())
+ c != UEOF && JAVA_PART_CHAR_P (c); c = java_get_unicode ())
{
java_unicode_2_utf8 (c);
if (all_ascii && c >= 128)
@@ -1524,7 +1532,8 @@ java_lex (YYSTYPE *java_lval)
obstack_1grow (&temporary_obstack, '\0');
string = obstack_finish (&temporary_obstack);
- java_unget_unicode ();
+ if (c != UEOF)
+ java_unget_unicode ();
/* If we have something all ascii, we consider a keyword, a boolean
literal, a null literal or an all ASCII identifier. Otherwise,