Browse Source

comments/loops improved in mkstructinfo while avoiding gawk assertion bug with LANG=C

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@169 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.2
Xuefer 15 years ago
parent
commit
4a8f977046
  1. 8
      config.m4
  2. 28
      mkstructinfo.awk

8
config.m4

@ -58,6 +58,14 @@ if test "$PHP_XCACHE" != "no"; then
PHP_SUBST([XCACHE_ENABLE_TEST])
AC_PATH_PROGS([AWK], [gawk awk])
dnl clean locale for gawk 3.1.5 assertion bug
if echo | LANG=C "$AWK" -- '' > /dev/null 2>&1 ; then
AWK="LANG=C $AWK"
else
if echo | /usr/bin/env - "$AWK" -- '' > /dev/null 2>&1 ; then
AWK="/usr/bin/env - $AWK"
fi
fi
PHP_SUBST([AWK])
AC_PATH_PROGS([M4], [m4])
PHP_SUBST([M4])

28
mkstructinfo.awk

@ -4,6 +4,9 @@ BEGIN {
brace = 0;
buffer_len = 0;
}
/^#/ {
next;
}
/^}.*;/ {
if (instruct) {
sub(";", "");
@ -50,6 +53,7 @@ BEGIN {
{
if (brace == 1 && instruct) {
gsub(/\/\*(.+?)\*\//, " "); # removes one line comment
sub(/.*[{}]/, "");
gsub(/\[[^\]]+\]/, ""); # ignore [...]
gsub(/:[0-9]+/, ""); # ignore struct bit
@ -68,32 +72,46 @@ BEGIN {
if (match($0, /[()]/)) {
next;
}
# unsigned int *a, b; int c;
gsub(/[*]/, " ");
# unsigned int a, b; int c;
gsub(/ +/, " ");
# unsigned int a, b; int c;
gsub(/ *[,;]/, ";");
# unsigned int a; b; int c;
if (!match($0, /;/)) {
next;
}
split($0, chunks, ";");
# get var of "int *var, var;" etc
for (i in chunks) {
# [unsigned int a, b, c]
for (i = 1; i in chunks; i ++) {
if (chunks[i] == "") {
delete chunks[i];
continue;
}
split(chunks[i], pieces, " ");
# [unsigned, int, a]
# [b]
# [c]
for (j in pieces) {
last_piece = "";
for (j = 1; j in pieces; j ++) {
last_piece = pieces[j];
delete pieces[i];
delete pieces[j];
}
if (last_piece == "") {
print "=====" chunks[i];
}
# a
# b
# c
buffer[buffer_len] = last_piece;
buffer_len ++;
delete chunks[i];
delete chunks[i]
}
last_piece = "";
}
next;
}

Loading…
Cancel
Save