diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-15 21:43:21 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-15 21:43:21 +0000 |
commit | 3fe7c9431a10fd60756e08ab9c8481b7baad1827 (patch) | |
tree | 67706b17f5cedee1c188770ea57183755dfc2428 /gcc/c-lex.c | |
parent | 1820c0c56fc4089dd79ce89ea68b7782925b2d0a (diff) | |
download | gcc-3fe7c9431a10fd60756e08ab9c8481b7baad1827.tar.gz |
gcc/ChangeLog:
* c-pragma.h (c_lex_string_translate): Change type to int.
* c-parse.in: Change all assignments of c_lex_string_translate
to true and false to 1 and 0.
* c-lex.c (c_lex_string_translate): Likewise.
(lex_string): Convert string without translation in the -1
case.
gcc/cp/ChangeLog:
* parser.c: Change all assignments of c_lex_string_translate
to true and false to 1 and 0.
(cp_lexer_read_token): Convert type of the translated string.
(cp_parser_skip_to_closing_parentheses): Preserve original
value of c_lex_string_translate, and set it to -1 while
running.
(cp_parser_cache_group): Likewise.
(cp_parser_cache_group_1): Renamed.
(cp_parser_asm_operand_list): Remove redundant setting of
c_lex_string_translate.
(cp_parser_primary_expression) [CPP_STRING, CPP_WSTRING]:
Handle chained strings.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83201 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r-- | gcc/c-lex.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 3a63a053b79..81723550b13 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -53,7 +53,12 @@ static splay_tree file_info_tree; int pending_lang_change; /* If we need to switch languages - C++ only */ int c_header_level; /* depth in C headers - C++ only */ -bool c_lex_string_translate = true; /* If we need to translate characters received. */ + +/* If we need to translate characters received. This is tri-state: + 0 means use only the untranslated string; 1 means use only + the translated string; -1 means chain the translated string + to the untranslated one. */ +int c_lex_string_translate = 1; static tree interpret_integer (const cpp_token *, unsigned int); static tree interpret_float (const cpp_token *, unsigned int); @@ -699,6 +704,28 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) { value = build_string (istr.len, (char *)istr.text); free ((void *)istr.text); + + if (c_lex_string_translate == -1) + { + if (!cpp_interpret_string_notranslate (parse_in, strs, count, + &istr, wide)) + /* Assume that, if we managed to translate the string + above, then the untranslated parsing will always + succeed. */ + abort (); + + if (TREE_STRING_LENGTH (value) != (int)istr.len + || 0 != strncmp (TREE_STRING_POINTER (value), (char *)istr.text, + istr.len)) + { + /* Arrange for us to return the untranslated string in + *valp, but to set up the C type of the translated + one. */ + *valp = build_string (istr.len, (char *)istr.text); + valp = &TREE_CHAIN (*valp); + } + free ((void *)istr.text); + } } else { |