restore correct datatype

This commit is contained in:
VaclavT 2022-01-16 19:54:06 +01:00
parent 01e700af54
commit a45423692e
3 changed files with 3 additions and 3 deletions

2
ml.cpp
View File

@ -1816,7 +1816,7 @@ MlValue string_find(std::vector<MlValue> args, MlEnvironment &env) {
throw MlError(MlValue("string-find", string_find), env, args.size() > 3 ? TOO_MANY_ARGS : TOO_FEW_ARGS);
size_t start_pos = args.size() > 2 ? args[2].as_int() : 0;
size_t pos = string_find_substr(args[0].as_string(), args[1].as_string(), start_pos);
long pos = string_find_substr(args[0].as_string(), args[1].as_string(), start_pos);
return pos == -1 ? MlValue::nil() : MlValue((long) pos);
}

View File

@ -148,7 +148,7 @@ std::string string_substring(const std::string & str, long pos, size_t count) {
return str.substr(start_pos, count);
}
size_t string_find_substr(const std::string & str, const std::string & pattern, size_t pos) {
long string_find_substr(const std::string & str, const std::string & pattern, size_t pos) {
if (pos >= str.size()) {
throw std::invalid_argument("Invalid parameter(s) for string-find.");
}

View File

@ -22,4 +22,4 @@ std::string string_padd(const std::string & str, size_t pad_len, char fill_char,
std::string string_substring(const std::string & str, long pos, size_t count);
size_t string_find_substr(const std::string & str, const std::string & pattern, size_t pos);
long string_find_substr(const std::string & str, const std::string & pattern, size_t pos);