This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH cpplib code cleanup v3
- To: Jeff Garzik <garzik at havoc dot gtf dot org>
- Subject: Re: PATCH cpplib code cleanup v3
- From: Dave Brolley <brolley at cygnus dot com>
- Date: Tue, 07 Sep 1999 15:55:36 -0400
- CC: zack at bitmover dot com, gcc-patches at gcc dot gnu dot org
- Organization: Cygnus Solutions Canada Ltd
- References: <199909071946.PAA05740@havoc.gtf.org>
Zack, does this address your concerns with the previous verion of this patch?
Dave
Jeff Garzik wrote:
> This is the next iteration of the cpplib code cleanup patch. Changes
> from the previous patch are:
>
> o removes changes applied by Kaveh G.
> o adds xmemdup to save some code
> o uses xcalloc to save some code
> o takes into account comments from Zack W. on previous patch
>
> 1999-09-07 Jeff Garzik <jgarzik@pobox.com>
>
> cpplib code cleanup version 3
>
> * cppalloc.c (xmemdup): New function.
> (xstrdup): Use xmemdup.
>
> * cppexp.c: Clarify module header, removing reference to CCCP.
> (cpp_parse_expr): Use xmemdup.
>
> * cppfiles.c (include_hash): Replace explicit mem zero w/ xcalloc().
> (redundant_include_p): Const-ify 'ilist' arg and associated 'l'
> iterator.
> (find_include_file): s/bcopy/memcpy/.
> (read_name_map): Replace xmalloc+strcpy with xmemdup.
> (remap_filename): s/bcopy/memcpy/.
> (find_position): Const-ify 'limit' arg.
> (initialize_input_buffer): Const-ify 'st' arg.
> Zero pipe buffer with xcalloc for safety.
> (deps_output): s/bcopy/memcpy/.
>
> * cpphash.c (cpp_install): Likewise. Also zero hashnode for safety.
> (collect_expansion): Use xcalloc to zero struct.
> s/bcopy/memcpy/.
> (macroexpand): Likewise.
> (dump_definition): Const-ify local var 'r'.
> s/unsigned char/U_CHAR/.
>
> * cppinit.c (path_include): Const-ify 'list' arg and associated
> 'p' and 'q' iterators.
> Use xstrdup instead of xmalloc+string build.
> Use xmemdup instead of xmalloc+memcpy.
> (base_name): Un-const-ify 'fname' arg. s/rindex/strrchr/.
> (cpp_options_init): s/bzero/memset/.
> (cpp_reader_init): Likewise. Also remove unused get_token ref.
> (initialize_dependency_output): Replace xmalloc+memcpy with xmemdup.
> Clear deps_buffer with xcalloc.
> s/rindex/strrchr/.
> (cpp_start_read): Replace xmalloc+memcpy with xmemdup.
> Zero 'ih_fake' with xcalloc instead of manually.
> (cpp_handle_option): Use s/xmalloc/xcalloc/ for safety and to eliminate
> manual initialization.
> s/xmalloc+memcpy/xmemdup/.
>
> * cpplib.c (null_underflow): Remove, unused.
> (check_macro_name): s/bcopy/memcpy/.
> (do_define): Likewise.
> (cpp_push_buffer): Correct order of xcalloc args.
> Remove init of unused 'underflow' member.
> (cpp_buf_line_and_col): Const-ify 'pbuf' arg.
> (do_include): s/unsigned char/U_CHAR/.
> (do_undef): s/bcopy/memcpy/.
> (do_pragma): Likewise.
> (do_xifdef): Replace xmalloc+bcopy with xmemdup.
> (consider_directive_while_skipping): xcalloc for safety.
> (cpp_get_token): s/bcopy/memcpy/. s/unsigned char/U_CHAR/.
> (cpp_unassert): s/unsigned char/U_CHAR/.
>
> * cpplib.h: Update/correct prototypes to reflect reality.
> (parse_underflow_t): Remove unused type.
> (struct cpp_buffer): s/unsigned char/U_CHAR/.
> Remove unused 'underflow' member.
> (struct cpp_reader): s/unsigned char/U_CHAR/.
> Remove unused 'get_token' member.
> (struct macrodef): s/unsigned char/U_CHAR/.
> (struct definition): Likewise.
> (is_idstart, is_idchar, is_hor_space, is_space, trigraph_table):
> s/unsigned char/U_CHAR/.
> (struct if_stack): Format comments. s/unsigned char/U_CHAR/.