diff options
author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-04-05 21:16:26 +0000 |
---|---|---|
committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-04-05 21:16:26 +0000 |
commit | ff8281e42fe545a0b86d5f185b9f44ea4f4c55a2 (patch) | |
tree | 444e0bc9b38ad6819d87db5007348f663acf5e60 /gcc/fix-header.c | |
parent | ad0e2334a8dbbaec4d046a4929b08571197a8ec8 (diff) | |
download | gcc-ff8281e42fe545a0b86d5f185b9f44ea4f4c55a2.tar.gz |
Re-write fixproto/fix-header/etc to use cpplib.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@9316 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fix-header.c')
-rw-r--r-- | gcc/fix-header.c | 497 |
1 files changed, 418 insertions, 79 deletions
diff --git a/gcc/fix-header.c b/gcc/fix-header.c index c21acf05476..4056605b8b7 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -1,5 +1,5 @@ /* fix-header.c - Make C header file suitable for C++. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -59,15 +59,14 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ b) it would be nice to allow update in place. Usage: - fix-header FOO.H INFILE.H OUTFILE.H REQUIRED_FUNCS <SCAN-FILE + fix-header FOO.H INFILE.H OUTFILE.H [OPTIONS] where: * FOO.H is the relative file name of the include file, as it would be #include'd by a C file. (E.g. stdio.h) * INFILE.H is a full pathname for the input file (e.g. /usr/include/stdio.h) * OUTFILE.H is the full pathname for where to write the output file, if anything needs to be done. (e.g. ./include/stdio.h) - * SCAN-FILE is the output of the scan-decls program. - * REQUIRED_FUNCS is a list of required function (e.g. fclose for stdio.h). + * OPTIONS are such as you would pass to cpp. Written by Per Bothner <bothner@cygnus.com>, July 1993. */ @@ -81,22 +80,44 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "hconfig.h" #include "obstack.h" #include "scan.h" +#include "cpplib.h" -extern sstring buf; +#if !__STDC__ +#define const /* nothing */ +#endif + +sstring buf; int verbose = 0; int partial_count = 0; -#if 0 -/* All uses of this are ifdefed out. This is no longer needed, because - cccp.c implicitly forces the standard include files to be treated as C. - Adding an explicit extern "C" is undesireable as it breaks the SunOS 4.x - sun4c/romvec.h file. */ +int warnings = 0; + +/* We no longer need to add extern "C", because cpp implicitly + forces the standard include files to be treated as C. */ +/*#define ADD_MISSING_EXTERN_C 1 */ + +#if ADD_MISSING_EXTERN_C int missing_extern_C_count = 0; #endif int missing_errno = 0; #include "xsys-protos.h" +#ifdef FIXPROTO_IGNORE_LIST +/* This is a currently unused feature. */ + +/* List of files and directories to ignore. + A directory name (ending in '/') means ignore anything in that + directory. (It might be more efficient to do directory pruning + earlier in fixproto, but this is simpler and easier to customize.) */ + +static char *files_to_ignore[] = { + "X11/", + FIXPROTO_IGNORE_LIST + 0 +}; +#endif + char *inf_buffer; char *inf_limit; char *inf_ptr; @@ -106,8 +127,134 @@ char *inf_ptr; enum special_file { no_special, - errno_special, - sys_stat_special + errno_h, + stdio_h, + sys_stat_h +}; + +/* A NAMELIST is a sequence of names, separated by '\0', and terminated + by an empty name (i.e. by "\0\0"). */ + +typedef const char* namelist; + +struct std_include_entry { + const char *name; + namelist required; + namelist extra; + int special; +}; + +/* End of namelist NAMES. */ + +namelist +namelist_end (names) + namelist names; +{ + register namelist ptr; + for (ptr = names; ; ptr++) + { + if (*ptr == '\0') + { + ptr++; + if (*ptr == '\0') + return ptr; + } + } +} + +const char NONE[] = ""; + +struct std_include_entry *include_entry; + +struct std_include_entry std_include_table [] = { + { "ctype.h", + "isalnum\0isalpha\0iscntrl\0isdigit\0isgraph\0islower\0\ +isprint\0ispunct\0isspace\0isupper\0isxdigit\0tolower\0toupper\0", NONE }, + + { "dirent.h", "closedir\0opendir\0readdir\0rewinddir\0", NONE}, + + { "errno.h", NONE, "errno\0" }, + + { "curses.h", "box\0delwin\0endwin\0getcurx\0getcury\0initscr\0\ +mvcur\0mvwprintw\0mvwscanw\0newwin\0overlay\0overwrite\0\ +scroll\0subwin\0touchwin\0waddstr\0wclear\0wclrtobot\0wclrtoeol\0\ +waddch\0wdelch\0wdeleteln\0werase\0wgetch\0wgetstr\0winsch\0winsertln\0\ +wmove\0wprintw\0wrefresh\0wscanw\0wstandend\0wstandout\0", NONE }, + + { "fcntl.h", "creat\0fcntl\0open\0", NONE }, + + /* Maybe also "getgrent fgetgrent setgrent endgrent" */ + { "grp.h", "getgrgid\0getgrnam\0", NONE }, + +/*{ "limit.h", ... provided by gcc }, */ + + { "locale.h", "localeconv\0setlocale\0", NONE }, + + { "math.h", "acos\0asin\0atan\0atan2\0ceil\0cos\0cosh\0exp\0\ +fabs\0floor\0fmod\0frexp\0ldexp\0log10\0log\0modf\0pow\0sin\0sinh\0sqrt\0\ +tan\0tanh\0", "HUGE_VAL\0" }, + + { "pwd.h", "getpwnam\0getpwuid\0", NONE }, + + /* Left out siglongjmp sigsetjmp - these depend on sigjmp_buf. */ + { "setjmp.h", "longjmp\0setjmp\0", NONE }, + + /* Left out signal() - its prototype is too complex for us! + Also left out "sigaction sigaddset sigdelset sigemptyset + sigfillset sigismember sigpending sigprocmask sigsuspend" + because these need sigset_t or struct sigaction. + Most systems that provide them will also declare them. */ + { "signal.h", "kill\0raise\0", NONE }, + + { "stdio.h", "clearerr\0fclose\0feof\0ferror\0fflush\0fgetc\0fgetpos\0\ +fgets\0fopen\0fprintf\0fputc\0fputs\0fread\0freopen\0fscanf\0fseek\0\ +fsetpos\0ftell\0fwrite\0getc\0getchar\0gets\0pclose\0perror\0popen\0\ +printf\0putc\0putchar\0puts\0remove\0rename\0rewind\0scanf\0setbuf\0\ +setvbuf\0sprintf\0sscanf\0vprintf\0vsprintf\0vfprintf\0tmpfile\0\ +tmpnam\0ungetc\0", NONE }, +/* Should perhaps also handle NULL, EOF, ... ? */ + + /* "div ldiv", - ignored because these depend on div_t, ldiv_t + ignore these: "mblen mbstowcs mbstowc wcstombs wctomb" + Left out getgroups, because SunOS4 has incompatible BSD and SVR4 versions. + Should perhaps also add NULL */ + { "stdlib.h", "abort\0abs\0atexit\0atof\0atoi\0atol\0bsearch\0calloc\0\ +exit\0free\0getenv\0labs\0malloc\0putenv\0qsort\0rand\0realloc\0\ +srand\0strtod\0strtol\0strtoul\0system\0", NONE }, + + { "string.h", "memchr\0memcmp\0memcpy\0memmove\0memset\0\ +strcat\0strchr\0strcmp\0strcoll\0strcpy\0strcspn\0strerror\0\ +strlen\0strncat\0strncmp\0strncpy\0strpbrk\0strrchr\0strspn\0strstr\0\ +strtok\0strxfrm\0", NONE }, +/* Should perhaps also add NULL and size_t */ + + { "sys/stat.h", "chmod\0fstat\0mkdir\0mkfifo\0stat\0lstat\0umask\0", + "S_ISDIR\0S_ISBLK\0S_ISCHR\0S_ISFIFO\0S_ISREG\0S_ISLNK\0S_IFDIR\0\ +S_IFBLK\0S_IFCHR\0S_IFIFO\0S_IFREG\0S_IFLNK\0" }, + + { "sys/times.h", "times\0", NONE }, + /* "sys/types.h" add types (not in old g++-include) */ + + { "sys/utsname.h", "uname\0", NONE }, + + { "sys/wait.h", "wait\0waitpid\0", + "WEXITSTATUS\0WIFEXITED\0WIFSIGNALED\0WIFSTOPPED\0WSTOPSIG\0\ +WTERMSIG\0WNOHANG\0WNOTRACED\0" }, + + { "tar.h", NONE, NONE }, + + { "termios.h", "cfgetispeed\0cfgetospeed\0cfsetispeed\0cfsetospeed\0tcdrain\0tcflow\0tcflush\0tcgetattr\0tcsendbreak\0tcsetattr\0", NONE }, + + { "time.h", "asctime\0clock\0ctime\0difftime\0gmtime\0localtime\0mktime\0strftime\0time\0tzset\0", NONE }, + + { "unistd.h", "_exit\0access\0alarm\0chdir\0chown\0close\0ctermid\0cuserid\0\ +dup\0dup2\0execl\0execle\0execlp\0execv\0execve\0execvp\0fork\0fpathconf\0\ +getcwd\0getegid\0geteuid\0getgid\0getlogin\0getopt\0getpgrp\0getpid\0\ +getppid\0getuid\0isatty\0link\0lseek\0pathconf\0pause\0pipe\0read\0rmdir\0\ +setgid\0setpgid\0setsid\0setuid\0sleep\0sysconf\0tcgetpgrp\0tcsetpgrp\0\ +ttyname\0unlink\0write\0", NONE }, + + { 0, NONE, NONE } }; enum special_file special_file_handling = no_special; @@ -146,10 +293,11 @@ struct obstack scan_file_obstack; /* NOTE: If you edit this, also edit gen-protos.c !! */ struct fn_decl * -lookup_std_proto (name) - char *name; +lookup_std_proto (name, name_length) + const char *name; + int name_length; { - int i = hash (name) % HASH_SIZE; + int i = hashf (name, name_length, HASH_SIZE); int i0 = i; for (;;) { @@ -157,7 +305,8 @@ lookup_std_proto (name) if (hash_tab[i] == 0) return NULL; fn = &std_protos[hash_tab[i]]; - if (strcmp (fn->fname, name) == 0) + if (strlen (fn->fname) == name_length + && strncmp (fn->fname, name, name_length) == 0) return fn; i = (i+1) % HASH_SIZE; if (i == i0) @@ -173,14 +322,14 @@ sstring line; int lbrac_line, rbrac_line; -char **required_functions; -int required_unseen_count; +namelist required_functions_list; +int required_unseen_count = 0; void write_lbrac () { -#if 0 +#if ADD_MISSING_EXTERN_C if (missing_extern_C_count + required_unseen_count > 0) fprintf (outf, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); #endif @@ -207,31 +356,33 @@ struct partial_proto struct partial_proto *partial_proto_list = NULL; -struct partial_proto required_dummy_proto; +struct partial_proto required_dummy_proto, seen_dummy_proto; #define REQUIRED(FN) ((FN)->partial == &required_dummy_proto) #define SET_REQUIRED(FN) ((FN)->partial = &required_dummy_proto) -#define CLEAR_REQUIRED(FN) ((FN)->partial = 0) +#define SET_SEEN(FN) ((FN)->partial = &seen_dummy_proto) +#define SEEN(FN) ((FN)->partial == &seen_dummy_proto) void recognized_macro (fname) char *fname; { /* The original include file defines fname as a macro. */ - struct fn_decl *fn = lookup_std_proto (fname); + struct fn_decl *fn = lookup_std_proto (fname, strlen (fname)); /* Since fname is a macro, don't require a prototype for it. */ - if (fn && REQUIRED (fn)) + if (fn) { - CLEAR_REQUIRED (fn); - required_unseen_count--; + if (REQUIRED (fn)) + required_unseen_count--; + SET_SEEN (fn); } switch (special_file_handling) { - case errno_special: + case errno_h: if (strcmp (fname, "errno") == 0) missing_errno = 0; break; - case sys_stat_special: + case sys_stat_h: if (fname[0] == 'S' && fname[1] == '_') { if (strcmp (fname, "S_IFBLK") == 0) seen_S_IFBLK++; @@ -251,14 +402,15 @@ recognized_macro (fname) } void -recognized_extern (name, type) +recognized_extern (name, name_length, type, type_length) char *name; char *type; + int name_length, type_length; { switch (special_file_handling) { - case errno_special: - if (strcmp (name, "errno") == 0) missing_errno = 0; + case errno_h: + if (strncmp (name, "errno", name_length) == 0) missing_errno = 0; break; } } @@ -272,33 +424,38 @@ recognized_extern (name, type) 'f' for other function declarations. */ void -recognized_function (fname, kind, rtype, args, file_seen, line_seen) +recognized_function (fname, fname_length, + kind, rtype, rtype_length, + have_arg_list, file_seen, line_seen) char *fname; + int fname_length; int kind; /* One of 'f' 'F' or 'I' */ char *rtype; - char *args; + int rtype_length; + int have_arg_list; char *file_seen; int line_seen; { struct partial_proto *partial; int i; struct fn_decl *fn; -#if 0 +#if ADD_MISSING_EXTERN_C if (kind == 'f') missing_extern_C_count++; #endif - fn = lookup_std_proto (fname); + fn = lookup_std_proto (fname, fname_length); /* Remove the function from the list of required function. */ - if (fn && REQUIRED (fn)) + if (fn) { - CLEAR_REQUIRED (fn); - required_unseen_count--; + if (REQUIRED (fn)) + required_unseen_count--; + SET_SEEN (fn); } /* If we have a full prototype, we're done. */ - if (args[0] != '\0') + if (have_arg_list) return; if (kind == 'I') /* don't edit inline function */ @@ -321,10 +478,11 @@ recognized_function (fname, kind, rtype, args, file_seen, line_seen) partial_count++; partial = (struct partial_proto*) obstack_alloc (&scan_file_obstack, sizeof (struct partial_proto)); - partial->fname = obstack_alloc (&scan_file_obstack, strlen (fname) + 1); - strcpy (partial->fname, fname); - partial->rtype = obstack_alloc (&scan_file_obstack, strlen (rtype) + 1); - strcpy (partial->rtype, rtype); + partial->fname = obstack_alloc (&scan_file_obstack, fname_length + 1); + bcopy (fname, partial->fname, fname_length); + partial->fname[fname_length] = 0; + partial->rtype = obstack_alloc (&scan_file_obstack, rtype_length + 1); + sprintf (partial->rtype, "%.*s", rtype_length, rtype); partial->line_seen = line_seen; partial->fn = fn; fn->partial = partial; @@ -333,20 +491,122 @@ recognized_function (fname, kind, rtype, args, file_seen, line_seen) if (verbose) { fprintf (stderr, "(%s: %s non-prototype function declaration.)\n", - inc_filename, fname); + inc_filename, partial->fname); + } +} + +/* For any name in NAMES that is defined as a macro, + call recognized_macro on it. */ + +void +check_macro_names (pfile, names) + struct parse_file *pfile; + namelist names; +{ + while (*names) + { + if (cpp_lookup (pfile, names, -1, -1)) + recognized_macro (names); + names += strlen (names) + 1; } } void -read_scan_file (scan_file) - FILE *scan_file; +read_scan_file (in_fname, argc, argv) + char *in_fname; + int argc; + char **argv; { + cpp_reader scan_in; + cpp_options scan_options; + struct fn_decl *fn; + int i; + obstack_init (&scan_file_obstack); - scan_decls (scan_file); + init_parse_file (&scan_in); + scan_in.data = &scan_options; + init_parse_options (&scan_options); + i = cpp_handle_options (&scan_in, argc, argv); + if (i < argc) + fatal ("Invalid option `%s'", argv[i]); + push_parse_file (&scan_in, in_fname); + CPP_OPTIONS (&scan_in)->no_line_commands = 1; + + scan_decls (&scan_in, argc, argv); + check_macro_names (&scan_in, include_entry->required); + check_macro_names (&scan_in, include_entry->extra); + + if (verbose && (scan_in.errors + warnings) > 0) + fprintf (stderr, "(%s: %d errors and %d warnings from cpp)\n", + inc_filename, scan_in.errors, warnings); + if (scan_in.errors) + exit (0); + + /* Traditionally, getc and putc are defined in terms of _filbuf and _flsbuf. + If so, those functions are also required. */ + if (special_file_handling == stdio_h + && (fn = lookup_std_proto ("_filbuf", 7)) != NULL) + { + static char getchar_call[] = "getchar();"; + cpp_buffer *buf = + cpp_push_buffer (&scan_in, getchar_call, sizeof(getchar_call) - 1); + int old_written = CPP_WRITTEN (&scan_in); + int seen_filbuf = 0; + + /* Scan the macro expansion of "getchar();". */ + for (;;) + { + enum cpp_token token = cpp_get_token (&scan_in); + int length = CPP_WRITTEN (&scan_in) - old_written; + CPP_SET_WRITTEN (&scan_in, old_written); + if (token == CPP_EOF) /* Should not happen ... */ + break; + if (token == CPP_POP && CPP_BUFFER (&scan_in) == buf) + { + cpp_pop_buffer (&scan_in); + break; + } + if (token == CPP_NAME && length == 7 + && strcmp ("_filbuf", scan_in.token_buffer + old_written) == 0) + seen_filbuf++; + } + if (seen_filbuf) + { + int need_filbuf = !SEEN (fn) && !REQUIRED (fn); + struct fn_decl *flsbuf_fn = lookup_std_proto ("_flsbuf", 7); + int need_flsbuf + = flsbuf_fn && !SEEN (flsbuf_fn) && !REQUIRED (flsbuf_fn); + + /* Append "_filbuf" and/or "_flsbuf" to end of + required_functions_list. */ + if (need_filbuf + need_flsbuf) + { + int old_len = namelist_end (required_functions_list) + - required_functions_list; + char *new_list = (char*) xmalloc (old_len + 20); + bcopy (required_functions_list, new_list, old_len); + if (need_filbuf) + { + strcpy (new_list + old_len, "_filbuf"); + old_len += 8; + SET_REQUIRED (fn); + } + if (need_flsbuf) + { + strcpy (new_list + old_len, "_flsbuf"); + old_len += 8; + SET_REQUIRED (flsbuf_fn); + } + new_list[old_len] = '\0'; + required_functions_list = (namelist)new_list; + required_unseen_count += need_filbuf + need_flsbuf; + } + } + } if (required_unseen_count + partial_count + missing_errno -#if 0 +#if ADD_MISSING_EXTERN_C + missing_extern_C_count #endif == 0) @@ -365,7 +625,7 @@ read_scan_file (scan_file) if (partial_count) fprintf (stderr, "%s: %d non-prototype function declarations.\n", inc_filename, partial_count); -#if 0 +#if ADD_MISSING_EXTERN_C if (missing_extern_C_count) fprintf (stderr, "%s: %d declarations not protected by extern \"C\".\n", @@ -378,7 +638,7 @@ void write_rbrac () { struct fn_decl *fn; - char **rptr; + const char *cptr; if (required_unseen_count) { @@ -390,11 +650,13 @@ write_rbrac () } /* Now we print out prototypes for those functions that we haven't seen. */ - for (rptr = required_functions; *rptr; rptr++) + for (cptr = required_functions_list; *cptr!= '\0'; ) { int macro_protect = 0; + int name_len = strlen (cptr); - fn = lookup_std_proto (*rptr); + fn = lookup_std_proto (cptr, name_len); + cptr+= name_len + 1; if (fn == NULL || !REQUIRED (fn)) continue; @@ -425,11 +687,11 @@ write_rbrac () switch (special_file_handling) { - case errno_special: + case errno_h: if (missing_errno) fprintf (outf, "extern int errno;\n"); break; - case sys_stat_special: + case sys_stat_h: if (!seen_S_ISBLK && seen_S_IFBLK) fprintf (outf, "#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)\n"); @@ -452,7 +714,7 @@ write_rbrac () } -#if 0 +#if ADD_MISSING_EXTERN_C if (missing_extern_C_count + required_unseen_count > 0) fprintf (outf, "#ifdef __cplusplus\n}\n#endif\n"); #endif @@ -674,7 +936,7 @@ main (argc, argv) struct stat sbuf; int c; int i, done; - char *cptr, *cptr0, **pptr; + const char *cptr0, *cptr, **pptr; int ifndef_line; int endif_line; long to_read; @@ -693,34 +955,58 @@ main (argc, argv) if (argc < 4) { - fprintf (stderr, "%s: Usage: foo.h infile.h outfile.h req_funcs <scan-file-name\n", + fprintf (stderr, "%s: Usage: foo.h infile.h outfile.h options\n", progname); exit (-1); } inc_filename = argv[1]; inc_filename_length = strlen (inc_filename); + +#ifdef FIXPROTO_IGNORE_LIST + for (i = 0; files_to_ignore[i] != NULL; i++) + { + char *ignore_name = files_to_ignore[i]; + int ignore_len = strlen (ignore_name); + if (strncmp (inc_filename, ignore_name, ignore_len) == 0) + { + if (ignore_name[ignore_len-1] == '/' + || inc_filename[ignore_len] == '\0') + { + if (verbose) + fprintf (stderr, "%s: ignoring %s\n", progname, inc_filename); + exit (0); + } + } + + } +#endif + if (strcmp (inc_filename, "sys/stat.h") == 0) - special_file_handling = sys_stat_special; + special_file_handling = sys_stat_h; else if (strcmp (inc_filename, "errno.h") == 0) - special_file_handling = errno_special, missing_errno = 1; - - /* Calculate an upper bound of the number of function names in argv[4] */ - for (i = 1, cptr = argv[4]; *cptr; cptr++) - if (*cptr == ' ') i++; - /* Find the list of prototypes required for this include file. */ - required_functions = (char**)xmalloc ((i+1) * sizeof (char*)); - for (cptr = argv[4], cptr0 = cptr, pptr = required_functions, done = 0; + special_file_handling = errno_h, missing_errno = 1; + else if (strcmp (inc_filename, "stdio.h") == 0) + special_file_handling = stdio_h; + include_entry = std_include_table; + while (include_entry->name != NULL + && strcmp (inc_filename, include_entry->name) != 0) + include_entry++; + + required_functions_list = include_entry->required; + + /* Count and mark the prototypes required for this include file. */ + for (cptr = required_functions_list, cptr0 = cptr, done = 0; !done; cptr++) { - done = *cptr == '\0'; - if (*cptr == ' ' || done) + if (*cptr == '\0') { - *cptr = '\0'; - if (cptr > cptr0) + if (cptr[1] == 0) + break; + else { - struct fn_decl *fn = lookup_std_proto (cptr0); - *pptr++ = cptr0; + struct fn_decl *fn = lookup_std_proto (cptr0, strlen (cptr0)); + required_unseen_count++; if (fn == NULL) fprintf (stderr, "Internal error: No prototype for %s\n", cptr0); @@ -730,10 +1016,8 @@ main (argc, argv) cptr0 = cptr + 1; } } - required_unseen_count = pptr - required_functions; - *pptr = 0; - read_scan_file (stdin); + read_scan_file (argv[2], argc - 4, argv + 4); inf_fd = open (argv[2], O_RDONLY, 0666); if (inf_fd < 0) @@ -794,10 +1078,6 @@ main (argc, argv) if (check_protection (&ifndef_line, &endif_line)) { -#if 0 - fprintf (stderr, "#ifndef %s on line %d; #endif on line %d\n", - protect_name, ifndef_line, endif_line); -#endif lbrac_line = ifndef_line+1; rbrac_line = endif_line; } @@ -828,7 +1108,7 @@ main (argc, argv) c = inf_scan_ident (&buf, c); INF_UNGET (c); fputs (buf.base, outf); - fn = lookup_std_proto (buf.base); + fn = lookup_std_proto (buf.base, strlen (buf.base)); /* We only want to edit the declaration matching the one seen by scan-decls, as there can be multiple declarations, selected by #ifdef __STDC__ or whatever. */ @@ -872,3 +1152,62 @@ main (argc, argv) return 0; } + +/* Stub error functions. These replace cpperror.c, + because we want to suppress error messages. */ + +void +cpp_file_line_for_message (pfile, filename, line, column) + cpp_reader *pfile; + char *filename; + int line, column; +{ + if (!verbose) + return; + if (column > 0) + fprintf (stderr, "%s:%d:%d: ", filename, line, column); + else + fprintf (stderr, "%s:%d: ", filename, line); +} + +void +cpp_print_containing_files (pfile) + cpp_reader *pfile; +{ +} + +/* IS_ERROR is 1 for error, 0 for warning */ +void cpp_message (pfile, is_error, msg, arg1, arg2, arg3) + int is_error; + cpp_reader *pfile; + char *msg; + char *arg1, *arg2, *arg3; +{ + if (is_error) + pfile->errors++; + if (!verbose) + return; + if (!is_error) + fprintf (stderr, "warning: "); + fprintf (stderr, msg, arg1, arg2, arg3); + fprintf (stderr, "\n"); +} + +void +fatal (str, arg) + char *str, *arg; +{ + fprintf (stderr, "%s: ", progname); + fprintf (stderr, str, arg); + fprintf (stderr, "\n"); + exit (FAILURE_EXIT_CODE); +} + +void +cpp_pfatal_with_name (pfile, name) + cpp_reader *pfile; + char *name; +{ + cpp_perror_with_name (pfile, name); + exit (FAILURE_EXIT_CODE); +} |