diff options
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/cpphash.c | 24 | ||||
-rw-r--r-- | gcc/cppinit.c | 21 | ||||
-rw-r--r-- | gcc/cpplib.c | 54 | ||||
-rw-r--r-- | gcc/cppmain.c | 24 |
5 files changed, 103 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b4f0b1f7ee..39a7bbc4744 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +Wed Aug 4 13:29:23 1999 Zack Weinberg <zack@bitmover.com> + + * cpphash.c (macroexpand): Delete leading whitespace when arg + is concatenated before. + (unsafe_chars): Correct test for whether + and - can extend a + token. + + * cppinit.c (cpp_start_read): Do dependencies for + -include/-imacros files also. + + * cpplib.c (cpp_scan_buffer): In no-output mode, don't bother + tokenizing non-directive lines. + (cpp_expand_to_buffer): Temporarily disable no-output mode. + * cppmain.c: In no-output mode, just call cpp_scan_buffer for + the input file. + Wed Aug 4 12:53:44 1999 Jason Merrill <jason@yorick.cygnus.com> * expr.c (expand_expr, case PLUS_EXPR): Fix parallel case, too. diff --git a/gcc/cpphash.c b/gcc/cpphash.c index 552cf2ef426..2b5291bea2b 100644 --- a/gcc/cpphash.c +++ b/gcc/cpphash.c @@ -1337,10 +1337,17 @@ macroexpand (pfile, hp) U_CHAR *l1 = p1 + arg->raw_length; if (ap->raw_before) { - while (p1 != l1 && is_space[*p1]) - p1++; - while (p1 != l1 && is_idchar[*p1]) - xbuf[totlen++] = *p1++; + /* Arg is concatenated before: delete leading whitespace, + whitespace markers, and no-reexpansion markers. */ + while (p1 != l1) + { + if (is_space[p1[0]]) + p1++; + else if (p1[0] == '\r') + p1 += 2; + else + break; + } } if (ap->raw_after) { @@ -1460,15 +1467,12 @@ unsafe_chars (c1, c2) { switch (c1) { - case '+': - case '-': + case '+': case '-': if (c2 == c1 || c2 == '=') return 1; goto letter; - case '.': case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': case '8': - case '9': case 'e': case 'E': case 'p': case 'P': + case 'e': case 'E': case 'p': case 'P': if (c2 == '-' || c2 == '+') return 1; /* could extend a pre-processing number */ goto letter; @@ -1478,6 +1482,8 @@ unsafe_chars (c1, c2) return 1; /* Could turn into L"xxx" or L'xxx'. */ goto letter; + case '.': case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': case '8': case '9': case '_': case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'q': case 'r': case 's': diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 7269c569c31..c9f7ece3521 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -1029,8 +1029,15 @@ cpp_start_read (pfile, fname) ih_fake->control_macro = 0; ih_fake->buf = (char *)-1; ih_fake->limit = 0; - if (!finclude (pfile, fd, ih_fake)) - cpp_scan_buffer (pfile); + if (finclude (pfile, fd, ih_fake)) + { + if (CPP_PRINT_DEPS (pfile)) + deps_output (pfile, ih_fake->name, ' '); + + cpp_scan_buffer (pfile); + } + else + cpp_pop_buffer (pfile); free (ih_fake); q = p->next; @@ -1062,8 +1069,14 @@ cpp_start_read (pfile, fname) ih_fake->buf = (char *)-1; ih_fake->limit = 0; if (finclude (pfile, fd, ih_fake)) - output_line_command (pfile, enter_file); - + { + if (CPP_PRINT_DEPS (pfile)) + deps_output (pfile, ih_fake->name, ' '); + + output_line_command (pfile, enter_file); + } + else + cpp_pop_buffer (pfile); q = p->next; free (p); p = q; diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 2718b08a6e6..ab2e203c27f 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -731,15 +731,42 @@ cpp_scan_buffer (pfile) cpp_reader *pfile; { cpp_buffer *buffer = CPP_BUFFER (pfile); - for (;;) + enum cpp_token token; + if (CPP_OPTIONS (pfile)->no_output) { - enum cpp_token token = cpp_get_token (pfile); - if (token == CPP_EOF) /* Should not happen ... */ - break; - if (token == CPP_POP && CPP_BUFFER (pfile) == buffer) + long old_written = CPP_WRITTEN (pfile); + /* In no-output mode, we can ignore everything but directives. */ + for (;;) { - cpp_pop_buffer (pfile); - break; + if (! pfile->only_seen_white) + skip_rest_of_line (pfile); + token = cpp_get_token (pfile); + if (token == CPP_EOF) /* Should not happen ... */ + break; + if (token == CPP_POP && CPP_BUFFER (pfile) == buffer) + { + if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) + != CPP_NULL_BUFFER (pfile)) + cpp_pop_buffer (pfile); + break; + } + } + CPP_SET_WRITTEN (pfile, old_written); + } + else + { + for (;;) + { + token = cpp_get_token (pfile); + if (token == CPP_EOF) /* Should not happen ... */ + break; + if (token == CPP_POP && CPP_BUFFER (pfile) == buffer) + { + if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) + != CPP_NULL_BUFFER (pfile)) + cpp_pop_buffer (pfile); + break; + } } } } @@ -760,13 +787,8 @@ cpp_expand_to_buffer (pfile, buf, length) int length; { register cpp_buffer *ip; -#if 0 - cpp_buffer obuf; -#endif U_CHAR *buf1; -#if 0 - int odepth = indepth; -#endif + int save_no_output; if (length < 0) { @@ -784,12 +806,12 @@ cpp_expand_to_buffer (pfile, buf, length) if (ip == NULL) return; ip->has_escapes = 1; -#if 0 - ip->lineno = obuf.lineno = 1; -#endif /* Scan the input, create the output. */ + save_no_output = CPP_OPTIONS (pfile)->no_output; + CPP_OPTIONS (pfile)->no_output = 0; cpp_scan_buffer (pfile); + CPP_OPTIONS (pfile)->no_output = save_no_output; CPP_NUL_TERMINATE (pfile); } diff --git a/gcc/cppmain.c b/gcc/cppmain.c index 0d891f80980..e2b5614667b 100644 --- a/gcc/cppmain.c +++ b/gcc/cppmain.c @@ -81,12 +81,12 @@ main (argc, argv) else if (! freopen (opts->out_fname, "w", stdout)) cpp_pfatal_with_name (&parse_in, opts->out_fname); - do + if (! opts->no_output) { - kind = cpp_get_token (&parse_in); - if (CPP_WRITTEN (&parse_in) >= BUFSIZ || kind == CPP_EOF) + do { - if (! opts->no_output) + kind = cpp_get_token (&parse_in); + if (CPP_WRITTEN (&parse_in) >= BUFSIZ || kind == CPP_EOF) { size_t rem, count = CPP_WRITTEN (&parse_in); @@ -94,12 +94,22 @@ main (argc, argv) if (rem < count) /* Write error. */ cpp_pfatal_with_name (&parse_in, opts->out_fname); - } - CPP_SET_WRITTEN (&parse_in, 0); + CPP_SET_WRITTEN (&parse_in, 0); + } + } + while (kind != CPP_EOF); + } + else + { + do + { + cpp_scan_buffer (&parse_in); + kind = cpp_get_token (&parse_in); } + while (kind != CPP_EOF); + CPP_SET_WRITTEN (&parse_in, 0); } - while (kind != CPP_EOF); cpp_finish (&parse_in); if (fwrite (parse_in.token_buffer, 1, CPP_WRITTEN (&parse_in), stdout) |