This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFC: init.c cleanup


Hello,

The attached patch changes the way init.c is generated.  It does the
following:

	o	introduces the type ``initialize_file_ftype''
		which should be used to declare all
		_initialize_*() functions.

	o	modifies init.c so that it includes
		relevant headers (defs.h, call-cmds.h)
		instead of assuming that it got it right.

	o	uses initialize_file_ftype to declare
		each _initialize_*()  function and
		puts the declarations out side of the
		initialize_all_files() function.
		(this makes init a two pass operation).

This significantly tightens the initialization code.

comments?

	Andrew

Mon Sep 20 18:19:09 1999  Andrew Cagney  <cagney@b1.cygnus.com>

	* defs.h (initialize_ftype): Add function typedef.

	* Makefile.in (init.c): Change generated file to include "defs.h"
 	and "call-cmds.h". Use initialize_file_ftype when declaring
 	initialize functions.
Index: defs.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/defs.h,v
retrieving revision 1.254
diff -p -r1.254 defs.h
*** defs.h	1999/09/16 21:16:50	1.254
--- defs.h	1999/09/20 09:19:50
*************** extern void symbol_file_command PARAMS (
*** 552,557 ****
--- 552,559 ----
  
  /* From top.c */
  
+ typedef void initialize_file_ftype (void);
+ 
  extern char *skip_quoted PARAMS ((char *));
  
  extern char *gdb_readline PARAMS ((char *));
Index: Makefile.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/Makefile.in,v
retrieving revision 1.711
diff -p -r1.711 Makefile.in
*** Makefile.in	1999/09/20 07:25:19	1.711
--- Makefile.in	1999/09/20 09:19:54
*************** uninstall: force
*** 725,736 ****
  
  init.c: $(OBS) $(TSOBS)
  	@echo Making init.c
! 	@rm -f init.c-tmp
! 	@echo '/* Do not modify this file.  */' >init.c-tmp
! 	@echo '/* It is created automatically by the Makefile.  */'>>init.c-tmp
! 	@echo '#include "ansidecl.h"' >>init.c-tmp
! 	@echo 'extern void initialize_all_files PARAMS ((void));' >>init.c-tmp
! 	@echo 'void initialize_all_files PARAMS ((void)) {' >>init.c-tmp
  	@-echo $(OBS) $(TSOBS) | \
  	tr ' ' '\012' | \
  	sed -e '/^Onindy.o/d' \
--- 725,731 ----
  
  init.c: $(OBS) $(TSOBS)
  	@echo Making init.c
! 	@rm -f init.c-tmp init.c-lst
  	@-echo $(OBS) $(TSOBS) | \
  	tr ' ' '\012' | \
  	sed -e '/^Onindy.o/d' \
*************** init.c: $(OBS) $(TSOBS)
*** 748,755 ****
  	    -e 's/\.o/.c/' \
  	    -e 's|\([^  ][^     ]*\)|$(srcdir)/\1|g' | \
  	while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \
! 	sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/  {extern void \1 PARAMS ((void)); \1 ();}/' >>init.c-tmp
  	@echo '}' >>init.c-tmp
  	@mv init.c-tmp init.c
  
  .PRECIOUS: init.c
--- 743,760 ----
  	    -e 's/\.o/.c/' \
  	    -e 's|\([^  ][^     ]*\)|$(srcdir)/\1|g' | \
  	while read f; do grep '^_initialize_[a-z_0-9A-Z]* *(' $$f 2>/dev/null; done | \
! 	sed -e 's/^.*://' -e 's/^\([a-z_0-9A-Z]*\).*/\1/' > init.c-lst
! 	@echo '/* Do not modify this file.  */' >>init.c-tmp
! 	@echo '/* It is created automatically by the Makefile.  */'>>init.c-tmp
! 	@echo '#include "defs.h"' >>init.c-tmp
! 	@echo '#include "call-cmds.h"' >>init.c-tmp
! 	@sed -e 's/\(.*\)/extern initialize_file_ftype \1;/' <init.c-lst >>init.c-tmp
! 	@echo 'void' >>init.c-tmp
! 	@echo 'initialize_all_files (void)' >>init.c-tmp
! 	@echo '{' >>init.c-tmp
! 	@sed -e 's/\(.*\)/  \1 ();/' <init.c-lst >>init.c-tmp
  	@echo '}' >>init.c-tmp
+ 	@rm init.c-lst
  	@mv init.c-tmp init.c
  
  .PRECIOUS: init.c


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]