1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-04 20:40:57 +02:00

Merge of 22585: makepro.awk: zsh.exports was missing VA_ALIST declarations.

This commit is contained in:
Paul Ackersviller 2007-10-27 21:28:58 +00:00
parent 69ef858c2b
commit 1f8f3c6e2f

View file

@ -49,15 +49,17 @@ BEGIN {
if(line ~ /\/\*/)
continue
# If it is a function definition, note so.
if(line ~ /\) *[{].*$/) #}
if(line ~ /\) *(VA_DCL )*[{].*$/) #}
isfunc = 1
if(sub(/ *[{;].*$/, "", line)) #}
break
}
if (!match(line, /VA_ALIST/)) {
# Put spaces around each identifier.
while(match(line, /[^_0-9A-Za-z ][_0-9A-Za-z]/) ||
match(line, /[_0-9A-Za-z][^_0-9A-Za-z ]/))
line = substr(line, 1, RSTART) " " substr(line, RSTART+1)
}
# Separate declarations into a type and a list of declarators.
# In each declarator, "@{" and "@}" are used in place of parens to
# mark function parameter lists, and "@!" is used in place of commas
@ -87,6 +89,32 @@ BEGIN {
exported = " " dtype " " ~ / mod_export /
line = substr(line, RLENGTH+1) ","
# Handle each declarator.
if (match(line, /VA_ALIST/)) {
# Already has VARARGS handling.
# Put parens etc. back
gsub(/@[{]/, "((", line)
gsub(/@}/, "))", line)
gsub(/@</, "(", line)
gsub(/@>/, ")", line)
gsub(/@!/, ",", line)
sub(/,$/, ";", line)
gsub(/mod_export/, "mod_import_function", dtype)
gsub(/VA_ALIST/, "VA_ALIST_PROTO", line)
sub(/ VA_DCL/, "", line)
if(locality ~ /E/)
dtype = "extern " dtype
if (match(line, /[_0-9A-Za-z]+\(VA_ALIST/))
dnam = substr(line, RSTART, RLENGTH-9)
# If this is exported, add it to the exported symbol list.
if (exported)
printf "X%s\n", dnam
printf "%s%s %s\n", locality, dtype, line
} else {
while(match(line, /^[^,]*,/)) {
# Separate out the name from the declarator. Use "@+" and "@-"
# to bracket the name within the declarator. Strip off any
@ -117,12 +145,17 @@ BEGIN {
dcl = dtype " " dcltor ";"
if(locality ~ /E/)
dcl = "extern " dcl
if(isfunc)
gsub(/ mod_export /, " mod_import_function ", dcl)
else
gsub(/ mod_export /, " mod_import_variable ", 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 {