zsh-workers
 help / color / mirror / code / Atom feed
* Re: Long directories in prompt
@ 1996-12-31 12:50 Zefram
  0 siblings, 0 replies; 2+ messages in thread
From: Zefram @ 1996-12-31 12:50 UTC (permalink / raw)
  To: Z Shell workers mailing list

-----BEGIN PGP SIGNED MESSAGE-----

Zoltan's fix broke prompt truncation.

 -zefram

      *** Src/prompt.c	1996/12/30 14:14:18	1.2
      --- Src/prompt.c	1996/12/30 14:47:46
      ***************
      *** 293,301 ****
        	    switch (*fm) {
        	    case '~':
        		if ((nd = finddir(pwd))) {
      ! 		    stradd("~");
      ! 		    stradd(nd->nam);
      ! 		    stradd(pwd + strlen(nd->dir));
        		    break;
        		}
        	    case 'd':
      --- 293,301 ----
        	    switch (*fm) {
        	    case '~':
        		if ((nd = finddir(pwd))) {
      ! 		    char *t = tricat("~", nd->nam, pwd + strlen(nd->dir));
      ! 		    stradd(t);
      ! 		    zsfree(t);
        		    break;
        		}
        	    case 'd':
      ***************
      *** 308,316 ****
        		    char *t;
        
        		    if ((nd = finddir(pwd)))
      ! 			t = pwd + strlen(nd->dir);
        		    else
      ! 			t = pwd;
        		    if (!arg)
        			arg++;
        		    for (ss = t + strlen(t); ss > t; ss--)
      --- 308,316 ----
        		    char *t;
        
        		    if ((nd = finddir(pwd)))
      ! 			t = tricat("~", nd->nam, pwd + strlen(nd->dir));
        		    else
      ! 			t = ztrdup(pwd);
        		    if (!arg)
        			arg++;
        		    for (ss = t + strlen(t); ss > t; ss--)
      ***************
      *** 318,329 ****
        			    ss++;
        			    break;
        			}
      ! 		    if (nd && ss == t && (*ss != '/' || arg > 1)) {
      ! 			stradd("~");
      ! 			stradd(nd->nam);
      ! 		    } else if (*ss == '/' && ss[1] && (ss != pwd))
        			ss++;
        		    stradd(ss);
        		    break;
        		}
        	    case 'C':
      --- 318,327 ----
        			    ss++;
        			    break;
        			}
      ! 		    if(*ss == '/' && ss[1] && ss != t)
        			ss++;
        		    stradd(ss);
      + 		    zsfree(t);
        		    break;
        		}
        	    case 'C':

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMsfXbnD/+HJTpU/hAQHrdAP+OoJD1x42fqkg47HY1/NjEqbXDsIlpqo/
pVAim1JjUdG70FHBNpMU5+k+r3raC9mki3Tqthj3/taVf95rkpOubLzEEx+4RocG
TSSe/UVnqTHxJdSR62UM63EciL+sximv04EUh0erLz0jJQzQoAwc8sl9uehe9s0W
t3j1JOjaWoQ=
=2/CR
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Long directories in prompt
@ 1996-12-30  3:39 Zoltan Hidvegi
  0 siblings, 0 replies; 2+ messages in thread
From: Zoltan Hidvegi @ 1996-12-30  3:39 UTC (permalink / raw)
  To: Zsh hacking and development

%~, %d, %c, %. and %C prompt escapes caused coredump when pwd was longer
than PATH_MAX.

This patch fixes putpromptchar() but still there is a bug in finddir()
causing coredumps when %~ is used.

This is for zsh-3.1.0 only.

Zoltan


*** Src/prompt.c	1996/12/21 02:35:32	3.1.1.0
--- Src/prompt.c	1996/12/30 03:20:14
***************
*** 293,300 ****
  	    switch (*fm) {
  	    case '~':
  		if ((nd = finddir(pwd))) {
! 		    sprintf(buf3, "~%s%s", nd->nam, pwd + strlen(nd->dir));
! 		    stradd(buf3);
  		    break;
  		}
  	    case 'd':
--- 293,301 ----
  	    switch (*fm) {
  	    case '~':
  		if ((nd = finddir(pwd))) {
! 		    stradd("~");
! 		    stradd(nd->nam);
! 		    stradd(pwd + strlen(nd->dir));
  		    break;
  		}
  	    case 'd':
***************
*** 303,333 ****
  		break;
  	    case 'c':
  	    case '.':
! 		if ((nd = finddir(pwd)))
! 		    sprintf(buf3, "~%s%s", nd->nam, pwd + strlen(nd->dir));
! 		else
! 		    strcpy(buf3, pwd);
! 		if (!arg)
! 		    arg++;
! 		for (ss = buf3 + strlen(buf3); ss > buf3; ss--)
! 		    if (*ss == '/' && !--arg) {
  			ss++;
! 			break;
! 		    }
! 		if (*ss == '/' && ss[1] && (ss != buf3))
! 		    ss++;
! 		stradd(ss);
! 		break;
  	    case 'C':
- 		strcpy(buf3, pwd);
  		if (!arg)
  		    arg++;
! 		for (ss = buf3 + strlen(buf3); ss > buf3; ss--)
  		    if (*ss == '/' && !--arg) {
  			ss++;
  			break;
  		    }
! 		if (*ss == '/' && ss[1] && (ss != buf3))
  		    ss++;
  		stradd(ss);
  		break;
--- 304,340 ----
  		break;
  	    case 'c':
  	    case '.':
! 	        {
! 		    char *t;
! 
! 		    if ((nd = finddir(pwd)))
! 			t = pwd + strlen(nd->dir);
! 		    else
! 			t = pwd;
! 		    if (!arg)
! 			arg++;
! 		    for (ss = t + strlen(t); ss > t; ss--)
! 			if (*ss == '/' && !--arg) {
! 			    ss++;
! 			    break;
! 			}
! 		    if (nd && ss == t && (*ss != '/' || arg > 1)) {
! 			stradd("~");
! 			stradd(nd->nam);
! 		    } else if (*ss == '/' && ss[1] && (ss != pwd))
  			ss++;
! 		    stradd(ss);
! 		    break;
! 		}
  	    case 'C':
  		if (!arg)
  		    arg++;
! 		for (ss = pwd + strlen(pwd); ss > pwd; ss--)
  		    if (*ss == '/' && !--arg) {
  			ss++;
  			break;
  		    }
! 		if (*ss == '/' && ss[1] && (ss != pwd))
  		    ss++;
  		stradd(ss);
  		break;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-12-31 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-31 12:50 Long directories in prompt Zefram
  -- strict thread matches above, loose matches on Subject: below --
1996-12-30  3:39 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).