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>
* 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;
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':

View File

@ -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;

View File

@ -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);
}

View File

@ -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)