BEGIN {
+if ( length(outfn) == 0) {
+ outfn = outfile
+}
char_shift=64
## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
c2n["A"]=1
/^#/ { next }
/^[ \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)]
+ if (NF > 2) {
+ table_name = $3
+ base_name = $2
+ } else {
+ table_name = $2
+ base_name = table_name
+ }
+ for(i=1; i<=length(base_name); i++) {
+ table_number=(table_number*char_shift)+c2n[substr(base_name,i,1)]
}
# We start playing *_high, *low games here because the some
# awk programs do not have the necessary precision (sigh)
tab_base_high--
}
}
+ prefix_str = ""
+ curr_idx = 0
curr_low = tab_base_low
curr_high = tab_base_high
curr_sign = tab_base_sign
print "/*" > outfile
- print " * " outfile ":" > outfile
+ print " * " outfn ":" > outfile
print " * This file is automatically generated; please do not edit it." > outfile
print " */" > outfile
print "" > outfile
}
/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,/ {
- tag=substr($2,1,length($2)-1)
+ # Be tolerant to missing whitespace after `,' ...
+ sub(/,/, ", ")
+
+ tag=prefix_str substr($2,1,length($2)-1)
if (curr_high == 0) {
printf "#define %-40s (%dL)\n", tag, \
curr_sign*curr_low > outfile
curr_low > outfile
}
curr_low += curr_sign;
+ curr_idx++;
if (curr_low >= mod_base) {
curr_low -= mod_base;
curr_high++
}
}
+/^[ \t]*(prefix)$/ {
+ prefix_str = ""
+}
+
+/^[ \t]*(prefix)[ \t]+[A-Z_0-9]+/ {
+ prefix_str = $2 "_"
+}
+
+/^[ \t]*(index)[ \t]+[A-Z_0-9]+/ {
+ new_idx = $2
+ curr_low += curr_sign * (new_idx - curr_idx)
+ curr_idx = new_idx
+ if (curr_low >= mod_base) {
+ curr_low -= mod_base;
+ curr_high++
+ }
+ if (curr_low < 0) {
+ cur_low += mod_base
+ cur_high--
+ }
+}
+
+
END {
print "extern const struct error_table et_" table_name "_error_table;" > outfile
print "extern void initialize_" table_name "_error_table(void);" > outfile
+ print "" > outfile
+ print "/* For compatibility with Heimdal */" > outfile
+ print "extern void initialize_" table_name "_error_table_r(struct et_list **list);" > outfile
+ print "" > outfile
if (tab_base_high == 0) {
print "#define ERROR_TABLE_BASE_" table_name " (" \
sprintf("%d", tab_base_sign*tab_base_low) \