From 810aaadc491601e9c6b5d64f938fd1b1ac34c11f Mon Sep 17 00:00:00 2001 From: Giftpflanze Date: Thu, 7 Mar 2024 21:33:55 +0100 Subject: [PATCH] libc: Add setlocale and LC_* constants --- basis/libc/freebsd/freebsd.factor | 8 ++++++++ basis/libc/libc.factor | 2 ++ basis/libc/linux/linux.factor | 14 ++++++++++++++ basis/libc/macosx/macosx.factor | 8 ++++++++ basis/libc/windows/windows.factor | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/basis/libc/freebsd/freebsd.factor b/basis/libc/freebsd/freebsd.factor index c98b26f6cd..f9221d3727 100644 --- a/basis/libc/freebsd/freebsd.factor +++ b/basis/libc/freebsd/freebsd.factor @@ -140,3 +140,11 @@ CONSTANT: EBADMSG 89 CONSTANT: EMULTIHOP 90 CONSTANT: ENOLINK 91 CONSTANT: EPROTO 92 + +CONSTANT: LC_ALL 0 +CONSTANT: LC_COLLATE 1 +CONSTANT: LC_CTYPE 2 +CONSTANT: LC_MONETARY 3 +CONSTANT: LC_NUMERIC 4 +CONSTANT: LC_TIME 5 +CONSTANT: LC_MESSAGES 6 diff --git a/basis/libc/libc.factor b/basis/libc/libc.factor index 38bc8f73d7..75afc27c68 100644 --- a/basis/libc/libc.factor +++ b/basis/libc/libc.factor @@ -123,5 +123,7 @@ FUNCTION: int system ( c-string command ) DESTRUCTOR: free +FUNCTION: c-string setlocale ( int category, c-string locale ) + ! For libc.linux, libc.windows, libc.macosx... << "libc." os name>> append require >> diff --git a/basis/libc/linux/linux.factor b/basis/libc/linux/linux.factor index b390b29594..7f96c68f77 100644 --- a/basis/libc/linux/linux.factor +++ b/basis/libc/linux/linux.factor @@ -176,3 +176,17 @@ M: linux strerror [ 1024 [ malloc &free ] keep strerror_r ] with-destructors ; + +CONSTANT: LC_CTYPE 0 +CONSTANT: LC_NUMERIC 1 +CONSTANT: LC_TIME 2 +CONSTANT: LC_COLLATE 3 +CONSTANT: LC_MONETARY 4 +CONSTANT: LC_MESSAGES 5 +CONSTANT: LC_ALL 6 +CONSTANT: LC_PAPER 7 +CONSTANT: LC_NAME 8 +CONSTANT: LC_ADDRESS 9 +CONSTANT: LC_TELEPHONE 10 +CONSTANT: LC_MEASUREMENT 11 +CONSTANT: LC_IDENTIFICATION 12 diff --git a/basis/libc/macosx/macosx.factor b/basis/libc/macosx/macosx.factor index ba6dfcf6a0..5f73c77e08 100644 --- a/basis/libc/macosx/macosx.factor +++ b/basis/libc/macosx/macosx.factor @@ -148,3 +148,11 @@ M: macosx strerror 1024 [ malloc &free ] keep [ strerror_r ] keepd nip alien>native-string ] with-destructors ; + +CONSTANT: LC_ALL 0 +CONSTANT: LC_COLLATE 1 +CONSTANT: LC_CTYPE 2 +CONSTANT: LC_MONETARY 3 +CONSTANT: LC_NUMERIC 4 +CONSTANT: LC_TIME 5 +CONSTANT: LC_MESSAGES 6 diff --git a/basis/libc/windows/windows.factor b/basis/libc/windows/windows.factor index 79dc9653fb..386fe44d55 100644 --- a/basis/libc/windows/windows.factor +++ b/basis/libc/windows/windows.factor @@ -114,3 +114,11 @@ M: windows strerror [ strerror_s drop ] keepdd utf8 alien>string ] with-destructors ; + +! These are uncertain: +CONSTANT: LC_ALL 0 +CONSTANT: LC_COLLATE 1 +CONSTANT: LC_CTYPE 2 +CONSTANT: LC_MONETARY 3 +CONSTANT: LC_NUMERIC 4 +CONSTANT: LC_TIME 5 -- 2.34.1