about summary refs log tree commit diff
path: root/Src/makepro.awk
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-12-01 15:27:25 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-12-01 15:27:25 +0000
commit26cf7b8d50f1b7d9d0b9115018ef4dc8624b5030 (patch)
tree2f5410a217d359e4447acb8563b28ae560b31718 /Src/makepro.awk
parent9ab8fed111413436683120ed3c13b59c745015e1 (diff)
downloadzsh-26cf7b8d50f1b7d9d0b9115018ef4dc8624b5030.tar.gz
zsh-26cf7b8d50f1b7d9d0b9115018ef4dc8624b5030.tar.xz
zsh-26cf7b8d50f1b7d9d0b9115018ef4dc8624b5030.zip
zsh-workers/8839
Diffstat (limited to 'Src/makepro.awk')
-rw-r--r--Src/makepro.awk48
1 files changed, 16 insertions, 32 deletions
diff --git a/Src/makepro.awk b/Src/makepro.awk
index ee302eada..98167fcad 100644
--- a/Src/makepro.awk
+++ b/Src/makepro.awk
@@ -18,13 +18,9 @@ BEGIN {
     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"
+    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,8 +39,8 @@ BEGIN {
 	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"
+	    printf "E%s\n", $0
+	    printf "L%s\n", $0
 	    next
 	}
 	gsub(/\t/, " ")
@@ -84,10 +80,12 @@ BEGIN {
     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 /
+    if(" " dtype " " ~ / static /)
+	locality = "L"
+    else
+	locality = "E"
     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
@@ -114,40 +112,26 @@ BEGIN {
 	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"
+	    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(!islocal)
+	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)
-	output = output dcl "\n"
+	printf "%s%s\n", locality, dcl
     }
-
-    # 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"
-    }
+    printf "E\n"
+    printf "E#endif /* !have_%s_globals */\n", name
 }