aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-11-23 15:30:56 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-23 18:07:39 +0300
commitfcfcc12f5f00bc2f646f4fe4f02d5ffed4a683dc (patch)
treee1be8dd9d4a7de5995a91f8b4c68dff442c30426 /libbuild2
parentf08aeee5272454c8c8eec73d0898bcbf9383e1b8 (diff)
Add $string.lcase() and $string.ucase() functions
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/functions-string.cxx22
-rw-r--r--libbuild2/utility.hxx1
2 files changed, 23 insertions, 0 deletions
diff --git a/libbuild2/functions-string.cxx b/libbuild2/functions-string.cxx
index f458a59..c5cb216 100644
--- a/libbuild2/functions-string.cxx
+++ b/libbuild2/functions-string.cxx
@@ -55,6 +55,28 @@ namespace build2
return names {name (trim (convert<string> (move (s))))};
};
+ // Convert ASCII strings into lower/upper case.
+ //
+ f["lcase"] = [](string s)
+ {
+ return lcase (move (s));
+ };
+
+ f[".lcase"] = [](names s)
+ {
+ return names {name (lcase (convert<string> (move (s))))};
+ };
+
+ f["ucase"] = [](string s)
+ {
+ return ucase (move (s));
+ };
+
+ f[".ucase"] = [](names s)
+ {
+ return names {name (ucase (convert<string> (move (s))))};
+ };
+
// String-specific overloads from builtins.
//
function_family b (m, "builtin");
diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx
index 7dbff2f..369e58b 100644
--- a/libbuild2/utility.hxx
+++ b/libbuild2/utility.hxx
@@ -66,6 +66,7 @@ namespace build2
using butl::icase_compare_string;
using butl::icase_compare_c_string;
using butl::lcase;
+ using butl::ucase;
using butl::alpha;
using butl::alnum;
using butl::digit;