zsh-workers
 help / color / mirror / code / Atom feed
* zgetcwd bug
@ 1996-12-30  3:32 Zoltan Hidvegi
  0 siblings, 0 replies; only message in thread
From: Zoltan Hidvegi @ 1996-12-30  3:32 UTC (permalink / raw)
  To: Zsh hacking and development

My previous patch to zgetcwd introduced a bug.  Fix is included below.

Zoltan


*** Src/init.c	1996/12/28 00:04:58	3.1.1.6
--- Src/init.c	1996/12/30 02:27:03
***************
*** 505,511 ****
      else if ((ptr = zgetenv("PWD")) && ispwd(ptr))
  	pwd = ztrdup(ptr);
      else
! 	pwd = metafy(zgetcwd(), -1, META_REALLOC);
  
      oldpwd = ztrdup(pwd);  /* initialize `OLDPWD' = `PWD' */
  
--- 505,511 ----
      else if ((ptr = zgetenv("PWD")) && ispwd(ptr))
  	pwd = ztrdup(ptr);
      else
! 	pwd = metafy(zgetcwd(), -1, META_DUP);
  
      oldpwd = ztrdup(pwd);  /* initialize `OLDPWD' = `PWD' */
  
*** Src/builtin.c	1996/12/26 03:55:34	3.1.1.2
--- Src/builtin.c	1996/12/30 02:26:51
***************
*** 897,909 ****
  
      if (stat(unmeta(pwd), &st1) < 0) {
  	zsfree(pwd);
! 	pwd = metafy(zgetcwd(), -1, META_REALLOC);
      } else if (stat(".", &st2) < 0)
  	chdir(unmeta(pwd));
      else if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) {
  	if (isset(CHASELINKS)) {
  	    zsfree(pwd);
! 	    pwd = metafy(zgetcwd(), -1, META_REALLOC);
  	} else {
  	    chdir(unmeta(pwd));
  	}
--- 897,909 ----
  
      if (stat(unmeta(pwd), &st1) < 0) {
  	zsfree(pwd);
! 	pwd = metafy(zgetcwd(), -1, META_DUP);
      } else if (stat(".", &st2) < 0)
  	chdir(unmeta(pwd));
      else if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) {
  	if (isset(CHASELINKS)) {
  	    zsfree(pwd);
! 	    pwd = metafy(zgetcwd(), -1, META_DUP);
  	} else {
  	    chdir(unmeta(pwd));
  	}
*** Src/compat.c	1996/12/26 03:55:34	3.1.1.1
--- Src/compat.c	1996/12/30 02:25:17
***************
*** 118,135 ****
      ino_t ino, pino;
      dev_t dev, pdev;
  
-     if (stat(".", &sbuf) < 0)
- 	return(ztrdup("."));
- 
-     holdintr();
      buf = halloc(bufsiz = PATH_MAX);
      pos = bufsiz - 1;
      buf[pos] = '\0';
      strcpy(nbuf, "../");
  
      pino = sbuf.st_ino;
      pdev = sbuf.st_dev;
  
      for (;;) {
  	if (stat("..", &sbuf) < 0)
  	    break;
--- 118,137 ----
      ino_t ino, pino;
      dev_t dev, pdev;
  
      buf = halloc(bufsiz = PATH_MAX);
      pos = bufsiz - 1;
      buf[pos] = '\0';
      strcpy(nbuf, "../");
+     if (stat(".", &sbuf) < 0) {
+ 	buf[0] = ".";
+ 	buf[1] = '\0';
+ 	return buf;
+     }
  
      pino = sbuf.st_ino;
      pdev = sbuf.st_dev;
  
+     holdintr();
      for (;;) {
  	if (stat("..", &sbuf) < 0)
  	    break;
***************
*** 183,189 ****
      if (*buf)
  	zchdir(buf + pos + 1);
      noholdintr();
!     return ztrdup(".");
  }
  
  /* chdir with arbitrary long pathname */
--- 185,193 ----
      if (*buf)
  	zchdir(buf + pos + 1);
      noholdintr();
!     buf[0] = ".";
!     buf[1] = '\0';
!     return buf;
  }
  
  /* chdir with arbitrary long pathname */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-12-30  3:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-30  3:32 zgetcwd bug Zoltan Hidvegi

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).