From mboxrd@z Thu Jan 1 00:00:00 1970 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes Resent-Date: Sun, 31 Jan 1999 22:00:19 -0500 (EST) To: zsh-workers@math.gatech.edu Subject: PATCH: zsh-3.1.5-pws-6: some basic cygwin path handling fixes From: Matt Armstrong MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: 31 Jan 1999 18:58:41 -0800 Message-ID: User-Agent: Gnus/5.07007 (Pterodactyl Gnus v0.70) Emacs/20.3 Resent-Message-ID: <"sU_Uz.0.6f6.2ZHjs"@math> Resent-From: zsh-workers@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Resent-Sender: zsh-workers-request@math.gatech.edu X-Mailing-List: 5133 This is a MIME multipart message. If you are reading this, you shouldn't. --=-=-= There are some problems with zsh's pathname handling that don't work when cygwin's (poorly thought out) drive letter hacks are in effect: 1) "///dir" is a valid path. builtin.c's fixdir() strips off double slashes, which breaks things. 2) If you chdir("..") while in //D you're put in "/" but "/D" is not a directory in "/". This breaks zgetdir(). (there is actually another bug in cygwin that breaks zgetdir(), but that is a moot point after my fix) The fixes: For #1, I just allow a leading // under cygwin. For #2, I just have zgetdir() call getcwd() under cygwin. I considered having zgetdir() use getcwd() for all systems that had it. I know the Linux kernel now has a getcwd() syscall, which is presumbably much faster than zgetdir(). But I backed down from this for fear that all the magic going on in zgetdir() works around bugs in some system's implementations of getcwd(). --=-=-= Content-Type: application/x-patch Content-Disposition: attachment; filename=cygwin-path.patch Content-Transfer-Encoding: 8bit Content-Description: Fix for cygwin path stuff Index: zsh/ChangeLog diff -c zsh/ChangeLog:1.1.1.1 zsh/ChangeLog:1.4 *** zsh/ChangeLog:1.1.1.1 Sat Jan 23 18:10:11 1999 --- zsh/ChangeLog Sat Jan 30 14:06:22 1999 *************** *** 1,3 **** --- 1,34 ---- + 1999-01-22 Matt Armstrong + + * Src/compat.c (zgetdir): Use cygwin's getcwd() to avoid problems + with cygwin drive letters. + + * Src/builtin.c (fixdir): Allow leading // under cygwin. + Thu Oct 29 21:51:10 1998 Andrew Main * Config/version.mk: Version 3.1.5. Index: zsh/Src/builtin.c diff -c zsh/Src/builtin.c:1.1.1.3 zsh/Src/builtin.c:1.4 *** zsh/Src/builtin.c:1.1.1.3 Sat Jan 30 10:15:04 1999 --- zsh/Src/builtin.c Sat Jan 30 10:30:07 1999 *************** *** 1036,1041 **** --- 1036,1044 ---- { char *dest = src; char *d0 = dest; + #ifdef __CYGWIN__ + char *s0 = src; + #endif /*** if have RFS superroot directory ***/ #ifdef HAVE_SUPERROOT *************** *** 1052,1057 **** --- 1055,1065 ---- for (;;) { /* compress multiple /es into single */ if (*src == '/') { + #ifdef __CYGWIN__ + /* allow leading // under cygwin */ + if (src == s0 && src[1] == '/') + *dest++ = *src++; + #endif *dest++ = *src++; while (*src == '/') src++; Index: zsh/Src/compat.c diff -c zsh/Src/compat.c:1.1.1.1 zsh/Src/compat.c:1.2 *** zsh/Src/compat.c:1.1.1.1 Sat Jan 23 18:10:11 1999 --- zsh/Src/compat.c Sat Jan 23 20:33:09 1999 *************** *** 111,122 **** { char nbuf[PATH_MAX+3]; char *buf; ! int bufsiz, pos, len; struct stat sbuf; struct dirent *de; DIR *dir; ! ino_t ino, pino; ! dev_t dev, pdev; buf = halloc(bufsiz = PATH_MAX); pos = bufsiz - 1; --- 111,127 ---- { char nbuf[PATH_MAX+3]; char *buf; ! int bufsiz, pos; struct stat sbuf; + ino_t pino; + dev_t pdev; + #ifndef __CYGWIN__ struct dirent *de; DIR *dir; ! dev_t dev; ! ino_t ino; ! int len; ! #endif buf = halloc(bufsiz = PATH_MAX); pos = bufsiz - 1; *************** *** 137,142 **** --- 142,148 ---- #ifdef HAVE_FCHDIR else #endif + #ifndef __CYGWIN__ holdintr(); for (;;) { *************** *** 221,226 **** --- 227,247 ---- if (*buf) zchdir(buf + pos + 1); noholdintr(); + + #else /* __CYGWIN__ case */ + + if (!getcwd(buf, bufsiz)) { + if (d) { + return NULL; + } + } else { + if (d) { + return d->dirname = ztrdup(buf); + } + return buf; + } + #endif + buf[0] = '.'; buf[1] = '\0'; return buf; --=-=-=--