Index: trunk/mkstructinfo.awk
===================================================================
--- trunk/mkstructinfo.awk	(revision 837)
+++ trunk/mkstructinfo.awk	(revision 891)
@@ -10,4 +10,18 @@
 	printf "define(`COUNTOF_%s', `%s')\n", structname, COUNTOF[structname];
 	printf "define(`SIZEOF_%s', `(  %s  )')\n", structname, SIZEOF[structname];
+}
+function countBrace(text,  len, i, char, braceCount) {
+	len = length(text);
+	braceCount = 0;
+	for (i = 1; i <= len; ++i) {
+		char = substr(text, i, 1);
+		if (char == "{") {
+			braceCount = braceCount + 1;
+		}
+		else if (char == "}") {
+			braceCount = braceCount - 1;
+		}
+	}
+	return braceCount;
 }
 
@@ -76,9 +90,6 @@
 }
 
-/.\{/ {
-	brace = brace + 1;
-}
-/.}/ {
-	brace = brace - 1;
+/.[{}]/ {
+	brace += countBrace($0);
 }
 
@@ -170,12 +181,32 @@
 }
 /^typedef struct .*\{[^}]*$/ {
-	brace = 1;
-	instruct = 1;
-	next;
-}
-
-/^struct .*\{/ {
-	instruct = $2;
-	brace = 1;
-	next;
-}
+	brace = countBrace($0);
+	if (brace > 0) {
+		instruct = 1;
+	}
+	else {
+		brace = 0;
+		instruct = 0;
+	}
+
+	for (i in buffer) {
+		delete buffer[i];
+	}
+	next;
+}
+
+/^struct .*\{.*/ {
+	brace = countBrace($0);
+	if (brace > 0) {
+		instruct = $2;
+	}
+	else {
+		brace = 0;
+		instruct = 0;
+	}
+
+	for (i in buffer) {
+		delete buffer[i];
+	}
+	next;
+}
