From: Bryce McKinlay Date: Wed, 26 May 2004 18:45:26 +0000 (+0000) Subject: lex.c (java_new_lexer): Set 'encoding'. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b9d861bc86c97e68ea474750bb33dfd10f72119d;p=gcc.git lex.c (java_new_lexer): Set 'encoding'. * lex.c (java_new_lexer): Set 'encoding'. (java_read_char): Improve error message for unrecognized characters. * lex.h (struct java_lexer): New field 'encoding'. From-SVN: r82292 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 2b6ada67561..a51d4a17517 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2004-05-26 Bryce McKinlay + + * 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 * Make-lang.in: Link in $(LIBCPP) instead of mkdeps.o. diff --git a/gcc/java/lex.c b/gcc/java/lex.c index 18c0a8adb9a..de9b2222e0b 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 c339cc13e51..213a80f3c5d 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