zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <schizo@debian.org>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: ztat revisited
Date: Wed, 27 Sep 2000 15:27:38 -0400	[thread overview]
Message-ID: <20000927152738.A4971@dman.com> (raw)

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. */


                 reply	other threads:[~2000-09-27 19:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000927152738.A4971@dman.com \
    --to=schizo@debian.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).