/* CPP Library. (Directive handling.)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
return;
/* Prevent #include recursion. */
- if (pfile->line_maps.depth >= CPP_STACK_MAX)
+ if (pfile->line_table->depth >= CPP_STACK_MAX)
cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply");
else
{
static void
do_line (cpp_reader *pfile)
{
+ const struct line_map *map = linemap_lookup (pfile->line_table, pfile->line);
const cpp_token *token;
- const char *new_file = pfile->map->to_file;
+ const char *new_file = map->to_file;
unsigned long new_lineno;
/* C99 raised the minimum limit on #line numbers. */
if (token->type == CPP_STRING)
{
cpp_string s = { 0, 0 };
- if (_cpp_interpret_string_notranslate (pfile, &token->val.str, &s))
+ if (cpp_interpret_string_notranslate (pfile, &token->val.str, 1,
+ &s, false))
new_file = (const char *)s.text;
check_eol (pfile);
}
skip_rest_of_line (pfile);
_cpp_do_file_change (pfile, LC_RENAME, new_file, new_lineno,
- pfile->map->sysp);
+ map->sysp);
}
/* Interpret the # 44 "file" [flags] notation, which has slightly
static void
do_linemarker (cpp_reader *pfile)
{
+ const struct line_map *map = linemap_lookup (pfile->line_table, pfile->line);
const cpp_token *token;
- const char *new_file = pfile->map->to_file;
+ const char *new_file = map->to_file;
unsigned long new_lineno;
- unsigned int new_sysp = pfile->map->sysp;
+ unsigned int new_sysp = map->sysp;
enum lc_reason reason = LC_RENAME;
int flag;
if (token->type == CPP_STRING)
{
cpp_string s = { 0, 0 };
- if (_cpp_interpret_string_notranslate (pfile, &token->val.str, &s))
+ if (cpp_interpret_string_notranslate (pfile, &token->val.str,
+ 1, &s, false))
new_file = (const char *)s.text;
new_sysp = 0;
flag = read_flag (pfile, flag);
if (flag == 4)
new_sysp = 2;
+ pfile->buffer->sysp = new_sysp;
}
check_eol (pfile);
const char *to_file, unsigned int file_line,
unsigned int sysp)
{
- pfile->map = linemap_add (&pfile->line_maps, reason, sysp,
- pfile->line, to_file, file_line);
+ const struct line_map *map = linemap_add (pfile->line_table, reason, sysp,
+ to_file, file_line);
+ if (map == NULL)
+ pfile->line = 0;
+ else
+ pfile->line = linemap_line_start (pfile->line_table, map->to_line, 127);
if (pfile->cb.file_change)
- pfile->cb.file_change (pfile, pfile->map);
+ pfile->cb.file_change (pfile, map);
}
/* Report a warning or error detected by the program we are
static void
do_diagnostic (cpp_reader *pfile, int code, int print_dir)
{
- if (_cpp_begin_message (pfile, code,
- pfile->cur_token[-1].line,
- pfile->cur_token[-1].col))
+ if (_cpp_begin_message (pfile, code, pfile->cur_token[-1].src_loc, 0))
{
if (print_dir)
fprintf (stderr, "#%s ", pfile->directive->name);
pfile->context = saved_context;
pfile->cur_token = saved_cur_token;
pfile->cur_run = saved_cur_run;
- pfile->line--;
}
/* See above comment. For the moment, we'd like
return &pfile->cb;
}
-/* The line map set. */
-const struct line_maps *
-cpp_get_line_maps (cpp_reader *pfile)
-{
- return &pfile->line_maps;
-}
-
/* Copy the given callbacks structure to our own. */
void
cpp_set_callbacks (cpp_reader *pfile, cpp_callbacks *cb)
int from_stage3)
{
cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer);
- const char *input = CPP_OPTION (pfile, input_charset);
/* Clears, amongst other things, if_stack and mi_cmacro. */
memset (new, 0, sizeof (cpp_buffer));
new->need_line = true;
pfile->buffer = new;
- _cpp_init_iconv_buffer (pfile, input);
return new;
}
/* In case of a missing #endif. */
pfile->state.skipping = 0;
- _cpp_close_iconv_buffer (pfile);
-
/* _cpp_do_file_change expects pfile->buffer to be the new one. */
pfile->buffer = buffer->prev;