summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 6e1529c..0c0121e 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -2862,22 +2862,22 @@ TclStringFind(
Tcl_Obj *haystack,
unsigned int start)
{
- int ln, lh;
+ int lh, ln = Tcl_GetCharLength(needle);
+
+ if (ln == 0) {
+ /*
+ * We don't find empty substrings. Bizarre!
+ *
+ * TODO: When we one day make this a true substring
+ * finder, change this to "return 0"
+ */
+ return -1;
+ }
if (TclIsPureByteArray(needle) && TclIsPureByteArray(haystack)) {
unsigned char *end, *try, *bh;
unsigned char *bn = Tcl_GetByteArrayFromObj(needle, &ln);
- if (ln == 0) {
- /*
- * We don't find empty substrings. Bizarre!
- *
- * TODO: When we one day make this a true substring
- * finder, change this to "return 0"
- */
- return -1;
- }
-
bh = Tcl_GetByteArrayFromObj(haystack, &lh);
end = bh + lh;
@@ -2902,11 +2902,6 @@ TclStringFind(
Tcl_UniChar *try, *end, *uh;
Tcl_UniChar *un = Tcl_GetUnicodeFromObj(needle, &ln);
- if (ln == 0) {
- /* See above */
- return -1;
- }
-
uh = Tcl_GetUnicodeFromObj(haystack, &lh);
end = uh + lh;