diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2005-02-20 17:01:32 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2005-02-20 17:01:32 +0000 |
commit | c5ff069dc46eb81aa4c0732ea5e6f76a535474b2 (patch) | |
tree | 60cdafb935d90504cac1d3437ff96f90d70b9c09 /gcc/c-pretty-print.c | |
parent | 5920b5d2e8ead646a8cbb66847a4586b4db16ad6 (diff) | |
download | gcc-c5ff069dc46eb81aa4c0732ea5e6f76a535474b2.zip gcc-c5ff069dc46eb81aa4c0732ea5e6f76a535474b2.tar.gz gcc-c5ff069dc46eb81aa4c0732ea5e6f76a535474b2.tar.bz2 |
re PR middle-end/18785 (isdigit builtin function fails with EBCDIC character sets)
PR 18785
libcpp:
* charset.c (LAST_POSSIBLY_BASIC_SOURCE_CHAR): New helper macro.
(cpp_host_to_exec_charset): New function.
* include/cpplib.h: Declare cpp_host_to_exec_charset.
gcc:
* langhooks.h (struct lang_hooks): Add to_target_charset.
* langhooks.c (lhd_to_target_charset): New function.
* langhooks-def.h: Declare lhd_to_target_charset.
(LANG_HOOKS_TO_TARGET_CHARSET): New macro.
(LANG_HOOKS_INITIALIZER): Update.
* c-common.c (c_common_to_target_charset): New function.
* c-common.h: Declare it.
* c-objc-common.h (LANG_HOOKS_TO_TARGET_CHARSET): Set to
c_common_to_target_charset.
* defaults.c (TARGET_BELL, TARGET_BS, TARGET_CR, TARGET_DIGIT0)
(TARGET_ESC, TARGET_FF, TARGET_NEWLINE, TARGET_TAB, TARGET_VT):
Delete definitions.
* system.h: Poison them.
* doc/tm.texi: Don't discuss them.
* builtins.c (fold_builtin_isdigit): Use lang_hooks.to_target_charset.
* c-pretty-print.c (pp_c_integer_constant): Don't use pp_c_char.
(pp_c_char): Do not attempt to generate letter escapes for
newline, tab, etc.
* config/arm/arm.c (output_ascii_pseudo_op): Likewise.
* config/mips/mips.c (mips_output_ascii): Likewise.
gcc/cp:
* cp-objcp-common.h (LANG_HOOKS_TO_TARGET_CHARSET): Set to
c_common_to_target_charset. Delete bogus comment.
gcc/testsuite:
* gcc.dg/charset/builtin1.c: New test.
From-SVN: r95304
Diffstat (limited to 'gcc/c-pretty-print.c')
-rw-r--r-- | gcc/c-pretty-print.c | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index 7b74124..aff29d9 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -712,50 +712,37 @@ pp_c_function_definition (c_pretty_printer *pp, tree t) /* Expressions. */ -/* Print out a c-char. */ +/* Print out a c-char. This is called solely for characters which are + in the *target* execution character set. We ought to convert them + back to the *host* execution character set before printing, but we + have no way to do this at present. A decent compromise is to print + all characters as if they were in the host execution character set, + and not attempt to recover any named escape characters, but render + all unprintables as octal escapes. If the host and target character + sets are the same, this produces relatively readable output. If they + are not the same, strings may appear as gibberish, but that's okay + (in fact, it may well be what the reader wants, e.g. if they are looking + to see if conversion to the target character set happened correctly). + + A special case: we need to prefix \, ", and ' with backslashes. It is + correct to do so for the *host*'s \, ", and ', because the rest of the + file appears in the host character set. */ static void pp_c_char (c_pretty_printer *pp, int c) { - switch (c) + if (ISPRINT (c)) { - case TARGET_NEWLINE: - pp_string (pp, "\\n"); - break; - case TARGET_TAB: - pp_string (pp, "\\t"); - break; - case TARGET_VT: - pp_string (pp, "\\v"); - break; - case TARGET_BS: - pp_string (pp, "\\b"); - break; - case TARGET_CR: - pp_string (pp, "\\r"); - break; - case TARGET_FF: - pp_string (pp, "\\f"); - break; - case TARGET_BELL: - pp_string (pp, "\\a"); - break; - case '\\': - pp_string (pp, "\\\\"); - break; - case '\'': - pp_string (pp, "\\'"); - break; - case '\"': - pp_string (pp, "\\\""); - break; - default: - if (ISPRINT (c)) - pp_character (pp, c); - else - pp_scalar (pp, "\\%03o", (unsigned) c); - break; + switch (c) + { + case '\\': pp_string (pp, "\\\\"); break; + case '\'': pp_string (pp, "\\\'"); break; + case '\"': pp_string (pp, "\\\""); break; + default: pp_character (pp, c); + } } + else + pp_scalar (pp, "\\%03o", (unsigned) c); } /* Print out a STRING literal. */ @@ -785,7 +772,7 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i) { if (tree_int_cst_sgn (i) < 0) { - pp_c_char (pp, '-'); + pp_character (pp, '-'); i = build_int_cst_wide (NULL_TREE, -TREE_INT_CST_LOW (i), ~TREE_INT_CST_HIGH (i) |