3 ## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
69 /^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ {
73 for(i=1; i<=length(table_name); i++) {
74 table_number=(table_number*char_shift)+c2n[substr(table_name,i,1)]
77 # We start playing *_high, *low games here because the some
78 # awk programs do not have the necessary precision (sigh)
79 tab_base_low = table_number % mod_base
80 tab_base_high = int(table_number / mod_base)
83 # figure out: table_number_base=table_number*256
84 tab_base_low = tab_base_low * 256
85 tab_base_high = (tab_base_high * 256) + \
86 int(tab_base_low / mod_base)
87 tab_base_low = tab_base_low % mod_base
89 if (table_number > 128*256*256) {
90 # figure out: table_number_base -= 256*256*256*256
91 # sub_high, sub_low is 256*256*256*256
92 sub_low = 256*256*256 % mod_base
93 sub_high = int(256*256*256 / mod_base)
95 sub_low = sub_low * 256
96 sub_high = (sub_high * 256) + int(sub_low / mod_base)
97 sub_low = sub_low % mod_base
99 tab_base_low = sub_low - tab_base_low;
100 tab_base_high = sub_high - tab_base_high;
102 if (tab_base_low < 0) {
103 tab_base_low = tab_base_low + mod_base
108 print " * " outfile ":" > outfile
109 print " * This file is automatically generated; please do not edit it." > outfile
110 print " */" > outfile
112 print "#ifdef __STDC__" > outfile
113 print "#define NOARGS void" > outfile
114 print "#else" > outfile
115 print "#define NOARGS" > outfile
116 print "#define const" > outfile
117 print "#endif" > outfile
119 print "static const char * const text[] = {" > outfile
123 /^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*$/ {
128 /^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"[ \t]*$/ {
130 for (i=3; i<=NF; i++) {
133 text=substr(text,2,length(text)-1);
134 printf "\t%s,\n", text > outfile
140 printf "\t%s,\n", $0 > outfile
151 print "struct error_table {" > outfile
152 print " char const * const * msgs;" > outfile
153 print " long base;" > outfile
154 print " int n_msgs;" > outfile
156 print "struct et_list {" > outfile
157 print " struct et_list *next;" > outfile
158 print " const struct error_table * table;" > outfile
160 print "extern struct et_list *_et_list;" > outfile
162 if (tab_base_high == 0) {
163 print "static const struct error_table et = { text, " \
164 sprintf("%dL, %d };", tab_base_sign*tab_base_low, \
165 table_item_count) > outfile
167 print "static const struct error_table et = { text, " \
168 sprintf("%d%06dL, %d };", tab_base_sign*tab_base_high, \
169 tab_base_low, table_item_count) > outfile
172 print "static struct et_list link = { 0, 0 };" > outfile
174 print "void initialize_" table_name "_error_table (NOARGS) {" > outfile
175 print " if (!link.table) {" > outfile
176 print " link.next = _et_list;" > outfile
177 print " link.table = &et;" > outfile
178 print " _et_list = &link;" > outfile