# /* vim: set filetype=awk : */ BEGIN { Who = "Tim Menzies"; What = "coc1nums"; When = "2006"; How = "cd:D:hpri:s"; Why = "convert a table of symbols to COCOMO-I values"; } function usage() { about(Who,What,When,Why); prints("Usage: "What" [FLAGS] FILE"," ", "FILE is a DVS file"," ", " -c show copyright", " -d CHAR input field seperator; default=[" FS "]", " -D CHAR output fields seperator; default=[" OFS "]", " -p use precise COCOMO 1 values (default)", " -r use rounded COCOMO 1 values", " -i STR ignore fields listed in comma-seperated string STR", " -s silent model (no warning messages)"); } # requirez(dvs.awk) # requirez(bad.awk) # requirez(table.awk) # requirez(commandLine.awk) # requirez(columnNumbers.awk) function defaults() { IsNervous=1; inits(How,"-d , -D , -p -i -2,-1 -s"); } function set(x,y) { if (x == "d") {return FS=y }; if (x == "c") {copyleft(); exit}; if (x == "D") {return OFS=y }; if (x == "h") {usage(); exit }; if (x == "p") {return Type="precise" }; if (x == "r") {return Type="rounded" }; if (x == "i") {return IgnoreStr=y }; if (x == "s") {return IsNervous=0 }; bad(x "? usage: " What " " How); exit; } # requirez(saya.awk) BEGIN { tables(); defaults(); getOpts(How); IGNORECASE = 1; } function tables( i,rows,cols) { table(Nums, "precise , xl , vl , l , n , h , vh , xh", " rely , , 0.75 , 0.88, 1.00 , 1.15, 1.40 , " \ ",data , , , 0.94, 1.00 , 1.08, 1.16 , " \ ",cplx , , 0.70 , 0.85, 1.00 , 1.15, 1.30 , 1.65"\ ",time , , , , 1.00 , 1.11, 1.30 , 1.66" \ ",stor , , , , 1.00 , 1.06, 1.21 , 1.56" \ ",virt , , , 0.87, 1.00 , 1.15, 1.30 , "\ ",turn , , , 0.87, 1.00 , 1.07, 1.15 , " \ ",acap , , 1.46 , 1.19, 1.00 , 0.86, 0.71 , " \ ",aexp , , 1.29 , 1.13, 1.00 , 0.91, 0.82 , " \ ",pcap , , 1.42 , 1.17, 1.00 , 0.86, 0.70 , " \ ",vexp , , 1.21 , 1.10, 1.00 , 0.90, , "\ ",lexp , , 1.14 , 1.07, 1.00 , 0.95, , " \ ",modp , , 1.24 , 1.10, 1.00 , 0.91, 0.82 , " \ ",tool , , 1.24 , 1.10, 1.00 , 0.91, 0.83 , " \ ",sced , , 1.23 , 1.08, 1.00 , 1.04, 1.10 , ", rows, cols); for(i in cols) if(i>0) IsCol[cols[i]]= i-1; for(i in rows) if(i>1) IsRow[rows[i]]= i; table(Nums, "rounded , xl , vl , l , n , h , vh , xh", " rely , , 0.8 , 0.9 , 1.00 , 1.1, 1.2 , " \ ",data , , , 0.9 , 1.00 , 1.1, 1.2 , " \ ",cplx , , 0.8 , 0.9 , 1.00 , 1.1, 1.2 , 1.3"\ ",time , , , , 1.00 , 1.1, 1.2 , 1.3" \ ",stor , , , , 1.00 , 1.1, 1.2 , 1.3" \ ",virt , , , 0.9 , 1.00 , 1.1, 1.2 , "\ ",turn , , , 0.9 , 1.00 , 1.1, 1.2 , " \ ",acap , , 1.2 , 1.1, 1.00 , 0.9, 0.8 , " \ ",aexp , , 1.2 , 1.1, 1.00 , 0.9, 0.8 , " \ ",pcap , , 1.2 , 1.1, 1.00 , 0.9, 0.8 , "\ ",vexp , , 1.2 , 1.1, 1.00 , 0.9, , " \ ",lexp , , 1.2 , 1.1, 1.00 , 0.9, , " \ ",modp , , 1.2 , 1.10, 1.00 , 0.9, 0.8 , " \ ",tool , , 1.2 , 1.10, 1.00 , 0.9, 0.8 , " \ ",sced , , 1.2 , 1.1, 1.00 , 1.1, 1.2 , " ); } { gsub(Ccomment ".*$","") gsub(/ /, "") } /^[ \t]*$/ { next } sub("^" Cheader,"",$1) { for(I=1;I<=NF;I++) { Name[++Name[0]]= $I; if(IsNervous && ! ($I in IsCol)) bad($I " unknown") } columnNumbers(IgnoreStr,Ignore,NF) ; print Cheader $0; next; } { for(I=1;I<=Name[0];I++) { if ( ! (I in Ignore)) if ($I !~ Cnothing ) if(IsNervous && !($I in IsRow)) { bad($I " unknown") } else { This=Name[I]; if(IsNervouse && !((Type,This,$I) in Nums)) { bad( $I " undefined"); } else { $I = Nums[Type,This,$I]; }}} } {print $0}