restore correct datatype
This commit is contained in:
2
ml.cpp
2
ml.cpp
@@ -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);
|
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 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);
|
return pos == -1 ? MlValue::nil() : MlValue((long) pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ std::string string_substring(const std::string & str, long pos, size_t count) {
|
|||||||
return str.substr(start_pos, 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()) {
|
if (pos >= str.size()) {
|
||||||
throw std::invalid_argument("Invalid parameter(s) for string-find.");
|
throw std::invalid_argument("Invalid parameter(s) for string-find.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user