Commit b9d861bc by Bryce McKinlay Committed by Bryce McKinlay

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
parent e0885edb
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.
......
......@@ -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;
}
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment