Commit e605b040 by Zack Weinberg Committed by Zack Weinberg

cppfiles.c (cpp_make_system_header): New function.

	* cppfiles.c (cpp_make_system_header): New function.
	* cpplib.h: Prototype it.
	* cpplib.c (do_line, do_pragma_system_header): Use it.
	* fix-header.c (read_scan_file): Use it.

	* fix-header.c (check_macro_names): Cast second arg of
	cpp_defined to const unsigned char *.
	(read_scan_file): Make getchar_call const unsigned char.

From-SVN: r34641
parent 229e1e4c
2000-06-21 Zack Weinberg <zack@wolery.cumb.org> 2000-06-21 Zack Weinberg <zack@wolery.cumb.org>
* cppfiles.c (cpp_make_system_header): New function.
* cpplib.h: Prototype it.
* cpplib.c (do_line, do_pragma_system_header): Use it.
* fix-header.c (read_scan_file): Use it.
* fix-header.c (check_macro_names): Cast second arg of
cpp_defined to const unsigned char *.
(read_scan_file): Make getchar_call const unsigned char.
2000-06-21 Zack Weinberg <zack@wolery.cumb.org>
* cppfiles.c: Include splay-tree.h, not hashtab.h. * cppfiles.c: Include splay-tree.h, not hashtab.h.
(redundant_include_p, make_IHASH, hash_IHASH, eq_IHASH): Delete. (redundant_include_p, make_IHASH, hash_IHASH, eq_IHASH): Delete.
(destroy_include_file_node): New. (destroy_include_file_node): New.
......
...@@ -308,6 +308,23 @@ _cpp_fake_include (pfile, fname) ...@@ -308,6 +308,23 @@ _cpp_fake_include (pfile, fname)
return (const char *)name; return (const char *)name;
} }
/* Not everyone who wants to set system-header-ness on a buffer can
see the details of struct include_file. This is an exported interface
because fix-header needs it. */
void
cpp_make_system_header (pfile, pbuf, flag)
cpp_reader *pfile;
cpp_buffer *pbuf;
int flag;
{
if (flag < 0 || flag > 2)
cpp_ice (pfile, "cpp_make_system_header: bad flag %d\n", flag);
else if (!pbuf->inc)
cpp_ice (pfile, "cpp_make_system_header called on non-file buffer");
else
pbuf->inc->sysp = flag;
}
#define PRINT_THIS_DEP(p, b) (CPP_PRINT_DEPS(p) > (b||p->system_include_depth)) #define PRINT_THIS_DEP(p, b) (CPP_PRINT_DEPS(p) > (b||p->system_include_depth))
void void
_cpp_execute_include (pfile, f, len, no_reinclude, search_start) _cpp_execute_include (pfile, f, len, no_reinclude, search_start)
......
...@@ -603,23 +603,23 @@ do_line (pfile) ...@@ -603,23 +603,23 @@ do_line (pfile)
if (action_number == 1) if (action_number == 1)
{ {
pfile->buffer_stack_depth++; pfile->buffer_stack_depth++;
ip->inc->sysp = 0; cpp_make_system_header (pfile, ip, 0);
read_line_number (pfile, &action_number); read_line_number (pfile, &action_number);
} }
else if (action_number == 2) else if (action_number == 2)
{ {
pfile->buffer_stack_depth--; pfile->buffer_stack_depth--;
ip->inc->sysp = 0; cpp_make_system_header (pfile, ip, 0);
read_line_number (pfile, &action_number); read_line_number (pfile, &action_number);
} }
if (action_number == 3) if (action_number == 3)
{ {
ip->inc->sysp = 1; cpp_make_system_header (pfile, ip, 1);
read_line_number (pfile, &action_number); read_line_number (pfile, &action_number);
} }
if (action_number == 4) if (action_number == 4)
{ {
ip->inc->sysp = 2; cpp_make_system_header (pfile, ip, 2);
read_line_number (pfile, &action_number); read_line_number (pfile, &action_number);
} }
} }
...@@ -978,7 +978,7 @@ do_pragma_system_header (pfile) ...@@ -978,7 +978,7 @@ do_pragma_system_header (pfile)
if (CPP_PREV_BUFFER (ip) == NULL) if (CPP_PREV_BUFFER (ip) == NULL)
cpp_warning (pfile, "#pragma system_header outside include file"); cpp_warning (pfile, "#pragma system_header outside include file");
else else
ip->inc->sysp = 1; cpp_make_system_header (pfile, ip, 1);
return 1; return 1;
} }
......
...@@ -714,6 +714,8 @@ extern cpp_hashnode *cpp_lookup PARAMS ((cpp_reader *, ...@@ -714,6 +714,8 @@ extern cpp_hashnode *cpp_lookup PARAMS ((cpp_reader *,
/* In cppfiles.c */ /* In cppfiles.c */
extern int cpp_included PARAMS ((cpp_reader *, const char *)); extern int cpp_included PARAMS ((cpp_reader *, const char *));
extern int cpp_read_file PARAMS ((cpp_reader *, const char *)); extern int cpp_read_file PARAMS ((cpp_reader *, const char *));
extern void cpp_make_system_header PARAMS ((cpp_reader *,
cpp_buffer *, int));
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -606,7 +606,7 @@ check_macro_names (pfile, names) ...@@ -606,7 +606,7 @@ check_macro_names (pfile, names)
while (*names) while (*names)
{ {
len = strlen (names); len = strlen (names);
if (cpp_defined (pfile, names, len)) if (cpp_defined (pfile, (const unsigned char *)names, len))
recognized_macro (names); recognized_macro (names);
names += len + 1; names += len + 1;
} }
...@@ -640,7 +640,7 @@ read_scan_file (in_fname, argc, argv) ...@@ -640,7 +640,7 @@ read_scan_file (in_fname, argc, argv)
exit (FATAL_EXIT_CODE); exit (FATAL_EXIT_CODE);
/* We are scanning a system header, so mark it as such. */ /* We are scanning a system header, so mark it as such. */
CPP_BUFFER (&scan_in)->system_header_p = 1; cpp_make_system_header (&scan_in, CPP_BUFFER (&scan_in), 1);
scan_decls (&scan_in, argc, argv); scan_decls (&scan_in, argc, argv);
for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++) for (cur_symbols = &symbol_table[0]; cur_symbols->names; cur_symbols++)
...@@ -657,7 +657,7 @@ read_scan_file (in_fname, argc, argv) ...@@ -657,7 +657,7 @@ read_scan_file (in_fname, argc, argv)
if (special_file_handling == stdio_h if (special_file_handling == stdio_h
&& (fn = lookup_std_proto ("_filbuf", 7)) != NULL) && (fn = lookup_std_proto ("_filbuf", 7)) != NULL)
{ {
static char getchar_call[] = "getchar();"; static const unsigned char getchar_call[] = "getchar();";
int old_written = CPP_WRITTEN (&scan_in); int old_written = CPP_WRITTEN (&scan_in);
int seen_filbuf = 0; int seen_filbuf = 0;
cpp_buffer *buf = CPP_BUFFER (&scan_in); cpp_buffer *buf = CPP_BUFFER (&scan_in);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment