This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] fix exec-charset


As Zack promised here's the patch that fixes exec-charset. Tested by
bootstrapping on x86-linux and hand testing with IBM1047 as an execution
character set.

OK?

Mark: I also suggest that this go into 3.4 since exec-charset is useless
(or almost so) without it.

-eric

-- 
Eric Christopher <echristo@redhat.com>

2004-02-12  Eric Christopher  <echristo@redhat.com>

	* c-lex.c (c_lex_string_translate): New global.
	(lex_string): Use.
	* c-pragma.h: Prototype.
	* c-parse.in: Have ATTRIBUTE start and stop string
	translation. Ditto with ASM_KEYWORD.
	(start_string_translation): New. Sets c_lex_string_translate.
	(stop_string_translation): Ditto.
	* cp/parser.c (cp_parser_asm_definition): Bracket parsing
	asm statements with c_lex_string_translate.
	(cp_parser_attribute_list): Ditto.

Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.219
diff -u -p -w -r1.219 c-lex.c
--- c-lex.c	11 Feb 2004 15:29:23 -0000	1.219
+++ c-lex.c	13 Feb 2004 00:20:54 -0000
@@ -54,6 +54,7 @@ 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.  */
 
 static tree interpret_integer (const cpp_token *, unsigned int);
 static tree interpret_float (const cpp_token *, unsigned int);
@@ -693,7 +694,9 @@ lex_string (const cpp_token *tok, tree *
   if (count > 1 && !objc_string && warn_traditional &&
!in_system_header)
     warning ("traditional C rejects string constant concatenation");
 
-  if (cpp_interpret_string (parse_in, strs, count, &istr, wide))
+  if ((c_lex_string_translate
+       ? cpp_interpret_string : cpp_interpret_string_notranslate)
+      (parse_in, strs, count, &istr, wide))
     {
       value = build_string (istr.len, (char *)istr.text);
       free ((void *)istr.text);
Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.200
diff -u -p -w -r1.200 c-parse.in
--- c-parse.in	12 Feb 2004 19:14:00 -0000	1.200
+++ c-parse.in	13 Feb 2004 00:20:55 -0000
@@ -1432,8 +1432,9 @@ attributes:
 	;
 
 attribute:
-      ATTRIBUTE '(' '(' attribute_list ')' ')'
-		{ $$ = $4; }
+      ATTRIBUTE stop_string_translation
+            '(' '(' attribute_list ')' ')' start_string_translation
+		{ $$ = $5; }
 	;
 
 attribute_list:
@@ -2480,7 +2481,7 @@ label:	  CASE expr_no_commas ':'
 /* simple_asm_expr is used in restricted contexts, where a full
    expression with inputs and outputs does not make sense.  */
 simple_asm_expr:
-	ASM_KEYWORD '(' STRING ')'
+	asm_keyword '(' STRING ')' start_string_translation
 		{ $$ = $3; }
 	;
 
@@ -2500,7 +2501,8 @@ asmdef:
 /* Full-blown asm statement with inputs, outputs, clobbers, and
    volatile tag allowed.  */
 asm_stmt:
-	ASM_KEYWORD maybe_volatile '(' asm_argument ')' ';'
+	asm_keyword maybe_volatile '(' asm_argument ')'
+	   start_string_translation ';'
 		{ stmt_count++;
 		  $$ = build_asm_stmt ($2, $4); }
 	;
@@ -2738,6 +2740,20 @@ extension:
 		  warn_traditional = 0;
 		  flag_iso = 0; }
 	;
+
+asm_keyword:
+        ASM_KEYWORD stop_string_translation
+        {}
+        ;
+
+stop_string_translation:
+        { c_lex_string_translate = false; }
+        ;
+
+start_string_translation:
+        { c_lex_string_translate = true; }
+        ;
+
 
 @@ifobjc
 /* Objective-C productions.  */
Index: c-pragma.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pragma.h,v
retrieving revision 1.38
diff -u -p -w -r1.38 c-pragma.h
--- c-pragma.h	31 Jan 2004 02:06:41 -0000	1.38
+++ c-pragma.h	13 Feb 2004 00:20:55 -0000
@@ -57,4 +57,8 @@ extern void add_to_renaming_pragma_list 
 extern int c_lex (tree *);
 extern int c_lex_with_flags (tree *, unsigned char *);
 
+/* If true, then lex strings into the execution character set.  
+   Otherwise, lex strings into the host character set.  */
+extern bool c_lex_string_translate;
+
 #endif /* GCC_C_PRAGMA_H */
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.172
diff -u -p -w -r1.172 parser.c
--- cp/parser.c	9 Feb 2004 14:55:59 -0000	1.172
+++ cp/parser.c	13 Feb 2004 00:21:01 -0000
@@ -9741,9 +9741,10 @@ cp_parser_asm_definition (cp_parser* par
   /* Look for the opening `('.  */
   cp_parser_require (parser, CPP_OPEN_PAREN, "`('");
   /* Look for the string.  */
+  c_lex_string_translate = false;
   token = cp_parser_require (parser, CPP_STRING, "asm body");
   if (!token)
-    return;
+    goto finish;
   string = token->value;
   /* If we're allowing GNU extensions, check for the extended assembly
      syntax.  Unfortunately, the `:' tokens need not be separated by 
@@ -9837,6 +9838,9 @@ cp_parser_asm_definition (cp_parser* par
     }
   else
     assemble_asm (string);
+
+ finish:
+  c_lex_string_translate = true;
 }
 
 /* Declarators [gram.dcl.decl] */
@@ -13396,6 +13400,7 @@ cp_parser_attribute_list (cp_parser* par
 {
   tree attribute_list = NULL_TREE;
 
+  c_lex_string_translate = false;
   while (true)
     {
       cp_token *token;
@@ -13441,6 +13446,7 @@ cp_parser_attribute_list (cp_parser* par
       /* Consume the comma and keep going.  */
       cp_lexer_consume_token (parser->lexer);
     }
+  c_lex_string_translate = true;
 
   /* We built up the list in reverse order.  */
   return nreverse (attribute_list);



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]