aboutsummaryrefslogtreecommitdiffstats
path: root/libwc/ambwidth_map.awk
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2014-10-04 14:06:29 +0000
committerTatsuya Kinoshita <tats@debian.org>2014-10-13 10:59:22 +0000
commitd3143d6ddfda0038989517800a6ac2f3eb425730 (patch)
tree384f3ae29d9ec0d746fc3a129a009b992bd19f08 /libwc/ambwidth_map.awk
parentMerge from upstream on 2012-05-22 (diff)
downloadw3m-d3143d6ddfda0038989517800a6ac2f3eb425730.tar.gz
w3m-d3143d6ddfda0038989517800a6ac2f3eb425730.zip
Fix incorrect generation of ucs_ambwidth_map
Diffstat (limited to '')
-rw-r--r--libwc/ambwidth_map.awk32
1 files changed, 12 insertions, 20 deletions
diff --git a/libwc/ambwidth_map.awk b/libwc/ambwidth_map.awk
index 8544f58..1d9d25f 100644
--- a/libwc/ambwidth_map.awk
+++ b/libwc/ambwidth_map.awk
@@ -3,9 +3,15 @@ BEGIN {
i = 0;
}
$2 == "A" {
- code = sprintf("0x%s", $1);
- if (strtonum(code) < 0x10000) {
- map[i] = code
+ code = code2 = strtonum(sprintf("0x%s", $1))
+ if (match($1, /[.]+[0-9A-Fa-f]+/)) {
+ s = substr($1, RSTART, RLENGTH)
+ sub(/[.]+/, "0x", s)
+ code2 = strtonum(s)
+ }
+ for (; code <= code2; code++) {
+ if (code >= 0x10000) { break }
+ map[i] = sprintf("0x%04X", code)
i++;
}
}
@@ -15,28 +21,14 @@ END {
prev = strtonum(map[0]);
for (j = 1; j < i; j++) {
cur = strtonum(map[j]);
- if (match(map[j], "[.]+")) {
+ if (cur - prev > 1) {
map2[n] = sprintf("%s, %s", start, map[j - 1]);
n++;
- gsub("[.]+", ", 0x", map[j])
- map2[n] = map[j];
- n++;
- start = map[j + 1];
- cur = strtonum(start);
- } else {
- if (cur - prev > 2) {
- map2[n] = sprintf("%s, %s", start, map[j - 1]);
- start = map[j];
- n++;
- }
-
- if (j == i - 1) {
- map2[n] = sprintf("%s, %s", start, map[j]);
- n++;
- }
+ start = map[j];
}
prev = cur;
}
+ if (i > 0) { map2[n] = sprintf("%s, %s", start, map[i - 1]); n++ }
printf("static wc_map ucs_ambwidth_map[] = {\n");
for (j = 0; j < n; j++) {