Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: separate local and global prototype headers



This patch separates local and global prototype files.  Local prototypes
go into the .pro file as before, so their inclusion from .c files
is unaffected.  Global prototypes go into new .epro files, which are
included by the generated .mdh files.

This is done primarily for the changes to makepro.awk, which make it
easier for it to generate more files in the future (e.g., the .export
files).  However, I think having the separate .pro and .epro files makes
things clearer.

The Makefile dependencies could do with a review, but I'd really like to
do that as a comprehensive overhaul after the impending round of symbol
table related changes (and when I have a properly usable development
environment[1]).  That is therefore beyond the scope of this patch;
I've left the dependencies as close to unaffected as is possible.

-zefram

[1] I'm working in Dublin for the next three months, starting this
week.  I'm developing on fysh.org, but the company is behind a slow and
unreliable link.  Having to wait five seconds for echo, and losing the
connection every ten minutes, makes serious work difficult.  I have yet
to install Linux on my desktop machine.

diff -cr ../zsh-/Src/.cvsignore ./Src/.cvsignore
*** ../zsh-/Src/.cvsignore	Wed Dec  1 11:01:50 1999
--- ./Src/.cvsignore	Wed Dec  1 12:39:12 1999
***************
*** 1,6 ****
--- 1,8 ----
  Makefile
  Makemod.in Makemod
  [_a-zA-Z0-9]*.pro
+ *.epro
+ *.syms
  *.o
  *.o.c
  *.so
diff -cr ../zsh-/Src/Builtins/.cvsignore ./Src/Builtins/.cvsignore
*** ../zsh-/Src/Builtins/.cvsignore	Wed Dec  1 11:01:51 1999
--- ./Src/Builtins/.cvsignore	Wed Dec  1 12:39:17 1999
***************
*** 2,7 ****
--- 2,9 ----
  Makefile.in
  so_locations
  *.pro
+ *.epro
+ *.syms
  *.o
  *.o.c
  *.so
diff -cr ../zsh-/Src/Makemod.in.in ./Src/Makemod.in.in
*** ../zsh-/Src/Makemod.in.in	Wed Dec  1 11:01:50 1999
--- ./Src/Makemod.in.in	Wed Dec  1 12:14:49 1999
***************
*** 58,64 ****
  ANSIOBJ=.o
  ANSI_OBJ=._foo_
  
! .SUFFIXES: .c .$(DL_EXT) ..o .._foo_ .o ._foo_ .pro
  
  .c$(ANSI@U@OBJ):
  	$(COMPILE) -o $@ $<
--- 58,64 ----
  ANSIOBJ=.o
  ANSI_OBJ=._foo_
  
! .SUFFIXES: .c .$(DL_EXT) ..o .._foo_ .o ._foo_ .syms .pro .epro
  
  .c$(ANSI@U@OBJ):
  	$(COMPILE) -o $@ $<
***************
*** 78,86 ****
  	$(DLCOMPILE) -o $@ $@.c
  	rm -f $@.c
  
! .c.pro:
  	$(AWK) -f $(sdir_src)/makepro.awk $< $(subdir) > $@
  
  PROTODEPS = $(sdir_src)/makepro.awk
  
  # ========== DEPENDENCIES FOR BUILDING ==========
--- 78,90 ----
  	$(DLCOMPILE) -o $@ $@.c
  	rm -f $@.c
  
! .c.syms:
  	$(AWK) -f $(sdir_src)/makepro.awk $< $(subdir) > $@
  
+ .syms.epro:
+ 	sed -n '/^E/{s/^E//;p;}' < $< > $@
+ 	sed -n '/^L/{s/^L//;p;}' < $< > `echo $@ | sed 's/\.epro$$/.pro/'`
+ 
  PROTODEPS = $(sdir_src)/makepro.awk
  
  # ========== DEPENDENCIES FOR BUILDING ==========
***************
*** 147,153 ****
  	rm -f *.o *.$(DL_EXT)
  
  clean-here:
! 	rm -f *.o.c *.pro *.mdh *.mdhi *.mdhs *.mdh.tmp
  
  distclean-here:
  	rm -f $(makefile) $(makefile).in
--- 151,157 ----
  	rm -f *.o *.$(DL_EXT)
  
  clean-here:
! 	rm -f *.o.c *.syms *.pro *.epro *.mdh *.mdhi *.mdhs *.mdh.tmp
  
  distclean-here:
  	rm -f $(makefile) $(makefile).in
diff -cr ../zsh-/Src/Modules/.cvsignore ./Src/Modules/.cvsignore
*** ../zsh-/Src/Modules/.cvsignore	Wed Dec  1 11:01:51 1999
--- ./Src/Modules/.cvsignore	Wed Dec  1 12:39:21 1999
***************
*** 2,7 ****
--- 2,9 ----
  Makefile.in
  so_locations
  *.pro
+ *.epro
+ *.syms
  *.o
  *.o.c
  *.so
diff -cr ../zsh-/Src/Zle/.cvsignore ./Src/Zle/.cvsignore
*** ../zsh-/Src/Zle/.cvsignore	Wed Dec  1 11:01:51 1999
--- ./Src/Zle/.cvsignore	Wed Dec  1 12:39:26 1999
***************
*** 2,7 ****
--- 2,9 ----
  Makefile.in
  so_locations
  *.pro
+ *.epro
+ *.syms
  *.o
  *.o.c
  *.so
diff -cr ../zsh-/Src/Zle/compcore.c ./Src/Zle/compcore.c
*** ../zsh-/Src/Zle/compcore.c	Wed Dec  1 11:01:51 1999
--- ./Src/Zle/compcore.c	Wed Dec  1 12:30:22 1999
***************
*** 28,36 ****
   */
  
  #include "complete.mdh"
- #define GLOBAL_PROTOTYPES
- #include "zle_tricky.pro"
- #undef GLOBAL_PROTOTYPES
  #include "compcore.pro"
  
  /* The last completion widget called. */
--- 28,33 ----
diff -cr ../zsh-/Src/Zle/compctl.c ./Src/Zle/compctl.c
*** ../zsh-/Src/Zle/compctl.c	Wed Dec  1 11:01:51 1999
--- ./Src/Zle/compctl.c	Wed Dec  1 12:33:42 1999
***************
*** 29,38 ****
  
  #include "compctl.mdh"
  #include "compctl.pro"
- #define GLOBAL_PROTOTYPES
- #include "zle_tricky.pro"
- #include "complete.pro"
- #undef GLOBAL_PROTOTYPES
  
  /* Default completion infos */
   
--- 29,34 ----
diff -cr ../zsh-/Src/Zle/complete.c ./Src/Zle/complete.c
*** ../zsh-/Src/Zle/complete.c	Wed Dec  1 11:01:51 1999
--- ./Src/Zle/complete.c	Wed Dec  1 12:33:50 1999
***************
*** 28,36 ****
   */
  
  #include "complete.mdh"
- #define GLOBAL_PROTOTYPES
- #include "zle_tricky.pro"
- #undef GLOBAL_PROTOTYPES
  #include "complete.pro"
  
  /* Global matcher. */
--- 28,33 ----
diff -cr ../zsh-/Src/Zle/compmatch.c ./Src/Zle/compmatch.c
*** ../zsh-/Src/Zle/compmatch.c	Wed Dec  1 11:01:51 1999
--- ./Src/Zle/compmatch.c	Wed Dec  1 12:33:59 1999
***************
*** 28,36 ****
   */
  
  #include "complete.mdh"
- #define GLOBAL_PROTOTYPES
- #include "zle_tricky.pro"
- #undef GLOBAL_PROTOTYPES
  #include "compmatch.pro"
  
  /* This compares two cpattern lists and returns non-zero if they are
--- 28,33 ----
diff -cr ../zsh-/Src/Zle/compresult.c ./Src/Zle/compresult.c
*** ../zsh-/Src/Zle/compresult.c	Wed Dec  1 11:01:51 1999
--- ./Src/Zle/compresult.c	Wed Dec  1 12:34:05 1999
***************
*** 28,36 ****
   */
  
  #include "complete.mdh"
- #define GLOBAL_PROTOTYPES
- #include "zle_tricky.pro"
- #undef GLOBAL_PROTOTYPES
  #include "compresult.pro"
  
  #define inststr(X) inststrlen((X),1,-1)
--- 28,33 ----
diff -cr ../zsh-/Src/makepro.awk ./Src/makepro.awk
*** ../zsh-/Src/makepro.awk	Wed Dec  1 11:01:50 1999
--- ./Src/makepro.awk	Wed Dec  1 11:19:34 1999
***************
*** 18,30 ****
      gsub(/\//, "_", name)
      ARGC--
  
!     # `locals' is a list of local declarations, built up while global
!     # declarations are output.
!     locals = ""
! 
!     printf "#ifndef have_%s_globals\n", name
!     printf "#define have_%s_globals\n", name
!     printf "\n"
  }
  
  # all relevant declarations are preceded by "/**/" on a line by itself
--- 18,26 ----
      gsub(/\//, "_", name)
      ARGC--
  
!     printf "E#ifndef have_%s_globals\n", name
!     printf "E#define have_%s_globals\n", name
!     printf "E\n"
  }
  
  # all relevant declarations are preceded by "/**/" on a line by itself
***************
*** 43,50 ****
  	if (line == "" && $0 ~ /^[ \t]*#/) {
              # Directly after the /**/ was a preprocessor line.
              # Spit it out and re-start the outer loop.
! 	    printf "%s\n", $0
! 	    locals = locals $0 "\n"
  	    next
  	}
  	gsub(/\t/, " ")
--- 39,46 ----
  	if (line == "" && $0 ~ /^[ \t]*#/) {
              # Directly after the /**/ was a preprocessor line.
              # Spit it out and re-start the outer loop.
! 	    printf "E%s\n", $0
! 	    printf "L%s\n", $0
  	    next
  	}
  	gsub(/\t/, " ")
***************
*** 84,93 ****
      match(line, /^((const|enum|static|struct|union) +)*([_0-9A-Za-z]+ +|((char|double|float|int|long|short|unsigned|void) +)+)((const|static) +)*/)
      dtype = substr(line, 1, RLENGTH)
      sub(/ *$/, "", dtype)
!     islocal = " " dtype " " ~ / static /
      line = substr(line, RLENGTH+1) ","
      # Handle each declarator.
-     output = ""
      while(match(line, /^[^,]*,/)) {
  	# Separate out the name from the declarator.  Use "@+" and "@-"
  	# to bracket the name within the declarator.  Strip off any
--- 80,91 ----
      match(line, /^((const|enum|static|struct|union) +)*([_0-9A-Za-z]+ +|((char|double|float|int|long|short|unsigned|void) +)+)((const|static) +)*/)
      dtype = substr(line, 1, RLENGTH)
      sub(/ *$/, "", dtype)
!     if(" " dtype " " ~ / static /)
! 	locality = "L"
!     else
! 	locality = "E"
      line = substr(line, RLENGTH+1) ","
      # Handle each declarator.
      while(match(line, /^[^,]*,/)) {
  	# Separate out the name from the declarator.  Use "@+" and "@-"
  	# to bracket the name within the declarator.  Strip off any
***************
*** 114,153 ****
  	if(" " dtype " " ~ / int / && dcltor ~ / *@\+(boot|cleanup|setup|finish)_[_0-9A-Za-z]+@- *_\(\( *Module +[_0-9A-Za-z]+ *\)\) */) {
  	    modtype = dnam
  	    sub(/_.*$/, "", modtype)
! 	    output = output "# if defined(DYNAMIC_NAME_CLASH_OK) && defined(MODULE)\n"
! 	    output = output "#  define " dnam " " modtype "_\n"
! 	    output = output "# endif\n"
  	}
  
  	# Format the declaration for output
  	dcl = dtype " " dcltor ";"
! 	if(!islocal)
  	    dcl = "extern " dcl
  	gsub(/@[+-]/, "", dcl)
  	gsub(/ +/, " ", dcl)
  	while(match(dcl, /[^_0-9A-Za-z] ./) || match(dcl, /. [^_0-9A-Za-z]/))
  	    dcl = substr(dcl, 1, RSTART) substr(dcl, RSTART+2)
! 	output = output dcl "\n"
      }
- 
-     # Output global declarations now, but save up locals until the end.
-     if(islocal)
- 	locals = locals output
-     else
- 	printf "%s", output
  }
  
  END {
      if(aborting)
  	exit 1
!     printf "\n"
!     printf "#endif /* !have_%s_globals */\n", name
!     if(locals != "") {
! 	printf "\n"
! 	printf "#ifndef GLOBAL_PROTOTYPES\n"
! 	printf "\n"
! 	print locals
! 	printf "\n"
! 	printf "#endif /* !GLOBAL_PROTOTYPES */\n"
!     }
  }
--- 112,137 ----
  	if(" " dtype " " ~ / int / && dcltor ~ / *@\+(boot|cleanup|setup|finish)_[_0-9A-Za-z]+@- *_\(\( *Module +[_0-9A-Za-z]+ *\)\) */) {
  	    modtype = dnam
  	    sub(/_.*$/, "", modtype)
! 	    printf "%s# if defined(DYNAMIC_NAME_CLASH_OK) && defined(MODULE)\n", locality
! 	    printf "%s#  define " dnam " " modtype "_\n", locality
! 	    printf "%s# endif\n", locality
  	}
  
  	# Format the declaration for output
  	dcl = dtype " " dcltor ";"
! 	if(locality ~ /E/)
  	    dcl = "extern " dcl
  	gsub(/@[+-]/, "", dcl)
  	gsub(/ +/, " ", dcl)
  	while(match(dcl, /[^_0-9A-Za-z] ./) || match(dcl, /. [^_0-9A-Za-z]/))
  	    dcl = substr(dcl, 1, RSTART) substr(dcl, RSTART+2)
! 	printf "%s%s\n", locality, dcl
      }
  }
  
  END {
      if(aborting)
  	exit 1
!     printf "E\n"
!     printf "E#endif /* !have_%s_globals */\n", name
  }
diff -cr ../zsh-/Src/mkmakemod.sh ./Src/mkmakemod.sh
*** ../zsh-/Src/mkmakemod.sh	Wed Dec  1 11:01:50 1999
--- ./Src/mkmakemod.sh	Wed Dec  1 12:18:30 1999
***************
*** 27,33 ****
  #   autoparams      parameters defined by the module, for autoloading
  #   automathfuncs   math functions defined by the module, for autoloading
  #   objects         .o files making up this module (*must* be defined)
! #   proto           .pro files for this module (default generated from $objects)
  #   headers         extra headers for this module (default none)
  #   hdrdeps         extra headers on which the .mdh depends (default none)
  #   otherincs       extra headers that are included indirectly (default none)
--- 27,33 ----
  #   autoparams      parameters defined by the module, for autoloading
  #   automathfuncs   math functions defined by the module, for autoloading
  #   objects         .o files making up this module (*must* be defined)
! #   proto           .syms files for this module (default generated from $objects)
  #   headers         extra headers for this module (default none)
  #   hdrdeps         extra headers on which the .mdh depends (default none)
  #   otherincs       extra headers that are included indirectly (default none)
***************
*** 39,47 ****
  # For each module in also knows how to build a .mdh file.  Each source file
  # should #include the .mdh file for the module it is a part of.  The .mdh
  # file #includes the .mdh files for any module dependencies, then each of
! # $headers, and then each of $proto (for global declarations).  It will
  # be recreated if any of the dependency .mdh files changes, or if any of
! # $headers or $hdrdeps changes.  When anything depends on it, all of $proto
  # and $otherincs will be made up to date, but the .mdh file won't actually
  # be rebuilt if those files change.
  #
--- 39,47 ----
  # For each module in also knows how to build a .mdh file.  Each source file
  # should #include the .mdh file for the module it is a part of.  The .mdh
  # file #includes the .mdh files for any module dependencies, then each of
! # $headers, and then each .epro (for global declarations).  It will
  # be recreated if any of the dependency .mdh files changes, or if any of
! # $headers or $hdrdeps changes.  When anything depends on it, all the .epros
  # and $otherincs will be made up to date, but the .mdh file won't actually
  # be rebuilt if those files change.
  #
***************
*** 178,184 ****
  	test -n "${moddeps+set}" || moddeps=
  	test -n "$nozshdep" || moddeps="$moddeps zsh"
  	test -n "${proto+set}" ||
! 	    proto=`echo $objects '' | sed 's,\.o ,.pro ,g'`
  
  	dobjects=`echo $objects '' | sed 's,\.o ,..o ,g'`
  	modhdeps=
--- 178,184 ----
  	test -n "${moddeps+set}" || moddeps=
  	test -n "$nozshdep" || moddeps="$moddeps zsh"
  	test -n "${proto+set}" ||
! 	    proto=`echo $objects '' | sed 's,\.o ,.syms ,g'`
  
  	dobjects=`echo $objects '' | sed 's,\.o ,..o ,g'`
  	modhdeps=
***************
*** 212,224 ****
  	echo
  	echo "MODOBJS_${module} = $objects"
  	echo "MODDOBJS_${module} = $dobjects \$(@E@NTRYOBJ)"
! 	echo "PROTO_${module} = $proto"
! 	echo "INCS_${module} = \$(PROTO_${module}) $otherincs"
  	echo "EXPIMP_${module} = $imports ${hasexport+\$(EXPOPT)\$(sdir)/$module.export}"
  	echo "NXPIMP_${module} ="
  	echo
! 	echo "proto.${module}: \$(PROTO_${module})"
! 	echo "\$(PROTO_${module}): \$(PROTODEPS)"
  	echo
  	echo "modobjs.${module}: \$(MODOBJS_${module})"
  	echo "	echo '' \$(MODOBJS_${module}) $modobjs_sed>> \$(dir_src)/stamp-modobjs.tmp"
--- 212,225 ----
  	echo
  	echo "MODOBJS_${module} = $objects"
  	echo "MODDOBJS_${module} = $dobjects \$(@E@NTRYOBJ)"
! 	echo "SYMS_${module} = $proto"
! 	echo "EPRO_${module} = "`echo $proto '' | sed 's,\.syms ,.epro ,g'`
! 	echo "INCS_${module} = \$(EPRO_${module}) $otherincs"
  	echo "EXPIMP_${module} = $imports ${hasexport+\$(EXPOPT)\$(sdir)/$module.export}"
  	echo "NXPIMP_${module} ="
  	echo
! 	echo "proto.${module}: \$(PRO_${module})"
! 	echo "\$(SYMS_${module}): \$(PROTODEPS)"
  	echo
  	echo "modobjs.${module}: \$(MODOBJS_${module})"
  	echo "	echo '' \$(MODOBJS_${module}) $modobjs_sed>> \$(dir_src)/stamp-modobjs.tmp"
***************
*** 274,284 ****
  	    echo "	    echo; \\"
  	fi
  	if test -n "$proto"; then
! 	    echo "	    echo '# define GLOBAL_PROTOTYPES'; \\"
! 	    echo "	    for pro in \$(PROTO_${module}); do \\"
! 	    echo "		echo '# include \"'\$\$pro'\"'; \\"
  	    echo "	    done; \\"
- 	    echo "	    echo '# undef GLOBAL_PROTOTYPES'; \\"
  	    echo "	    echo; \\"
  	fi
  	echo "	    echo '#endif /* !have_${module}_module */'; \\"
--- 275,283 ----
  	    echo "	    echo; \\"
  	fi
  	if test -n "$proto"; then
! 	    echo "	    for epro in \$(EPRO_${module}); do \\"
! 	    echo "		echo '# include \"'\$\$epro'\"'; \\"
  	    echo "	    done; \\"
  	    echo "	    echo; \\"
  	fi
  	echo "	    echo '#endif /* !have_${module}_module */'; \\"
diff -cr ../zsh-/Src/zsh.mdd ./Src/zsh.mdd
*** ../zsh-/Src/zsh.mdd	Wed Dec  1 11:01:50 1999
--- ./Src/zsh.mdd	Wed Dec  1 12:25:27 1999
***************
*** 80,88 ****
  	rm -f sigcount.h signames.c bltinmods.list version.h zshpaths.h zshxmods.h
  
  # This is not properly part of this module, but it is built as if it were.
! main.o: main.c zsh.mdh main.pro
  	$(CC) -c -I. $(CPPFLAGS) $(DEFS) $(CFLAGS) -o $@ $(sdir)/main.c
  
! main.pro: $(PROTODEPS)
! proto.zsh: main.pro
  Make
--- 80,88 ----
  	rm -f sigcount.h signames.c bltinmods.list version.h zshpaths.h zshxmods.h
  
  # This is not properly part of this module, but it is built as if it were.
! main.o: main.c zsh.mdh main.epro
  	$(CC) -c -I. $(CPPFLAGS) $(DEFS) $(CFLAGS) -o $@ $(sdir)/main.c
  
! main.syms: $(PROTODEPS)
! proto.zsh: main.epro
  Make
END



Messages sorted by: Reverse Date, Date, Thread, Author