Commit 9d10c9a9 by Neil Booth Committed by Neil Booth

Makefile.in (c-ppoutput.o): Update.

	* Makefile.in (c-ppoutput.o): Update.
	* c-common.h (init_pp_output): New.
	(preprocess_file): Update.
	* c-lex.c (init_c_lex): Move mbchar initialization to cpplib.
	Register builtins.
	* c-opts.c (c_common_init): Call init_pp_output if preprocessing.
	Make call to cpp_read_main_file common to whether preprocessing
	or not.  Don't register builtins.
	* c-ppoutput.c: Include c-pragma.h.
	(setup_callbacks): Rename init_pp_output.
	(preprocess_file): No longer setup callbacks or call
	cpp_read_main_file.
	* cpphash.h (_cpp_init_mbchar): New.
	* cppinit.c (init_library): Call _cpp_init_mbchar.
	* cpplex.c (_cpp_init_mbchar): New.

From-SVN: r63913
parent d1867128
2003-03-06 Neil Booth <neil@daikokuya.co.uk>
* Makefile.in (c-ppoutput.o): Update.
* c-common.h (init_pp_output): New.
(preprocess_file): Update.
* c-lex.c (init_c_lex): Move mbchar initialization to cpplib.
Register builtins.
* c-opts.c (c_common_init): Call init_pp_output if preprocessing.
Make call to cpp_read_main_file common to whether preprocessing
or not. Don't register builtins.
* c-ppoutput.c: Include c-pragma.h.
(setup_callbacks): Rename init_pp_output.
(preprocess_file): No longer setup callbacks or call
cpp_read_main_file.
* cpphash.h (_cpp_init_mbchar): New.
* cppinit.c (init_library): Call _cpp_init_mbchar.
* cpplex.c (_cpp_init_mbchar): New.
2003-03-06 Roger Sayle <roger@eyesopen.com>
* emit-rtl.c (gen_lowpart): When requesting the low-part of a
......
......@@ -1236,7 +1236,7 @@ c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
c-pragma.h input.h intl.h flags.h toplev.h output.h \
mbchar.h $(CPPLIB_H) $(EXPR_H) $(TM_P_H)
c-ppoutput.o : c-ppoutput.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
c-common.h $(TREE_H) $(CPPLIB_H) cpphash.h $(TM_P_H)
c-common.h $(TREE_H) $(CPPLIB_H) cpphash.h $(TM_P_H) c-pragma.h
c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) $(RTL_H) insn-config.h integrate.h $(EXPR_H) $(C_TREE_H) \
flags.h toplev.h tree-inline.h diagnostic.h integrate.h $(VARRAY_H) \
......
......@@ -1292,8 +1292,9 @@ extern void c_common_read_pch PARAMS ((cpp_reader *pfile,
int fd,
const char *orig));
extern void c_common_write_pch PARAMS ((void));
extern void preprocess_file PARAMS ((cpp_reader *,
const char *,
FILE *));
/* In c-ppoutput.c */
extern void init_pp_output PARAMS ((FILE *));
extern void preprocess_file PARAMS ((cpp_reader *));
#endif /* ! GCC_C_COMMON_H */
......@@ -111,14 +111,9 @@ init_c_lex ()
toplevel->time = body_time;
}
#ifdef MULTIBYTE_CHARS
/* Change to the native locale for multibyte conversions. */
setlocale (LC_CTYPE, "");
GET_ENVIRONMENT (literal_codeset, "LANG");
#endif
cb = cpp_get_callbacks (parse_in);
cb->register_builtins = cb_register_builtins;
cb->line_change = cb_line_change;
cb->ident = cb_ident;
cb->file_change = cb_file_change;
......
......@@ -1512,10 +1512,6 @@ c_common_init (filename)
cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
/* Register preprocessor built-ins before calls to
cpp_main_file. */
cpp_get_callbacks (parse_in)->register_builtins = cb_register_builtins;
if (flag_preprocess_only)
{
/* Open the output now. We must do so even if flag_no_output is
......@@ -1527,23 +1523,31 @@ c_common_init (filename)
out_stream = fopen (out_fname, "w");
if (out_stream == NULL)
fatal_io_error ("opening output file %s", out_fname);
else
/* Preprocess the input file to out_stream. */
preprocess_file (parse_in, in_fname, out_stream);
{
fatal_io_error ("opening output file %s", out_fname);
return NULL;
}
/* Exit quickly in toplev.c. */
return NULL;
init_pp_output (out_stream);
}
else
{
init_c_lex ();
init_c_lex ();
/* Start it at 0. */
lineno = 0;
/* Yuk. WTF is this? I do know ObjC relies on it somewhere. */
lineno = 0;
}
/* NOTE: we use in_fname here, not the one supplied. */
filename = cpp_read_main_file (parse_in, in_fname, ident_hash);
if (flag_preprocess_only)
{
if (filename)
preprocess_file (parse_in);
return NULL;
}
/* Has to wait until now so that cpplib has its hash table. */
init_pragma ();
......
......@@ -24,7 +24,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cpplib.h"
#include "cpphash.h"
#include "tree.h"
#include "c-common.h"
#include "c-common.h" /* For flags. */
#include "c-pragma.h" /* For parse_in. */
/* Encapsulates state used to convert a stream of tokens into a text
file. */
......@@ -38,8 +39,6 @@ static struct
unsigned char printed; /* Nonzero if something output at line. */
} print;
static void setup_callbacks PARAMS ((cpp_reader *));
/* General output routines. */
static void scan_translation_unit PARAMS ((cpp_reader *));
static void scan_translation_unit_trad PARAMS ((cpp_reader *));
......@@ -64,44 +63,28 @@ static void cb_def_pragma PARAMS ((cpp_reader *, unsigned int));
/* Preprocess and output. */
void
preprocess_file (pfile, in_fname, out_stream)
preprocess_file (pfile)
cpp_reader *pfile;
const char *in_fname;
FILE *out_stream;
{
/* Initialize the print structure. Setting print.line to -1 here is
a trick to guarantee that the first token of the file will cause
a linemarker to be output by maybe_print_line. */
print.line = (unsigned int) -1;
print.printed = 0;
print.prev = 0;
print.map = 0;
print.outf = out_stream;
cpp_finish_options (pfile);
setup_callbacks (pfile);
if (cpp_read_main_file (pfile, in_fname, NULL))
/* A successful cpp_read_main_file guarantees that we can call
cpp_scan_nooutput or cpp_get_token next. */
if (flag_no_output)
{
cpp_finish_options (pfile);
/* A successful cpp_read_main_file guarantees that we can call
cpp_scan_nooutput or cpp_get_token next. */
if (flag_no_output)
{
/* Scan -included buffers, then the main file. */
while (pfile->buffer->prev)
cpp_scan_nooutput (pfile);
cpp_scan_nooutput (pfile);
}
else if (cpp_get_options (pfile)->traditional)
scan_translation_unit_trad (pfile);
else
scan_translation_unit (pfile);
/* -dM command line option. Should this be elsewhere? */
if (flag_dump_macros == 'M')
cpp_forall_identifiers (pfile, dump_macro, NULL);
/* Scan -included buffers, then the main file. */
while (pfile->buffer->prev)
cpp_scan_nooutput (pfile);
cpp_scan_nooutput (pfile);
}
else if (cpp_get_options (pfile)->traditional)
scan_translation_unit_trad (pfile);
else
scan_translation_unit (pfile);
/* -dM command line option. Should this be elsewhere? */
if (flag_dump_macros == 'M')
cpp_forall_identifiers (pfile, dump_macro, NULL);
/* Flush any pending output. */
if (print.printed)
......@@ -109,19 +92,20 @@ preprocess_file (pfile, in_fname, out_stream)
}
/* Set up the callbacks as appropriate. */
static void
setup_callbacks (pfile)
cpp_reader *pfile;
void
init_pp_output (out_stream)
FILE *out_stream;
{
cpp_options *options = &pfile->opts;
cpp_callbacks *cb = cpp_get_callbacks (pfile);
cpp_callbacks *cb = cpp_get_callbacks (parse_in);
cb->register_builtins = cb_register_builtins;
if (!flag_no_output)
{
cb->line_change = cb_line_change;
/* Don't emit #pragma or #ident directives if we are processing
assembly language; the assembler may choke on them. */
if (options->lang != CLK_ASM)
if (cpp_get_options (parse_in)->lang != CLK_ASM)
{
cb->ident = cb_ident;
cb->def_pragma = cb_def_pragma;
......@@ -138,6 +122,15 @@ setup_callbacks (pfile)
cb->define = cb_define;
cb->undef = cb_undef;
}
/* Initialize the print structure. Setting print.line to -1 here is
a trick to guarantee that the first token of the file will cause
a linemarker to be output by maybe_print_line. */
print.line = (unsigned int) -1;
print.printed = 0;
print.prev = 0;
print.map = 0;
print.outf = out_stream;
}
/* Writes out the preprocessed file, handling spacing and paste
......
......@@ -517,6 +517,7 @@ extern cpp_token *_cpp_lex_direct PARAMS ((cpp_reader *));
extern int _cpp_equiv_tokens PARAMS ((const cpp_token *,
const cpp_token *));
extern void _cpp_init_tokenrun PARAMS ((tokenrun *, unsigned int));
extern void _cpp_init_mbchar PARAMS ((void));
/* In cppinit.c. */
extern void _cpp_maybe_push_include_file PARAMS ((cpp_reader *));
......
......@@ -191,6 +191,8 @@ init_library ()
we were compiled with a compiler that supports C99 designated
initializers. */
init_trigraph_map ();
_cpp_init_mbchar ();
}
}
......
......@@ -89,6 +89,16 @@ static tokenrun *next_tokenrun PARAMS ((tokenrun *));
static unsigned int hex_digit_value PARAMS ((unsigned int));
static _cpp_buff *new_buff PARAMS ((size_t));
/* Change to the native locale for multibyte conversions. */
void
_cpp_init_mbchar ()
{
#ifdef MULTIBYTE_CHARS
setlocale (LC_CTYPE, "");
GET_ENVIRONMENT (literal_codeset, "LANG");
#endif
}
/* Utility routine:
Compares, the token TOKEN to the NUL-terminated string STRING.
......
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