Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: zasprintf
- X-seq: zsh-workers 12823
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: PATCH: zasprintf
- Date: Sun, 17 Sep 2000 12:43:16 -0400
- Cc: zsh-workers@xxxxxxxxxxxxxx
- In-reply-to: <1000917161356.ZM19396@xxxxxxxxxxxxxxxxxxxxxxx>; from schaefer@xxxxxxxxxxxxxxxxxxxxxxx on Sun, Sep 17, 2000 at 04:13:56PM +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <20000916145333.A29559@xxxxxxxx> <1000917004721.ZM18698@xxxxxxxxxxxxxxxxxxxxxxx> <20000917002552.A31354@xxxxxxxx> <1000917053751.ZM18817@xxxxxxxxxxxxxxxxxxxxxxx> <20000917110403.A4270@xxxxxxxx> <1000917161356.ZM19396@xxxxxxxxxxxxxxxxxxxxxxx>
> This is a case where a zsh-heap-allocating version of tricat() would be
> slightly preferable to a permanent-heap-allocating version.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.34
diff -u -r1.34 builtin.c
--- Src/builtin.c 2000/09/17 16:24:06 1.34
+++ Src/builtin.c 2000/09/17 16:38:39
@@ -3297,25 +3297,25 @@
break;
}
if (!*s || (ret && isset(PATHDIRS) && diddot < 2 && dotdot == 0)) {
+ pushheap();
/* search path for script */
for (t = path; *t; t++) {
if (!(*t)[0] || ((*t)[0] == '.' && !(*t)[1])) {
if (diddot)
continue;
diddot = 1;
- buf = ztrdup(arg0);
+ buf = dupstring(arg0);
} else
- buf = tricat(*t, "/", arg0);
+ buf = zhtricat(*t, "/", arg0);
s = unmeta(buf);
if (access(s, F_OK) == 0 && stat(s, &st) >= 0
&& !S_ISDIR(st.st_mode)) {
ret = source(enam = buf);
- zsfree(buf);
break;
}
- zsfree(buf);
}
+ popheap();
}
}
/* clean up and return */
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.14
diff -u -r1.14 utils.c
--- Src/utils.c 2000/08/29 20:27:48 1.14
+++ Src/utils.c 2000/09/17 16:38:46
@@ -3473,6 +3473,20 @@
}
/**/
+mod_export char *
+zhtricat(char const *s1, char const *s2, char const *s3)
+{
+ char *ptr;
+
+ ptr = (char *)zhalloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
+ strcpy(ptr, s1);
+ strcat(ptr, s2);
+ strcat(ptr, s3);
+ return ptr;
+}
+
+
+/**/
static int
upchdir(int n)
{
Messages sorted by:
Reverse Date,
Date,
Thread,
Author