diff --git a/libs/ruamoko/rua_string.c b/libs/ruamoko/rua_string.c index 31b717273..754d1627e 100644 --- a/libs/ruamoko/rua_string.c +++ b/libs/ruamoko/rua_string.c @@ -265,6 +265,22 @@ bi_str_lower (progs_t *pr) RETURN_STRING (pr, lower); } +static void +bi_str_upper (progs_t *pr) +{ + const char *str = P_GSTRING (pr, 0); + char *upper = alloca (strlen (str) + 1); + char *l = upper; + byte c; + + while ((c = *str++)) { + *l++ = toupper (c); + } + *l++ = 0; + + RETURN_STRING (pr, upper); +} + static builtin_t builtins[] = { {"strlen", bi_strlen, -1}, {"sprintf", bi_sprintf, -1}, @@ -283,6 +299,7 @@ static builtin_t builtins[] = { {"str_char", bi_str_char, -1}, {"str_quote", bi_str_quote, -1}, {"str_lower", bi_str_lower, -1}, + {"str_upper", bi_str_upper, -1}, {0} }; diff --git a/ruamoko/include/string.h b/ruamoko/include/string.h index 8087ef67e..3d978cfd5 100644 --- a/ruamoko/include/string.h +++ b/ruamoko/include/string.h @@ -18,5 +18,6 @@ int str_str (string haystack, string needle); @extern int str_char (string str, int ind); string str_quote (string str); string str_lower (string str); +string str_upper (string str); #endif//__ruamoko_string_h diff --git a/ruamoko/lib/string.r b/ruamoko/lib/string.r index 3858ef7d6..5169296a0 100644 --- a/ruamoko/lib/string.r +++ b/ruamoko/lib/string.r @@ -17,3 +17,4 @@ int str_str (string haystack, string needle) = #0; int str_char (string str, int ind) = #0; string str_quote (string str) = #0; string str_lower (string str) = #0; +string str_upper (string str) = #0;