cpphash.c (macroexpand): Delete leading whitespace when arg is concatenated before.

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.

From-SVN: r28512
This commit is contained in:
Zack Weinberg 1999-08-04 20:39:33 +00:00 committed by Zack Weinberg
parent 2a94e396c6
commit 5d83f44baa
5 changed files with 103 additions and 36 deletions

View File

@ -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> Wed Aug 4 12:53:44 1999 Jason Merrill <jason@yorick.cygnus.com>
* expr.c (expand_expr, case PLUS_EXPR): Fix parallel case, too. * expr.c (expand_expr, case PLUS_EXPR): Fix parallel case, too.

View File

@ -1337,10 +1337,17 @@ macroexpand (pfile, hp)
U_CHAR *l1 = p1 + arg->raw_length; U_CHAR *l1 = p1 + arg->raw_length;
if (ap->raw_before) if (ap->raw_before)
{ {
while (p1 != l1 && is_space[*p1]) /* Arg is concatenated before: delete leading whitespace,
p1++; whitespace markers, and no-reexpansion markers. */
while (p1 != l1 && is_idchar[*p1]) while (p1 != l1)
xbuf[totlen++] = *p1++; {
if (is_space[p1[0]])
p1++;
else if (p1[0] == '\r')
p1 += 2;
else
break;
}
} }
if (ap->raw_after) if (ap->raw_after)
{ {
@ -1460,15 +1467,12 @@ unsafe_chars (c1, c2)
{ {
switch (c1) switch (c1)
{ {
case '+': case '+': case '-':
case '-':
if (c2 == c1 || c2 == '=') if (c2 == c1 || c2 == '=')
return 1; return 1;
goto letter; goto letter;
case '.': case '0': case '1': case '2': case '3': case 'e': case 'E': case 'p': case 'P':
case '4': case '5': case '6': case '7': case '8':
case '9': case 'e': case 'E': case 'p': case 'P':
if (c2 == '-' || c2 == '+') if (c2 == '-' || c2 == '+')
return 1; /* could extend a pre-processing number */ return 1; /* could extend a pre-processing number */
goto letter; goto letter;
@ -1478,6 +1482,8 @@ unsafe_chars (c1, c2)
return 1; /* Could turn into L"xxx" or L'xxx'. */ return 1; /* Could turn into L"xxx" or L'xxx'. */
goto letter; 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 '_': case 'a': case 'b': case 'c': case 'd': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'q': case 'r': case 's': case 'm': case 'n': case 'o': case 'q': case 'r': case 's':

View File

@ -1029,8 +1029,15 @@ cpp_start_read (pfile, fname)
ih_fake->control_macro = 0; ih_fake->control_macro = 0;
ih_fake->buf = (char *)-1; ih_fake->buf = (char *)-1;
ih_fake->limit = 0; ih_fake->limit = 0;
if (!finclude (pfile, fd, ih_fake)) if (finclude (pfile, fd, ih_fake))
cpp_scan_buffer (pfile); {
if (CPP_PRINT_DEPS (pfile))
deps_output (pfile, ih_fake->name, ' ');
cpp_scan_buffer (pfile);
}
else
cpp_pop_buffer (pfile);
free (ih_fake); free (ih_fake);
q = p->next; q = p->next;
@ -1062,8 +1069,14 @@ cpp_start_read (pfile, fname)
ih_fake->buf = (char *)-1; ih_fake->buf = (char *)-1;
ih_fake->limit = 0; ih_fake->limit = 0;
if (finclude (pfile, fd, ih_fake)) 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; q = p->next;
free (p); free (p);
p = q; p = q;

View File

@ -731,15 +731,42 @@ cpp_scan_buffer (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
cpp_buffer *buffer = CPP_BUFFER (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); long old_written = CPP_WRITTEN (pfile);
if (token == CPP_EOF) /* Should not happen ... */ /* In no-output mode, we can ignore everything but directives. */
break; for (;;)
if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
{ {
cpp_pop_buffer (pfile); if (! pfile->only_seen_white)
break; 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; int length;
{ {
register cpp_buffer *ip; register cpp_buffer *ip;
#if 0
cpp_buffer obuf;
#endif
U_CHAR *buf1; U_CHAR *buf1;
#if 0 int save_no_output;
int odepth = indepth;
#endif
if (length < 0) if (length < 0)
{ {
@ -784,12 +806,12 @@ cpp_expand_to_buffer (pfile, buf, length)
if (ip == NULL) if (ip == NULL)
return; return;
ip->has_escapes = 1; ip->has_escapes = 1;
#if 0
ip->lineno = obuf.lineno = 1;
#endif
/* Scan the input, create the output. */ /* 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_scan_buffer (pfile);
CPP_OPTIONS (pfile)->no_output = save_no_output;
CPP_NUL_TERMINATE (pfile); CPP_NUL_TERMINATE (pfile);
} }

View File

@ -81,12 +81,12 @@ main (argc, argv)
else if (! freopen (opts->out_fname, "w", stdout)) else if (! freopen (opts->out_fname, "w", stdout))
cpp_pfatal_with_name (&parse_in, opts->out_fname); cpp_pfatal_with_name (&parse_in, opts->out_fname);
do if (! opts->no_output)
{ {
kind = cpp_get_token (&parse_in); do
if (CPP_WRITTEN (&parse_in) >= BUFSIZ || kind == CPP_EOF)
{ {
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); size_t rem, count = CPP_WRITTEN (&parse_in);
@ -94,12 +94,22 @@ main (argc, argv)
if (rem < count) if (rem < count)
/* Write error. */ /* Write error. */
cpp_pfatal_with_name (&parse_in, opts->out_fname); 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); cpp_finish (&parse_in);
if (fwrite (parse_in.token_buffer, 1, CPP_WRITTEN (&parse_in), stdout) if (fwrite (parse_in.token_buffer, 1, CPP_WRITTEN (&parse_in), stdout)