From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12463 invoked from network); 27 Sep 2000 19:28:15 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 27 Sep 2000 19:28:15 -0000 Received: (qmail 15574 invoked by alias); 27 Sep 2000 19:27:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12863 Received: (qmail 15567 invoked from network); 27 Sep 2000 19:27:45 -0000 Date: Wed, 27 Sep 2000 15:27:38 -0400 From: Clint Adams To: zsh-workers@sunsite.auc.dk Subject: PATCH: ztat revisited Message-ID: <20000927152738.A4971@dman.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.1.2i 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. */