[ruamoko] Add binding for str_upper

I can't believe I didn't do that when I did str_lower.
This commit is contained in:
Bill Currie 2021-01-05 18:24:18 +09:00
parent 3cf8a336a8
commit 37b6d11c01
3 changed files with 19 additions and 0 deletions

View file

@ -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}
};

View file

@ -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

View file

@ -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;