aboutsummaryrefslogtreecommitdiff
path: root/pseudocode-lib
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-20 11:02:36 +0000
committer_ov4 <ov4@ov4.org>2026-10-20 11:02:36 +0000
commit496c020541d4d35e5800b813b3f8d113a8f2b90b (patch)
tree938a85ff36482af576ecbdd9cd3745ee6d25a336 /pseudocode-lib
parenta1ba45b28c94244d2e1c6f00372d51d294cc3edc (diff)
feat(library): add experimental string UCASE overloads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'pseudocode-lib')
-rw-r--r--pseudocode-lib/README.md2
-rw-r--r--pseudocode-lib/_exp_string.cc12
-rw-r--r--pseudocode-lib/_exp_string.cps10
3 files changed, 24 insertions, 0 deletions
diff --git a/pseudocode-lib/README.md b/pseudocode-lib/README.md
index 8049ede..bd646ee 100644
--- a/pseudocode-lib/README.md
+++ b/pseudocode-lib/README.md
@@ -26,3 +26,5 @@ The library provides `&`, `_EXP_STRING_NUM_TO_STR` (INTEGER/REAL), `_EXP_STRING_
`_EXP_STRING_MID(S : _EXP_STRING, Start : INTEGER, Count : INTEGER)` returns a new `_EXP_STRING` containing up to Count bytes from the one-based Start position. Starts below 1 clamp to 1; starts beyond the end and nonpositive counts return an empty string. Counts clamp to the remaining bytes. Embedded NUL bytes are preserved.
`_EXP_STRING_LCASE(S : _EXP_STRING)` returns a new `_EXP_STRING` with letters converted to lower case. Its `(Ch : CHAR)` overload returns CHAR, following guide section 5.5. Nonletters and embedded NUL bytes are preserved; the source is unchanged. Use ASCII for predictable case conversion.
+
+`_EXP_STRING_UCASE(S : _EXP_STRING)` returns a new `_EXP_STRING` with letters converted to upper case. Its `(Ch : CHAR)` overload returns CHAR, following guide section 5.5. Nonletters and embedded NUL bytes are preserved; the source is unchanged. Use ASCII for predictable case conversion.
diff --git a/pseudocode-lib/_exp_string.cc b/pseudocode-lib/_exp_string.cc
index 6155319..bd476b8 100644
--- a/pseudocode-lib/_exp_string.cc
+++ b/pseudocode-lib/_exp_string.cc
@@ -101,6 +101,18 @@ char _exp_string_impl_lcase_char(char Ch) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(Ch)));
});
}
+void _exp_string_impl_ucase(void *Target, void *Handle) {
+ checked([&] {
+ text(Target) = text(Handle);
+ for (char &Ch : text(Target))
+ Ch = static_cast<char>(std::toupper(static_cast<unsigned char>(Ch)));
+ });
+}
+char _exp_string_impl_ucase_char(char Ch) {
+ return checked([&] {
+ return static_cast<char>(std::toupper(static_cast<unsigned char>(Ch)));
+ });
+}
void _exp_string_impl_output(void *Handle) {
checked([&] {
const auto &Text = text(Handle);
diff --git a/pseudocode-lib/_exp_string.cps b/pseudocode-lib/_exp_string.cps
index a25b3ef..a56ed04 100644
--- a/pseudocode-lib/_exp_string.cps
+++ b/pseudocode-lib/_exp_string.cps
@@ -19,6 +19,8 @@ EXTERN "C" EXTERN_PROCEDURE _exp_string_impl_right(_EXP_STRING_HANDLE, _EXP_STRI
EXTERN "C" EXTERN_PROCEDURE _exp_string_impl_mid(_EXP_STRING_HANDLE, _EXP_STRING_HANDLE, _EXP_STRING_C_INTEGER, _EXP_STRING_C_INTEGER)
EXTERN "C" EXTERN_PROCEDURE _exp_string_impl_lcase(_EXP_STRING_HANDLE, _EXP_STRING_HANDLE)
EXTERN "C" EXTERN_FUNCTION _exp_string_impl_lcase_char(C_CHAR) RETURNS C_CHAR
+EXTERN "C" EXTERN_PROCEDURE _exp_string_impl_ucase(_EXP_STRING_HANDLE, _EXP_STRING_HANDLE)
+EXTERN "C" EXTERN_FUNCTION _exp_string_impl_ucase_char(C_CHAR) RETURNS C_CHAR
EXTERN "C" EXTERN_PROCEDURE _exp_string_impl_output(_EXP_STRING_HANDLE)
CLASS _EXP_STRING
@@ -93,3 +95,11 @@ ENDFUNCTION
OVERLOAD FUNCTION _EXP_STRING_LCASE(Ch : CHAR) RETURNS CHAR
RETURN (CHAR)_exp_string_impl_lcase_char((C_CHAR)Ch)
ENDFUNCTION
+OVERLOAD FUNCTION _EXP_STRING_UCASE(S : _EXP_STRING) RETURNS _EXP_STRING
+ DECLARE Result : _EXP_STRING
+ CALL _exp_string_impl_ucase(Result._HANDLE, S._HANDLE)
+ RETURN Result
+ENDFUNCTION
+OVERLOAD FUNCTION _EXP_STRING_UCASE(Ch : CHAR) RETURNS CHAR
+ RETURN (CHAR)_exp_string_impl_ucase_char((C_CHAR)Ch)
+ENDFUNCTION