11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
print "#define kpw_emit_short_option_switch \\"
end = "\\"
} else if (emit == "usage") {
print "const char kpw_usage[] ="
}
globalc = 0
}
function say(line) {
if (NF == 5) {
print "\tkpw_only_" $5 "(" line ") " end
globals[globalc] = $5
++ globalc
} else {
print "\t" line " " end
}
}
{ optstr = optstr $1 }
emit == "enum" { say("arg_" $2 ",") }
emit == "argtbl" { say("{ arg_" $2", \"" $2 "\" },") }
emit == "olong" { say("case arg_" $2 ": " $3 "; break;") }
emit == "oshort" { say("case '" $1 "': " $3 "; break;") }
emit == "usage" { say("\"\\t-"$1", --"$2": "$4"\\n\"") }
emit == "cond" {
if (NF == 5 && !($5 in condlist)) {
condlist[$5] = 1
print "#ifdef " $5
|
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
print "#define kpw_emit_short_option_switch \\"
end = "\\"
} else if (emit == "usage") {
print "const char kpw_usage[] ="
}
globalc = 0
}
function cify(str) {
gsub(/[- ]/, "_", str);
return str;
}
function say(line) {
if (NF == 5) {
print "\tkpw_only_" $5 "(" line ") " end
globals[globalc] = $5
++ globalc
} else {
print "\t" line " " end
}
}
{ optstr = optstr $1 }
emit == "enum" { say("arg_" cify($2) ",") }
emit == "argtbl" { say("{ arg_" cify($2)", \"" $2 "\" },") }
emit == "olong" { say("case arg_" cify($2) ": " $3 "; break;") }
emit == "oshort" { say("case '" $1 "': " $3 "; break;") }
emit == "usage" { say("\"\\t-"$1", --"$2": "$4"\\n\"") }
emit == "cond" {
if (NF == 5 && !($5 in condlist)) {
condlist[$5] = 1
print "#ifdef " $5
|