Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: zsh-3.1.5-pws-6: some basic cygwin path handling fixes
- X-seq: zsh-workers 5133
- From: Matt Armstrong <matt_armstrong@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: PATCH: zsh-3.1.5-pws-6: some basic cygwin path handling fixes
- Date: 31 Jan 1999 18:58:41 -0800
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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) "//<drive-letter>/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().
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 <matt_armstrong@bigfoot.com>
+
+ * 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 <zefram@zsh.org>
* 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author