From 9db190eb31d4adc412d50bc03574951f9a1f9dae Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 14 Jan 2011 12:47:10 +0000 Subject: * builtins.substring: if "start" is beyond the end of the string, return the empty string. --- src/libexpr/primops.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr') diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index a4812de06..3e955ea3f 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -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); } -- cgit v1.2.3