[ruamoko] Fix daft str_str abi

Returning a string was a bad idea as it makes str_str difficult to use
with str_mid. (actually, iirc, it was the only reason I moved all
strings into progs memory... hmm).
This commit is contained in:
Bill Currie 2020-04-08 21:54:41 +09:00
parent b7b8df0801
commit 54f2e417dc
4 changed files with 7 additions and 6 deletions

View File

@ -192,9 +192,10 @@ bi_str_str (progs_t *pr)
const char *needle = P_GSTRING (pr, 1);
char *res = strstr (haystack, needle);
R_STRING (pr) = 0;
if (res)
R_STRING (pr) = res - pr->pr_strings;
R_INT (pr) = -1;
if (res) {
R_INT (pr) = res - haystack;
}
}
static void

View File

@ -81,7 +81,7 @@ class_from_plist (PLDictionary *pldict)
break;
case "0": case "1": case "2": case "3": case "4":
case "5": case "6": case "7": case "8": case "9":
if (str_str (paramstr, "."))
if (str_str (paramstr, ".") >= 0)
va_list.list[j].float_val = stof (paramstr);
else
va_list.list[j].integer_val = stoi (paramstr);

View File

@ -14,7 +14,7 @@
@extern string str_clear (string str);
@extern @overload string str_mid (string str, int start);
@extern @overload string str_mid (string str, int start, int len);
@extern string str_str (string haystack, string needle);
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);

View File

@ -13,7 +13,7 @@ string (string dst, string src) str_cat = #0;
string (string str) str_clear = #0;
string (string str, int start) str_mid = #0;
string (string str, int start, int len) str_mid = #0;
string (string haystack, string needle) str_str = #0;
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;