diff options
Diffstat (limited to 'generic/tclExecute.c')
| -rw-r--r-- | generic/tclExecute.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index ca4312a..e98545e 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclExecute.c,v 1.427 2009/02/14 20:30:13 dgp Exp $ + * RCS: @(#) $Id: tclExecute.c,v 1.428 2009/02/25 14:56:07 dgp Exp $ */ #include "tclInt.h" @@ -4657,11 +4657,7 @@ TclExecuteByteCode( valuePtr = OBJ_AT_TOS; - if (valuePtr->typePtr == &tclByteArrayType) { - (void) Tcl_GetByteArrayFromObj(valuePtr, &length); - } else { - length = Tcl_GetCharLength(valuePtr); - } + length = Tcl_GetCharLength(valuePtr); TclNewIntObj(objResultPtr, length); TRACE(("%.20s => %d\n", O2S(valuePtr), length)); NEXT_INST_F(1, 1, 1); @@ -4681,21 +4677,9 @@ TclExecuteByteCode( valuePtr = OBJ_UNDER_TOS; /* - * If we have a ByteArray object, avoid indexing in the Utf string - * since the byte array contains one byte per character. Otherwise, - * use the Unicode string rep to get the index'th char. + * Get char length to calulate what 'end' means. */ - - if (valuePtr->typePtr == &tclByteArrayType) { - bytes = (char *)Tcl_GetByteArrayFromObj(valuePtr, &length); - } else { - /* - * Get Unicode char length to calulate what 'end' means. - */ - - length = Tcl_GetCharLength(valuePtr); - } - + length = Tcl_GetCharLength(valuePtr); result = TclGetIntForIndexM(interp, value2Ptr, length - 1, &index); if (result != TCL_OK) { goto checkForCatch; @@ -4703,8 +4687,8 @@ TclExecuteByteCode( if ((index >= 0) && (index < length)) { if (valuePtr->typePtr == &tclByteArrayType) { - objResultPtr = Tcl_NewByteArrayObj((unsigned char *) - (&bytes[index]), 1); + objResultPtr = Tcl_NewByteArrayObj( + Tcl_GetByteArrayFromObj(valuePtr, &length)+index, 1); } else if (valuePtr->bytes && length == valuePtr->length) { objResultPtr = Tcl_NewStringObj((const char *) (&valuePtr->bytes[index]), 1); |
