diff options
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/lex.c | 13 | ||||
-rw-r--r-- | gcc/java/lex.h | 3 |
3 files changed, 19 insertions, 3 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 2b6ada6..a51d4a1 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2004-05-26 Bryce McKinlay <mckinlay@redhat.com> + + * lex.c (java_new_lexer): Set 'encoding'. + (java_read_char): Improve error message for unrecognized characters. + * lex.h (struct java_lexer): New field 'encoding'. + 2004-05-23 Paolo Bonzini <bonzini@gnu.org> * Make-lang.in: Link in $(LIBCPP) instead of mkdeps.o. diff --git a/gcc/java/lex.c b/gcc/java/lex.c index 18c0a8a..de9b222 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -228,6 +228,7 @@ java_new_lexer (FILE *finput, const char *encoding) lex->bs_count = 0; lex->unget_value = 0; lex->hit_eof = 0; + lex->encoding = encoding; #ifdef HAVE_ICONV lex->handle = iconv_open ("UCS-2", encoding); @@ -295,7 +296,10 @@ java_new_lexer (FILE *finput, const char *encoding) enc_error = 1; #ifdef HAVE_ICONV else - lex->use_fallback = 1; + { + lex->use_fallback = 1; + lex->encoding = "UTF-8"; + } #endif /* HAVE_ICONV */ } @@ -430,8 +434,11 @@ java_read_char (java_lexer *lex) else { /* A more serious error. */ - java_lex_error ("unrecognized character in input stream", - 0); + char buffer[128]; + sprintf (buffer, + "Unrecognized character for encoding '%s'", + lex->encoding); + java_lex_error (buffer, 0); return UEOF; } } diff --git a/gcc/java/lex.h b/gcc/java/lex.h index c339cc1..213a80f 100644 --- a/gcc/java/lex.h +++ b/gcc/java/lex.h @@ -116,6 +116,9 @@ struct java_lexer /* If nonzero, we've hit EOF. Used only by java_get_unicode(). */ int hit_eof : 1; + + /* Name of the character encoding we're using. */ + const char *encoding; #ifdef HAVE_ICONV /* Nonzero if we've read any bytes. We only recognize the |