mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-20 01:19:21 +08:00
cpplib.c (read_line_number): New fn, split out of...
* cpplib.c (read_line_number): New fn, split out of... (do_line): Here. From-SVN: r28707
This commit is contained in:
parent
8dd3f57a9e
commit
d3a34a0a7e
@ -1,3 +1,8 @@
|
||||
Fri Aug 13 17:41:55 1999 Jason Merrill <jason@yorick.cygnus.com>
|
||||
|
||||
* cpplib.c (read_line_number): New fn, split out of...
|
||||
(do_line): Here.
|
||||
|
||||
Fri Aug 13 14:18:27 1999 Gavin Romig-Koch <gavin@cygnus.com>
|
||||
|
||||
tree.c (lang_unsave_expr_now) : New.
|
||||
|
69
gcc/cpplib.c
69
gcc/cpplib.c
@ -1208,6 +1208,34 @@ do_include (pfile, keyword)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Subroutine of do_line. Read next token from PFILE without adding it to
|
||||
the output buffer. If it is a number between 1 and 4, store it in *NUM
|
||||
and return 1; otherwise, return 0 and complain if we aren't at the end
|
||||
of the directive. */
|
||||
|
||||
static int
|
||||
read_line_number (pfile, num)
|
||||
cpp_reader *pfile;
|
||||
int *num;
|
||||
{
|
||||
long save_written = CPP_WRITTEN (pfile);
|
||||
U_CHAR *p = pfile->token_buffer + save_written;
|
||||
enum cpp_token token = get_directive_token (pfile);
|
||||
CPP_SET_WRITTEN (pfile, save_written);
|
||||
|
||||
if (token == CPP_NUMBER && *p >= '1' && *p <= '4' && p[1] == '\0')
|
||||
{
|
||||
*num = p[0] - '0';
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP)
|
||||
cpp_error (pfile, "invalid format `#line' command");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Interpret #line command.
|
||||
Note that the filename string (if any) is treated as if it were an
|
||||
include filename. That means no escape handling. */
|
||||
@ -1249,41 +1277,32 @@ do_line (pfile, keyword)
|
||||
{
|
||||
U_CHAR *fname = pfile->token_buffer + old_written + 1;
|
||||
U_CHAR *end_name = CPP_PWRITTEN (pfile) - 1;
|
||||
long num_start = CPP_WRITTEN (pfile);
|
||||
int action_number = 0;
|
||||
|
||||
token = get_directive_token (pfile);
|
||||
if (token != CPP_VSPACE && token != CPP_EOF && token != CPP_POP)
|
||||
if (read_line_number (pfile, &action_number))
|
||||
{
|
||||
U_CHAR *p = pfile->token_buffer + num_start;
|
||||
if (CPP_PEDANTIC (pfile))
|
||||
cpp_pedwarn (pfile, "garbage at end of `#line' command");
|
||||
|
||||
if (token != CPP_NUMBER || *p < '0' || *p > '4' || p[1] != '\0')
|
||||
if (action_number == 1)
|
||||
{
|
||||
cpp_error (pfile, "invalid format `#line' command");
|
||||
goto bad_line_directive;
|
||||
file_change = enter_file;
|
||||
read_line_number (pfile, &action_number);
|
||||
}
|
||||
if (*p == '1')
|
||||
file_change = enter_file;
|
||||
else if (*p == '2')
|
||||
file_change = leave_file;
|
||||
else if (*p == '3')
|
||||
ip->system_header_p = 1;
|
||||
else /* if (*p == '4') */
|
||||
ip->system_header_p = 2;
|
||||
|
||||
CPP_SET_WRITTEN (pfile, num_start);
|
||||
token = get_directive_token (pfile);
|
||||
p = pfile->token_buffer + num_start;
|
||||
if (token == CPP_NUMBER && p[1] == '\0' && (*p == '3' || *p== '4'))
|
||||
else if (action_number == 2)
|
||||
{
|
||||
ip->system_header_p = *p == '3' ? 1 : 2;
|
||||
token = get_directive_token (pfile);
|
||||
file_change = leave_file;
|
||||
read_line_number (pfile, &action_number);
|
||||
}
|
||||
if (token != CPP_VSPACE)
|
||||
if (action_number == 3)
|
||||
{
|
||||
cpp_error (pfile, "invalid format `#line' command");
|
||||
goto bad_line_directive;
|
||||
ip->system_header_p = 1;
|
||||
read_line_number (pfile, &action_number);
|
||||
}
|
||||
if (action_number == 4)
|
||||
{
|
||||
ip->system_header_p = 2;
|
||||
read_line_number (pfile, &action_number);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user