blob: 42b9900f206aac20224c6b7bfe35309e2f879408 (
plain)
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
|
BEGIN { n = 0
printf "static const char %s[] = {\n", arrayname
for (i = 0; i < 255; i++)
_ord_[sprintf("%c", i)] = i
}
{
split($0, line, "");
printf " "
for (i = 1; i <= length($0); i++) {
c = line[i]
if (c == "'") {
printf "'\\''"
} else if (c == "\\") {
printf "'\\\\'"
} else if (_ord_[c] >= 32 && _ord_[c] < 127) {
printf "'%s'", c
} else {
printf "'\\%03o'", _ord_[c]
}
printf ", "
if (i % 10 == 0)
printf "\n "
}
printf "'\\n', \n"
}
END {
print " 0 };"
}
|