aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2004-06-15 21:43:21 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2004-06-15 21:43:21 +0000
commit0173bb6f2d715c4c3839c17e26a38bd522e07fa4 (patch)
tree67706b17f5cedee1c188770ea57183755dfc2428 /gcc/c-lex.c
parentd0b25f9a2b786f80b5a794f99732b7653afb1ec4 (diff)
downloadgcc-0173bb6f2d715c4c3839c17e26a38bd522e07fa4.zip
gcc-0173bb6f2d715c4c3839c17e26a38bd522e07fa4.tar.gz
gcc-0173bb6f2d715c4c3839c17e26a38bd522e07fa4.tar.bz2
c-pragma.h (c_lex_string_translate): Change type to int.
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. From-SVN: r83201
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 3a63a05..8172355 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
{