diff --git a/hall.scm b/hall.scm index 1ada03c..3cfe209 100644 --- a/hall.scm +++ b/hall.scm @@ -22,10 +22,14 @@ ((directory "runewidth" ((scheme-file "emoji") + (directory "eastasian" + ((scheme-file "locale"))) (scheme-file "eastasian") (scheme-file "internal"))) (scheme-file "runewidth"))) - (tests ((directory "tests" ((scheme-file "test-posix"))))) + (tests ((directory + "tests" + ((scheme-file "test-eastasian-locale"))))) (programs ((directory "scripts" @@ -40,5 +44,4 @@ (infrastructure ((scheme-file "guix") (text-file ".gitignore") - (scheme-file "hall") - (directory "tests" ((scheme-file "test-posix"))))))) + (scheme-file "hall"))))) diff --git a/runewidth/posix.scm b/runewidth/eastasian/locale.scm similarity index 86% rename from runewidth/posix.scm rename to runewidth/eastasian/locale.scm index 89f4fc2..4eb0c1e 100644 --- a/runewidth/posix.scm +++ b/runewidth/eastasian/locale.scm @@ -1,6 +1,6 @@ -(define-module (runewidth posix) +(define-module (runewidth eastasian locale) #:use-module (ice-9 regex) - #:export (east-asian?)) + #:export (eastasian-locale?)) (define wide-locales (list @@ -36,7 +36,7 @@ (getenv "LANG") "")) -(define* (east-asian? #:optional (locale (get-env-locale))) +(define* (eastasian-locale? #:optional (locale (get-env-locale))) "Check if a given locale (or the currently installed locale from the environment) is considered an east asian locale" (unless (string? locale) (error "`locale' must be a string")) @@ -52,13 +52,19 @@ (match:substring locale-match 2))) locale))) + (pk locale) + (pk charset) + (and (not (regexp-exec c-or-posix-regexp locale)) (not (string-suffix? "@cjk_narrow" charset)) (let ((index-@ (string-index charset #\@))) ;; strip @foo from the end of the charset (when index-@ - (set! charset (substring/shared charset 0 index-@))) + (set! charset (substring charset 0 index-@))) + + (pk charset) + (pk locale) (and (member charset wide-locales) (or diff --git a/tests/test-posix.scm b/tests/test-eastasian-locale.scm similarity index 55% rename from tests/test-posix.scm rename to tests/test-eastasian-locale.scm index efc1d68..0872005 100644 --- a/tests/test-posix.scm +++ b/tests/test-eastasian-locale.scm @@ -1,11 +1,14 @@ -(define-module (tests test-posix) - #:use-module (runewidth posix) +(define-module (tests test-eastasian-locale) + #:use-module (runewidth eastasian locale) #:use-module (srfi srfi-64)) -(test-begin "test-posix") +(test-begin "test-eastasian-locale") (define (test-east expected charset) - (test-equal expected (east-asian? charset))) + (test-equal + (format #f "check ~a" charset) + expected + (eastasian-locale? charset))) (define data '((#f "foo@cjk_narrow") @@ -20,4 +23,4 @@ (for-each (λ (p) (apply test-east p)) data) -(test-end "test-posix") +(test-end "test-eastasian-locale")