create a punctuation table Reference: /n/atom/patch/applied2013/mkrunepunct Date: Mon Nov 25 15:41:31 CET 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/runetype/mkfile Mon Nov 25 15:41:14 2013 +++ /sys/src/cmd/runetype/mkfile Mon Nov 25 15:41:15 2013 @@ -15,6 +15,7 @@ runeclass.h\ runecompose.h\ runedecompose.h\ + runepunct.h\ L=unicode\ --- /sys/src/cmd/runetype/runepunct.rc Thu Jan 1 00:00:00 1970 +++ /sys/src/cmd/runetype/runepunct.rc Mon Nov 25 15:41:15 2013 @@ -0,0 +1,67 @@ +#!/bin/rc + +c=() + +. common.rc + +Unicode | awk -F';' ' +' ^ $hex ^ ' + +function init() { + mark=0; # decimal of 1st matching in range + mdes=""; # description of mark. + last=0; # last in range + lastt=0; # last type + ldes=""; # last desc. +} + +BEGIN { + print "static"; + print "Rune\t__punct3[] ="; + print "{" + + init(); +} + +$3 ~ /P./ { + codepoint=hex($1); + t=substr($3,2,2); + if (last + 1 == codepoint && t == type){ + last = codepoint; + ldes = tolower($2); + next; + } + + type = t; + if (last && last > mark){ + printf("\t0x%04x, 0x%04x, ''%c'', \t/* \\u%04x-\\u%04x; %s - %s */\n", mark, last, type, mark, last, mdes, ldes); + } else if (last) { + single = single sprintf("\t0x%04x, 0x%04x, ''%c'', \t/* \\u%04x; %s */\n", mark, last, type, last, ldes); + } + + init(); + mark=last=codepoint; + ldes=mdes=tolower($2); +} + + + +END { + if (last && last > mark){ + printf("\t0x%04x, 0x%04x, ''%c'', \t/* \\u%04x-\\u%04x; %s - %s */\n", mark, last, type, mark, last, mdes, ldes); + } else if (last) { + single = single sprintf("\t0x%04x, 0x%04x, ''%c'', \t/* \\u%04x; %s */\n", mark, last, type, last, ldes); + } + print "};" + print "" + + print "static"; + print "Rune\t__punct2[] ="; + print "{"; + + print single; + + print "};"; + print ""; +} + ' | Sprint