aboutsummaryrefslogtreecommitdiffstats
path: root/libwc/ambwidth_map.awk
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:45:29 +0000
committerTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:45:29 +0000
commit2945f70be161735bf7efaefde43125a9ad3a4c88 (patch)
treeda85d4bca39cba5a7c4e6714c8b73d6a8cd547fe /libwc/ambwidth_map.awk
parentReleasing debian version 0.5.2-10 (diff)
downloadw3m-2945f70be161735bf7efaefde43125a9ad3a4c88.tar.gz
w3m-2945f70be161735bf7efaefde43125a9ad3a4c88.zip
Releasing debian version 0.5.3-1debian/0.5.3-1
Diffstat (limited to '')
-rw-r--r--libwc/ambwidth_map.awk47
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");
+}