diff --git a/.gitignore b/.gitignore index e78ee84..9cf609d 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,5 @@ stamp-h[0-9] tmp /.version /doc/stamp-[0-9] +scripts/* +!scripts/*.in \ No newline at end of file diff --git a/guix.scm b/guix.scm index d263790..a07615a 100644 --- a/guix.scm +++ b/guix.scm @@ -26,7 +26,62 @@ (string-contains file my-string)) (list ".git" ".dir-locals.el" "guix.scm")))))) (build-system gnu-build-system) - (arguments `()) + (arguments + `(#:modules + ((ice-9 match) + (ice-9 ftw) + ,@%gnu-build-system-modules) + #:phases + (modify-phases + %standard-phases + (add-after + 'install + 'hall-wrap-binaries + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((compiled-dir + (lambda (out version) + (string-append + out + "/lib/guile/" + version + "/site-ccache"))) + (uncompiled-dir + (lambda (out version) + (string-append + out + "/share/guile/site" + (if (string-null? version) "" "/") + version))) + (dep-path + (lambda (env modules path) + (list env + ":" + 'prefix + (cons modules + (map (lambda (input) + (string-append + (assoc-ref inputs input) + path)) + ,''()))))) + (out (assoc-ref outputs "out")) + (bin (string-append out "/bin/")) + (site (uncompiled-dir out ""))) + (match (scandir site) + (("." ".." version) + (for-each + (lambda (file) + (wrap-program + (string-append bin file) + (dep-path + "GUILE_LOAD_PATH" + (uncompiled-dir out version) + (uncompiled-dir "" version)) + (dep-path + "GUILE_LOAD_COMPILED_PATH" + (compiled-dir out version) + (compiled-dir "" version)))) + ,''("generate-east-asian" "generate-emoji")) + #t)))))))) (native-inputs (list autoconf automake pkg-config texinfo)) (inputs (list guile-3.0)) diff --git a/hall.scm b/hall.scm index 2b70a9a..1ada03c 100644 --- a/hall.scm +++ b/hall.scm @@ -19,10 +19,18 @@ (native-language-support #f) (licensing #f))) (files (libraries - ((directory "runewidth" ()) + ((directory + "runewidth" + ((scheme-file "emoji") + (scheme-file "eastasian") + (scheme-file "internal"))) (scheme-file "runewidth"))) (tests ((directory "tests" ((scheme-file "test-posix"))))) - (programs ()) + (programs + ((directory + "scripts" + ((in-file "generate-east-asian") + (in-file "generate-emoji"))))) (documentation ((org-file "README") (symlink "README" "README.org") @@ -33,4 +41,4 @@ ((scheme-file "guix") (text-file ".gitignore") (scheme-file "hall") - (directory "tests" ()))))) + (directory "tests" ((scheme-file "test-posix"))))))) diff --git a/runewidth/eastasian.scm b/runewidth/eastasian.scm new file mode 100644 index 0000000..d8c4623 --- /dev/null +++ b/runewidth/eastasian.scm @@ -0,0 +1,2537 @@ +;; Code generated by script/generate. DO NOT EDIT + +(define-module + (runewidth eastasian) + #:use-module + (ice-9 hash-table) + #:use-module + (srfi srfi-1) + #:export + (char-set:eastasian-combining + char-set:eastasian-doublewidth + char-set:eastasian-halfwidth + char-set:eastasian-narrow + char-set:eastasian-neutral + char-set:eastasian-ambiguous)) +(define chars-ht + (alist->hashq-table + '((doublewidth + (201547 262141) + (196608 201546) + (195104 196605) + (195102 195103) + (194560 195101) + (191457 194559) + (183984 191456) + (183970 183983) + (178208 183969) + (178206 178207) + (177984 178205) + (177973 177983) + (173824 177972) + (173790 173823) + (131072 173789) + (129744 129750) + (129728 129730) + (129712 129718) + (129680 129704) + (129664 129670) + (129656 129658) + (129648 129652) + (129485 129535) + (129402 129483) + (129351 129400) + (129340 129349) + (129292 129338) + (128992 129003) + (128756 128764) + (128747 128748) + (128725 128727) + (128720 128722) + (128716 128716) + (128640 128709) + (128512 128591) + (128507 128511) + (128420 128420) + (128405 128406) + (128378 128378) + (128336 128359) + (128331 128334) + (128255 128317) + (128066 128252) + (128064 128064) + (128000 128062) + (127995 127999) + (127992 127994) + (127988 127988) + (127968 127984) + (127951 127955) + (127904 127946) + (127870 127891) + (127799 127868) + (127789 127797) + (127744 127776) + (127584 127589) + (127568 127569) + (127552 127560) + (127504 127547) + (127488 127490) + (127377 127386) + (127374 127374) + (127183 127183) + (126980 126980) + (110960 111355) + (110948 110951) + (110928 110930) + (110848 110878) + (110592 110847) + (101632 101640) + (101120 101589) + (100352 101119) + (94208 100343) + (94192 94193) + (94180 94180) + (94179 94179) + (94178 94178) + (94176 94177) + (65509 65510) + (65508 65508) + (65507 65507) + (65506 65506) + (65504 65505) + (65376 65376) + (65375 65375) + (65374 65374) + (65373 65373) + (65372 65372) + (65371 65371) + (65345 65370) + (65344 65344) + (65343 65343) + (65342 65342) + (65341 65341) + (65340 65340) + (65339 65339) + (65313 65338) + (65311 65312) + (65308 65310) + (65306 65307) + (65296 65305) + (65294 65295) + (65293 65293) + (65292 65292) + (65291 65291) + (65290 65290) + (65289 65289) + (65288 65288) + (65285 65287) + (65284 65284) + (65281 65283) + (65130 65131) + (65129 65129) + (65128 65128) + (65124 65126) + (65123 65123) + (65122 65122) + (65119 65121) + (65118 65118) + (65117 65117) + (65116 65116) + (65115 65115) + (65114 65114) + (65113 65113) + (65112 65112) + (65108 65111) + (65104 65106) + (65101 65103) + (65097 65100) + (65096 65096) + (65095 65095) + (65093 65094) + (65092 65092) + (65091 65091) + (65090 65090) + (65089 65089) + (65088 65088) + (65087 65087) + (65086 65086) + (65085 65085) + (65084 65084) + (65083 65083) + (65082 65082) + (65081 65081) + (65080 65080) + (65079 65079) + (65078 65078) + (65077 65077) + (65075 65076) + (65073 65074) + (65072 65072) + (65049 65049) + (65048 65048) + (65047 65047) + (65040 65046) + (64218 64255) + (64112 64217) + (64110 64111) + (63744 64109) + (44032 55203) + (43360 43388) + (42128 42182) + (40982 42124) + (40981 40981) + (40960 40980) + (40957 40959) + (19968 40956) + (13312 19903) + (13056 13311) + (12992 13055) + (12977 12991) + (12938 12976) + (12928 12937) + (12896 12927) + (12881 12895) + (12880 12880) + (12842 12871) + (12832 12841) + (12800 12830) + (12784 12799) + (12736 12771) + (12704 12735) + (12694 12703) + (12690 12693) + (12688 12689) + (12593 12686) + (12549 12591) + (12543 12543) + (12540 12542) + (12539 12539) + (12449 12538) + (12448 12448) + (12447 12447) + (12445 12446) + (12443 12444) + (12353 12438) + (12350 12350) + (12349 12349) + (12348 12348) + (12347 12347) + (12344 12346) + (12342 12343) + (12337 12341) + (12336 12336) + (12334 12335) + (12330 12333) + (12321 12329) + (12320 12320) + (12318 12319) + (12317 12317) + (12316 12316) + (12315 12315) + (12314 12314) + (12313 12313) + (12312 12312) + (12311 12311) + (12310 12310) + (12309 12309) + (12308 12308) + (12306 12307) + (12305 12305) + (12304 12304) + (12303 12303) + (12302 12302) + (12301 12301) + (12300 12300) + (12299 12299) + (12298 12298) + (12297 12297) + (12296 12296) + (12295 12295) + (12294 12294) + (12293 12293) + (12292 12292) + (12289 12291) + (12288 12288) + (12272 12283) + (12032 12245) + (11931 12019) + (11904 11929) + (11093 11093) + (11088 11088) + (11035 11036) + (10175 10175) + (10160 10160) + (10133 10135) + (10071 10071) + (10067 10069) + (10062 10062) + (10060 10060) + (10024 10024) + (9994 9995) + (9989 9989) + (9981 9981) + (9978 9978) + (9973 9973) + (9970 9971) + (9962 9962) + (9940 9940) + (9934 9934) + (9924 9925) + (9917 9918) + (9898 9899) + (9889 9889) + (9875 9875) + (9855 9855) + (9800 9811) + (9748 9749) + (9725 9726) + (9203 9203) + (9200 9200) + (9193 9196) + (9002 9002) + (9001 9001) + (8986 8987) + (4352 4447)) + (ambiguous + (1048576 1114109) + (983040 1048573) + (917760 917999) + (127387 127404) + (127375 127376) + (127344 127373) + (127280 127337) + (127248 127277) + (127232 127242) + (65533 65533) + (65024 65039) + (57344 63743) + (12872 12879) + (11094 11097) + (10102 10111) + (10045 10045) + (9982 9983) + (9979 9980) + (9974 9977) + (9972 9972) + (9963 9969) + (9960 9961) + (9955 9955) + (9941 9953) + (9935 9939) + (9926 9933) + (9919 9919) + (9886 9887) + (9839 9839) + (9836 9837) + (9831 9834) + (9827 9829) + (9824 9825) + (9794 9794) + (9792 9792) + (9758 9758) + (9756 9756) + (9742 9743) + (9737 9737) + (9733 9734) + (9711 9711) + (9698 9701) + (9678 9681) + (9675 9675) + (9670 9672) + (9665 9665) + (9664 9664) + (9660 9661) + (9655 9655) + (9654 9654) + (9650 9651) + (9635 9641) + (9632 9633) + (9618 9621) + (9600 9615) + (9552 9587) + (9472 9547) + (9451 9471) + (9372 9449) + (9312 9371) + (8978 8978) + (8895 8895) + (8869 8869) + (8857 8857) + (8853 8853) + (8838 8839) + (8834 8835) + (8814 8815) + (8810 8811) + (8804 8807) + (8800 8801) + (8786 8786) + (8780 8780) + (8776 8776) + (8764 8765) + (8756 8759) + (8750 8750) + (8743 8748) + (8741 8741) + (8739 8739) + (8733 8736) + (8730 8730) + (8725 8725) + (8721 8721) + (8719 8719) + (8715 8715) + (8711 8712) + (8706 8707) + (8704 8704) + (8679 8679) + (8660 8660) + (8658 8658) + (8632 8633) + (8597 8601) + (8592 8596) + (8585 8585) + (8560 8569) + (8544 8555) + (8539 8542) + (8531 8532) + (8491 8491) + (8486 8486) + (8481 8482) + (8470 8470) + (8467 8467) + (8457 8457) + (8453 8453) + (8451 8451) + (8364 8364) + (8321 8324) + (8319 8319) + (8308 8308) + (8254 8254) + (8251 8251) + (8245 8245) + (8242 8243) + (8240 8240) + (8228 8231) + (8224 8226) + (8221 8221) + (8220 8220) + (8217 8217) + (8216 8216) + (8214 8214) + (8211 8213) + (8208 8208) + (1105 1105) + (1040 1103) + (1025 1025) + (963 969) + (945 961) + (931 937) + (913 929) + (735 735) + (733 733) + (728 731) + (720 720) + (717 717) + (713 715) + (711 711) + (708 708) + (609 609) + (593 593) + (476 476) + (474 474) + (472 472) + (470 470) + (468 468) + (466 466) + (464 464) + (462 462) + (363 363) + (358 359) + (338 339) + (333 333) + (328 331) + (324 324) + (319 322) + (312 312) + (305 307) + (299 299) + (294 295) + (283 283) + (275 275) + (273 273) + (257 257) + (254 254) + (252 252) + (248 250) + (247 247) + (242 243) + (240 240) + (236 237) + (232 234) + (230 230) + (222 225) + (216 216) + (215 215) + (208 208) + (198 198) + (191 191) + (188 190) + (186 186) + (185 185) + (184 184) + (182 183) + (180 180) + (178 179) + (177 177) + (176 176) + (174 174) + (173 173) + (170 170) + (168 168) + (167 167) + (164 164) + (161 161)) + (combining + (125136 125142) + (122918 122922) + (122915 122916) + (122907 122913) + (122888 122904) + (122880 122886) + (119362 119364) + (119210 119213) + (119173 119179) + (119163 119170) + (119149 119154) + (119143 119145) + (119141 119142) + (92912 92916) + (70512 70516) + (70502 70508) + (70459 70460) + (70400 70401) + (69446 69456) + (69291 69292) + (66422 66426) + (66045 66045) + (65056 65071) + (43232 43249) + (42736 42737) + (42654 42655) + (42612 42621) + (42608 42610) + (42607 42607) + (12441 12442) + (11744 11775) + (11503 11505) + (8421 8432) + (8418 8420) + (8417 8417) + (8413 8416) + (8400 8412) + (7675 7679) + (7616 7673) + (7019 7027) + (6847 6848) + (6846 6846) + (6832 6845) + (6783 6783) + (4957 4959) + (3328 3329) + (3076 3076) + (3072 3072) + (2027 2035) + (1160 1161) + (1155 1159) + (768 879)) + (neutral + (917536 917631) + (917505 917505) + (130032 130041) + (129940 129994) + (129792 129938) + (129632 129645) + (129536 129619) + (129350 129350) + (129339 129339) + (129280 129291) + (129200 129201) + (129168 129197) + (129120 129159) + (129104 129113) + (129040 129095) + (129024 129035) + (128896 128984) + (128768 128883) + (128752 128755) + (128736 128746) + (128723 128724) + (128717 128719) + (128710 128715) + (128592 128639) + (128421 128506) + (128407 128419) + (128379 128404) + (128360 128377) + (128335 128335) + (128318 128330) + (128253 128254) + (128065 128065) + (128063 128063) + (127989 127991) + (127985 127987) + (127956 127967) + (127947 127950) + (127892 127903) + (127869 127869) + (127798 127798) + (127777 127788) + (127462 127487) + (127405 127405) + (127338 127343) + (127278 127279) + (127245 127247) + (127243 127244) + (127185 127221) + (127169 127182) + (127153 127167) + (127136 127150) + (127024 127123) + (126981 127019) + (126976 126979) + (126704 126705) + (126635 126651) + (126629 126633) + (126625 126627) + (126603 126619) + (126592 126601) + (126590 126590) + (126585 126588) + (126580 126583) + (126572 126578) + (126567 126570) + (126564 126564) + (126561 126562) + (126559 126559) + (126557 126557) + (126555 126555) + (126553 126553) + (126551 126551) + (126548 126548) + (126545 126546) + (126541 126543) + (126539 126539) + (126537 126537) + (126535 126535) + (126530 126530) + (126523 126523) + (126521 126521) + (126516 126519) + (126505 126514) + (126503 126503) + (126500 126500) + (126497 126498) + (126469 126495) + (126464 126467) + (126255 126269) + (126254 126254) + (126209 126253) + (126129 126132) + (126128 126128) + (126125 126127) + (126124 126124) + (126065 126123) + (125278 125279) + (125264 125273) + (125259 125259) + (125252 125258) + (125184 125251) + (125127 125135) + (124928 125124) + (123647 123647) + (123632 123641) + (123628 123631) + (123584 123627) + (123215 123215) + (123214 123214) + (123200 123209) + (123191 123197) + (123184 123190) + (123136 123180) + (121505 121519) + (121499 121503) + (121479 121483) + (121477 121478) + (121476 121476) + (121462 121475) + (121461 121461) + (121453 121460) + (121403 121452) + (121399 121402) + (121344 121398) + (120832 121343) + (120782 120831) + (120772 120779) + (120771 120771) + (120746 120770) + (120745 120745) + (120714 120744) + (120713 120713) + (120688 120712) + (120687 120687) + (120656 120686) + (120655 120655) + (120630 120654) + (120629 120629) + (120598 120628) + (120597 120597) + (120572 120596) + (120571 120571) + (120540 120570) + (120539 120539) + (120514 120538) + (120513 120513) + (120488 120512) + (120146 120485) + (120138 120144) + (120134 120134) + (120128 120132) + (120123 120126) + (120094 120121) + (120086 120092) + (120077 120084) + (120071 120074) + (120005 120069) + (119997 120003) + (119995 119995) + (119982 119993) + (119977 119980) + (119973 119974) + (119970 119970) + (119966 119967) + (119894 119964) + (119808 119892) + (119648 119672) + (119552 119638) + (119520 119539) + (119365 119365) + (119296 119361) + (119214 119272) + (119180 119209) + (119171 119172) + (119155 119162) + (119146 119148) + (119081 119140) + (119040 119078) + (118784 119029) + (113824 113827) + (113823 113823) + (113821 113822) + (113820 113820) + (113808 113817) + (113792 113800) + (113776 113788) + (113664 113770) + (94099 94111) + (94095 94098) + (94033 94087) + (94032 94032) + (94031 94031) + (93952 94026) + (93847 93850) + (93824 93846) + (93760 93823) + (93053 93071) + (93027 93047) + (93019 93025) + (93008 93017) + (92997 92997) + (92996 92996) + (92992 92995) + (92988 92991) + (92983 92987) + (92976 92982) + (92928 92975) + (92917 92917) + (92880 92909) + (92782 92783) + (92768 92777) + (92736 92766) + (92160 92728) + (82944 83526) + (78896 78904) + (77824 78894) + (74880 75075) + (74864 74868) + (74752 74862) + (73728 74649) + (73727 73727) + (73697 73713) + (73693 73696) + (73685 73692) + (73664 73684) + (73648 73648) + (73463 73464) + (73461 73462) + (73459 73460) + (73440 73458) + (73120 73129) + (73112 73112) + (73111 73111) + (73110 73110) + (73109 73109) + (73107 73108) + (73104 73105) + (73098 73102) + (73066 73097) + (73063 73064) + (73056 73061) + (73040 73049) + (73031 73031) + (73030 73030) + (73023 73029) + (73020 73021) + (73018 73018) + (73009 73014) + (72971 73008) + (72968 72969) + (72960 72966) + (72885 72886) + (72884 72884) + (72882 72883) + (72881 72881) + (72874 72880) + (72873 72873) + (72850 72871) + (72818 72847) + (72816 72817) + (72794 72812) + (72784 72793) + (72769 72773) + (72768 72768) + (72767 72767) + (72766 72766) + (72760 72765) + (72752 72758) + (72751 72751) + (72714 72750) + (72704 72712) + (72384 72440) + (72350 72354) + (72349 72349) + (72346 72348) + (72344 72345) + (72343 72343) + (72330 72342) + (72284 72329) + (72281 72283) + (72279 72280) + (72273 72278) + (72272 72272) + (72263 72263) + (72255 72262) + (72251 72254) + (72250 72250) + (72249 72249) + (72243 72248) + (72203 72242) + (72193 72202) + (72192 72192) + (72164 72164) + (72163 72163) + (72162 72162) + (72161 72161) + (72160 72160) + (72156 72159) + (72154 72155) + (72148 72151) + (72145 72147) + (72106 72144) + (72096 72103) + (72016 72025) + (72004 72006) + (72003 72003) + (72002 72002) + (72001 72001) + (72000 72000) + (71999 71999) + (71998 71998) + (71997 71997) + (71995 71996) + (71991 71992) + (71984 71989) + (71960 71983) + (71957 71958) + (71948 71955) + (71945 71945) + (71936 71942) + (71935 71935) + (71914 71922) + (71904 71913) + (71840 71903) + (71739 71739) + (71737 71738) + (71736 71736) + (71727 71735) + (71724 71726) + (71680 71723) + (71487 71487) + (71484 71486) + (71482 71483) + (71472 71481) + (71463 71467) + (71462 71462) + (71458 71461) + (71456 71457) + (71453 71455) + (71424 71450) + (71360 71369) + (71352 71352) + (71351 71351) + (71350 71350) + (71344 71349) + (71342 71343) + (71341 71341) + (71340 71340) + (71339 71339) + (71296 71338) + (71264 71276) + (71248 71257) + (71236 71236) + (71233 71235) + (71231 71232) + (71230 71230) + (71229 71229) + (71227 71228) + (71219 71226) + (71216 71218) + (71168 71215) + (71132 71133) + (71128 71131) + (71105 71127) + (71103 71104) + (71102 71102) + (71100 71101) + (71096 71099) + (71090 71093) + (71087 71089) + (71040 71086) + (70864 70873) + (70855 70855) + (70854 70854) + (70852 70853) + (70850 70851) + (70849 70849) + (70847 70848) + (70843 70846) + (70842 70842) + (70841 70841) + (70835 70840) + (70832 70834) + (70784 70831) + (70751 70753) + (70750 70750) + (70749 70749) + (70746 70747) + (70736 70745) + (70731 70735) + (70727 70730) + (70726 70726) + (70725 70725) + (70722 70724) + (70720 70721) + (70712 70719) + (70709 70711) + (70656 70708) + (70498 70499) + (70493 70497) + (70487 70487) + (70480 70480) + (70475 70477) + (70471 70472) + (70465 70468) + (70464 70464) + (70462 70463) + (70461 70461) + (70453 70457) + (70450 70451) + (70442 70448) + (70419 70440) + (70415 70416) + (70405 70412) + (70402 70403) + (70384 70393) + (70371 70378) + (70368 70370) + (70367 70367) + (70320 70366) + (70313 70313) + (70303 70312) + (70287 70301) + (70282 70285) + (70280 70280) + (70272 70278) + (70206 70206) + (70200 70205) + (70198 70199) + (70197 70197) + (70196 70196) + (70194 70195) + (70191 70193) + (70188 70190) + (70163 70187) + (70144 70161) + (70113 70132) + (70109 70111) + (70108 70108) + (70107 70107) + (70106 70106) + (70096 70105) + (70095 70095) + (70094 70094) + (70093 70093) + (70089 70092) + (70085 70088) + (70081 70084) + (70079 70080) + (70070 70078) + (70067 70069) + (70019 70066) + (70018 70018) + (70016 70017) + (70006 70006) + (70004 70005) + (70003 70003) + (69968 70002) + (69959 69959) + (69957 69958) + (69956 69956) + (69952 69955) + (69942 69951) + (69933 69940) + (69932 69932) + (69927 69931) + (69891 69926) + (69888 69890) + (69872 69881) + (69840 69864) + (69837 69837) + (69822 69825) + (69821 69821) + (69819 69820) + (69817 69818) + (69815 69816) + (69811 69814) + (69808 69810) + (69763 69807) + (69762 69762) + (69760 69761) + (69759 69759) + (69734 69743) + (69714 69733) + (69703 69709) + (69688 69702) + (69635 69687) + (69634 69634) + (69633 69633) + (69632 69632) + (69600 69622) + (69573 69579) + (69552 69572) + (69461 69465) + (69457 69460) + (69424 69445) + (69415 69415) + (69405 69414) + (69376 69404) + (69296 69297) + (69293 69293) + (69248 69289) + (69216 69246) + (68912 68921) + (68900 68903) + (68864 68899) + (68858 68863) + (68800 68850) + (68736 68786) + (68608 68680) + (68521 68527) + (68505 68508) + (68480 68497) + (68472 68479) + (68448 68466) + (68440 68447) + (68416 68437) + (68409 68415) + (68352 68405) + (68336 68342) + (68331 68335) + (68325 68326) + (68297 68324) + (68296 68296) + (68288 68295) + (68253 68255) + (68224 68252) + (68223 68223) + (68221 68222) + (68192 68220) + (68176 68184) + (68160 68168) + (68159 68159) + (68152 68154) + (68121 68149) + (68117 68119) + (68112 68115) + (68108 68111) + (68101 68102) + (68097 68099) + (68096 68096) + (68050 68095) + (68032 68047) + (68030 68031) + (68028 68029) + (68000 68023) + (67968 67999) + (67903 67903) + (67872 67897) + (67871 67871) + (67862 67867) + (67840 67861) + (67835 67839) + (67828 67829) + (67808 67826) + (67751 67759) + (67712 67742) + (67705 67711) + (67703 67704) + (67680 67702) + (67672 67679) + (67671 67671) + (67648 67669) + (67647 67647) + (67644 67644) + (67639 67640) + (67594 67637) + (67592 67592) + (67584 67589) + (67424 67431) + (67392 67413) + (67072 67382) + (66927 66927) + (66864 66915) + (66816 66855) + (66776 66811) + (66736 66771) + (66720 66729) + (66688 66717) + (66640 66687) + (66560 66639) + (66513 66517) + (66512 66512) + (66504 66511) + (66464 66499) + (66463 66463) + (66432 66461) + (66384 66421) + (66378 66378) + (66370 66377) + (66369 66369) + (66352 66368) + (66349 66351) + (66336 66339) + (66304 66335) + (66273 66299) + (66272 66272) + (66208 66256) + (66176 66204) + (66000 66044) + (65952 65952) + (65936 65948) + (65932 65934) + (65930 65931) + (65913 65929) + (65909 65912) + (65856 65908) + (65847 65855) + (65799 65843) + (65792 65794) + (65664 65786) + (65616 65629) + (65599 65613) + (65596 65597) + (65576 65594) + (65549 65574) + (65536 65547) + (65532 65532) + (65529 65531) + (65279 65279) + (65142 65276) + (65136 65140) + (65021 65021) + (65020 65020) + (65008 65019) + (64914 64967) + (64848 64911) + (64831 64831) + (64830 64830) + (64467 64829) + (64434 64449) + (64336 64433) + (64326 64335) + (64323 64324) + (64320 64321) + (64318 64318) + (64312 64316) + (64298 64310) + (64297 64297) + (64287 64296) + (64286 64286) + (64285 64285) + (64275 64279) + (64256 64262) + (55243 55291) + (55216 55238) + (44016 44025) + (44013 44013) + (44012 44012) + (44011 44011) + (44009 44010) + (44008 44008) + (44006 44007) + (44005 44005) + (44003 44004) + (43968 44002) + (43888 43967) + (43882 43883) + (43881 43881) + (43872 43880) + (43868 43871) + (43867 43867) + (43824 43866) + (43816 43822) + (43808 43814) + (43793 43798) + (43785 43790) + (43777 43782) + (43766 43766) + (43765 43765) + (43763 43764) + (43762 43762) + (43760 43761) + (43758 43759) + (43756 43757) + (43755 43755) + (43744 43754) + (43742 43743) + (43741 43741) + (43739 43740) + (43714 43714) + (43713 43713) + (43712 43712) + (43710 43711) + (43705 43709) + (43703 43704) + (43701 43702) + (43698 43700) + (43697 43697) + (43696 43696) + (43648 43695) + (43646 43647) + (43645 43645) + (43644 43644) + (43643 43643) + (43642 43642) + (43639 43641) + (43633 43638) + (43632 43632) + (43616 43631) + (43612 43615) + (43600 43609) + (43597 43597) + (43596 43596) + (43588 43595) + (43587 43587) + (43584 43586) + (43573 43574) + (43571 43572) + (43569 43570) + (43567 43568) + (43561 43566) + (43520 43560) + (43514 43518) + (43504 43513) + (43495 43503) + (43494 43494) + (43493 43493) + (43488 43492) + (43486 43487) + (43472 43481) + (43471 43471) + (43457 43469) + (43454 43456) + (43452 43453) + (43450 43451) + (43446 43449) + (43444 43445) + (43443 43443) + (43396 43442) + (43395 43395) + (43392 43394) + (43359 43359) + (43346 43347) + (43335 43345) + (43312 43334) + (43310 43311) + (43302 43309) + (43274 43301) + (43264 43273) + (43263 43263) + (43261 43262) + (43260 43260) + (43259 43259) + (43256 43258) + (43250 43255) + (43216 43225) + (43214 43215) + (43204 43205) + (43188 43203) + (43138 43187) + (43136 43137) + (43124 43127) + (43072 43123) + (43065 43065) + (43064 43064) + (43062 43063) + (43056 43061) + (43052 43052) + (43048 43051) + (43047 43047) + (43045 43046) + (43043 43044) + (43020 43042) + (43019 43019) + (43015 43018) + (43014 43014) + (43011 43013) + (43010 43010) + (43008 43009) + (43003 43007) + (43002 43002) + (43000 43001) + (42999 42999) + (42997 42998) + (42946 42954) + (42896 42943) + (42895 42895) + (42891 42894) + (42889 42890) + (42888 42888) + (42865 42887) + (42864 42864) + (42786 42863) + (42784 42785) + (42775 42783) + (42752 42774) + (42738 42743) + (42726 42735) + (42656 42725) + (42652 42653) + (42624 42651) + (42623 42623) + (42622 42622) + (42611 42611) + (42606 42606) + (42560 42605) + (42538 42539) + (42528 42537) + (42512 42527) + (42509 42511) + (42508 42508) + (42240 42507) + (42238 42239) + (42232 42237) + (42192 42231) + (19904 19967) + (12351 12351) + (11858 11858) + (11856 11857) + (11843 11855) + (11842 11842) + (11841 11841) + (11840 11840) + (11836 11839) + (11834 11835) + (11824 11833) + (11823 11823) + (11818 11822) + (11817 11817) + (11816 11816) + (11815 11815) + (11814 11814) + (11813 11813) + (11812 11812) + (11811 11811) + (11810 11810) + (11809 11809) + (11808 11808) + (11806 11807) + (11805 11805) + (11804 11804) + (11803 11803) + (11802 11802) + (11800 11801) + (11799 11799) + (11790 11798) + (11789 11789) + (11788 11788) + (11787 11787) + (11786 11786) + (11785 11785) + (11782 11784) + (11781 11781) + (11780 11780) + (11779 11779) + (11778 11778) + (11776 11777) + (11736 11742) + (11728 11734) + (11720 11726) + (11712 11718) + (11704 11710) + (11696 11702) + (11688 11694) + (11680 11686) + (11648 11670) + (11647 11647) + (11632 11632) + (11631 11631) + (11568 11623) + (11565 11565) + (11559 11559) + (11520 11557) + (11518 11519) + (11517 11517) + (11513 11516) + (11506 11507) + (11499 11502) + (11493 11498) + (11392 11492) + (11390 11391) + (11388 11389) + (11360 11387) + (11312 11358) + (11264 11310) + (11159 11263) + (11126 11157) + (11098 11123) + (11089 11092) + (11085 11087) + (11079 11084) + (11077 11078) + (11056 11076) + (11037 11055) + (11008 11034) + (10752 11007) + (10750 10751) + (10749 10749) + (10748 10748) + (10716 10747) + (10715 10715) + (10714 10714) + (10713 10713) + (10712 10712) + (10649 10711) + (10648 10648) + (10647 10647) + (10646 10646) + (10645 10645) + (10644 10644) + (10643 10643) + (10642 10642) + (10641 10641) + (10640 10640) + (10639 10639) + (10638 10638) + (10637 10637) + (10636 10636) + (10635 10635) + (10634 10634) + (10633 10633) + (10632 10632) + (10631 10631) + (10628 10628) + (10627 10627) + (10624 10626) + (10496 10623) + (10240 10495) + (10224 10239) + (10223 10223) + (10222 10222) + (10183 10213) + (10182 10182) + (10181 10181) + (10176 10180) + (10161 10174) + (10136 10159) + (10132 10132) + (10112 10131) + (10101 10101) + (10100 10100) + (10099 10099) + (10098 10098) + (10097 10097) + (10096 10096) + (10095 10095) + (10094 10094) + (10093 10093) + (10092 10092) + (10091 10091) + (10090 10090) + (10089 10089) + (10088 10088) + (10072 10087) + (10070 10070) + (10063 10066) + (10061 10061) + (10046 10059) + (10025 10044) + (9996 10023) + (9990 9993) + (9984 9988) + (9956 9959) + (9954 9954) + (9920 9923) + (9900 9916) + (9890 9897) + (9888 9888) + (9876 9885) + (9856 9874) + (9840 9854) + (9838 9838) + (9835 9835) + (9830 9830) + (9826 9826) + (9812 9823) + (9795 9799) + (9793 9793) + (9759 9791) + (9757 9757) + (9750 9755) + (9744 9747) + (9738 9741) + (9735 9736) + (9728 9732) + (9727 9727) + (9720 9724) + (9712 9719) + (9702 9710) + (9682 9697) + (9676 9677) + (9673 9674) + (9666 9669) + (9662 9663) + (9656 9659) + (9652 9653) + (9642 9649) + (9634 9634) + (9622 9631) + (9616 9617) + (9588 9599) + (9548 9551) + (9450 9450) + (9280 9290) + (9216 9254) + (9204 9215) + (9201 9202) + (9197 9199) + (9186 9192) + (9180 9185) + (9140 9179) + (9115 9139) + (9085 9114) + (9084 9084) + (9003 9083) + (8994 9000) + (8992 8993) + (8988 8991) + (8979 8985) + (8972 8977) + (8971 8971) + (8970 8970) + (8969 8969) + (8968 8968) + (8960 8967) + (8896 8959) + (8870 8894) + (8858 8868) + (8854 8856) + (8840 8852) + (8836 8837) + (8816 8833) + (8812 8813) + (8808 8809) + (8802 8803) + (8787 8799) + (8781 8785) + (8777 8779) + (8766 8775) + (8760 8763) + (8751 8755) + (8749 8749) + (8742 8742) + (8740 8740) + (8737 8738) + (8731 8732) + (8726 8729) + (8722 8724) + (8720 8720) + (8716 8718) + (8713 8714) + (8708 8710) + (8705 8705) + (8692 8703) + (8680 8691) + (8661 8678) + (8659 8659) + (8656 8657) + (8654 8655) + (8634 8653) + (8623 8631) + (8622 8622) + (8615 8621) + (8614 8614) + (8612 8613) + (8611 8611) + (8609 8610) + (8608 8608) + (8604 8607) + (8602 8603) + (8586 8587) + (8581 8584) + (8579 8580) + (8570 8578) + (8556 8559) + (8543 8543) + (8533 8538) + (8528 8530) + (8527 8527) + (8526 8526) + (8524 8525) + (8523 8523) + (8522 8522) + (8517 8521) + (8512 8516) + (8508 8511) + (8506 8507) + (8505 8505) + (8501 8504) + (8495 8500) + (8494 8494) + (8492 8493) + (8490 8490) + (8489 8489) + (8488 8488) + (8487 8487) + (8485 8485) + (8484 8484) + (8483 8483) + (8478 8480) + (8473 8477) + (8472 8472) + (8471 8471) + (8469 8469) + (8468 8468) + (8458 8466) + (8456 8456) + (8455 8455) + (8454 8454) + (8452 8452) + (8450 8450) + (8448 8449) + (8365 8383) + (8362 8363) + (8352 8360) + (8336 8348) + (8334 8334) + (8333 8333) + (8330 8332) + (8325 8329) + (8320 8320) + (8318 8318) + (8317 8317) + (8314 8316) + (8309 8313) + (8305 8305) + (8304 8304) + (8294 8303) + (8288 8292) + (8287 8287) + (8277 8286) + (8276 8276) + (8275 8275) + (8274 8274) + (8263 8273) + (8262 8262) + (8261 8261) + (8260 8260) + (8257 8259) + (8255 8256) + (8252 8253) + (8250 8250) + (8249 8249) + (8246 8248) + (8244 8244) + (8241 8241) + (8239 8239) + (8234 8238) + (8233 8233) + (8232 8232) + (8227 8227) + (8223 8223) + (8222 8222) + (8219 8219) + (8218 8218) + (8215 8215) + (8209 8210) + (8203 8207) + (8192 8202) + (8189 8190) + (8182 8188) + (8178 8180) + (8173 8175) + (8160 8172) + (8157 8159) + (8150 8155) + (8144 8147) + (8141 8143) + (8134 8140) + (8130 8132) + (8127 8129) + (8126 8126) + (8125 8125) + (8118 8124) + (8064 8116) + (8031 8061) + (8029 8029) + (8027 8027) + (8025 8025) + (8016 8023) + (8008 8013) + (7968 8005) + (7960 7965) + (7936 7957) + (7680 7935) + (7579 7615) + (7552 7578) + (7545 7551) + (7544 7544) + (7531 7543) + (7468 7530) + (7424 7467) + (7418 7418) + (7416 7417) + (7415 7415) + (7413 7414) + (7412 7412) + (7406 7411) + (7405 7405) + (7401 7404) + (7394 7400) + (7393 7393) + (7380 7392) + (7379 7379) + (7376 7378) + (7360 7367) + (7357 7359) + (7312 7354) + (7296 7304) + (7294 7295) + (7288 7293) + (7258 7287) + (7248 7257) + (7245 7247) + (7232 7241) + (7227 7231) + (7222 7223) + (7220 7221) + (7212 7219) + (7204 7211) + (7168 7203) + (7164 7167) + (7154 7155) + (7151 7153) + (7150 7150) + (7149 7149) + (7146 7148) + (7144 7145) + (7143 7143) + (7142 7142) + (7104 7141) + (7098 7103) + (7088 7097) + (7086 7087) + (7083 7085) + (7082 7082) + (7080 7081) + (7078 7079) + (7074 7077) + (7073 7073) + (7043 7072) + (7042 7042) + (7040 7041) + (7028 7036) + (7009 7018) + (7002 7008) + (6992 7001) + (6981 6987) + (6979 6980) + (6978 6978) + (6973 6977) + (6972 6972) + (6971 6971) + (6966 6970) + (6965 6965) + (6964 6964) + (6917 6963) + (6916 6916) + (6912 6915) + (6824 6829) + (6823 6823) + (6816 6822) + (6800 6809) + (6784 6793) + (6771 6780) + (6765 6770) + (6757 6764) + (6755 6756) + (6754 6754) + (6753 6753) + (6752 6752) + (6744 6750) + (6743 6743) + (6742 6742) + (6741 6741) + (6688 6740) + (6686 6687) + (6683 6683) + (6681 6682) + (6679 6680) + (6656 6678) + (6624 6655) + (6622 6623) + (6618 6618) + (6608 6617) + (6576 6601) + (6528 6571) + (6512 6516) + (6480 6509) + (6470 6479) + (6468 6469) + (6464 6464) + (6457 6459) + (6451 6456) + (6450 6450) + (6448 6449) + (6441 6443) + (6439 6440) + (6435 6438) + (6432 6434) + (6400 6430) + (6320 6389) + (6314 6314) + (6313 6313) + (6279 6312) + (6277 6278) + (6272 6276) + (6212 6264) + (6211 6211) + (6176 6210) + (6160 6169) + (6158 6158) + (6155 6157) + (6151 6154) + (6150 6150) + (6144 6149) + (6128 6137) + (6112 6121) + (6109 6109) + (6108 6108) + (6107 6107) + (6104 6106) + (6103 6103) + (6100 6102) + (6089 6099) + (6087 6088) + (6086 6086) + (6078 6085) + (6071 6077) + (6070 6070) + (6068 6069) + (6016 6067) + (6002 6003) + (5998 6000) + (5984 5996) + (5970 5971) + (5952 5969) + (5941 5942) + (5938 5940) + (5920 5937) + (5906 5908) + (5902 5905) + (5888 5900) + (5873 5880) + (5870 5872) + (5867 5869) + (5792 5866) + (5788 5788) + (5787 5787) + (5761 5786) + (5760 5760) + (5743 5759) + (5742 5742) + (5741 5741) + (5121 5740) + (5120 5120) + (5112 5117) + (5024 5109) + (5008 5017) + (4992 5007) + (4969 4988) + (4960 4968) + (4888 4954) + (4882 4885) + (4824 4880) + (4808 4822) + (4802 4805) + (4800 4800) + (4792 4798) + (4786 4789) + (4752 4784) + (4746 4749) + (4704 4744) + (4698 4701) + (4696 4696) + (4688 4694) + (4682 4685) + (4608 4680) + (4448 4607) + (4349 4351) + (4348 4348) + (4347 4347) + (4304 4346) + (4301 4301) + (4295 4295) + (4256 4293) + (4254 4255) + (4253 4253) + (4250 4252) + (4240 4249) + (4239 4239) + (4238 4238) + (4237 4237) + (4231 4236) + (4229 4230) + (4227 4228) + (4226 4226) + (4213 4225) + (4209 4212) + (4206 4208) + (4199 4205) + (4197 4198) + (4194 4196) + (4193 4193) + (4190 4192) + (4186 4189) + (4184 4185) + (4182 4183) + (4176 4181) + (4170 4175) + (4160 4169) + (4159 4159) + (4157 4158) + (4155 4156) + (4153 4154) + (4152 4152) + (4146 4151) + (4145 4145) + (4141 4144) + (4139 4140) + (4096 4138) + (4057 4058) + (4053 4056) + (4048 4052) + (4046 4047) + (4039 4044) + (4038 4038) + (4030 4037) + (3993 4028) + (3981 3991) + (3976 3980) + (3974 3975) + (3973 3973) + (3968 3972) + (3967 3967) + (3953 3966) + (3913 3948) + (3904 3911) + (3902 3903) + (3901 3901) + (3900 3900) + (3899 3899) + (3898 3898) + (3897 3897) + (3896 3896) + (3895 3895) + (3894 3894) + (3893 3893) + (3892 3892) + (3882 3891) + (3872 3881) + (3866 3871) + (3864 3865) + (3861 3863) + (3860 3860) + (3859 3859) + (3844 3858) + (3841 3843) + (3840 3840) + (3804 3807) + (3792 3801) + (3784 3789) + (3782 3782) + (3776 3780) + (3773 3773) + (3764 3772) + (3762 3763) + (3761 3761) + (3751 3760) + (3749 3749) + (3724 3747) + (3718 3722) + (3716 3716) + (3713 3714) + (3674 3675) + (3664 3673) + (3663 3663) + (3655 3662) + (3654 3654) + (3648 3653) + (3647 3647) + (3636 3642) + (3634 3635) + (3633 3633) + (3585 3632) + (3572 3572) + (3570 3571) + (3558 3567) + (3544 3551) + (3542 3542) + (3538 3540) + (3535 3537) + (3530 3530) + (3520 3526) + (3517 3517) + (3507 3515) + (3482 3505) + (3461 3478) + (3458 3459) + (3457 3457) + (3450 3455) + (3449 3449) + (3440 3448) + (3430 3439) + (3426 3427) + (3423 3425) + (3416 3422) + (3415 3415) + (3412 3414) + (3407 3407) + (3406 3406) + (3405 3405) + (3402 3404) + (3398 3400) + (3393 3396) + (3390 3392) + (3389 3389) + (3387 3388) + (3346 3386) + (3342 3344) + (3332 3340) + (3330 3331) + (3313 3314) + (3302 3311) + (3298 3299) + (3296 3297) + (3294 3294) + (3285 3286) + (3276 3277) + (3274 3275) + (3271 3272) + (3270 3270) + (3264 3268) + (3263 3263) + (3262 3262) + (3261 3261) + (3260 3260) + (3253 3257) + (3242 3251) + (3218 3240) + (3214 3216) + (3205 3212) + (3204 3204) + (3202 3203) + (3201 3201) + (3200 3200) + (3199 3199) + (3192 3198) + (3191 3191) + (3174 3183) + (3170 3171) + (3168 3169) + (3160 3162) + (3157 3158) + (3146 3149) + (3142 3144) + (3137 3140) + (3134 3136) + (3133 3133) + (3114 3129) + (3090 3112) + (3086 3088) + (3077 3084) + (3073 3075) + (3066 3066) + (3065 3065) + (3059 3064) + (3056 3058) + (3046 3055) + (3031 3031) + (3024 3024) + (3021 3021) + (3018 3020) + (3014 3016) + (3009 3010) + (3008 3008) + (3006 3007) + (2990 3001) + (2984 2986) + (2979 2980) + (2974 2975) + (2972 2972) + (2969 2970) + (2962 2965) + (2958 2960) + (2949 2954) + (2947 2947) + (2946 2946) + (2930 2935) + (2929 2929) + (2928 2928) + (2918 2927) + (2914 2915) + (2911 2913) + (2908 2909) + (2903 2903) + (2901 2902) + (2893 2893) + (2891 2892) + (2887 2888) + (2881 2884) + (2880 2880) + (2879 2879) + (2878 2878) + (2877 2877) + (2876 2876) + (2869 2873) + (2866 2867) + (2858 2864) + (2835 2856) + (2831 2832) + (2821 2828) + (2818 2819) + (2817 2817) + (2810 2815) + (2809 2809) + (2801 2801) + (2800 2800) + (2790 2799) + (2786 2787) + (2784 2785) + (2768 2768) + (2765 2765) + (2763 2764) + (2761 2761) + (2759 2760) + (2753 2757) + (2750 2752) + (2749 2749) + (2748 2748) + (2741 2745) + (2738 2739) + (2730 2736) + (2707 2728) + (2703 2705) + (2693 2701) + (2691 2691) + (2689 2690) + (2678 2678) + (2677 2677) + (2674 2676) + (2672 2673) + (2662 2671) + (2654 2654) + (2649 2652) + (2641 2641) + (2635 2637) + (2631 2632) + (2625 2626) + (2622 2624) + (2620 2620) + (2616 2617) + (2613 2614) + (2610 2611) + (2602 2608) + (2579 2600) + (2575 2576) + (2565 2570) + (2563 2563) + (2561 2562) + (2558 2558) + (2557 2557) + (2556 2556) + (2555 2555) + (2554 2554) + (2548 2553) + (2546 2547) + (2544 2545) + (2534 2543) + (2530 2531) + (2527 2529) + (2524 2525) + (2519 2519) + (2510 2510) + (2509 2509) + (2507 2508) + (2503 2504) + (2497 2500) + (2494 2496) + (2493 2493) + (2492 2492) + (2486 2489) + (2482 2482) + (2474 2480) + (2451 2472) + (2447 2448) + (2437 2444) + (2434 2435) + (2433 2433) + (2432 2432) + (2418 2431) + (2417 2417) + (2416 2416) + (2406 2415) + (2404 2405) + (2402 2403) + (2392 2401) + (2385 2391) + (2384 2384) + (2382 2383) + (2381 2381) + (2377 2380) + (2369 2376) + (2366 2368) + (2365 2365) + (2364 2364) + (2363 2363) + (2362 2362) + (2308 2361) + (2307 2307) + (2304 2306) + (2275 2303) + (2274 2274) + (2259 2273) + (2230 2247) + (2208 2228) + (2144 2154) + (2142 2142) + (2137 2139) + (2112 2136) + (2096 2110) + (2089 2093) + (2088 2088) + (2085 2087) + (2084 2084) + (2075 2083) + (2074 2074) + (2070 2073) + (2048 2069) + (2046 2047) + (2045 2045) + (2042 2042) + (2039 2041) + (2038 2038) + (2036 2037) + (1994 2026) + (1984 1993) + (1969 1969) + (1958 1968) + (1920 1957) + (1872 1919) + (1869 1871) + (1840 1866) + (1810 1839) + (1809 1809) + (1808 1808) + (1807 1807) + (1792 1805) + (1791 1791) + (1789 1790) + (1786 1788) + (1776 1785) + (1774 1775) + (1770 1773) + (1769 1769) + (1767 1768) + (1765 1766) + (1759 1764) + (1758 1758) + (1757 1757) + (1750 1756) + (1749 1749) + (1748 1748) + (1649 1747) + (1648 1648) + (1646 1647) + (1642 1645) + (1632 1641) + (1611 1631) + (1601 1610) + (1600 1600) + (1568 1599) + (1566 1567) + (1564 1564) + (1563 1563) + (1552 1562) + (1550 1551) + (1548 1549) + (1547 1547) + (1545 1546) + (1542 1544) + (1536 1541) + (1523 1524) + (1519 1522) + (1488 1514) + (1479 1479) + (1478 1478) + (1476 1477) + (1475 1475) + (1473 1474) + (1472 1472) + (1471 1471) + (1470 1470) + (1425 1469) + (1423 1423) + (1421 1422) + (1418 1418) + (1417 1417) + (1376 1416) + (1370 1375) + (1369 1369) + (1329 1366) + (1280 1327) + (1162 1279) + (1154 1154) + (1106 1153) + (1104 1104) + (1026 1039) + (1024 1024) + (1015 1023) + (1014 1014) + (970 1013) + (962 962) + (938 944) + (910 912) + (908 908) + (904 906) + (903 903) + (902 902) + (900 901) + (895 895) + (894 894) + (891 893) + (890 890) + (886 887) + (885 885) + (884 884) + (880 883) + (751 767) + (750 750) + (749 749) + (748 748) + (741 747) + (736 740) + (734 734) + (732 732) + (722 727) + (721 721) + (718 719) + (716 716) + (712 712) + (710 710) + (709 709) + (706 707) + (688 705) + (661 687) + (660 660) + (610 659) + (594 608) + (592 592) + (477 591) + (475 475) + (473 473) + (471 471) + (469 469) + (467 467) + (465 465) + (463 463) + (452 461) + (448 451) + (444 447) + (443 443) + (384 442) + (364 383) + (360 362) + (340 357) + (334 337) + (332 332) + (325 327) + (323 323) + (313 318) + (308 311) + (300 304) + (296 298) + (284 293) + (276 282) + (274 274) + (258 272) + (256 256) + (255 255) + (253 253) + (251 251) + (244 246) + (241 241) + (238 239) + (235 235) + (231 231) + (226 229) + (217 221) + (209 214) + (199 207) + (192 197) + (187 187) + (181 181) + (171 171) + (169 169) + (160 160) + (128 159) + (127 127) + (0 31)) + (narrow + (10630 10630) + (10629 10629) + (10221 10221) + (10220 10220) + (10219 10219) + (10218 10218) + (10217 10217) + (10216 10216) + (10215 10215) + (10214 10214) + (175 175) + (172 172) + (166 166) + (165 165) + (162 163) + (126 126) + (125 125) + (124 124) + (123 123) + (97 122) + (96 96) + (95 95) + (94 94) + (93 93) + (92 92) + (91 91) + (65 90) + (63 64) + (60 62) + (58 59) + (48 57) + (46 47) + (45 45) + (44 44) + (43 43) + (42 42) + (41 41) + (40 40) + (37 39) + (36 36) + (33 35) + (32 32)) + (halfwidth + (65517 65518) + (65513 65516) + (65512 65512) + (65498 65500) + (65490 65495) + (65482 65487) + (65474 65479) + (65440 65470) + (65438 65439) + (65393 65437) + (65392 65392) + (65382 65391) + (65380 65381) + (65379 65379) + (65378 65378) + (65377 65377) + (8361 8361))))) + +(define-syntax-rule + (ranges->charset! name symbol) + (let* ((pairs (hashq-ref chars-ht name))) + (for-each + (λ (pair) + (ucs-range->char-set! + (first pair) + (+ (second pair) 1) + #t + symbol)) + pairs))) + +(define char-set:eastasian-combining (char-set)) +(define char-set:eastasian-doublewidth + (char-set)) +(define char-set:eastasian-halfwidth (char-set)) +(define char-set:eastasian-narrow (char-set)) +(define char-set:eastasian-neutral (char-set)) +(define char-set:eastasian-ambiguous (char-set)) + +(ranges->charset! + 'combining + char-set:eastasian-combining) +(ranges->charset! + 'doublewidth + char-set:eastasian-doublewidth) +(ranges->charset! + 'halfwidth + char-set:eastasian-halfwidth) +(ranges->charset! + 'narrow + char-set:eastasian-narrow) +(ranges->charset! + 'neutral + char-set:eastasian-neutral) +(ranges->charset! + 'ambiguous + char-set:eastasian-ambiguous) diff --git a/runewidth/emoji.scm b/runewidth/emoji.scm new file mode 100644 index 0000000..f198c56 --- /dev/null +++ b/runewidth/emoji.scm @@ -0,0 +1,509 @@ +;; Code generated by script/generate. DO NOT EDIT + +(define-module + (runewidth emoji) + #:use-module + (srfi srfi-1) + #:export + (char-set:emoji)) +(define emoji-list + '((130048 131069) + (129751 129791) + (129744 129750) + (129731 129743) + (129728 129730) + (129719 129727) + (129712 129718) + (129705 129711) + (129686 129704) + (129680 129685) + (129671 129679) + (129667 129670) + (129664 129666) + (129659 129663) + (129656 129658) + (129653 129655) + (129652 129652) + (129648 129651) + (129536 129647) + (129511 129535) + (129488 129510) + (129485 129487) + (129484 129484) + (129483 129483) + (129475 129482) + (129473 129474) + (129472 129472) + (129466 129471) + (129456 129465) + (129454 129455) + (129451 129453) + (129445 129450) + (129443 129444) + (129432 129442) + (129426 129431) + (129413 129425) + (129408 129412) + (129404 129407) + (129403 129403) + (129402 129402) + (129401 129401) + (129399 129400) + (129395 129398) + (129394 129394) + (129393 129393) + (129388 129392) + (129375 129387) + (129360 129374) + (129357 129359) + (129356 129356) + (129351 129355) + (129344 129349) + (129343 129343) + (129340 129342) + (129331 129338) + (129329 129330) + (129328 129328) + (129320 129327) + (129312 129319) + (129311 129311) + (129305 129310) + (129296 129304) + (129293 129295) + (129292 129292) + (129198 129279) + (129160 129167) + (129114 129119) + (129096 129103) + (129036 129039) + (129004 129023) + (128992 129003) + (128981 128991) + (128884 128895) + (128765 128767) + (128763 128764) + (128762 128762) + (128761 128761) + (128759 128760) + (128756 128758) + (128755 128755) + (128753 128754) + (128752 128752) + (128749 128751) + (128747 128748) + (128746 128746) + (128745 128745) + (128742 128744) + (128736 128741) + (128728 128735) + (128726 128727) + (128725 128725) + (128723 128724) + (128721 128722) + (128720 128720) + (128717 128719) + (128716 128716) + (128715 128715) + (128710 128714) + (128705 128709) + (128704 128704) + (128703 128703) + (128697 128702) + (128695 128696) + (128694 128694) + (128691 128693) + (128690 128690) + (128686 128689) + (128679 128685) + (128678 128678) + (128676 128677) + (128675 128675) + (128674 128674) + (128667 128673) + (128665 128666) + (128664 128664) + (128663 128663) + (128662 128662) + (128661 128661) + (128660 128660) + (128657 128659) + (128656 128656) + (128655 128655) + (128654 128654) + (128653 128653) + (128652 128652) + (128650 128651) + (128649 128649) + (128648 128648) + (128647 128647) + (128646 128646) + (128643 128645) + (128641 128642) + (128640 128640) + (128581 128591) + (128577 128580) + (128567 128576) + (128566 128566) + (128565 128565) + (128564 128564) + (128560 128563) + (128558 128559) + (128557 128557) + (128556 128556) + (128552 128555) + (128550 128551) + (128544 128549) + (128543 128543) + (128540 128542) + (128539 128539) + (128538 128538) + (128537 128537) + (128536 128536) + (128535 128535) + (128534 128534) + (128533 128533) + (128530 128532) + (128529 128529) + (128528 128528) + (128527 128527) + (128526 128526) + (128521 128525) + (128519 128520) + (128513 128518) + (128512 128512) + (128507 128511) + (128506 128506) + (128500 128505) + (128499 128499) + (128496 128498) + (128495 128495) + (128489 128494) + (128488 128488) + (128484 128487) + (128483 128483) + (128482 128482) + (128481 128481) + (128479 128480) + (128476 128478) + (128468 128475) + (128465 128467) + (128453 128464) + (128450 128452) + (128445 128449) + (128444 128444) + (128435 128443) + (128433 128434) + (128425 128432) + (128424 128424) + (128422 128423) + (128421 128421) + (128420 128420) + (128407 128419) + (128405 128406) + (128401 128404) + (128400 128400) + (128398 128399) + (128394 128397) + (128392 128393) + (128391 128391) + (128379 128390) + (128378 128378) + (128371 128377) + (128369 128370) + (128367 128368) + (128360 128366) + (128348 128359) + (128336 128347) + (128335 128335) + (128331 128334) + (128329 128330) + (128326 128328) + (128302 128317) + (128300 128301) + (128278 128299) + (128277 128277) + (128266 128276) + (128265 128265) + (128264 128264) + (128260 128263) + (128259 128259) + (128255 128258) + (128254 128254) + (128253 128253) + (128249 128252) + (128248 128248) + (128246 128247) + (128245 128245) + (128240 128244) + (128239 128239) + (128238 128238) + (128236 128237) + (128184 128235) + (128182 128183) + (128174 128181) + (128173 128173) + (128110 128172) + (128108 128109) + (128102 128107) + (128101 128101) + (128066 128100) + (128065 128065) + (128064 128064) + (128063 128063) + (128043 128062) + (128042 128042) + (128023 128041) + (128022 128022) + (128021 128021) + (128020 128020) + (128019 128019) + (128017 128018) + (128015 128016) + (128012 128014) + (128009 128011) + (128008 128008) + (128000 128007) + (127992 127994) + (127991 127991) + (127990 127990) + (127989 127989) + (127988 127988) + (127987 127987) + (127985 127986) + (127973 127984) + (127972 127972) + (127968 127971) + (127956 127967) + (127951 127955) + (127947 127950) + (127946 127946) + (127945 127945) + (127944 127944) + (127943 127943) + (127942 127942) + (127941 127941) + (127904 127940) + (127902 127903) + (127900 127901) + (127897 127899) + (127896 127896) + (127894 127895) + (127892 127893) + (127872 127891) + (127870 127871) + (127869 127869) + (127868 127868) + (127825 127867) + (127824 127824) + (127820 127823) + (127819 127819) + (127799 127818) + (127798 127798) + (127796 127797) + (127794 127795) + (127792 127793) + (127789 127791) + (127780 127788) + (127778 127779) + (127777 127777) + (127775 127776) + (127773 127774) + (127772 127772) + (127771 127771) + (127770 127770) + (127769 127769) + (127766 127768) + (127763 127765) + (127762 127762) + (127761 127761) + (127760 127760) + (127759 127759) + (127757 127758) + (127744 127756) + (127570 127743) + (127568 127569) + (127561 127567) + (127548 127551) + (127538 127546) + (127535 127535) + (127514 127514) + (127491 127503) + (127489 127490) + (127405 127461) + (127377 127386) + (127374 127374) + (127358 127359) + (127344 127345) + (127340 127343) + (127279 127279) + (127245 127247) + (127184 127231) + (127183 127183) + (126981 127182) + (126980 126980) + (126976 126979) + (12953 12953) + (12951 12951) + (12349 12349) + (12336 12336) + (11093 11093) + (11088 11088) + (11035 11036) + (11013 11015) + (10548 10549) + (10175 10175) + (10160 10160) + (10145 10145) + (10133 10135) + (10085 10087) + (10084 10084) + (10083 10083) + (10071 10071) + (10067 10069) + (10062 10062) + (10060 10060) + (10055 10055) + (10052 10052) + (10035 10036) + (10024 10024) + (10017 10017) + (10013 10013) + (10006 10006) + (10004 10004) + (10002 10002) + (10000 10001) + (9999 9999) + (9998 9998) + (9997 9997) + (9992 9996) + (9989 9989) + (9987 9988) + (9986 9986) + (9982 9985) + (9981 9981) + (9979 9980) + (9978 9978) + (9975 9977) + (9974 9974) + (9973 9973) + (9972 9972) + (9970 9971) + (9968 9969) + (9963 9967) + (9962 9962) + (9961 9961) + (9941 9960) + (9940 9940) + (9939 9939) + (9938 9938) + (9937 9937) + (9936 9936) + (9935 9935) + (9934 9934) + (9929 9933) + (9928 9928) + (9926 9927) + (9924 9925) + (9919 9923) + (9917 9918) + (9906 9916) + (9904 9905) + (9900 9903) + (9898 9899) + (9896 9897) + (9895 9895) + (9890 9894) + (9888 9889) + (9885 9887) + (9883 9884) + (9882 9882) + (9881 9881) + (9880 9880) + (9878 9879) + (9877 9877) + (9876 9876) + (9875 9875) + (9874 9874) + (9872 9873) + (9856 9861) + (9855 9855) + (9854 9854) + (9852 9853) + (9851 9851) + (9833 9850) + (9832 9832) + (9831 9831) + (9829 9830) + (9828 9828) + (9827 9827) + (9825 9826) + (9824 9824) + (9823 9823) + (9812 9822) + (9800 9811) + (9795 9799) + (9794 9794) + (9793 9793) + (9792 9792) + (9787 9791) + (9786 9786) + (9784 9785) + (9776 9783) + (9775 9775) + (9774 9774) + (9771 9773) + (9770 9770) + (9767 9769) + (9766 9766) + (9764 9765) + (9762 9763) + (9761 9761) + (9760 9760) + (9758 9759) + (9757 9757) + (9753 9756) + (9752 9752) + (9750 9751) + (9748 9749) + (9746 9746) + (9745 9745) + (9743 9744) + (9742 9742) + (9735 9741) + (9733 9733) + (9732 9732) + (9730 9731) + (9728 9729) + (9723 9726) + (9664 9664) + (9654 9654) + (9642 9643) + (9410 9410) + (9208 9210) + (9203 9203) + (9201 9202) + (9200 9200) + (9199 9199) + (9197 9198) + (9193 9196) + (9167 9167) + (9096 9096) + (9000 9000) + (8986 8987) + (8617 8618) + (8596 8601) + (8505 8505) + (8482 8482) + (8265 8265) + (8252 8252))) + +(define char-set:emoji (char-set)) + +(for-each + (λ (pair) + (ucs-range->char-set! + (first pair) + (+ 1 (second pair)) + #t + char-set:emoji)) + emoji-list) diff --git a/runewidth/internal.scm b/runewidth/internal.scm new file mode 100644 index 0000000..863d455 --- /dev/null +++ b/runewidth/internal.scm @@ -0,0 +1,67 @@ +(define-module (runewidth internal) + #:use-module (ice-9 peg) + #:use-module (ice-9 textual-ports) + #:use-module (ice-9 exceptions) + #:use-module (ice-9 i18n) + #:use-module (web uri) + #:use-module (web client) + #:use-module (web request) + #:use-module (srfi srfi-71) + #:export (@hex + @codepoint + @codepoint-range + @comment + @ws + hex-string->integer + format-exception-msg + in-surrogate-range + wget-to-lines + file-to-lines)) + +(define-peg-pattern @hex body (peg "[a-fA-F0-9]")) + +(define-peg-pattern @codepoint all + (* @hex)) + +(define-peg-pattern @codepoint-range all + (or + (and @codepoint (ignore "..") @codepoint) + @codepoint)) + + +(define-peg-pattern @comment all + (and (ignore "#") (* peg-any))) + +(define-peg-pattern @ws none + (or " " "\t")) + +(define (hex-string->integer str) + ;; XXX: We would ideally do integer->char here and save it to file as such + ;; However read-expr* does not actually work for all the characters! + ;; So they can't be written out as such. + (locale-string->integer str 16)) + +(define (format-exception-msg port err) + (apply format port (exception-message err) (exception-irritants err)) + (display "\n" port)) + +(define (in-surrogate-range num) + (and (>= num #xd800) + (<= num #xdfff))) + + +(define* (wget-to-lines url #:optional (port #f)) + (format port "Downloading from ~a..." url) + + (let* ((response body (http-get (string->uri url))) + (lines (string-split body #\newline))) + (format port " done.\n") + lines)) + +(define* (file-to-lines path #:optional (port #f)) + (format port "Loading from local file ~a\n" path) + (string-split + (with-input-from-file path + (λ () (get-string-all (current-input-port)))) #\newline)) + + diff --git a/scripts/generate-east-asian.in b/scripts/generate-east-asian.in new file mode 100644 index 0000000..aba5aff --- /dev/null +++ b/scripts/generate-east-asian.in @@ -0,0 +1,165 @@ +#!@GUILE@ --no-auto-compile +-*- scheme -*- +!# + +;; Can be called with a trailing argument pointing to the file on disk. + +(use-modules + (runewidth internal) + (ice-9 pretty-print) + (ice-9 peg) + (ice-9 format) + (ice-9 exceptions) + (ice-9 match) + (ice-9 hash-table) + (srfi srfi-1)) + +(define stdout (current-output-port)) + +(define east-asian-url + "https://unicode.org/Public/13.0.0/ucd/EastAsianWidth.txt") + +(define-peg-pattern @ea-width-prop all + (or "A" "F" "H" "Na" "N" "W")) + +(define-peg-pattern @ea-datum body + (and @codepoint-range (* @ws) (ignore ";") (* @ws) @ea-width-prop)) + +(define-peg-pattern @ea-line body + (and @ea-datum (* @ws) @comment)) + +(define ea-chars-ht (make-hash-table 6)) + +(define (process-east-asian-line line) + (define (cons-ht! key low high) + (let* ((old (hashq-ref ea-chars-ht key)) + (value (list low high)) + (new-lst + (if old + (cons value old) + (list value)))) + (hashq-set! ea-chars-ht key new-lst))) + + (define tree (peg:tree (match-pattern @ea-line line))) + + (unless (or (not tree) + (null? tree) + (eq? '@comment (car tree))) + + (match tree + (((('@codepoint-range + ('@codepoint codepoints) ...) + ('@ea-width-prop width-prop)) + ('@comment comment)) + + (with-exception-handler + (λ (err) + (format stdout "Skipping line due to error :: ") + (format-exception-msg stdout err)) + (λ () + (let ((f (hex-string->integer (first codepoints))) + (l (hex-string->integer (last codepoints)))) + + (when (or (in-surrogate-range f) + (in-surrogate-range l)) + (error (format #f "chars in surrogate range ~x -> ~x" f l))) + + (if (string-contains comment "COMBINING") + (cons-ht! 'combining f l) + (match width-prop + ((or "W" "F") + (cons-ht! 'doublewidth f l)) + ("H" + (cons-ht! 'halfwidth f l)) + ("Na" + (cons-ht! 'narrow f l)) + ("N" + (cons-ht! 'neutral f l)) + ("A" + (cons-ht! 'ambiguous f l)))))) + #:unwind? #t))))) + +(define ea-sets + '(combining + doublewidth + halfwidth + narrow + neutral + ambiguous)) + +(define ea-symbol-names + (map + (λ (set) + (string->symbol + (string-concatenate + (list "char-set:eastasian-" + (symbol->string set))))) + ea-sets)) + +(define ea-sets-and-symbols + (zip ea-sets ea-symbol-names)) + + +(define line-func + (if (= 2 (length (command-line))) + (λ () + (file-to-lines (last (command-line)) stdout)) + (λ () + (wget-to-lines east-asian-url stdout)))) + +(define file "runewidth/eastasian.scm") + +(format stdout "Writing to ~a...\n" file) + +(with-output-to-file file + (λ () + (display ";; Code generated by script/generate. DO NOT EDIT\n\n") + + (for-each process-east-asian-line (line-func)) + + (pretty-print + `(define-module (runewidth eastasian) + #:use-module (ice-9 hash-table) + #:use-module (srfi srfi-1) + #:export + ,ea-symbol-names)) + + (pretty-print + `(define chars-ht + (alist->hashq-table ',(hash-map->list cons ea-chars-ht)))) + + (display "\n") + + (pretty-print + `(define-syntax-rule (ranges->charset! name symbol) + (let* ((pairs (hashq-ref chars-ht name))) + (for-each + (λ (pair) + (ucs-range->char-set! + (first pair) + ;; Exclusive upper range, so add one + (+ (second pair) 1) + #t symbol)) + pairs)))) + + (display "\n") + + (for-each + (λ (sym) + (pretty-print + `(define ,sym (char-set)))) + ea-symbol-names) + + (display "\n") + + (for-each + (λ (set-pair) + (let ((name (first set-pair)) + (symbol (second set-pair))) + (pretty-print + `(ranges->charset! ',name ,symbol)))) + ea-sets-and-symbols) + + (display "Code generation complete.\n" stdout))) + +(format stdout "Written to ~a.\n" file) diff --git a/scripts/generate-emoji.in b/scripts/generate-emoji.in new file mode 100644 index 0000000..6f2acda --- /dev/null +++ b/scripts/generate-emoji.in @@ -0,0 +1,109 @@ +#!@GUILE@ --no-auto-compile +-*- scheme -*- +!# + +;; Can be called with a trailing argument pointing to the file on disk. + +(use-modules + (runewidth internal) + (ice-9 pretty-print) + (ice-9 peg) + (ice-9 format) + (ice-9 exceptions) + (ice-9 match) + (srfi srfi-1)) + +(define stdout (current-output-port)) + +(define emoji-url + "https://unicode.org/Public/13.0.0/ucd/emoji/emoji-data.txt") + +(define-peg-pattern @emoji-category all + (* (peg "[a-zA-Z_]"))) + +(define-peg-pattern @emoji-datum body + (and @codepoint-range (* @ws) (ignore ";") (* @ws) @emoji-category)) + +(define-peg-pattern @emoji-line body + (and @emoji-datum (* @ws) @comment)) + +(define emoji-list '()) + +(define (process-emoji-line line) + (define tree (peg:tree (match-pattern @emoji-line line))) + + (define (in-surrogate-range num) + (and (>= num #xd800) + (<= num #xdfff))) + + (unless (or (not tree) + (null? tree) + (eq? '@comment (car tree))) + + (match tree + (((('@codepoint-range + ('@codepoint codepoints) ...) + ('@emoji-category category)) + ('@comment comment)) + + (with-exception-handler + (λ (err) + (format stdout "Skipping line due to error :: ") + (format-exception-msg stdout err)) + (λ () + (let ((f (hex-string->integer (first codepoints))) + (l (hex-string->integer (last codepoints)))) + + (when (or (in-surrogate-range f) + (in-surrogate-range l)) + (error (format #f "chars in surrogate range ~x -> ~x" f l))) + + (when (and (equal? "Extended_Pictographic" category) + (> l #xFF)) + (set! emoji-list (cons (list f l) emoji-list))))) + #:unwind? #t))))) + +(define line-func + (if (= 2 (length (command-line))) + (λ () + (file-to-lines (last (command-line)) stdout)) + (λ () + (wget-to-lines emoji-url stdout)))) + +(define file "runewidth/emoji.scm") + +(format stdout "Writing to ~a...\n" file) + +(with-output-to-file file + (λ () + (display ";; Code generated by script/generate. DO NOT EDIT\n\n") + + (for-each process-emoji-line (line-func)) + + (pretty-print + `(define-module (runewidth emoji) + #:use-module (srfi srfi-1) + #:export (char-set:emoji))) + + (pretty-print + `(define emoji-list ',emoji-list)) + + (display "\n") + + (pretty-print + `(define char-set:emoji (char-set))) + + (display "\n") + + (pretty-print + `(for-each + (λ (pair) + (ucs-range->char-set! + (first pair) + (+ 1 (second pair)) + #t char-set:emoji)) + emoji-list)) + + (display "Code generation complete.\n" stdout))) + +(format stdout "Written to ~a.\n" file) diff --git a/scripts/generate.in b/scripts/generate.in deleted file mode 100644 index 9b57a99..0000000 --- a/scripts/generate.in +++ /dev/null @@ -1,61 +0,0 @@ -#!@GUILE@ --no-auto-compile --*- scheme -*- -!# - -(use-modules - (ice-9 pretty-print) - (ice-9 peg) - (web uri) - (web request)) - -(define stdout (current-output-port)) - -(define east-asian-url - "https://unicode.org/Public/13.0.0/ucd/EastAsianWidth.txt") - -(define emoji-url - "https://unicode.org/Public/13.0.0/ucd/emoji/emoji-data.txt") - -(define-peg-pattern @hex body (peg "[a-fA-F0-9]")) - -(define-peg-pattern @codepoint all - (* @hex)) - -(define-peg-pattern @ea-width-prop all - (or "A" "F" "H" "N" "Na" "W")) - -(define-peg-pattern @codepoint-range all - (or - (and @codepoint (ignore "..") @codepoint) - @codepoint)) - -(define-peg-pattern @ea-datum body - (and @codepoint-range (ignore ";") @ea-width-prop)) - -(define-peg-pattern @comment none - (and "#" peg-any)) - -(define-peg-pattern @ea-line body - (and (? @ea-datum) (? @comment))) - - -(define (process-east-asian-line line) - (let ((tree (peg:tree (match-pattern @ea-line line)))) - (unless (null? tree) - (pk tree)))) - - -(define (wget-to-lines url) - (string-split (http-get (string->uri url)) #\newline)) - -(with-output-to-file "../runewidth/table.scm" - (λ () - - (display ";; Code generated by script/generate. DO NOT EDIT\n\n") - (display "(define-module (runewidth table))\n\n") - - (format "Downloading and processing from ~a..." east-asian-url) - (for-each process-east-asian-line (wget-to-lines east-asian-url))) - - (format "Downloading and processing from ~a..." emoji-url) - (for-each process-emoji-line (wget-to-lines emoji-url))))