OSDN Git Service

* cpperror.c (cpp_file_line_for_message): Constify a char*.
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 7 Sep 1999 15:41:26 +0000 (15:41 +0000)
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 7 Sep 1999 15:41:26 +0000 (15:41 +0000)
* cppexp.c (parse_number, parse_charconst, cpp_lex,
cpp_parse_expr): Add static prototypes.
(parse_charconst): Don't cast away const-ness.
(token): Constify a char*.

* cppfiles.c (file_name_list, include_hash, find_include_file,
finclude, initialize_input_buffer): Constify a char*.
(file_cleanup, find_position): Add static prototypes.

* cpphash.c (macro_cleanup, macarg, timestamp, special_symbol,
collect_expansion): Add static prototypes.
(cpp_install, create_definition, monthnames): Constify a char*.

* cpphash.h (cpp_install): Likewise.

* cppinit.c (known_suffixes, default_include,
dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise.
(base_name, dump_special_to_buffer, initialize_dependency_output):
Add static prototypes.

* cpplib.c (my_strerror): Constify a char*.
(null_underflow, null_cleanup, skip_comment, copy_comment,
copy_rest_of_line, handle_directive, pass_thru_directive,
get_directive_token, read_line_number, cpp_print_file_and_line,
v_cpp_error, v_cpp_warning, v_cpp_error_with_line,
v_cpp_warning_with_line, detect_if_not_defined,
consider_directive_while_skipping): Add static prototypes.
(pass_thru_directive, check_macro_name, cpp_expand_to_buffer,
cpp_pedwarn_with_file_and_line): Constify a char*.

* cpplib.h (cpp_options, include_hash, progname, definition,
cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer,
check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message,
find_include_file, deps_output, include_hash): Constify a char*.

* cppmain.c (progname): Constify.
(main): Add prototype.  Use return, not exit.

* fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac,
recognized_macro, check_macro_names, read_scan_file, write_rbrac,
inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident,
check_protection): Add static prototype.
(xfree): Remove.
(progname, recognized_macrom, recognized_extern): Constify a char*.
(main): Add prototype.

* gen-protos.c (progname): Constify a char*.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29171 138bc75d-0d04-0410-961f-82ee72b054a4

12 files changed:
gcc/ChangeLog
gcc/cpperror.c
gcc/cppexp.c
gcc/cppfiles.c
gcc/cpphash.c
gcc/cpphash.h
gcc/cppinit.c
gcc/cpplib.c
gcc/cpplib.h
gcc/cppmain.c
gcc/fix-header.c
gcc/gen-protos.c

index 5bc407c..5409be5 100644 (file)
@@ -1,3 +1,55 @@
+Tue Sep  7 11:39:41 1999  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * cpperror.c (cpp_file_line_for_message): Constify a char*.
+
+       * cppexp.c (parse_number, parse_charconst, cpp_lex,
+       cpp_parse_expr): Add static prototypes.
+       (parse_charconst): Don't cast away const-ness.
+       (token): Constify a char*.
+
+       * cppfiles.c (file_name_list, include_hash, find_include_file,
+       finclude, initialize_input_buffer): Constify a char*.
+       (file_cleanup, find_position): Add static prototypes.
+
+       * cpphash.c (macro_cleanup, macarg, timestamp, special_symbol,
+       collect_expansion): Add static prototypes.
+       (cpp_install, create_definition, monthnames): Constify a char*.
+
+       * cpphash.h (cpp_install): Likewise.
+
+       * cppinit.c (known_suffixes, default_include,
+       dump_special_to_buffer, NAME, cpp_start_read, cpp_finish): Likewise.
+       (base_name, dump_special_to_buffer, initialize_dependency_output):
+       Add static prototypes.
+
+       * cpplib.c (my_strerror): Constify a char*.
+       (null_underflow, null_cleanup, skip_comment, copy_comment,
+       copy_rest_of_line, handle_directive, pass_thru_directive,
+       get_directive_token, read_line_number, cpp_print_file_and_line,
+       v_cpp_error, v_cpp_warning, v_cpp_error_with_line,
+       v_cpp_warning_with_line, detect_if_not_defined,
+       consider_directive_while_skipping): Add static prototypes.
+       (pass_thru_directive, check_macro_name, cpp_expand_to_buffer,
+       cpp_pedwarn_with_file_and_line): Constify a char*.
+
+       * cpplib.h (cpp_options, include_hash, progname, definition,
+       cpp_pedwarn_with_file_and_line, cpp_expand_to_buffer,
+       check_macro_name, cpp_pfatal_with_name, cpp_file_line_for_message,
+       find_include_file, deps_output, include_hash): Constify a char*.
+
+       * cppmain.c (progname): Constify.
+       (main): Add prototype.  Use return, not exit.
+
+       * fix-header.c (fatal, add_symbols, lookup_std_proto, write_lbrac,
+       recognized_macro, check_macro_names, read_scan_file, write_rbrac,
+       inf_skip_spaces, inf_read_upto, inf_scan_ident, inf_scan_ident,
+       check_protection): Add static prototype.
+       (xfree): Remove.
+       (progname, recognized_macrom, recognized_extern): Constify a char*.
+       (main): Add prototype.
+
+       * gen-protos.c (progname): Constify a char*.
+
 Tue Sep  7 00:47:52 1999  Mark Mitchell  <mark@codesourcery.com>
 
        * emit-rtl.c (free_emit_status): Take decl as a parameter.
index c7339dc..99c5a5d 100644 (file)
@@ -81,7 +81,7 @@ cpp_print_containing_files (pfile)
 void
 cpp_file_line_for_message (pfile, filename, line, column)
      cpp_reader *pfile ATTRIBUTE_UNUSED;
-     char *filename;
+     const char *filename;
      int line, column;
 {
   if (column > 0)
index aef6d19..f42e0b9 100644 (file)
@@ -79,6 +79,10 @@ Written by Per Bothner 1994.  */
 static void integer_overflow PARAMS ((cpp_reader *));
 static HOST_WIDEST_INT left_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT, int, unsigned HOST_WIDEST_INT));
 static HOST_WIDEST_INT right_shift PARAMS ((cpp_reader *, HOST_WIDEST_INT, int, unsigned HOST_WIDEST_INT));
+static struct operation parse_number PARAMS ((cpp_reader *, U_CHAR *, U_CHAR *));
+static struct operation parse_charconst PARAMS ((cpp_reader *, U_CHAR *, U_CHAR *));
+static struct operation cpp_lex PARAMS ((cpp_reader *, int));
+extern HOST_WIDEST_INT cpp_parse_expr PARAMS ((cpp_reader *));
 
 #define ERROR 299
 #define OROR 300
@@ -325,7 +329,7 @@ parse_charconst (pfile, start, end)
   /* If char type is signed, sign-extend the constant.  */
   num_bits = num_chars * width;
       
-  if (cpp_lookup (pfile, (U_CHAR *)"__CHAR_UNSIGNED__",
+  if (cpp_lookup (pfile, (const U_CHAR *)"__CHAR_UNSIGNED__",
                  sizeof ("__CHAR_UNSIGNED__")-1, -1)
       || ((result >> (num_bits - 1)) & 1) == 0)
     op.value = result & ((unsigned HOST_WIDEST_INT) ~0
@@ -346,7 +350,7 @@ parse_charconst (pfile, start, end)
 
 
 struct token {
-  char *operator;
+  const char *operator;
   int token;
 };
 
index 1e70d3e..2aa2eeb 100644 (file)
@@ -43,10 +43,14 @@ static char *remap_filename                 PROTO ((cpp_reader *, char *,
                                                struct file_name_list *));
 static long read_and_prescan           PROTO ((cpp_reader *, cpp_buffer *,
                                                int, size_t));
-static struct file_name_list *actual_directory PROTO ((cpp_reader *, char *));
-
+static struct file_name_list *actual_directory PROTO ((cpp_reader *,
+                                                      const char *));
 static void initialize_input_buffer    PROTO ((cpp_reader *, int,
                                                struct stat *));
+static int file_cleanup                        PROTO ((cpp_buffer *, cpp_reader *));
+static void find_position              PROTO ((U_CHAR *, U_CHAR *,
+                                               unsigned long *,
+                                               unsigned long *));
 
 #if 0
 static void hack_vms_include_specification PROTO ((char *));
@@ -199,12 +203,12 @@ merge_include_chains (opts)
 struct include_hash *
 include_hash (pfile, fname, add)
      cpp_reader *pfile;
-     char *fname;
+     const char *fname;
      int add;
 {
   unsigned int hash = 0;
   struct include_hash *l, *m;
-  char *f = fname;
+  const char *f = fname;
 
   while (*f)
     hash += *f++;
@@ -306,7 +310,7 @@ file_cleanup (pbuf, pfile)
 int
 find_include_file (pfile, fname, search_start, ihash, before)
      cpp_reader *pfile;
-     char *fname;
+     const char *fname;
      struct file_name_list *search_start;
      struct include_hash **ihash;
      int *before;
@@ -715,7 +719,7 @@ finclude (pfile, fd, ihash)
 static struct file_name_list *
 actual_directory (pfile, fname)
      cpp_reader *pfile;
-     char *fname;
+     const char *fname;
 {
   char *last_slash, *dir;
   size_t dlen;
@@ -1151,7 +1155,7 @@ initialize_input_buffer (pfile, fd, st)
 void
 deps_output (pfile, string, spacer)
      cpp_reader *pfile;
-     char *string;
+     const char *string;
      int spacer;
 {
   int size;
index 66fa358..c75cad1 100644 (file)
@@ -34,6 +34,11 @@ static int change_newlines    PARAMS ((U_CHAR *, int));
 static void push_macro_expansion PARAMS ((cpp_reader *,
                                          U_CHAR *, int, HASHNODE *));
 static int unsafe_chars                 PARAMS ((int, int));
+static int macro_cleanup        PARAMS ((cpp_buffer *, cpp_reader *));
+static enum cpp_token macarg    PARAMS ((cpp_reader *, int));
+static struct tm *timestamp     PARAMS ((cpp_reader *));
+static void special_symbol      PARAMS ((HASHNODE *, cpp_reader *));
+
 
 #define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
 #define CPP_IS_MACRO_BUFFER(PBUF) ((PBUF)->data != NULL)
@@ -61,6 +66,9 @@ struct arglist
   char rest_args;
 };
 
+static DEFINITION *collect_expansion PARAMS ((cpp_reader *, U_CHAR *, U_CHAR *,
+                                             int, struct arglist *));
+
 /* This structure represents one parsed argument in a macro call.
    `raw' points to the argument text as written (`raw_length' is its length).
    `expanded' points to the argument's macro-expansion
@@ -203,7 +211,7 @@ delete_macro (hp)
 HASHNODE *
 cpp_install (pfile, name, len, type, value, hash)
      cpp_reader *pfile;
-     U_CHAR *name;
+     const U_CHAR *name;
      int len;
      enum node_type type;
      const char *value;
@@ -211,7 +219,7 @@ cpp_install (pfile, name, len, type, value, hash)
 {
   register HASHNODE *hp;
   register int i, bucket;
-  register U_CHAR *p;
+  register const U_CHAR *p;
 
   if (len < 0)
     {
@@ -594,7 +602,8 @@ create_definition (buf, limit, pfile, predefinition)
   int sym_length;              /* and how long it is */
   int rest_args = 0;
   long line, col;
-  char *file = CPP_BUFFER (pfile) ? CPP_BUFFER (pfile)->nominal_fname : "";
+  const char *file =
+    CPP_BUFFER (pfile) ? CPP_BUFFER (pfile)->nominal_fname : "";
   DEFINITION *defn;
   int arglengths = 0;          /* Accumulate lengths of arg names
                                   plus number of args.  */
@@ -883,7 +892,7 @@ timestamp (pfile)
   return pfile->timebuf;
 }
 
-static char *monthnames[] =
+static const char * const monthnames[] =
 {
   "Jan", "Feb", "Mar", "Apr", "May", "Jun",
   "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
index bb306d9..5422979 100644 (file)
@@ -48,7 +48,7 @@ typedef struct hashnode HASHNODE;
 #define HASHSTEP(old, c) ((old << 2) + c)
 #define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
 
-extern HASHNODE *cpp_install     PARAMS ((cpp_reader *, U_CHAR *, int,
+extern HASHNODE *cpp_install     PARAMS ((cpp_reader *, const U_CHAR *, int,
                                           enum node_type, const char *, int));
 extern int hashf                 PARAMS ((const U_CHAR *, int, int));
 extern void delete_macro         PARAMS ((HASHNODE *));
index f0088e3..e7d1426 100644 (file)
@@ -85,7 +85,7 @@ extern char *version_string;
 #endif
 
 /* Suffix for object files, and known input-file extensions. */
-static char *known_suffixes[] =
+static const char * const known_suffixes[] =
 {
   ".c",  ".C",   ".s",   ".S",   ".m",
   ".cc", ".cxx", ".cpp", ".cp",  ".c++",
@@ -113,8 +113,8 @@ static char *known_suffixes[] =
 
 static struct default_include
 {
-  char *fname;                 /* The name of the directory.  */
-  char *component;             /* The component containing the directory
+  const char *fname;           /* The name of the directory.  */
+  const char *component;       /* The component containing the directory
                                   (see update_path in prefix.c) */
   int cplusplus;               /* Only look here if we're compiling C++.  */
   int cxx_aware;               /* Includes in this directory don't need to
@@ -203,6 +203,9 @@ static void initialize_builtins             PARAMS ((cpp_reader *));
 static void append_include_chain       PARAMS ((cpp_reader *,
                                                 struct cpp_pending *,
                                                 char *, int));
+static char *base_name                 PARAMS ((const char *));
+static void dump_special_to_buffer     PARAMS ((cpp_reader *, const char *));
+static void initialize_dependency_output PARAMS ((cpp_reader *));
 
 /* Last argument to append_include_chain: chain to use */
 enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
@@ -501,7 +504,7 @@ append_include_chain (pfile, pend, dir, path)
 static void
 dump_special_to_buffer (pfile, macro_name)
      cpp_reader *pfile;
-     char *macro_name;
+     const char *macro_name;
 {
   static char define_directive[] = "#define ";
   int macro_name_length = strlen (macro_name);
@@ -614,7 +617,7 @@ static void
 initialize_builtins (pfile)
      cpp_reader *pfile;
 {
-#define NAME(str) (U_CHAR *)str, sizeof str - 1
+#define NAME(str) (const U_CHAR *)str, sizeof str - 1
   cpp_install (pfile, NAME("__TIME__"),                  T_TIME,       0, -1);
   cpp_install (pfile, NAME("__DATE__"),                  T_DATE,       0, -1);
   cpp_install (pfile, NAME("__FILE__"),                  T_FILE,       0, -1);
@@ -938,8 +941,8 @@ cpp_start_read (pfile, fname)
              || (opts->cplusplus
                  && !opts->no_standard_cplusplus_includes))
            {
-             char *str = (char *) update_path (p->fname, p->component);
-             str = xstrdup (str);  /* XXX Potential memory leak! */
+             /* XXX Potential memory leak! */
+             char *str = xstrdup (update_path (p->fname, p->component));
              append_include_chain (pfile, opts->pending, str, SYSTEM);
            }
        }
@@ -1112,7 +1115,7 @@ cpp_finish (pfile)
       /* Don't actually write the deps file if compilation has failed.  */
       if (pfile->errors == 0)
        {
-         char *deps_mode = opts->print_deps_append ? "a" : "w";
+         const char *deps_mode = opts->print_deps_append ? "a" : "w";
          if (opts->deps_file == 0)
            deps_stream = stdout;
          else if ((deps_stream = fopen (opts->deps_file, deps_mode)) == 0)
index 8194246..1c85ba7 100644 (file)
@@ -38,7 +38,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* Forward declarations.  */
 
-static char *my_strerror               PROTO ((int));
+static const char *my_strerror         PROTO ((int));
 static void validate_else              PROTO ((cpp_reader *, const char *));
 static HOST_WIDEST_INT eval_if_expression      PROTO ((cpp_reader *));
 
@@ -86,6 +86,24 @@ static int do_sccs PARAMS ((cpp_reader *, const struct directive *));
 static int do_assert PARAMS ((cpp_reader *, const struct directive *));
 static int do_unassert PARAMS ((cpp_reader *, const struct directive *));
 static int do_warning PARAMS ((cpp_reader *, const struct directive *));
+static enum cpp_token null_underflow PARAMS ((cpp_reader *));
+static int null_cleanup PARAMS ((cpp_buffer *, cpp_reader *));
+static int skip_comment PARAMS ((cpp_reader *, int));
+static int copy_comment PARAMS ((cpp_reader *, int));
+static void copy_rest_of_line PARAMS ((cpp_reader *));
+static int handle_directive PARAMS ((cpp_reader *));
+static void pass_thru_directive PARAMS ((const U_CHAR *, size_t, cpp_reader *,
+                                        const struct directive *));
+static enum cpp_token get_directive_token PARAMS ((cpp_reader *));
+static int read_line_number PARAMS ((cpp_reader *, int *));
+static void cpp_print_file_and_line PARAMS ((cpp_reader *));
+static void v_cpp_error PARAMS ((cpp_reader *, const char *, va_list));
+static void v_cpp_warning PARAMS ((cpp_reader *, const char *, va_list));
+static void v_cpp_error_with_line PARAMS ((cpp_reader *, int, int,
+                                          const char *, va_list));
+static void v_cpp_warning_with_line PARAMS ((cpp_reader *, int, int, const char *, va_list));
+static U_CHAR *detect_if_not_defined PARAMS ((cpp_reader *));
+static int consider_directive_while_skipping PARAMS ((cpp_reader *, IF_STACK_FRAME *));
 
 /* Here is the actual list of #-directives.
    This table is ordered by frequency of occurrence; the numbers
@@ -557,7 +575,7 @@ handle_directive (pfile)
 
 static void
 pass_thru_directive (buf, len, pfile, keyword)
-     U_CHAR *buf;
+     const U_CHAR *buf;
      size_t len;
      cpp_reader *pfile;
      const struct directive *keyword;
@@ -578,10 +596,10 @@ pass_thru_directive (buf, len, pfile, keyword)
 int
 check_macro_name (pfile, symname, assertion)
      cpp_reader *pfile;
-     U_CHAR *symname;
+     const U_CHAR *symname;
      int assertion;
 {
-  U_CHAR *p;
+  const U_CHAR *p;
   int sym_length;
 
   for (p = symname; is_idchar[*p]; p++)
@@ -786,7 +804,7 @@ cpp_scan_buffer (pfile)
 void
 cpp_expand_to_buffer (pfile, buf, length)
      cpp_reader *pfile;
-     U_CHAR *buf;
+     const U_CHAR *buf;
      int length;
 {
   register cpp_buffer *ip;
@@ -3076,7 +3094,7 @@ parse_goto_mark (pfile)
   ip->mark = -1;
 }
 
-void
+static void
 cpp_print_file_and_line (pfile)
      cpp_reader *pfile;
 {
@@ -3312,12 +3330,12 @@ cpp_pedwarn_with_line VPROTO ((cpp_reader * pfile, int line, int column,
    giving specified file name and line number, not current.  */
 
 void
-cpp_pedwarn_with_file_and_line VPROTO ((cpp_reader *pfile, char *file, int line,
-                                       const char *msgid, ...))
+cpp_pedwarn_with_file_and_line VPROTO ((cpp_reader *pfile, const char *file,
+                                       int line, const char *msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   cpp_reader *pfile;
-  char *file;
+  const char *file;
   int line;
   const char *msgid;
 #endif
@@ -3327,7 +3345,7 @@ cpp_pedwarn_with_file_and_line VPROTO ((cpp_reader *pfile, char *file, int line,
 
 #ifndef ANSI_PROTOTYPES
   pfile = va_arg (ap, cpp_reader *);
-  file = va_arg (ap, char *);
+  file = va_arg (ap, const char *);
   line = va_arg (ap, int);
   msgid = va_arg (ap, const char *);
 #endif
@@ -3344,11 +3362,11 @@ cpp_pedwarn_with_file_and_line VPROTO ((cpp_reader *pfile, char *file, int line,
 /* my_strerror - return the descriptive text associated with an
    `errno' code.  */
 
-static char *
+static const char *
 my_strerror (errnum)
      int errnum;
 {
-  char *result;
+  const char *result;
 
 #ifndef VMS
 #ifndef HAVE_STRERROR
index d92228e..619645f 100644 (file)
@@ -327,7 +327,7 @@ struct cpp_options {
   char *in_fname;
 
   /* Name of output file, for error messages.  */
-  char *out_fname;
+  const char *out_fname;
 
   struct file_name_map_list *map_list;
 
@@ -551,14 +551,14 @@ struct include_hash
   struct file_name_list *foundhere;
   char *name;          /* (partial) pathname of file */
   char *nshort;                /* name of file as referenced in #include */
-  char *control_macro; /* macro, if any, preventing reinclusion - see
-                          redundant_include_p */
+  const char *control_macro; /* macro, if any, preventing reinclusion - see
+                               redundant_include_p */
   char *buf, *limit;   /* for file content cache, not yet implemented */
 };
 
 /* Name under which this program was invoked.  */
 
-extern char *progname;
+extern const char *progname;
 
 /* The structure of a node in the hash table.  The hash table
    has entries for all tokens defined by #define commands (type T_MACRO),
@@ -641,7 +641,7 @@ struct definition {
                                /* came from the command line */
   unsigned char *expansion;
   int line;                    /* Line number of definition */
-  char *file;                  /* File of definition */
+  const char *file;            /* File of definition */
   char rest_args;              /* Nonzero if last arg. absorbs the rest */
   struct reflist {
     struct reflist *next;
@@ -711,7 +711,7 @@ extern void cpp_warning_with_line PVPROTO ((cpp_reader *, int, int, const char *
   ATTRIBUTE_PRINTF_4;
 extern void cpp_pedwarn_with_line PVPROTO ((cpp_reader *, int, int, const char *, ...))
   ATTRIBUTE_PRINTF_4;
-extern void cpp_pedwarn_with_file_and_line PVPROTO ((cpp_reader *, char *, int, const char *, ...))
+extern void cpp_pedwarn_with_file_and_line PVPROTO ((cpp_reader *, const char *, int, const char *, ...))
   ATTRIBUTE_PRINTF_4;
 extern void cpp_message_from_errno PROTO ((cpp_reader *, int, const char *));
 extern void cpp_error_from_errno PROTO ((cpp_reader *, const char *));
@@ -735,9 +735,10 @@ extern void skip_rest_of_line PARAMS ((cpp_reader *));
 extern void cpp_finish PARAMS ((cpp_reader *));
 
 extern void quote_string               PARAMS ((cpp_reader *, const char *));
-extern void cpp_expand_to_buffer       PARAMS ((cpp_reader *, U_CHAR *, int));
+extern void cpp_expand_to_buffer       PARAMS ((cpp_reader *, const U_CHAR *,
+                                                int));
 extern void cpp_scan_buffer            PARAMS ((cpp_reader *));
-extern int check_macro_name            PARAMS ((cpp_reader *, U_CHAR *, int));
+extern int check_macro_name            PARAMS ((cpp_reader *, const U_CHAR *, int));
 
 /* Last arg to output_line_command.  */
 enum file_change_code {same_file, enter_file, leave_file};
@@ -749,22 +750,25 @@ extern void cpp_fatal PVPROTO ((cpp_reader *, const char *, ...))
   ATTRIBUTE_PRINTF_2;
 extern void cpp_message PVPROTO ((cpp_reader *, int, const char *, ...))
   ATTRIBUTE_PRINTF_3;
-extern void cpp_pfatal_with_name PROTO ((cpp_reader *, const char *));
-extern void cpp_file_line_for_message PROTO ((cpp_reader *, char *, int, int));
+extern void cpp_pfatal_with_name PROTO ((cpp_reader *, const char *))
+  ATTRIBUTE_NORETURN;
+extern void cpp_file_line_for_message PROTO ((cpp_reader *, const char *,
+                                             int, int));
 extern void cpp_print_containing_files PROTO ((cpp_reader *));
 extern void cpp_notice PVPROTO ((const char *msgid, ...)) ATTRIBUTE_PRINTF_1;
 
 /* In cppfiles.c */
 extern void simplify_pathname          PROTO ((char *));
 extern void merge_include_chains       PROTO ((struct cpp_options *));
-extern int find_include_file           PROTO ((cpp_reader *, char *,
+extern int find_include_file           PROTO ((cpp_reader *, const char *,
                                                struct file_name_list *,
                                                struct include_hash **,
                                                int *));
 extern int finclude                    PROTO ((cpp_reader *, int,
                                                struct include_hash *));
-extern void deps_output                        PROTO ((cpp_reader *, char *, int));
-extern struct include_hash *include_hash PROTO ((cpp_reader *, char *, int));
+extern void deps_output                        PROTO ((cpp_reader *,
+                                               const char *, int));
+extern struct include_hash *include_hash PROTO ((cpp_reader *, const char *, int));
 
 #ifndef INCLUDE_LEN_FUDGE
 #define INCLUDE_LEN_FUDGE 0
index e2b5614..c0dec16 100644 (file)
@@ -32,12 +32,13 @@ extern char *getenv ();
 #include "cpplib.h"
 #include "intl.h"
 
-char *progname;
+const char *progname;
 
 cpp_reader parse_in;
 cpp_options options;
 
 \f
+extern int main                                PARAMS ((int, char **));
 int
 main (argc, argv)
      int argc;
@@ -67,12 +68,12 @@ main (argc, argv)
   if (argi < argc && ! CPP_FATAL_ERRORS (&parse_in))
     cpp_fatal (&parse_in, "Invalid option `%s'", argv[argi]);
   if (CPP_FATAL_ERRORS (&parse_in))
-    exit (FATAL_EXIT_CODE);
+    return (FATAL_EXIT_CODE);
       
   parse_in.show_column = 1;
 
   if (! cpp_start_read (&parse_in, opts->in_fname))
-    exit (FATAL_EXIT_CODE);
+    return (FATAL_EXIT_CODE);
 
   /* Now that we know the input file is valid, open the output.  */
 
@@ -117,6 +118,6 @@ main (argc, argv)
     cpp_pfatal_with_name (&parse_in, opts->out_fname);
 
   if (parse_in.errors)
-    exit (FATAL_EXIT_CODE);
-  exit (SUCCESS_EXIT_CODE);
+    return (FATAL_EXIT_CODE);
+  return (SUCCESS_EXIT_CODE);
 }
index 1e6c5c4..c789e99 100644 (file)
@@ -78,7 +78,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "cpphash.h"
 
 static void v_fatal PROTO ((const char *, va_list)) ATTRIBUTE_NORETURN;
-void fatal PVPROTO ((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+static void fatal PVPROTO ((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
 
 sstring buf;
 
@@ -187,7 +187,19 @@ struct symbol_list {
 struct symbol_list symbol_table[SYMBOL_TABLE_SIZE];
 int cur_symbol_table_size;
 
-void
+static void add_symbols PROTO ((symbol_flags, namelist));
+static struct fn_decl *lookup_std_proto PROTO ((const char *, int));
+static void write_lbrac PROTO ((void));
+static void recognized_macro PROTO ((const char *));
+static void check_macro_names PROTO ((cpp_reader *, namelist));
+static void read_scan_file PROTO ((char *, int, char **));
+static void write_rbrac PROTO ((void));
+static int inf_skip_spaces PROTO ((int));
+static int inf_read_upto PROTO ((sstring *, int));
+static int inf_scan_ident PROTO ((sstring *, int));
+static int check_protection PROTO ((int *, int *));
+
+static void
 add_symbols (flags, names)
      symbol_flags flags;
      namelist names;
@@ -358,22 +370,13 @@ int seen_errno = 0;
 /* The following are only used when handling stdlib.h */
 int seen_EXIT_FAILURE = 0, seen_EXIT_SUCCESS = 0;
 \f
-/* Wrapper around free, to avoid prototype clashes.  */
-
-void
-xfree (ptr)
-     char *ptr;
-{
-  free (ptr);
-}
-
 #define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free xfree
+#define obstack_chunk_free free
 struct obstack scan_file_obstack;
 
 /* NOTE:  If you edit this, also edit gen-protos.c !! */
 
-struct fn_decl *
+static struct fn_decl *
 lookup_std_proto (name, name_length)
      const char *name;
      int name_length;
@@ -397,7 +400,7 @@ lookup_std_proto (name, name_length)
 
 char *inc_filename;
 int inc_filename_length;
-char *progname = "fix-header";
+const char *progname = "fix-header";
 FILE *outf;
 sstring line;
 
@@ -406,7 +409,7 @@ int lbrac_line, rbrac_line;
 int required_unseen_count = 0;
 int required_other = 0;
 
-void 
+static void 
 write_lbrac ()
 {
   
@@ -443,9 +446,9 @@ struct partial_proto required_dummy_proto, seen_dummy_proto;
 #define SET_SEEN(FN) ((FN)->partial = &seen_dummy_proto)
 #define SEEN(FN) ((FN)->partial == &seen_dummy_proto)
 
-void
+static void
 recognized_macro (fname)
-     char *fname;
+     const char *fname;
 {
   /* The original include file defines fname as a macro.  */
   struct fn_decl *fn = lookup_std_proto (fname, strlen (fname));
@@ -496,8 +499,8 @@ recognized_macro (fname)
 void
 recognized_extern (name, name_length, type, type_length)
      char *name;
-     char *type;
-     int name_length, type_length;
+     char *type ATTRIBUTE_UNUSED;
+     int name_length, type_length ATTRIBUTE_UNUSED;
 {
   switch (special_file_handling)
     {
@@ -594,7 +597,7 @@ recognized_function (fname, fname_length,
 /* For any name in NAMES that is defined as a macro,
    call recognized_macro on it.  */
 
-void
+static void
 check_macro_names (pfile, names)
      cpp_reader *pfile;
      namelist names;
@@ -607,7 +610,7 @@ check_macro_names (pfile, names)
     }
 }
 
-void
+static void
 read_scan_file (in_fname, argc, argv)
      char *in_fname;
      int argc;
@@ -728,7 +731,7 @@ read_scan_file (in_fname, argc, argv)
     }
 }
 
-void
+static void
 write_rbrac ()
 {
   struct fn_decl *fn;
@@ -871,7 +874,7 @@ write_rbrac ()
 #define INF_GET() (inf_ptr < inf_limit ? *(unsigned char *) inf_ptr++ : EOF)
 #define INF_UNGET(c) ((c)!=EOF && inf_ptr--)
 
-int
+static int
 inf_skip_spaces (c)
      int c;
 {
@@ -910,7 +913,7 @@ inf_skip_spaces (c)
 
 /* Read into STR from inf_buffer upto DELIM.  */
 
-int
+static int
 inf_read_upto (str, delim)
      sstring *str;
      int delim;
@@ -928,7 +931,7 @@ inf_read_upto (str, delim)
   return ch;
 }
 
-int
+static int
 inf_scan_ident (s, c)
      register sstring *s;
      int c;
@@ -954,7 +957,7 @@ inf_scan_ident (s, c)
    and setting *endif_line to the final #endif.
    Otherwise return 0.  */
 
-int
+static int
 check_protection (ifndef_line, endif_line)
      int *ifndef_line, *endif_line;
 {
@@ -1059,6 +1062,8 @@ check_protection (ifndef_line, endif_line)
   return 1;
 }
 
+extern int main                        PROTO ((int, char **));
+
 int
 main (argc, argv)
      int argc;
@@ -1314,7 +1319,7 @@ v_fatal (str, ap)
   exit (FATAL_EXIT_CODE);
 }
 
-void
+static void
 fatal VPROTO ((const char *str, ...))
 {
 #ifndef ANSI_PROTOTYPES
index fcec762..5c1f51c 100644 (file)
@@ -23,7 +23,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #undef abort
 
 int verbose = 0;
-char *progname;
+const char *progname;
 
 #define HASH_SIZE 2503 /* a prime */
 int hash_tab[HASH_SIZE];