diff options
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 5422b7f..bf75d44 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -395,9 +395,13 @@ Tcl_RegexpObjCmd( newPtr = Tcl_NewListObj(2, objs); } else { if (i <= info.nsubs) { - newPtr = Tcl_GetRange(objPtr, - offset + info.matches[i].start, - offset + info.matches[i].end - 1); + if (info.matches[i].end <= 0) { + TclNewObj(newPtr); + } else { + newPtr = Tcl_GetRange(objPtr, + offset + info.matches[i].start, + offset + info.matches[i].end - 1); + } } else { TclNewObj(newPtr); } @@ -2183,7 +2187,9 @@ StringRangeCmd( return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_GetRange(objv[1], first, last)); + if (last >= 0) { + Tcl_SetObjResult(interp, Tcl_GetRange(objv[1], first, last)); + } return TCL_OK; } |