util  Diff

Differences From Artifact [b43a4e1b77]:

To Artifact [7d6b5c7a46]:


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