Commit 9b55f29a by Neil Booth Committed by Neil Booth

cppinit.c: (cpp_reader_init): Allow digraphs by default.

	* cppinit.c: (cpp_reader_init): Allow digraphs by default.
	(handle_option): Set digraphs according to standard.
	Merge OPT_lang_c89 handler with OPT_std_c89.

	* cpplex.c: (lex_line, can_paste): Honour digraphs in
	accordance with	the digraphs flag.

	* cpplib.h: (struct cpp_options): New option digraphs.

From-SVN: r34956
parent bb6a53c7
2000-07-11 Neil Booth <NeilB@earthling.net>
* cppinit.c: (cpp_reader_init): Allow digraphs by default.
(handle_option): Set digraphs according to standard.
Merge OPT_lang_c89 handler with OPT_std_c89.
* cpplex.c: (lex_line, can_paste): Honour digraphs in
accordance with the digraphs flag.
* cpplib.h: (struct cpp_options): New option digraphs.
2000-07-10 Hans-Peter Nilsson <hp@axis.com> 2000-07-10 Hans-Peter Nilsson <hp@axis.com>
Bruce Korb <bkorb@gnu.org> Bruce Korb <bkorb@gnu.org>
......
...@@ -418,6 +418,7 @@ cpp_reader_init (pfile) ...@@ -418,6 +418,7 @@ cpp_reader_init (pfile)
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, warn_import) = 1; CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, warn_paste) = 1; CPP_OPTION (pfile, warn_paste) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, discard_comments) = 1; CPP_OPTION (pfile, discard_comments) = 1;
CPP_OPTION (pfile, show_column) = 1; CPP_OPTION (pfile, show_column) = 1;
CPP_OPTION (pfile, tabstop) = 8; CPP_OPTION (pfile, tabstop) = 8;
...@@ -1270,6 +1271,7 @@ handle_option (pfile, argc, argv) ...@@ -1270,6 +1271,7 @@ handle_option (pfile, argc, argv)
CPP_OPTION (pfile, traditional) = 1; CPP_OPTION (pfile, traditional) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 0; CPP_OPTION (pfile, cplusplus_comments) = 0;
CPP_OPTION (pfile, trigraphs) = 0; CPP_OPTION (pfile, trigraphs) = 0;
CPP_OPTION (pfile, digraphs) = 0;
CPP_OPTION (pfile, warn_trigraphs) = 0; CPP_OPTION (pfile, warn_trigraphs) = 0;
break; break;
case OPT_trigraphs: case OPT_trigraphs:
...@@ -1291,23 +1293,16 @@ handle_option (pfile, argc, argv) ...@@ -1291,23 +1293,16 @@ handle_option (pfile, argc, argv)
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 1; CPP_OPTION (pfile, c99) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
break; break;
case OPT_lang_c89:
CPP_OPTION (pfile, cplusplus) = 0;
CPP_OPTION (pfile, cplusplus_comments) = 0;
CPP_OPTION (pfile, c89) = 1;
CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, trigraphs) = 1;
new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
break;
case OPT_lang_cplusplus: case OPT_lang_cplusplus:
CPP_OPTION (pfile, cplusplus) = 1; CPP_OPTION (pfile, cplusplus) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, digraphs) = 1;
new_pending_directive (pend, "__cplusplus", cpp_define); new_pending_directive (pend, "__cplusplus", cpp_define);
break; break;
case OPT_lang_objcplusplus: case OPT_lang_objcplusplus:
...@@ -1353,6 +1348,7 @@ handle_option (pfile, argc, argv) ...@@ -1353,6 +1348,7 @@ handle_option (pfile, argc, argv)
CPP_OPTION (pfile, c89) = 1; CPP_OPTION (pfile, c89) = 1;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, digraphs) = 1;
break; break;
case OPT_std_gnu9x: case OPT_std_gnu9x:
case OPT_std_gnu99: case OPT_std_gnu99:
...@@ -1360,6 +1356,7 @@ handle_option (pfile, argc, argv) ...@@ -1360,6 +1356,7 @@ handle_option (pfile, argc, argv)
CPP_OPTION (pfile, cplusplus_comments) = 1; CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 1; CPP_OPTION (pfile, c99) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
new_pending_directive (CPP_OPTION (pfile, pending), new_pending_directive (CPP_OPTION (pfile, pending),
"__STDC_VERSION__=199901L", cpp_define); "__STDC_VERSION__=199901L", cpp_define);
...@@ -1370,14 +1367,15 @@ handle_option (pfile, argc, argv) ...@@ -1370,14 +1367,15 @@ handle_option (pfile, argc, argv)
/* Fall through */ /* Fall through */
case OPT_std_iso9899_1990: case OPT_std_iso9899_1990:
case OPT_std_c89: case OPT_std_c89:
case OPT_lang_c89:
CPP_OPTION (pfile, cplusplus) = 0; CPP_OPTION (pfile, cplusplus) = 0;
CPP_OPTION (pfile, cplusplus_comments) = 0; CPP_OPTION (pfile, cplusplus_comments) = 0;
CPP_OPTION (pfile, c89) = 1; CPP_OPTION (pfile, c89) = 1;
CPP_OPTION (pfile, c99) = 0; CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, digraphs) = opt_code == OPT_std_iso9899_199409;
CPP_OPTION (pfile, trigraphs) = 1; CPP_OPTION (pfile, trigraphs) = 1;
new_pending_directive (CPP_OPTION (pfile, pending), new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
"__STRICT_ANSI__", cpp_define);
break; break;
case OPT_std_iso9899_199x: case OPT_std_iso9899_199x:
case OPT_std_iso9899_1999: case OPT_std_iso9899_1999:
...@@ -1388,6 +1386,7 @@ handle_option (pfile, argc, argv) ...@@ -1388,6 +1386,7 @@ handle_option (pfile, argc, argv)
CPP_OPTION (pfile, c89) = 0; CPP_OPTION (pfile, c89) = 0;
CPP_OPTION (pfile, c99) = 1; CPP_OPTION (pfile, c99) = 1;
CPP_OPTION (pfile, objc) = 0; CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, trigraphs) = 1; CPP_OPTION (pfile, trigraphs) = 1;
new_pending_directive (CPP_OPTION (pfile, pending), new_pending_directive (CPP_OPTION (pfile, pending),
"__STRICT_ANSI__", cpp_define); "__STRICT_ANSI__", cpp_define);
......
...@@ -24,7 +24,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ...@@ -24,7 +24,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
Cleanups to do:- Cleanups to do:-
o Get use of digraphs in sync with the standard reqd on the command line.
o -dM and with _cpp_dump_list: too many \n output. o -dM and with _cpp_dump_list: too many \n output.
o Put a printer object in cpp_reader? o Put a printer object in cpp_reader?
o Check line numbers assigned to all errors. o Check line numbers assigned to all errors.
...@@ -1572,8 +1571,10 @@ lex_line (pfile, list) ...@@ -1572,8 +1571,10 @@ lex_line (pfile, list)
if (PREV_TOKEN_TYPE == CPP_COLON if (PREV_TOKEN_TYPE == CPP_COLON
&& CPP_OPTION (pfile, cplusplus)) && CPP_OPTION (pfile, cplusplus))
BACKUP_TOKEN (CPP_SCOPE); BACKUP_TOKEN (CPP_SCOPE);
else if (CPP_OPTION (pfile, digraphs))
{
/* Digraph: "<:" is a '[' */ /* Digraph: "<:" is a '[' */
else if (PREV_TOKEN_TYPE == CPP_LESS) if (PREV_TOKEN_TYPE == CPP_LESS)
BACKUP_DIGRAPH (CPP_OPEN_SQUARE); BACKUP_DIGRAPH (CPP_OPEN_SQUARE);
/* Digraph: "%:" is a '#' */ /* Digraph: "%:" is a '#' */
else if (PREV_TOKEN_TYPE == CPP_MOD) else if (PREV_TOKEN_TYPE == CPP_MOD)
...@@ -1582,6 +1583,7 @@ lex_line (pfile, list) ...@@ -1582,6 +1583,7 @@ lex_line (pfile, list)
goto make_hash; goto make_hash;
} }
} }
}
cur_token++; cur_token++;
break; break;
...@@ -1623,13 +1625,16 @@ lex_line (pfile, list) ...@@ -1623,13 +1625,16 @@ lex_line (pfile, list)
BACKUP_TOKEN (CPP_RSHIFT); BACKUP_TOKEN (CPP_RSHIFT);
else if (PREV_TOKEN_TYPE == CPP_MINUS) else if (PREV_TOKEN_TYPE == CPP_MINUS)
BACKUP_TOKEN (CPP_DEREF); BACKUP_TOKEN (CPP_DEREF);
else if (CPP_OPTION (pfile, digraphs))
{
/* Digraph: ":>" is a ']' */ /* Digraph: ":>" is a ']' */
else if (PREV_TOKEN_TYPE == CPP_COLON) if (PREV_TOKEN_TYPE == CPP_COLON)
BACKUP_DIGRAPH (CPP_CLOSE_SQUARE); BACKUP_DIGRAPH (CPP_CLOSE_SQUARE);
/* Digraph: "%>" is a '}' */ /* Digraph: "%>" is a '}' */
else if (PREV_TOKEN_TYPE == CPP_MOD) else if (PREV_TOKEN_TYPE == CPP_MOD)
BACKUP_DIGRAPH (CPP_CLOSE_BRACE); BACKUP_DIGRAPH (CPP_CLOSE_BRACE);
} }
}
cur_token++; cur_token++;
break; break;
...@@ -1652,7 +1657,8 @@ lex_line (pfile, list) ...@@ -1652,7 +1657,8 @@ lex_line (pfile, list)
case '%': case '%':
/* Digraph: "<%" is a '{' */ /* Digraph: "<%" is a '{' */
cur_token->type = CPP_MOD; cur_token->type = CPP_MOD;
if (IMMED_TOKEN () && PREV_TOKEN_TYPE == CPP_LESS) if (IMMED_TOKEN () && PREV_TOKEN_TYPE == CPP_LESS
&& CPP_OPTION (pfile, digraphs))
BACKUP_DIGRAPH (CPP_OPEN_BRACE); BACKUP_DIGRAPH (CPP_OPEN_BRACE);
cur_token++; cur_token++;
break; break;
...@@ -2421,10 +2427,13 @@ can_paste (pfile, token1, token2, digraph) ...@@ -2421,10 +2427,13 @@ can_paste (pfile, token1, token2, digraph)
if (b == a) return CPP_LSHIFT; if (b == a) return CPP_LSHIFT;
if (b == CPP_QUERY && cxx) return CPP_MIN; if (b == CPP_QUERY && cxx) return CPP_MIN;
if (b == CPP_LESS_EQ) return CPP_LSHIFT_EQ; if (b == CPP_LESS_EQ) return CPP_LSHIFT_EQ;
if (CPP_OPTION (pfile, digraphs))
{
if (b == CPP_COLON) if (b == CPP_COLON)
{*digraph = 1; return CPP_OPEN_SQUARE;} /* <: digraph */ {*digraph = 1; return CPP_OPEN_SQUARE;} /* <: digraph */
if (b == CPP_MOD) if (b == CPP_MOD)
{*digraph = 1; return CPP_OPEN_BRACE;} /* <% digraph */ {*digraph = 1; return CPP_OPEN_BRACE;} /* <% digraph */
}
break; break;
case CPP_PLUS: if (b == a) return CPP_PLUS_PLUS; break; case CPP_PLUS: if (b == a) return CPP_PLUS_PLUS; break;
...@@ -2437,15 +2446,18 @@ can_paste (pfile, token1, token2, digraph) ...@@ -2437,15 +2446,18 @@ can_paste (pfile, token1, token2, digraph)
break; break;
case CPP_COLON: case CPP_COLON:
if (b == a && cxx) return CPP_SCOPE; if (b == a && cxx) return CPP_SCOPE;
if (b == CPP_GREATER) if (b == CPP_GREATER && CPP_OPTION (pfile, digraphs))
{*digraph = 1; return CPP_CLOSE_SQUARE;} /* :> digraph */ {*digraph = 1; return CPP_CLOSE_SQUARE;} /* :> digraph */
break; break;
case CPP_MOD: case CPP_MOD:
if (CPP_OPTION (pfile, digraphs))
{
if (b == CPP_GREATER) if (b == CPP_GREATER)
{*digraph = 1; return CPP_CLOSE_BRACE;} /* %> digraph */ {*digraph = 1; return CPP_CLOSE_BRACE;} /* %> digraph */
if (b == CPP_COLON) if (b == CPP_COLON)
{*digraph = 1; return CPP_HASH;} /* %: digraph */ {*digraph = 1; return CPP_HASH;} /* %: digraph */
}
break; break;
case CPP_DEREF: case CPP_DEREF:
if (b == CPP_MULT && cxx) return CPP_DEREF_STAR; if (b == CPP_MULT && cxx) return CPP_DEREF_STAR;
......
...@@ -329,6 +329,9 @@ struct cpp_options ...@@ -329,6 +329,9 @@ struct cpp_options
/* Nonzero means process the ISO trigraph sequences. */ /* Nonzero means process the ISO trigraph sequences. */
unsigned char trigraphs; unsigned char trigraphs;
/* Nonzero means process the ISO digraph sequences. */
unsigned char digraphs;
/* Nonzero means print the names of included files rather than the /* Nonzero means print the names of included files rather than the
preprocessed output. 1 means just the #include "...", 2 means preprocessed output. 1 means just the #include "...", 2 means
#include <...> as well. */ #include <...> as well. */
......
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