simplify newlocale and allow failure for explicit locale names
[musl.git] / tools / add-cfi.common.awk
blob04482d43843d023b21279ac044fe6fa07bf0bc05
1 function hex2int(str, i) {
2 str = tolower(str)
4 for (i = 1; i <= 16; i++) {
5 char = substr("0123456789abcdef", i, 1)
6 lookup[char] = i-1
9 result = 0
10 for (i = 1; i <= length(str); i++) {
11 result = result * 16
12 char = substr(str, i, 1)
13 result = result + lookup[char]
15 return result
18 function parse_const(str) {
19 sign = sub(/^-/, "", str)
20 hex = sub(/^0x/, "", str)
21 if (hex)
22 n = hex2int(str)
23 else
24 n = str+0
25 return sign ? -n : n