diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-06-29 17:03:49 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-06-29 17:03:49 +0000 |
commit | 61d5c158833392a84403997867962ca7368392ee (patch) | |
tree | a5d813f0a2b5a9f34a9c63ae7df162dfa36725b8 /gcc | |
parent | 3097c22b202d860d624a6ada70866096d1b2aa5a (diff) | |
download | gcc-61d5c158833392a84403997867962ca7368392ee.zip gcc-61d5c158833392a84403997867962ca7368392ee.tar.gz gcc-61d5c158833392a84403997867962ca7368392ee.tar.bz2 |
lex.c (java_lineterminator): Don't recognize \r after \n.
* lex.c (java_lineterminator): Don't recognize \r after \n. If \r
follows \r, then unget it at a lower level.
From-SVN: r34782
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/java/lex.c | 24 |
2 files changed, 19 insertions, 10 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index fbd319b..dba6dc4 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2000-06-27 Tom Tromey <tromey@cygnus.com> + + * lex.c (java_lineterminator): Don't recognize \r after \n. If \r + follows \r, then unget it at a lower level. + 2000-06-26 Tom Tromey <tromey@cygnus.com> * parse.y (resolve_field_access): Pass decl, not DECL_INITIAL, to diff --git a/gcc/java/lex.c b/gcc/java/lex.c index c1d4c03..6efb907 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -347,19 +347,23 @@ static int java_lineterminator (c) unicode_t c; { - int unicode_escape_p; - if (c == '\n') /* CR */ + if (c == '\n') /* LF */ + return 1; + else if (c == '\r') /* CR */ { - if ((c = java_read_unicode (1, &unicode_escape_p)) != '\r') + int unicode_escape_p; + c = java_read_unicode (1, &unicode_escape_p); + if (c == '\r') { - ctxp->c_line->ahead [0] = c; - ctxp->c_line->unicode_escape_ahead_p = unicode_escape_p; + /* In this case we will have another terminator. For some + reason the lexer has several different unget methods. We + can't use the `ahead' method because then the \r will end + up in the actual text of the line, causing an error. So + instead we choose a very low-level method. FIXME: this + is incredibly ugly. */ + UNGETC (c); } - return 1; - } - else if (c == '\r') /* LF */ - { - if ((c = java_read_unicode (1, &unicode_escape_p)) != '\n') + else if (c != '\n') { ctxp->c_line->ahead [0] = c; ctxp->c_line->unicode_escape_ahead_p = unicode_escape_p; |