/usr/share/et/et_c.awk is in comerr-dev 2.1-1.42.12-2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | BEGIN {
if ( length(outfn) == 0) {
outfn = outfile
}
char_shift=64
## "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
c2n["A"]=1
c2n["B"]=2
c2n["C"]=3
c2n["D"]=4
c2n["E"]=5
c2n["F"]=6
c2n["G"]=7
c2n["H"]=8
c2n["I"]=9
c2n["J"]=10
c2n["K"]=11
c2n["L"]=12
c2n["M"]=13
c2n["N"]=14
c2n["O"]=15
c2n["P"]=16
c2n["Q"]=17
c2n["R"]=18
c2n["S"]=19
c2n["T"]=20
c2n["U"]=21
c2n["V"]=22
c2n["W"]=23
c2n["X"]=24
c2n["Y"]=25
c2n["Z"]=26
c2n["a"]=27
c2n["b"]=28
c2n["c"]=29
c2n["d"]=30
c2n["e"]=31
c2n["f"]=32
c2n["g"]=33
c2n["h"]=34
c2n["i"]=35
c2n["j"]=36
c2n["k"]=37
c2n["l"]=38
c2n["m"]=39
c2n["n"]=40
c2n["o"]=41
c2n["p"]=42
c2n["q"]=43
c2n["r"]=44
c2n["s"]=45
c2n["t"]=46
c2n["u"]=47
c2n["v"]=48
c2n["w"]=49
c2n["x"]=50
c2n["y"]=51
c2n["z"]=52
c2n["0"]=53
c2n["1"]=54
c2n["2"]=55
c2n["3"]=56
c2n["4"]=57
c2n["5"]=58
c2n["6"]=59
c2n["7"]=60
c2n["8"]=61
c2n["9"]=62
c2n["_"]=63
}
/^#/ { next }
/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ {
table_number = 0
mod_base = 1000000
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_low = table_number % mod_base
if (tab_base_low < 0) {
# Work around stupid bug in the ARM libm
tab_base_low = tab_base_low + 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 (tab_base_low < 0) {
# Work around stupid bug in the ARM libm
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--
}
}
print "/*" > outfile
print " * " outfn ":" > outfile
print " * This file is automatically generated; please do not edit it." > outfile
print " */" > outfile
print "" > outfile
print "#include <stdlib.h>" > outfile
print "" > outfile
print "#define N_(a) a" > outfile
print "" > outfile
print "static const char * const text[] = {" > outfile
table_item_count = 0
}
(continuation == 1) && ($0 ~ /\\[ \t]*$/) {
text=substr($0,1,length($0)-1);
# printf "\t\t\"%s\"\n", text > outfile
cont_buf=cont_buf text;
}
(continuation == 1) && ($0 ~ /"[ \t]*$/) {
# printf "\t\t\"%s,\n", $0 > outfile
printf "\tN_(%s),\n", cont_buf $0 > outfile
continuation = 0;
}
/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[^ \t]/ {
# Be tolerant to missing whitespace after `,' ...
sub(/,/, ", ")
}
/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*$/ {
table_item_count++
skipone=1
next
}
/^[ \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 "\tN_(%s),\n", text > outfile
table_item_count++
}
/^[ \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)-2);
# printf "\t%s\"\n", text > outfile
cont_buf=text
table_item_count++
continuation++;
}
/^[ \t]*".*\\[ \t]*$/ {
if (skipone) {
text=substr($0,1,length($0)-1);
# printf "\t%s\"\n", text > outfile
cont_buf=text
continuation++;
}
skipone=0
}
{
if (skipone) {
printf "\tN_(%s),\n", $0 > outfile
}
skipone=0
}
/^[ \t]*(prefix)$/ {
prefix_str = ""
}
/^[ \t]*(prefix)[ \t]+[A-Z_0-9]+/ {
prefix_str = $2 "_"
}
/^[ \t]*(index)[ \t]+[A-Z_0-9]+/ {
new_idx = $2
for (i = table_item_count ; i < new_idx; i++) {
printf "\tN_(\"Reserved %s error (%d)\"),\n", \
table_name, table_item_count++ > outfile
}
}
END {
print " 0" > outfile
print "};" > outfile
print "" > outfile
print "struct error_table {" > outfile
print " char const * const * msgs;" > outfile
print " long base;" > outfile
print " int n_msgs;" > outfile
print "};" > outfile
print "struct et_list {" > outfile
print " struct et_list *next;" > outfile
print " const struct error_table * table;" > outfile
print "};" > outfile
print "extern struct et_list *_et_list;" > outfile
print "" > outfile
if (tab_base_high == 0) {
print "const struct error_table et_" table_name "_error_table = { text, " \
sprintf("%dL, %d };", tab_base_sign*tab_base_low, \
table_item_count) > outfile
} else {
print "const struct error_table et_" table_name "_error_table = { 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
print "void initialize_" table_name "_error_table_r(struct et_list **list);" > outfile
print "void initialize_" table_name "_error_table(void);" > outfile
print "" > outfile
print "void initialize_" table_name "_error_table(void) {" > outfile
print " initialize_" table_name "_error_table_r(&_et_list);" > outfile
print "}" > outfile
print "" > outfile
print "/* For Heimdal compatibility */" > outfile
print "void initialize_" table_name "_error_table_r(struct et_list **list)" > outfile
print "{" > outfile
print " struct et_list *et, **end;" > outfile
print "" > outfile
print " for (end = list, et = *list; et; end = &et->next, et = et->next)" > outfile
print " if (et->table->msgs == text)" > outfile
print " return;" > outfile
print " et = malloc(sizeof(struct et_list));" > outfile
print " if (et == 0) {" > outfile
print " if (!link.table)" > outfile
print " et = &link;" > outfile
print " else" > outfile
print " return;" > outfile
print " }" > outfile
print " et->table = &et_" table_name "_error_table;" > outfile
print " et->next = 0;" > outfile
print " *end = et;" > outfile
print "}" > outfile
}
|