Commit 05e81724 by Neil Booth

[multiple changes]

2001-01-11  Neil Booth  <neil@daikokuya.demon.co.uk>

        * cppinit.c (cpp_start_read): If -fpreprocessed, ignore
	-D, -U and -A, and don't initialize the builtins.
	* cppmain.c (cb_define, cb_undef): Unconditionally process
	the callback.
	* tradcpp.c (main): Fix typo.

2000-01-11  Mark Elbrecht  <snowball3@bigfoot.com>

        * cppfiles.c (cpp_included, find_include_file, _cpp_execute_include)
          (read_name_map): Use IS_ABSOLUTE_PATH.
        * tradcpp.c (get_filename): Likewise.

From-SVN: r38925
parent 76d06edc
2001-01-11 Neil Booth <neil@daikokuya.demon.co.uk>
* cppinit.c (cpp_start_read): If -fpreprocessed, ignore
-D, -U and -A, and don't initialize the builtins.
* cppmain.c (cb_define, cb_undef): Unconditionally process
the callback.
* tradcpp.c (main): Fix typo.
2000-01-11 Mark Elbrecht <snowball3@bigfoot.com>
* cppfiles.c (cpp_included, find_include_file, _cpp_execute_include)
(read_name_map): Use IS_ABSOLUTE_PATH.
* tradcpp.c (get_filename): Likewise.
2001-01-11 Stephane Carrez <Stephane.Carrez@worldnet.fr> 2001-01-11 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/m68hc11/m68hc11.md (*adcq, *subcq): Fix operand numbers. * config/m68hc11/m68hc11.md (*adcq, *subcq): Fix operand numbers.
......
...@@ -430,7 +430,7 @@ cpp_included (pfile, fname) ...@@ -430,7 +430,7 @@ cpp_included (pfile, fname)
char *name; char *name;
splay_tree_node nd; splay_tree_node nd;
if (fname[0] == '/') if (IS_ABSOLUTE_PATHNAME (fname))
{ {
/* Just look it up. */ /* Just look it up. */
nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname); nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname);
...@@ -470,7 +470,7 @@ find_include_file (pfile, fname, search_start) ...@@ -470,7 +470,7 @@ find_include_file (pfile, fname, search_start)
char *name; char *name;
struct include_file *file; struct include_file *file;
if (fname[0] == '/') if (IS_ABSOLUTE_PATHNAME (fname))
return open_file (pfile, fname); return open_file (pfile, fname);
/* Search directory path for the file. */ /* Search directory path for the file. */
...@@ -648,7 +648,7 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next) ...@@ -648,7 +648,7 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next)
if (CPP_OPTION (pfile, print_deps_missing_files) if (CPP_OPTION (pfile, print_deps_missing_files)
&& PRINT_THIS_DEP (pfile, angle_brackets)) && PRINT_THIS_DEP (pfile, angle_brackets))
{ {
if (!angle_brackets || *fname == '/') if (!angle_brackets || IS_ABSOLUTE_PATHNAME (fname))
deps_add_dep (pfile->deps, fname); deps_add_dep (pfile->deps, fname);
else else
{ {
...@@ -890,7 +890,7 @@ read_name_map (pfile, dirname) ...@@ -890,7 +890,7 @@ read_name_map (pfile, dirname)
ptr->map_from = from; ptr->map_from = from;
/* Make the real filename absolute. */ /* Make the real filename absolute. */
if (*to == '/') if (IS_ABSOLUTE_PATHNAME (to))
ptr->map_to = to; ptr->map_to = to;
else else
{ {
......
...@@ -849,9 +849,11 @@ do_includes (pfile, p, scan) ...@@ -849,9 +849,11 @@ do_includes (pfile, p, scan)
{ {
struct pending_option *q; struct pending_option *q;
/* Later: maybe update this to use the #include "" search path /* Don't handle if -fpreprocessed. Later: maybe update this to
if cpp_read_file fails. */ use the #include "" search path if cpp_read_file fails. */
if (_cpp_read_file (pfile, p->arg) && scan) if (! CPP_OPTION (pfile, preprocessed))
cpp_error (pfile, "-include and -imacros cannot be used with -fpreprocessed");
else if (_cpp_read_file (pfile, p->arg) && scan)
cpp_scan_buffer_nooutput (pfile, 0); cpp_scan_buffer_nooutput (pfile, 0);
q = p->next; q = p->next;
free (p); free (p);
...@@ -859,10 +861,9 @@ do_includes (pfile, p, scan) ...@@ -859,10 +861,9 @@ do_includes (pfile, p, scan)
} }
} }
/* This is called after options have been processed. Check options /* This is called after options have been processed. Setup for
for consistency, and setup for processing input from the file named processing input from the file named FNAME. (Use standard input if
FNAME. (Use standard input if FNAME == NULL.) Return 1 on success, FNAME == NULL.) Return 1 on success, 0 on failure. */
0 on failure. */
int int
cpp_start_read (pfile, fname) cpp_start_read (pfile, fname)
...@@ -915,18 +916,22 @@ cpp_start_read (pfile, fname) ...@@ -915,18 +916,22 @@ cpp_start_read (pfile, fname)
if (!_cpp_read_file (pfile, fname)) if (!_cpp_read_file (pfile, fname))
return 0; return 0;
/* Install __LINE__, etc. */ /* If already preprocessed, don't install __LINE__, etc., and ignore
command line definitions and assertions. Handle -U's, -D's and
-A's in the order they were seen. */
if (! CPP_OPTION (pfile, preprocessed))
init_builtins (pfile); init_builtins (pfile);
/* Do -U's, -D's and -A's in the order they were seen. */
p = CPP_OPTION (pfile, pending)->directive_head; p = CPP_OPTION (pfile, pending)->directive_head;
while (p) while (p)
{ {
if (! CPP_OPTION (pfile, preprocessed))
(*p->handler) (pfile, p->arg); (*p->handler) (pfile, p->arg);
q = p->next; q = p->next;
free (p); free (p);
p = q; p = q;
} }
pfile->done_initializing = 1; pfile->done_initializing = 1;
/* The -imacros files can be scanned now, but the -include files /* The -imacros files can be scanned now, but the -include files
...@@ -1131,10 +1136,10 @@ static const struct cl_option cl_options[] = ...@@ -1131,10 +1136,10 @@ static const struct cl_option cl_options[] =
command-line matches. Returns its index in the option array, command-line matches. Returns its index in the option array,
negative on failure. Complications arise since some options can be negative on failure. Complications arise since some options can be
suffixed with an argument, and multiple complete matches can occur, suffixed with an argument, and multiple complete matches can occur,
e.g. -iwithprefix and -iwithprefixbefore. Moreover, we want to e.g. -iwithprefix and -iwithprefixbefore. Moreover, we need to
accept options beginning with -g and -W that we do not recognise, accept options beginning with -W that we do not recognise, but not
but not to swallow any subsequent command line argument; these are to swallow any subsequent command line argument; this is handled as
handled as special cases in cpp_handle_option. */ special cases in cpp_handle_option. */
static int static int
parse_option (input) parse_option (input)
const char *input; const char *input;
......
...@@ -344,8 +344,6 @@ cb_define (pfile, node) ...@@ -344,8 +344,6 @@ cb_define (pfile, node)
cpp_reader *pfile; cpp_reader *pfile;
cpp_hashnode *node; cpp_hashnode *node;
{ {
if (pfile->done_initializing)
{
maybe_print_line (cpp_get_line (pfile)->output_line); maybe_print_line (cpp_get_line (pfile)->output_line);
fprintf (print.outf, "#define %s", node->name); fprintf (print.outf, "#define %s", node->name);
...@@ -355,7 +353,6 @@ cb_define (pfile, node) ...@@ -355,7 +353,6 @@ cb_define (pfile, node)
putc ('\n', print.outf); putc ('\n', print.outf);
print.lineno++; print.lineno++;
}
} }
static void static void
...@@ -363,12 +360,9 @@ cb_undef (pfile, node) ...@@ -363,12 +360,9 @@ cb_undef (pfile, node)
cpp_reader *pfile; cpp_reader *pfile;
cpp_hashnode *node; cpp_hashnode *node;
{ {
if (pfile->done_initializing)
{
maybe_print_line (cpp_get_line (pfile)->output_line); maybe_print_line (cpp_get_line (pfile)->output_line);
fprintf (print.outf, "#undef %s\n", node->name); fprintf (print.outf, "#undef %s\n", node->name);
print.lineno++; print.lineno++;
}
} }
static void static void
......
...@@ -647,7 +647,7 @@ main (argc, argv) ...@@ -647,7 +647,7 @@ main (argc, argv)
int quoted = argv[i][2] == 'Q'; int quoted = argv[i][2] == 'Q';
if (*tgt == '\0' && i + 1 == argc) if (*tgt == '\0' && i + 1 == argc)
fatal ("Filename missing after %s option", argv[i]); fatal ("Target missing after %s option", argv[i]);
else else
{ {
if (*tgt == '\0') if (*tgt == '\0')
...@@ -2374,7 +2374,7 @@ get_filename: ...@@ -2374,7 +2374,7 @@ get_filename:
/* If specified file name is absolute, just open it. */ /* If specified file name is absolute, just open it. */
if (*fbeg == '/') { if (IS_ABSOLUTE_PATHNAME (fbeg)) {
strncpy (fname, (const char *)fbeg, flen); strncpy (fname, (const char *)fbeg, flen);
fname[flen] = 0; fname[flen] = 0;
f = open (fname, O_RDONLY, 0666); f = open (fname, O_RDONLY, 0666);
...@@ -2409,7 +2409,7 @@ get_filename: ...@@ -2409,7 +2409,7 @@ get_filename:
else else
stackp = include; stackp = include;
if (!system_header_p || *fbeg == '/' || !stackp->fname) if (!system_header_p || IS_ABSOLUTE_PATHNAME (fbeg) || !stackp->fname)
deps_add_dep (deps, fname); deps_add_dep (deps, fname);
else { else {
char *p; char *p;
......
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