diff options
| author | Theodore Tso <tytso@mit.edu> | 1993-06-03 12:27:22 +0000 |
|---|---|---|
| committer | Theodore Tso <tytso@mit.edu> | 1993-06-03 12:27:22 +0000 |
| commit | df53bcea92bd141193e4d63cd1cccdab138579b7 (patch) | |
| tree | 42a5d4686a8035c6d69bcce626a8b69a013eb806 /src/util | |
| parent | d75c692451b8918ef6f8f46874545c7b22eb703b (diff) | |
| download | krb5-df53bcea92bd141193e4d63cd1cccdab138579b7.tar.gz krb5-df53bcea92bd141193e4d63cd1cccdab138579b7.tar.xz krb5-df53bcea92bd141193e4d63cd1cccdab138579b7.zip | |
Changed to support double-precision math; some broken awk's can't handle
numbers as big as this script needs to manipulate.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2609 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/et/et_c.awk | 50 | ||||
| -rw-r--r-- | src/util/et/et_h.awk | 65 |
2 files changed, 100 insertions, 15 deletions
diff --git a/src/util/et/et_c.awk b/src/util/et/et_c.awk index afb4404746..4f53fc3eb5 100644 --- a/src/util/et/et_c.awk +++ b/src/util/et/et_c.awk @@ -69,14 +69,41 @@ c2n["_"]=63 /^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ { table_number = 0 table_name = $2 + mod_base = 1000000 for(i=1; i<=length(table_name); i++) { table_number=(table_number*char_shift)+c2n[substr(table_name,i,1)] } - table_number_base=table_number*256 - if(table_number_base > 128*256*256*256) { - table_number_base -= 256*256*256*256 + + # We start playing *_high, *low games here because the some + # awk programs do not have the necessary precision (sigh) + tab_base_low = table_number % mod_base + tab_base_high = int(table_number / mod_base) + tab_base_sign = 1; + + # figure out: table_number_base=table_number*256 + tab_base_low = tab_base_low * 256 + tab_base_high = (tab_base_high * 256) + \ + int(tab_base_low / mod_base) + tab_base_low = tab_base_low % mod_base + + if (table_number > 128*256*256) { + # figure out: table_number_base -= 256*256*256*256 + # sub_high, sub_low is 256*256*256*256 + sub_low = 256*256*256 % mod_base + sub_high = int(256*256*256 / mod_base) + + sub_low = sub_low * 256 + sub_high = (sub_high * 256) + int(sub_low / mod_base) + sub_low = sub_low % mod_base + + tab_base_low = sub_low - tab_base_low; + tab_base_high = sub_high - tab_base_high; + tab_base_sign = -1; + if (tab_base_low < 0) { + tab_base_low = tab_base_low + mod_base + tab_base_high-- + } } - curr_table = table_number_base print "/*" > outfile print " * " outfile ":" > outfile print " * This file is automatically generated; please do not edit it." > outfile @@ -98,20 +125,19 @@ c2n["_"]=63 next } -/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"$/ { +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"[ \t]*$/ { text="" for (i=3; i<=NF; i++) { text = text FS $i } + text=substr(text,2,length(text)-1); printf "\t%s,\n", text > outfile - curr_table++ table_item_count++ } { if (skipone) { printf "\t%s,\n", $0 > outfile - curr_table++ table_item_count++ } skipone=0 @@ -133,7 +159,15 @@ END { print "};" > outfile print "extern struct et_list *_et_list;" > outfile print "" > outfile - print "static const struct error_table et = { text, " sprintf("%d",table_number_base) "L, " table_item_count " };" > outfile + if (tab_base_high == 0) { + print "static const struct error_table et = { text, " \ + sprintf("%dL, %d };", tab_base_sign*tab_base_low, \ + table_item_count) > outfile + } else { + print "static const struct error_table et = { text, " \ + sprintf("%d%06dL, %d };", tab_base_sign*tab_base_high, \ + tab_base_low, table_item_count) > outfile + } print "" > outfile print "static struct et_list link = { 0, 0 };" > outfile print "" > outfile diff --git a/src/util/et/et_h.awk b/src/util/et/et_h.awk index 939cdfadec..5851dd87a3 100644 --- a/src/util/et/et_h.awk +++ b/src/util/et/et_h.awk @@ -69,14 +69,43 @@ c2n["_"]=63 /^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ { table_number = 0 table_name = $2 + mod_base = 1000000 for(i=1; i<=length(table_name); i++) { table_number=(table_number*char_shift)+c2n[substr(table_name,i,1)] } - table_number_base=table_number*256 - if(table_number_base > 128*256*256*256) { - table_number_base -= 256*256*256*256 + # We start playing *_high, *low games here because the some + # awk programs do not have the necessary precision (sigh) + tab_base_low = table_number % mod_base + tab_base_high = int(table_number / mod_base) + tab_base_sign = 1; + + # figure out: table_number_base=table_number*256 + tab_base_low = tab_base_low * 256 + tab_base_high = (tab_base_high * 256) + \ + int(tab_base_low / mod_base) + tab_base_low = tab_base_low % mod_base + + if (table_number > 128*256*256) { + # figure out: table_number_base -= 256*256*256*256 + # sub_high, sub_low is 256*256*256*256 + sub_low = 256*256*256 % mod_base + sub_high = int(256*256*256 / mod_base) + + sub_low = sub_low * 256 + sub_high = (sub_high * 256) + int(sub_low / mod_base) + sub_low = sub_low % mod_base + + tab_base_low = sub_low - tab_base_low; + tab_base_high = sub_high - tab_base_high; + tab_base_sign = -1; + if (tab_base_low < 0) { + tab_base_low = tab_base_low + mod_base + tab_base_high-- + } } - curr_table = table_number_base + curr_low = tab_base_low + curr_high = tab_base_high + curr_sign = tab_base_sign print "/*" > outfile print " * " outfile ":" > outfile print " * This file is automatically generated; please do not edit it." > outfile @@ -85,13 +114,35 @@ c2n["_"]=63 /^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/ { tag=substr($2,1,length($2)-1) - printf "#define %-40s (%ldL)\n", tag, curr_table > outfile - curr_table++ + if (curr_high == 0) { + printf "#define %-40s (%dL)\n", tag, \ + curr_sign*curr_low > outfile + } else { + printf "#define %-40s (%d%06dL)\n", tag, curr_high*curr_sign, \ + curr_low > outfile + } + curr_low += curr_sign; + if (curr_low >= mod_base) { + curr_low -= mod_base; + curr_high++ + } + if (curr_low < 0) { + cur_low += mod_base + cur_high-- + } } END { print "extern void initialize_" table_name "_error_table ();" > outfile - print "#define ERROR_TABLE_BASE_" table_name " (" sprintf("%d",table_number_base) "L)" > outfile + if (tab_base_high == 0) { + print "#define ERROR_TABLE_BASE_" table_name " (" \ + sprintf("%d", tab_base_sign*tab_base_low) \ + "L)" > outfile + } else { + print "#define ERROR_TABLE_BASE_" table_name " (" \ + sprintf("%d%06d", tab_base_sign*tab_base_high, \ + tab_base_low) "L)" > outfile + } print "" > outfile print "/* for compatibility with older versions... */" > outfile print "#define init_" table_name "_err_tbl initialize_" table_name "_error_table" > outfile |
