Reorganize, fix a bug with string shared
This commit is contained in:
parent
470b20a74c
commit
5b440bbb64
3 changed files with 24 additions and 12 deletions
9
hall.scm
9
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")))))
|
||||
|
|
|
@ -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
|
|
@ -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")
|
Loading…
Reference in a new issue