Commit 783e2989 by Neil Booth Committed by Neil Booth

c-opts.c: Default TARGET_EBCDIC to 0 if not defined.

	* c-opts.c: Default TARGET_EBCDIC to 0 if not defined.
	(c_common_init): Set EBCDIC in cpp options.
	* cpplex.c (maybe_read_ucs, cpp_parse_escape): Use EBCDIC option,
	not conditional compilation.
	* cpplib.h (struct cpp_options): New entry EBCDIC.

From-SVN: r64471
parent 72ecfc60
2003-03-17 Neil Booth <neil@daikokuya.co.uk> 2003-03-17 Neil Booth <neil@daikokuya.co.uk>
* c-opts.c: Default TARGET_EBCDIC to 0 if not defined.
(c_common_init): Set EBCDIC in cpp options.
* cpplex.c (maybe_read_ucs, cpp_parse_escape): Use EBCDIC option,
not conditional compilation.
* cpplib.h (struct cpp_options): New entry EBCDIC.
2003-03-17 Neil Booth <neil@daikokuya.co.uk>
* fix-header.c (read_scan_file): Need to malloc arguments to add_path. * fix-header.c (read_scan_file): Need to malloc arguments to add_path.
2003-03-17 Michael Hayes <m.hayes@elec.canterbury.ac.nz> 2003-03-17 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
......
...@@ -40,6 +40,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -40,6 +40,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# define TARGET_SYSTEM_ROOT NULL # define TARGET_SYSTEM_ROOT NULL
#endif #endif
#ifndef TARGET_EBCDIC
# define TARGET_EBCDIC 0
#endif
static int saved_lineno; static int saved_lineno;
/* CPP's options. */ /* CPP's options. */
...@@ -1590,6 +1594,7 @@ c_common_init () ...@@ -1590,6 +1594,7 @@ c_common_init ()
cpp_opts->int_precision = TYPE_PRECISION (integer_type_node); cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node); cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node); cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
cpp_opts->EBCDIC = TARGET_EBCDIC;
if (flag_preprocess_only) if (flag_preprocess_only)
{ {
......
...@@ -1731,14 +1731,15 @@ maybe_read_ucs (pfile, pstr, limit, pc) ...@@ -1731,14 +1731,15 @@ maybe_read_ucs (pfile, pstr, limit, pc)
} }
} }
#ifdef TARGET_EBCDIC if (CPP_OPTION (pfile, EBCDIC))
cpp_error (pfile, DL_ERROR, "universal-character-name on EBCDIC target"); {
code = 0x3f; /* EBCDIC invalid character */ cpp_error (pfile, DL_ERROR, "universal-character-name on EBCDIC target");
#else code = 0x3f; /* EBCDIC invalid character */
/* True extended characters are OK. */ }
if (code >= 0xa0 /* True extended characters are OK. */
&& !(code & 0x80000000) else if (code >= 0xa0
&& !(code >= 0xD800 && code <= 0xDFFF)) && !(code & 0x80000000)
&& !(code >= 0xD800 && code <= 0xDFFF))
; ;
/* The standard permits $, @ and ` to be specified as UCNs. We use /* The standard permits $, @ and ` to be specified as UCNs. We use
hex escapes so that this also works with EBCDIC hosts. */ hex escapes so that this also works with EBCDIC hosts. */
...@@ -1747,7 +1748,6 @@ maybe_read_ucs (pfile, pstr, limit, pc) ...@@ -1747,7 +1748,6 @@ maybe_read_ucs (pfile, pstr, limit, pc)
/* Don't give another error if one occurred above. */ /* Don't give another error if one occurred above. */
else if (length == 0) else if (length == 0)
cpp_error (pfile, DL_ERROR, "universal-character-name out of range"); cpp_error (pfile, DL_ERROR, "universal-character-name out of range");
#endif
*pstr = p; *pstr = p;
*pc = code; *pc = code;
...@@ -1766,11 +1766,20 @@ cpp_parse_escape (pfile, pstr, limit, wide) ...@@ -1766,11 +1766,20 @@ cpp_parse_escape (pfile, pstr, limit, wide)
const unsigned char *limit; const unsigned char *limit;
int wide; int wide;
{ {
/* Values of \a \b \e \f \n \r \t \v respectively. */
static const uchar ascii[] = { 7, 8, 27, 12, 10, 13, 9, 11 };
static const uchar ebcdic[] = { 47, 22, 39, 12, 21, 13, 5, 11 };
int unknown = 0; int unknown = 0;
const unsigned char *str = *pstr; const unsigned char *str = *pstr, *charconsts;
cppchar_t c, mask; cppchar_t c, mask;
unsigned int width; unsigned int width;
if (CPP_OPTION (pfile, EBCDIC))
charconsts = ebcdic;
else
charconsts = ascii;
if (wide) if (wide)
width = CPP_OPTION (pfile, wchar_precision); width = CPP_OPTION (pfile, wchar_precision);
else else
...@@ -1784,12 +1793,12 @@ cpp_parse_escape (pfile, pstr, limit, wide) ...@@ -1784,12 +1793,12 @@ cpp_parse_escape (pfile, pstr, limit, wide)
switch (c) switch (c)
{ {
case '\\': case '\'': case '"': case '?': break; case '\\': case '\'': case '"': case '?': break;
case 'b': c = TARGET_BS; break; case 'b': c = charconsts[1]; break;
case 'f': c = TARGET_FF; break; case 'f': c = charconsts[3]; break;
case 'n': c = TARGET_NEWLINE; break; case 'n': c = charconsts[4]; break;
case 'r': c = TARGET_CR; break; case 'r': c = charconsts[5]; break;
case 't': c = TARGET_TAB; break; case 't': c = charconsts[6]; break;
case 'v': c = TARGET_VT; break; case 'v': c = charconsts[7]; break;
case '(': case '{': case '[': case '%': case '(': case '{': case '[': case '%':
/* '\(', etc, are used at beginning of line to avoid confusing Emacs. /* '\(', etc, are used at beginning of line to avoid confusing Emacs.
...@@ -1801,14 +1810,14 @@ cpp_parse_escape (pfile, pstr, limit, wide) ...@@ -1801,14 +1810,14 @@ cpp_parse_escape (pfile, pstr, limit, wide)
if (CPP_WTRADITIONAL (pfile)) if (CPP_WTRADITIONAL (pfile))
cpp_error (pfile, DL_WARNING, cpp_error (pfile, DL_WARNING,
"the meaning of '\\a' is different in traditional C"); "the meaning of '\\a' is different in traditional C");
c = TARGET_BELL; c = charconsts[0];
break; break;
case 'e': case 'E': case 'e': case 'E':
if (CPP_PEDANTIC (pfile)) if (CPP_PEDANTIC (pfile))
cpp_error (pfile, DL_PEDWARN, cpp_error (pfile, DL_PEDWARN,
"non-ISO-standard escape sequence, '\\%c'", (int) c); "non-ISO-standard escape sequence, '\\%c'", (int) c);
c = TARGET_ESC; c = charconsts[2];
break; break;
case 'u': case 'U': case 'u': case 'U':
......
...@@ -329,6 +329,12 @@ struct cpp_options ...@@ -329,6 +329,12 @@ struct cpp_options
/* True for traditional preprocessing. */ /* True for traditional preprocessing. */
unsigned char traditional; unsigned char traditional;
/* True to warn about precompiled header files we couldn't use. */
bool warn_invalid_pch;
/* True if dependencies should be restored from a precompiled header. */
bool restore_pch_deps;
/* Dependency generation. */ /* Dependency generation. */
struct struct
{ {
...@@ -355,14 +361,11 @@ struct cpp_options ...@@ -355,14 +361,11 @@ struct cpp_options
/* True means chars (wide chars) are unsigned. */ /* True means chars (wide chars) are unsigned. */
bool unsigned_char, unsigned_wchar; bool unsigned_char, unsigned_wchar;
/* True if target is EBCDIC. */
bool EBCDIC;
/* Nonzero means __STDC__ should have the value 0 in system headers. */ /* Nonzero means __STDC__ should have the value 0 in system headers. */
unsigned char stdc_0_in_system_headers; unsigned char stdc_0_in_system_headers;
/* True to warn about precompiled header files we couldn't use. */
bool warn_invalid_pch;
/* True if dependencies should be restored from a precompiled header. */
bool restore_pch_deps;
}; };
/* Call backs. */ /* Call backs. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment