From 5397d09e585a1938fb64bc9c5cd5daed1959eb90 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:41:45 +0900 Subject: Adding upstream version 0.5.3 --- libwc/ambwidth_map.awk | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 libwc/ambwidth_map.awk (limited to 'libwc/ambwidth_map.awk') 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"); +} -- cgit v1.2.3 From 1d0ba25a660483da1272a31dd077ed94441e3d9f Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Sat, 2 Jan 2021 09:20:37 +0900 Subject: New upstream version 0.5.3+git20210102 --- libwc/ambwidth_map.awk | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'libwc/ambwidth_map.awk') 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++) { -- cgit v1.2.3