Changeset 237
- Timestamp:
- 10/11/2006 05:49:59 AM (7 years ago)
- Files:
-
- 1 modified
-
branches/1.0/mkstructinfo.awk (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/mkstructinfo.awk
r52 r237 3 3 BEGIN { 4 4 brace = 0; 5 incomment = 0; 5 6 buffer_len = 0; 6 7 } 8 9 # multiline comment handling 10 { 11 # removes one line comment 12 gsub(/\/\*(.+?)\*\//, " "); 13 } 14 /\*\// { 15 if (incomment) { 16 sub(/.*\*\//, ""); 17 incomment = 0; 18 } 19 } 20 incomment { 21 next; 22 } 23 /\/\*/ { 24 sub(/\/\*.*/, ""); 25 incomment = 1; 26 # fall through 27 } 28 29 # skip file/line mark here to be faster 30 /^#/ { 31 next; 32 } 33 7 34 /^}.*;/ { 8 35 if (instruct) { … … 51 78 { 52 79 if (brace == 1 && instruct) { 80 gsub(/(^[\t ]+|[\t ]+$)/, ""); # trim whitespaces 53 81 sub(/.*[{}]/, ""); 54 82 gsub(/\[[^\]]+\]/, ""); # ignore [...] … … 63 91 } 64 92 else { 93 # process normal variables 94 65 95 # ignore any ()s 66 96 while (gsub(/(\([^)]*\))/, "")) { … … 69 99 next; 70 100 } 101 # unsigned int *a, b; int c; 71 102 gsub(/[*]/, " "); 103 # unsigned int a, b; int c; 72 104 gsub(/ +/, " "); 105 # unsigned int a, b; int c; 73 106 gsub(/ *[,;]/, ";"); 107 # unsigned int a; b; int c; 74 108 if (!match($0, /;/)) { 75 109 next; 76 110 } 111 # print "=DEBUG=" $0 "=="; 77 112 split($0, chunks, ";"); 78 # get var of "int *var, var;" etc 79 for (i in chunks) { 113 # [unsigned int a, b, c] 114 115 for (i = 1; i in chunks; i ++) { 80 116 if (chunks[i] == "") { 81 117 delete chunks[i]; … … 83 119 } 84 120 split(chunks[i], pieces, " "); 121 # [unsigned, int, a] 122 # [b] 123 # [c] 85 124 86 for (j in pieces) { 125 last_piece = ""; 126 for (j = 1; j in pieces; j ++) { 87 127 last_piece = pieces[j]; 88 delete pieces[ i];128 delete pieces[j]; 89 129 } 90 130 if (last_piece == "") { 91 print "=====" chunks[i]; 131 # print "=ERROR=" chunks[i] "=="; 132 delete chunks[i]; 133 continue; 92 134 } 135 # a 136 # b 137 # c 138 93 139 buffer[buffer_len] = last_piece; 94 140 buffer_len ++; 95 delete chunks[i] ;141 delete chunks[i] 96 142 } 143 last_piece = ""; 97 144 } 98 145 next; … … 105 152 next; 106 153 } 107 /^typedef struct .*\{ / {154 /^typedef struct .*\{[^}]*$/ { 108 155 brace = 1; 109 156 instruct = 1;

