* PATCH: ztat revisited
@ 2000-09-27 19:27 Clint Adams
0 siblings, 0 replies; only message in thread
From: Clint Adams @ 2000-09-27 19:27 UTC (permalink / raw)
To: zsh-workers
This folds back the guts of ztrdupstrip into ztat, and changes
the memory allocation to VARARR.
Index: Src/string.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/string.c,v
retrieving revision 1.2
diff -u -r1.2 string.c
--- Src/string.c 2000/09/22 22:16:16 1.2
+++ Src/string.c 2000/09/27 19:19:32
@@ -133,23 +133,3 @@
{
return strcat(realloc(base, strlen(base) + strlen(append) + 1), append);
}
-
-/* Duplicate a string, stripping delimiters. */
-
-/**/
-mod_export char *
-ztrdupstrip(const char *nam, char delim)
-{
- char *p, *buf;
-
- buf = zalloc(strlen(nam));
-
- for (p = buf; *nam; nam++)
- if (*nam == delim && nam[1])
- *p++ = *++nam;
- else
- *p++ = *nam;
- *p = '\0';
-
- return buf;
-}
Index: Src/Zle/compresult.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compresult.c,v
retrieving revision 1.22
diff -u -r1.22 compresult.c
--- Src/Zle/compresult.c 2000/09/22 22:16:16 1.22
+++ Src/Zle/compresult.c 2000/09/27 19:19:42
@@ -732,16 +732,22 @@
ztat(char *nam, struct stat *buf, int ls)
{
int e;
- char *b;
if (!(ls ? lstat(nam, buf) : stat(nam, buf)))
return 0;
+ else {
+ char *p;
+ VARARR(char, b, strlen(nam) + 1);
- b = ztrdupstrip(nam, '\\');
-
- e = ls ? lstat(b, buf) : stat(b, buf);
- zsfree(b);
- return e;
+ for (p = b; *nam; nam++)
+ if (*nam == '\\' && nam[1])
+ *p++ = *++nam;
+ else
+ *p++ = *nam;
+ *p = '\0';
+
+ return ls ? lstat(b, buf) : stat(b, buf);
+ }
}
/* Insert a single match in the command line. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-09-27 19:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-27 19:27 PATCH: ztat revisited Clint Adams
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).