ref: d133a4306688e51df959da814d48f10f33cad23a
parent: 23b63e6c9668efb47e01ebfca03b0aed5cbbe327
author: qwx <qwx@sciops.net>
date: Mon Oct 27 01:38:11 EDT 2025
split: give up on looking up names to avoid strdup the first arg may be a tempcell with no name; with additional checks this is getting unwieldy just to avoid a strdup. example: i="2/WRITE"; split(tolower(i), a, "/")
--- a/run.c
+++ b/run.c
@@ -1244,8 +1244,9 @@
int n, nb, sep, arg3type;
y = execute(a[0]); /* source string */
- ds = nil;
- s = getsval(y);
+ ds = s = tostring(getsval(y));
+ if (istemp(y))
+ tfree(y);
arg3type = ptoi(a[3]);
if (a[2] == 0) /* fs string */
fs = *FS;
@@ -1258,8 +1259,6 @@
FATAL("illegal type of split");sep = *fs;
ap = execute(a[1]); /* array name */
- if (isarr(ap) && lookup(y->nval, (Array *)ap->sval) != nil)
- ds = s = tostring(s);
freesymtab(ap);
dprint( ("split: s=|%s|, a=%s, sep=|%s|\n", s, ap->nval, fs) );ap->tval &= ~STR;
@@ -1362,8 +1361,6 @@
free(ds);
if (istemp(ap))
tfree(ap);
- if (istemp(y))
- tfree(y);
if (a[2] != 0 && arg3type == STRING)
if (istemp(x))
tfree(x);
--
⑨