diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-09-12 22:23:59 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-09-12 22:23:59 +0000 |
commit | d19cbcb5e3dd83e2628d25d2cd23892a4cac83b0 (patch) | |
tree | 21cc6935b87686835780712e1d9a7d64eae418d0 /gcc/java/lex.h | |
parent | ee17a29049f330ff40a486e56826468a223323c2 (diff) | |
download | gcc-d19cbcb5e3dd83e2628d25d2cd23892a4cac83b0.zip gcc-d19cbcb5e3dd83e2628d25d2cd23892a4cac83b0.tar.gz gcc-d19cbcb5e3dd83e2628d25d2cd23892a4cac83b0.tar.bz2 |
re GNATS gcj/33 (gcj mangles composed characters)
Fix for PR gcj/33:
* jv-scan.c (help): Document --encoding.
(options): Added `encoding' entry.
(OPT_ENCODING): New define.
(main): Handle --encoding.
Include <langinfo.h> if nl_langinfo exists.
* lang-options.h: Document --classpath, --CLASSPATH, --main, and
--encoding.
* jcf-parse.c Include <langinfo.h> if we have nl_langinfo.
(parse_source_file): Correctly call java_init_lex. Added `finput'
argument. Use nl_langinfo to determine default encoding.
* java-tree.h (current_encoding): Declare.
* parse.y (java_parser_context_restore_global): Don't restore
`finput'.
(java_parser_context_save_global): Don't set `finput' field.
(java_pop_parser_context): Don't restore `finput'. Free old lexer
if required.
* lang.c (current_encoding): New global.
(lang_decode_option): Recognize `-fencoding='.
(finish_parse): Don't close finput.
* parse.h (struct parser_ctxt): Removed `finput' and
`unget_utf8_value' fields. Added `lexer' field.
(java_init_lex): Fixed declaration.
* lex.c (java_new_lexer): New function.
(java_destroy_lexer): Likewise.
(java_read_char): Added `lex' argument. Handle iconv case.
(java_read_unicode): Added `lex' argument. Count backslashes in
lexer structure.
(java_init_lex): Added `finput' and `encoding' arguments. Set
`lexer' field in ctxp.
(BAD_UTF8_VALUE): Removed.
(java_lex): Handle seeing UEOF in the middle of a string literal.
* lex.h: Include <iconv.h> if HAVE_ICONV defined.
(java_lexer): New structure.
(UNGETC): Removed.
(GETC): Removed.
(DEFAULT_ENCODING): New define.
(java_destroy_lexer): Declare.
From-SVN: r36377
Diffstat (limited to 'gcc/java/lex.h')
-rw-r--r-- | gcc/java/lex.h | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/gcc/java/lex.h b/gcc/java/lex.h index d4754ab..cf29aa1 100644 --- a/gcc/java/lex.h +++ b/gcc/java/lex.h @@ -35,6 +35,13 @@ extern int lineno; /* A Unicode character, as read from the input file */ typedef unsigned short unicode_t; +#ifdef HAVE_ICONV +#include <iconv.h> +#endif /* HAVE_ICONV */ + +/* Default encoding to use if no encoding is specified. */ +#define DEFAULT_ENCODING "UTF-8" + /* Debug macro to print-out what we match */ #ifdef JAVA_LEX_DEBUG #ifdef JAVA_LEX_DEBUG_CHAR @@ -96,12 +103,38 @@ typedef struct _java_lc { int col; } java_lc; +typedef struct java_lexer +{ + /* The file from which we're reading. */ + FILE *finput; -#define JAVA_LINE_MAX 80 + /* Number of consecutive backslashes we've read. */ + int bs_count; + + /* If nonzero, a value that was pushed back. */ + unicode_t unget_value; + +#ifdef HAVE_ICONV + /* The handle for the iconv converter we're using. */ + iconv_t handle; -/* Macro to read and unread bytes */ -#define UNGETC(c) ungetc(c, finput) -#define GETC() getc(finput) + /* Bytes we've read from the file but have not sent to iconv. */ + char buffer[1024]; + + /* Index of first valid character in buffer, -1 if no valid + characters. */ + int first; + + /* Index of last valid character in buffer, plus one. -1 if no + valid characters in buffer. */ + int last; +#endif /* HAVE_ICONV */ +} java_lexer; + +/* Destroy a lexer object. */ +extern void java_destroy_lexer PARAMS ((java_lexer *)); + +#define JAVA_LINE_MAX 80 /* Build a location compound integer */ #define BUILD_LOCATION() ((ctxp->elc.line << 12) | (ctxp->elc.col & 0xfff)) |