zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: zsh-workers@math.gatech.edu (Zsh hacking and development)
Subject: Long directories in prompt
Date: Mon, 30 Dec 1996 04:39:51 +0100 (MET)	[thread overview]
Message-ID: <199612300339.EAA04022@hzoli.ppp.cs.elte.hu> (raw)

%~, %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;


             reply	other threads:[~1996-12-30  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-30  3:39 Zoltan Hidvegi [this message]
1996-12-31 12:50 Zefram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199612300339.EAA04022@hzoli.ppp.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).