diff options
author | Ito Hiroyuki <ZXB01226@nifty.com> | 2010-07-25 09:55:05 +0000 |
---|---|---|
committer | Ito Hiroyuki <ZXB01226@nifty.com> | 2010-07-25 09:55:05 +0000 |
commit | e2782c2ae915a60778c3c43804926f1efc92cc6a (patch) | |
tree | d1195dc29ff2c4b4c859634b670b03549c34367b /libwc/ambwidth_map.awk | |
parent | [w3m-dev 04326] suppress compile warnings. (diff) | |
download | w3m-e2782c2ae915a60778c3c43804926f1efc92cc6a.tar.gz w3m-e2782c2ae915a60778c3c43804926f1efc92cc6a.zip |
* merge ambiguous width patch
* http://www.j10n.org/files/w3m-cvs-1.914-ambwidth.patch
Diffstat (limited to '')
-rw-r--r-- | libwc/ambwidth_map.awk | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libwc/ambwidth_map.awk b/libwc/ambwidth_map.awk new file mode 100644 index 0000000..8544f58 --- /dev/null +++ b/libwc/ambwidth_map.awk @@ -0,0 +1,47 @@ +BEGIN { + FS = "[; ]"; + i = 0; +} +$2 == "A" { + code = sprintf("0x%s", $1); + if (strtonum(code) < 0x10000) { + map[i] = code + i++; + } +} +END { + n = 0; + start = map[0] + prev = strtonum(map[0]); + for (j = 1; j < i; j++) { + cur = strtonum(map[j]); + if (match(map[j], "[.]+")) { + 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++; + } + } + prev = cur; + } + + printf("static wc_map ucs_ambwidth_map[] = {\n"); + for (j = 0; j < n; j++) { + printf(" { %s },\n", map2[j]); + } + printf("};\n"); + printf("#define N_ucs_ambwidth_map (sizeof(ucs_ambwidth_map) / sizeof(*ucs_ambwidth_map))\n"); +} |