forked from lix-project/lix
* builtins.substring: if "start" is beyond the end of the string,
return the empty string.
This commit is contained in:
parent
d6c8b995c5
commit
9db190eb31
|
@ -965,7 +965,7 @@ static void prim_substring(EvalState & state, Value * * args, Value & v)
|
|||
|
||||
if (start < 0) throw EvalError("negative start position in `substring'");
|
||||
|
||||
mkString(v, string(s, start, len), context);
|
||||
mkString(v, start >= s.size() ? "" : string(s, start, len), context);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
"ooxfoobarybarzobaabb"
|
||||
"ooxfoobarybarzobaabbc"
|
||||
|
|
|
@ -17,3 +17,5 @@ substring 1 2 s
|
|||
+ substring 3 0 s
|
||||
+ "b"
|
||||
+ substring 3 1 s
|
||||
+ "c"
|
||||
+ substring 5 10 "perl"
|
||||
|
|
Loading…
Reference in a new issue