2 if ( length(outfn) == 0) {
6 ## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
72 /^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ {
80 base_name = table_name
82 for(i=1; i<=length(base_name); i++) {
83 table_number=(table_number*char_shift)+c2n[substr(base_name,i,1)]
85 # We start playing *_high, *low games here because the some
86 # awk programs do not have the necessary precision (sigh)
87 tab_base_low = table_number % mod_base
88 if (tab_base_low < 0) {
89 # Work around stupid bug in the ARM libm
90 tab_base_low = tab_base_low + mod_base
92 tab_base_high = int(table_number / mod_base)
95 # figure out: table_number_base=table_number*256
96 tab_base_low = tab_base_low * 256
97 tab_base_high = (tab_base_high * 256) + \
98 int(tab_base_low / mod_base)
99 tab_base_low = tab_base_low % mod_base
100 if (tab_base_low < 0) {
101 # Work around stupid bug in the ARM libm
102 tab_base_low = tab_base_low + mod_base
105 if (table_number > 128*256*256) {
106 # figure out: table_number_base -= 256*256*256*256
107 # sub_high, sub_low is 256*256*256*256
108 sub_low = 256*256*256 % mod_base
109 sub_high = int(256*256*256 / mod_base)
111 sub_low = sub_low * 256
112 sub_high = (sub_high * 256) + int(sub_low / mod_base)
113 sub_low = sub_low % mod_base
115 tab_base_low = sub_low - tab_base_low;
116 tab_base_high = sub_high - tab_base_high;
118 if (tab_base_low < 0) {
119 tab_base_low = tab_base_low + mod_base
125 curr_low = tab_base_low
126 curr_high = tab_base_high
127 curr_sign = tab_base_sign
129 print " * " outfn ":" > outfile
130 print " * This file is automatically generated; please do not edit it." > outfile
131 print " */" > outfile
133 print "#include <et/com_err.h>" > outfile
137 /^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/ {
138 # Be tolerant to missing whitespace after `,' ...
141 tag=prefix_str substr($2,1,length($2)-1)
142 if (curr_high == 0) {
143 printf "#define %-40s (%dL)\n", tag, \
144 curr_sign*curr_low > outfile
146 printf "#define %-40s (%d%06dL)\n", tag, curr_high*curr_sign, \
149 curr_low += curr_sign;
151 if (curr_low >= mod_base) {
152 curr_low -= mod_base;
165 /^[ \t]*(prefix)[ \t]+[A-Z_0-9]+/ {
169 /^[ \t]*(index)[ \t]+[A-Z_0-9]+/ {
171 curr_low += curr_sign * (new_idx - curr_idx)
173 if (curr_low >= mod_base) {
174 curr_low -= mod_base;
185 print "extern const struct error_table et_" table_name "_error_table;" > outfile
186 print "extern void initialize_" table_name "_error_table(void);" > outfile
188 print "/* For compatibility with Heimdal */" > outfile
189 print "extern void initialize_" table_name "_error_table_r(struct et_list **list);" > outfile
191 if (tab_base_high == 0) {
192 print "#define ERROR_TABLE_BASE_" table_name " (" \
193 sprintf("%d", tab_base_sign*tab_base_low) \
196 print "#define ERROR_TABLE_BASE_" table_name " (" \
197 sprintf("%d%06d", tab_base_sign*tab_base_high, \
198 tab_base_low) "L)" > outfile
201 print "/* for compatibility with older versions... */" > outfile
202 print "#define init_" table_name "_err_tbl initialize_" table_name "_error_table" > outfile
203 print "#define " table_name "_err_base ERROR_TABLE_BASE_" table_name > outfile