about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-01-14T12·47+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-01-14T12·47+0000
commit9db190eb31d4adc412d50bc03574951f9a1f9dae (patch)
tree788c4f95e32361f34dd309b9e82cc477dee41dbc /src/libexpr/primops.cc
parentd6c8b995c5c08a6c6a6b18f0b2cf5b4b95cfc1b1 (diff)
* builtins.substring: if "start" is beyond the end of the string,
  return the empty string.

Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index a4812de065..3e955ea3fe 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);
 }