From fcfcc12f5f00bc2f646f4fe4f02d5ffed4a683dc Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 23 Nov 2020 15:30:56 +0300 Subject: Add $string.lcase() and $string.ucase() functions --- libbuild2/functions-string.cxx | 22 ++++++++++++++++++++++ libbuild2/utility.hxx | 1 + 2 files changed, 23 insertions(+) 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 (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 (move (s))))}; + }; + + f["ucase"] = [](string s) + { + return ucase (move (s)); + }; + + f[".ucase"] = [](names s) + { + return names {name (ucase (convert (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; -- cgit v1.1