zsh-workers
 help / color / mirror / code / Atom feed
* 4 bugs
@ 1996-10-30  0:48 Geoff Wing
  1996-10-31  1:28 ` Zoltan Hidvegi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Geoff Wing @ 1996-10-30  0:48 UTC (permalink / raw)
  To: zsh-workers

Heyla,
  just some bugs:

1. Setting terminals to a low number of columns (under 5 or so) still coredumps
  during use.

2. There's still a refresh bug that I'll look into - it looks like one I
  thought I got rid off - relating to both delete & insert done on a line

3. Really long lines in your HISTFILE get chopped into 1K blocks and allocated
  a history line each when you start a shell - probably also when you load at
  other times.

4. I'm sitting here trying to think of the fourth bug I found.......
   just a minute... I'm sure it'll come back to me....... typing doesn't
   help you remember......oh yes, it was:
% $(cat nothing)<TAB>

produces
% $(cat nothing)cat: nothing: No such file or directory
 <--- cursor here

-- 
Geoff Wing [gwing@primenet.com.au]     PrimeNet - Internet Consultancy
  Web   : http://www.primenet.com.au/  Phone    : +61-3-9818 2977
  Mobile: 0412 162 441		       Facsimile: +61-3-9819 3788


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

* Re: 4 bugs
  1996-10-30  0:48 4 bugs Geoff Wing
@ 1996-10-31  1:28 ` Zoltan Hidvegi
  1996-11-08 12:24 ` 4 bugs (1 more fixed) Geoff Wing
  1996-11-09  5:24 ` 4 bugs Geoff Wing
  2 siblings, 0 replies; 6+ messages in thread
From: Zoltan Hidvegi @ 1996-10-31  1:28 UTC (permalink / raw)
  To: Geoff Wing; +Cc: zsh-workers

> 3. Really long lines in your HISTFILE get chopped into 1K blocks and allocated
>   a history line each when you start a shell - probably also when you load at
>   other times.

That's fixed by the patch below together by an other bug: <-21> range glob
does not work.  That stopped working when I modified zstrtol to recognize
signed numbers.  I do hope that it did not break anything else.

Zoltan

*** Src/glob.c	1996/10/30 23:41:58	3.1.0.0
--- Src/glob.c	1996/10/31 00:34:57	3.1.0.1
***************
*** 1089,1101 ****
  	int cnt;
  
  	for (str4 = str, cnt = 0; cnt || (*str != Comma && *str !=
! 					  Outbrace); str++)
  	    if (*str == Inbrace)
  		cnt++;
  	    else if (*str == Outbrace)
  		cnt--;
! 	    else if (!*str)
! 		exit(10);	/* slightly overemphatic, perhaps??? */
  	/* Concatenate the string before the braces (str3), the section *
  	 * just found (str4) and the text after the braces (str2)       */
  	zz = (char *)ncalloc(prev + (str - str4) + strlen(str2) + 1);
--- 1089,1101 ----
  	int cnt;
  
  	for (str4 = str, cnt = 0; cnt || (*str != Comma && *str !=
! 					  Outbrace); str++) {
  	    if (*str == Inbrace)
  		cnt++;
  	    else if (*str == Outbrace)
  		cnt--;
! 	    DPUTS(!*str, "BUG: illegal brace expansion");
! 	}
  	/* Concatenate the string before the braces (str3), the section *
  	 * just found (str4) and the text after the braces (str2)       */
  	zz = (char *)ncalloc(prev + (str - str4) + strlen(str2) + 1);
***************
*** 1783,1795 ****
  	    unsigned long t1, t2, t3;
  	    char *ptr;
  
  	    if (*++pat == Outang || 
  		(*pat == '-' && pat[1] == Outang && ++pat)) {
  		/* <> or <->:  any number matches */
! 		(void)zstrtol(pptr, &ptr, 10);
! 		if (ptr == pptr)
! 		    break;
! 		pptr = ptr;
  		pat++;
  	    } else {
  		/* Flag that there is no upper limit */
--- 1783,1794 ----
  	    unsigned long t1, t2, t3;
  	    char *ptr;
  
+ 	    if (!idigit(*pptr))
+ 		break;
  	    if (*++pat == Outang || 
  		(*pat == '-' && pat[1] == Outang && ++pat)) {
  		/* <> or <->:  any number matches */
! 		while (idigit(*++pptr));
  		pat++;
  	    } else {
  		/* Flag that there is no upper limit */
***************
*** 1800,1817 ****
  		 * unsigned arithmetic.
  		 */
  		t1 = (unsigned long)zstrtol(pptr, &ptr, 10);
- 		if (ptr == pptr)
- 		    break;
  		pptr = ptr;
  		/* t2 = lower limit */
! 		t2 = (unsigned long)zstrtol(pat, &ptr, 10);
  		if (*ptr != '-' || (not3 = (ptr[1] == Outang)))
  				/* exact match or no upper limit */
  		    t3 = t2, pat = ptr + not3;
  		else		/* t3 = upper limit */
  		    t3 = (unsigned long)zstrtol(ptr + 1, &pat, 10);
! 		if (*pat++ != Outang)
! 		    exit(21);
  		if (t1 < t2 || (!not3 && t1 > t3))
  		    break;
  	    }
--- 1799,1817 ----
  		 * unsigned arithmetic.
  		 */
  		t1 = (unsigned long)zstrtol(pptr, &ptr, 10);
  		pptr = ptr;
  		/* t2 = lower limit */
! 		if (idigit(*pat))
! 		    t2 = (unsigned long)zstrtol(pat, &ptr, 10);
! 		else
! 		    t2 = 0, ptr = pat;
  		if (*ptr != '-' || (not3 = (ptr[1] == Outang)))
  				/* exact match or no upper limit */
  		    t3 = t2, pat = ptr + not3;
  		else		/* t3 = upper limit */
  		    t3 = (unsigned long)zstrtol(ptr + 1, &pat, 10);
! 		DPUTS(*pat != Outang, "BUG: wrong internal range pattern");
! 		pat++;
  		if (t1 < t2 || (!not3 && t1 > t3))
  		    break;
  	    }
*** Src/hist.c	1996/10/30 23:41:58	3.1.0.0
--- Src/hist.c	1996/10/31 01:21:15
***************
*** 1325,1352 ****
  void
  readhistfile(char *s, int err)
  {
!     char buf[1024];
      FILE *in;
      Histent ent;
      time_t tim = time(NULL);
      short *wordlist;
!     int nwordpos, nwordlist;
  
      if (!s)
  	return;
      if ((in = fopen(unmeta(s), "r"))) {
  	nwordlist = 16;
  	wordlist = (short *)zalloc(nwordlist*sizeof(short));
  
! 	while (fgets(buf, sizeof(buf), in)) {
  	    int l = strlen(buf);
  	    char *pt, *start;
  
! 	    while (l && buf[l - 1] == '\n') {
  		buf[l - 1] = '\0';
  		if (l > 1 && buf[l - 2] == '\\') {
  		    buf[l - 2] = '\n';
! 		    fgets(buf + l - 1, sizeof(buf) - (l - 1), in);
  		    l = strlen(buf);
  		} else
  		    break;
--- 1325,1363 ----
  void
  readhistfile(char *s, int err)
  {
!     char *buf;
      FILE *in;
      Histent ent;
      time_t tim = time(NULL);
      short *wordlist;
!     int nwordpos, nwordlist, bufsiz;
  
      if (!s)
  	return;
      if ((in = fopen(unmeta(s), "r"))) {
  	nwordlist = 16;
  	wordlist = (short *)zalloc(nwordlist*sizeof(short));
+ 	bufsiz = 1024;
+ 	buf = zalloc(bufsiz);
  
! 	while (fgets(buf, bufsiz, in)) {
  	    int l = strlen(buf);
  	    char *pt, *start;
  
! 	    while (l) {
! 		while (buf[l - 1] != '\n') {
! 		    buf = zrealloc(buf, 2 * bufsiz);
! 		    bufsiz = 2 * bufsiz;
! 		    if (!fgets(buf + l, bufsiz - l, in)) {
! 			l++;
! 			break;
! 		    }
! 		    l = strlen(buf);
! 		}
  		buf[l - 1] = '\0';
  		if (l > 1 && buf[l - 2] == '\\') {
  		    buf[l - 2] = '\n';
! 		    fgets(buf + l - 1, bufsiz - (l - 1), in);
  		    l = strlen(buf);
  		} else
  		    break;
***************
*** 1410,1415 ****
--- 1421,1427 ----
  	fclose(in);
  
  	zfree(wordlist, nwordlist*sizeof(short));
+ 	zfree(buf, bufsiz);
      } else if (err)
  	zerr("can't read history file", s, 0);
  }


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

* Re: 4 bugs (1 more fixed)
  1996-10-30  0:48 4 bugs Geoff Wing
  1996-10-31  1:28 ` Zoltan Hidvegi
@ 1996-11-08 12:24 ` Geoff Wing
  1996-11-08 16:33   ` Bart Schaefer
  1996-11-09  5:24 ` 4 bugs Geoff Wing
  2 siblings, 1 reply; 6+ messages in thread
From: Geoff Wing @ 1996-11-08 12:24 UTC (permalink / raw)
  To: zsh-workers

I wrote:
:  just some bugs:
:2. There's still a refresh bug that I'll look into - it looks like one I
:  thought I got rid off - relating to both delete & insert done on a line

There's a mixed bag of changes here: only affects init.c & zle_refresh.c
They are diffs to 3.0.1

1 ) Old line cropping should now be correct with insert, so if a delete
    follows an insert, the line should be correct.
2a) Multiple right movement capability is used as first preference.
2b) Hard tabs are used next if the tty settings aren't set to expand tabs as
    spaces - this could use some checking by people who have old sgtty stuff.
3 ) cost calculations for select() calls have been amalgamated with the 
    actual output calls.  This is a minor inefficiency (processor not output),
    but makes it much easier to read the code and should be accurate, where
    the old way was easily prone to error.


I was also planning to change the display manner of greater than screen high
lines/multi-lines.  If the last bindkey setting was emacs style than have
emacs style scrolling, otherwise vi style scrolling.  Any comments welcome.
This is going to take quite a bit of planning so it'll be a while before
it comes along.




*** init.c	1996/10/15 20:16:35	2.46
--- init.c	1996/11/08 11:48:00
***************
*** 425,432 ****
  	    if (!(pp = tgetstr(tccapnams[t0], &pp)))
  		tcstr[t0] = NULL, tclen[t0] = 0;
  	    else {
! 		tcstr[t0] = (char *) zalloc(tclen[t0] = strlen(pp) + 1);
! 		memcpy(tcstr[t0], pp, tclen[t0]);
  	    }
  	}
  
--- 425,433 ----
  	    if (!(pp = tgetstr(tccapnams[t0], &pp)))
  		tcstr[t0] = NULL, tclen[t0] = 0;
  	    else {
! 		tclen[t0] = strlen(pp);
! 		tcstr[t0] = (char *) zalloc(tclen[t0] + 1);
! 		memcpy(tcstr[t0], pp, tclen[t0] + 1);
  	    }
  	}
  


*** zle_refresh.c	1996/10/15 20:16:35	2.19
--- zle_refresh.c	1996/11/08 11:48:41
***************
*** 34,41 ****
--- 34,45 ----
  
  #ifdef HAVE_SELECT
  #define SELECT_ADD_COST(X)	cost += X
+ #define zputc(a, b)		putc(a, b), cost++
+ #define zwrite(a, b, c, d)	fwrite(a, b, c, d), cost += (b * c)
  #else
  #define SELECT_ADD_COST(X)
+ #define zputc(a, b)		putc(a, b)
+ #define zwrite(a, b, c, d)	fwrite(a, b, c, d)
  #endif
  
  /* Oct/Nov 94: <mason> some code savagely redesigned to fix several bugs -
***************
*** 186,192 ****
      clearf = 0,			/* alwayslastprompt used immediately before */
      hasam;			/* terminal should have auto-margin	    */
  static int put_rpmpt,		/* whether we should display right-prompt   */
!     oput_rpmpt;			/* whether displayed right-prompt last time */
  extern int clearflag;		/* set to non-zero if alwayslastprompt used */
  
  /**/
--- 190,197 ----
      clearf = 0,			/* alwayslastprompt used immediately before */
      hasam;			/* terminal should have auto-margin	    */
  static int put_rpmpt,		/* whether we should display right-prompt   */
!     oput_rpmpt,			/* whether displayed right-prompt last time */
!     oxtabs;			/* oxtabs - tabs expand to spaces if set    */
  extern int clearflag;		/* set to non-zero if alwayslastprompt used */
  
  /**/
***************
*** 214,219 ****
--- 219,242 ----
  #ifdef HAVE_SELECT
      cost = 0;			/* reset */
  #endif
+ 
+ /* Nov 96: <mason>  This looks ugly and I haven't checked how complete it is.
+    sgtty stuff may or may not work */
+ #if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
+     oxtabs = (shttyinfo.tio.c_oflag &
+ #else	/* we're using sgtty */
+     oxtabs = (shttyinfo.sgttyb.sg_flags &
+ #endif
+ # ifdef TAB3
+ 				 	TAB3) == TAB3;
+ # else
+ #  ifdef OXTABS
+ 					OXTABS) == OXTABS;
+ #  else
+ 					XTABS) == XTABS;
+ #  endif
+ # endif
+ 
      cleareol = 0;		/* unset */
      more_start = more_end = 0;	/* unset */
      if (resetneeded) {
***************
*** 237,253 ****
              olnct = t0;
          if (isset(SINGLELINEZLE) || termok != TERM_OK)
              vcs = 0;
!         else if (!clearflag && lpptlen) {
!             fwrite(lpptbuf, lpptlen, 1, shout);
! 	    SELECT_ADD_COST(lpptlen);
! 	    fflush(shout);
! 	}
  	if (clearflag) {
! 	    putc('\r', shout);
! 	    SELECT_ADD_COST(1);
  	    vcs = 0;
  	    moveto(0, pptw);
  	}
  	clearf = clearflag;
      } else if (winw != columns)
  	resetvideo();
--- 260,273 ----
              olnct = t0;
          if (isset(SINGLELINEZLE) || termok != TERM_OK)
              vcs = 0;
!         else if (!clearflag && lpptlen)
!             zwrite(lpptbuf, lpptlen, 1, shout);
  	if (clearflag) {
! 	    zputc('\r', shout);
  	    vcs = 0;
  	    moveto(0, pptw);
  	}
+ 	fflush(shout);
  	clearf = clearflag;
      } else if (winw != columns)
  	resetvideo();
***************
*** 400,406 ****
      /* output the right-prompt if appropriate */
  	if (put_rpmpt && !ln && !oput_rpmpt) {
  	    moveto(0, winw - 1 - rpw);
! 	    fwrite(rpptbuf, rpptlen, 1, shout);
  	    vcs = winw - 1;
  	/* reset character attributes to that set by the main prompt */
  	    txtchange = pmpt_attr;
--- 420,426 ----
      /* output the right-prompt if appropriate */
  	if (put_rpmpt && !ln && !oput_rpmpt) {
  	    moveto(0, winw - 1 - rpw);
! 	    zwrite(rpptbuf, rpptlen, 1, shout);
  	    vcs = winw - 1;
  	/* reset character attributes to that set by the main prompt */
  	    txtchange = pmpt_attr;
***************
*** 507,513 ****
  	&& tccan(TCCLEAREOL)) {
  	moveto(ln, 0);
  	tcout(TCCLEAREOL);
- 	SELECT_ADD_COST(tclen[TCCLEAREOL]);
  	return;	
      }
  
--- 527,532 ----
***************
*** 559,567 ****
      if (hasam && vcs == winw) {
  	vln++, vcs = 1;
          if (nbuf[vln]  && *nbuf[vln])
! 	    putc(*nbuf[vln], shout);
  	else
! 	    putc(' ', shout);            /* I don't think this should happen */
  	nl++;
  	if (*ol)
  	    ol++;
--- 578,586 ----
      if (hasam && vcs == winw) {
  	vln++, vcs = 1;
          if (nbuf[vln]  && *nbuf[vln])
! 	    zputc(*nbuf[vln], shout);
  	else
! 	    zputc(' ', shout);            /* I don't think this should happen */
  	nl++;
  	if (*ol)
  	    ol++;
***************
*** 598,604 ****
      /* if we can finish quickly, do so */
  	if ((col_cleareol >= 0) && (ccs >= col_cleareol)) {
  	    tcout(TCCLEAREOL);
- 	    SELECT_ADD_COST(tclen[TCCLEAREOL]);
  	    return;
  	}
  
--- 617,622 ----
***************
*** 608,617 ****
  	    if (tccan(TCDEL) && (tcdelcost(i) <= i + 1))
  		tc_delchars(i);
  	    else {
- 		SELECT_ADD_COST(i);
  		vcs += i;
  		while (i-- > 0)
! 		    putc(' ', shout);
  	    }
  	    return;
  	}
--- 626,634 ----
  	    if (tccan(TCDEL) && (tcdelcost(i) <= i + 1))
  		tc_delchars(i);
  	    else {
  		vcs += i;
  		while (i-- > 0)
! 		    zputc(' ', shout);
  	    }
  	    return;
  	}
***************
*** 621,633 ****
  	if (!*ol) {
  	    i = (col_cleareol >= 0) ? col_cleareol : nllen;
  	    i -= ccs;
! 	    fwrite(nl, i, 1, shout);
! 	    SELECT_ADD_COST(i);
  	    vcs += i;
! 	    if (col_cleareol >= 0) {
  		tcout(TCCLEAREOL);
- 		SELECT_ADD_COST(tclen[TCCLEAREOL]);
- 	    }
  	    return;
  	}
  
--- 638,647 ----
  	if (!*ol) {
  	    i = (col_cleareol >= 0) ? col_cleareol : nllen;
  	    i -= ccs;
! 	    zwrite(nl, i, 1, shout);
  	    vcs += i;
! 	    if (col_cleareol >= 0)
  		tcout(TCCLEAREOL);
  	    return;
  	}
  
***************
*** 640,654 ****
  	   eg. oldline: hifoobar \ hopefully cheaper here to delete two
  	       newline: foobar	 / characters, then we have six matches */
  	    if (tccan(TCDEL)) {
! 		for (i = 1, p1 = ol + 1; *p1; p1++, i++)
! 		    if (tcdelcost(i) < pfxlen(p1, nl)) {
  			tc_delchars(i);
! 			SELECT_ADD_COST(i);
! 			ol = p1;
  			char_ins -= i;
  			break;
  		    }
! 		if (*p1)
  		    continue;
  	    }
  	/* inserting characters - characters pushed off the right should be
--- 654,668 ----
  	   eg. oldline: hifoobar \ hopefully cheaper here to delete two
  	       newline: foobar	 / characters, then we have six matches */
  	    if (tccan(TCDEL)) {
! 		for (i = 1; *(ol + i); i++)
! 		    if (tcdelcost(i) < pfxlen(ol + i, nl)) {
  			tc_delchars(i);
! 			ol += i;
  			char_ins -= i;
+ 			i = 0;
  			break;
  		    }
! 		if (!i)
  		    continue;
  	    }
  	/* inserting characters - characters pushed off the right should be
***************
*** 656,685 ****
  	   undesired scrolling occurs due to `illegal' characters on screen */
  
  	    if (tccan(TCINS) && (vln != lines - 1)) {	/* not on last line */
! 		for (i = 1, p1 = nl + 1; *p1; p1++, i++)
! 		    if (tcinscost(i) < pfxlen(p1, ol)) {
  			tc_inschars(i);
! 			SELECT_ADD_COST(2 * i);
! 			fwrite(nl, i, 1, shout);
! 			ccs = (vcs += i);
! 			nl = p1;
  			char_ins += i;
  		    /* if we've pushed off the right, truncate oldline */
! 			for (j = ccs - i, p1 = ol; *p1 && j + char_ins < winw;
! 			     p1++, j++);
! 			if (j + char_ins == winw)
! 			    *p1 = '\0';
! 			p1 = ol;
  			break;
  		    }
! 		if (*p1)
  		    continue;
  	    }
  	}
      /* we can't do any fancy tricks, so just dump the single character
         and keep on trying */
! 	putc(*nl, shout);
! 	SELECT_ADD_COST(1);
  	nl++, ol++;
  	ccs++, vcs++;
      }
--- 670,696 ----
  	   undesired scrolling occurs due to `illegal' characters on screen */
  
  	    if (tccan(TCINS) && (vln != lines - 1)) {	/* not on last line */
! 		for (i = 1; *(nl + i); i++)
! 		    if (tcinscost(i) < pfxlen(nl + i, ol)) {
  			tc_inschars(i);
! 			zwrite(nl, i, 1, shout);
! 			nl += i;
  			char_ins += i;
+ 			ccs = (vcs += i);
  		    /* if we've pushed off the right, truncate oldline */
! 			for (i = 0; *(ol + i) && i < winw - ccs; i++);
! 			if (i == winw - ccs)
! 			    *(ol + i) = '\0';
! 			i = 0;
  			break;
  		    }
! 		if (!i)
  		    continue;
  	    }
  	}
      /* we can't do any fancy tricks, so just dump the single character
         and keep on trying */
! 	zputc(*nl, shout);
  	nl++, ol++;
  	ccs++, vcs++;
      }
***************
*** 695,712 ****
      if (vcs == winw) {
  	vln++, vcs = 0;
  	if (!hasam) {
! 	    putc('\r', shout);
! 	    putc('\n', shout);
  	} else {
  	    if ((vln < nlnct) && nbuf[vln] && *nbuf[vln])
! 		putc(*nbuf[vln], shout);
  	    else
! 		putc(' ', shout);
! 	    putc('\r', shout);
  	    if ((vln < olnct) && obuf[vln] && *obuf[vln])
  		*obuf[vln] = *nbuf[vln];
  	}
- 	SELECT_ADD_COST(2);
      }
  
      if (ln == vln && cl == vcs)
--- 706,722 ----
      if (vcs == winw) {
  	vln++, vcs = 0;
  	if (!hasam) {
! 	    zputc('\r', shout);
! 	    zputc('\n', shout);
  	} else {
  	    if ((vln < nlnct) && nbuf[vln] && *nbuf[vln])
! 		zputc(*nbuf[vln], shout);
  	    else
! 		zputc(' ', shout);
! 	    zputc('\r', shout);
  	    if ((vln < olnct) && obuf[vln] && *obuf[vln])
  		*obuf[vln] = *nbuf[vln];
  	}
      }
  
      if (ln == vln && cl == vcs)
***************
*** 732,742 ****
  		vln = ln;
  		continue;
  	    }
! 	putc('\r', shout), vcs = 0; /* safety precaution */
! 	SELECT_ADD_COST(1);
  	while (ln > vln) {
! 	    putc('\n', shout);
! 	    SELECT_ADD_COST(1);
  	    vln++;
  	}
      }
--- 742,750 ----
  		vln = ln;
  		continue;
  	    }
! 	zputc('\r', shout), vcs = 0; /* safety precaution */
  	while (ln > vln) {
! 	    zputc('\n', shout);
  	    vln++;
  	}
      }
***************
*** 747,754 ****
  /* choose cheapest movements for ttys without multiple movement capabilities -
     do this now because it's easier (to code) */
      if (cl <= vcs / 2) {
! 	putc('\r', shout);
! 	SELECT_ADD_COST(1);
  	vcs = 0;
      }
      if (vcs < cl)
--- 755,761 ----
  /* choose cheapest movements for ttys without multiple movement capabilities -
     do this now because it's easier (to code) */
      if (cl <= vcs / 2) {
! 	zputc('\r', shout);
  	vcs = 0;
      }
      if (vcs < cl)
***************
*** 762,773 ****
  int
  tcmultout(int cap, int multcap, int ct)
  {
!     if (tccan(multcap) && (!tccan(cap) || tclen[multcap] < tclen[cap] * ct)) {
  	tcoutarg(multcap, ct);
- 	SELECT_ADD_COST(tclen[multcap]);
  	return 1;
      } else if (tccan(cap)) {
- 	SELECT_ADD_COST((tclen[cap] * ct));
  	while (ct--)
  	    tcout(cap);
  	return 1;
--- 769,778 ----
  int
  tcmultout(int cap, int multcap, int ct)
  {
!     if (tccan(multcap) && (!tccan(cap) || tclen[multcap] <= tclen[cap] * ct)) {
  	tcoutarg(multcap, ct);
  	return 1;
      } else if (tccan(cap)) {
  	while (ct--)
  	    tcout(cap);
  	return 1;
***************
*** 780,816 ****
  tc_rightcurs(int cl)
  {
      int ct,			/* number of characters to move across	    */
! 	horz_tabs = 0,		/* number of horizontal tabs if we do them  */
  	i = vcs,		/* cursor position after initial movements  */
! 	j;			/* number of chars outputted		    */
      char *t;
  
!     j = ct = cl - vcs;
  
! /* calculate how many horizontal tabs it would take, if we can do them -
!    tabs are assumed to be 8 spaces */
!     if (tccan(TCNEXTTAB) && ((vcs | 7) < cl)) {
! 	horz_tabs = 1;
! 	i = (vcs | 7) + 1;
! 	for (; i + 8 <= cl; i += 8)
! 	    horz_tabs++;
! 	j = cl - i;		/* number of chars after last tab */
! 	j += (horz_tabs * tclen[TCNEXTTAB]); /* # of chars if we use tabs */
!     }
! 
! /* do a multright if we can - if it's cheaper or we can't use other tricks */
!     if (tccan(TCMULTRIGHT)
! 	&& (!tccan(TCNEXTTAB) || (tclen[TCMULTRIGHT] <= j)
! 	    || (vln == 0 && i < pptw))) {
  	tcoutarg(TCMULTRIGHT, ct);
- 	SELECT_ADD_COST(tclen[TCMULTRIGHT]);
  	return;
      }
  
! /* try to go with tabs if a multright is not feasible/convenient */
!     if (horz_tabs) {
! 	SELECT_ADD_COST((tclen[TCNEXTTAB] * horz_tabs));
! 	for (; horz_tabs--;)
  	    tcout(TCNEXTTAB);
  	if ((ct = cl - i) == 0) /* number of chars still to move across */
  	    return;
--- 785,808 ----
  tc_rightcurs(int cl)
  {
      int ct,			/* number of characters to move across	    */
! 	horz_tabs,		/* number of horizontal tabs if we do them  */
  	i = vcs,		/* cursor position after initial movements  */
! 	j;
      char *t;
  
!     ct = cl - vcs;
  
! /* do a multright if we can - it's the most reliable */
!     if (tccan(TCMULTRIGHT)) {
  	tcoutarg(TCMULTRIGHT, ct);
  	return;
      }
  
! /* try tabs if tabs are non destructive and multright is not possible */
!     if (!oxtabs && tccan(TCNEXTTAB) && ((vcs | 7) < cl)) {
! 	horz_tabs = 1;
! 	i = (vcs | 7) + 1;
! 	for ( ; i + 8 <= cl; i += 8)
  	    tcout(TCNEXTTAB);
  	if ((ct = cl - i) == 0) /* number of chars still to move across */
  	    return;
***************
*** 820,854 ****
     if we're anywhere in the prompt, goto the left column and write the whole
     prompt out unless lpptlen == pptw : we can cheat then */
      if (vln == 0 && i < pptw) {
! 	if (lpptlen == pptw) {
! 	    SELECT_ADD_COST(lpptlen - i);
! 	    fwrite(lpptbuf + i, lpptlen - i, 1, shout);
! 	} else if (tccan(TCRIGHT) && (tclen[TCRIGHT] * ct < lpptlen)) {
  	    /* it is cheaper to send TCRIGHT than reprint the whole prompt */
- 	    SELECT_ADD_COST(ct);
  	    for ( ; ct--; )
  		tcout(TCRIGHT);
!         } else {
! 	    if (i != 0) {
! 		SELECT_ADD_COST(1);
! 		putc('\r', shout);
! 	    }
! 	    SELECT_ADD_COST(lpptlen);
! 	    fwrite(lpptbuf, lpptlen, 1, shout);
  	}
  	i = pptw;
  	ct = cl - i;
      }
  
-     SELECT_ADD_COST(ct);
      if (nbuf[vln]) {
  	for (j = 0, t = nbuf[vln]; *t && (j < i); j++, t++);
  	if (j == i)
  	    for ( ; *t && ct; ct--, t++)
! 		putc(*t, shout);
      }
      while (ct--)
! 	putc(' ', shout);	/* not my fault your terminal can't go right */
  }
  
  /**/
--- 812,840 ----
     if we're anywhere in the prompt, goto the left column and write the whole
     prompt out unless lpptlen == pptw : we can cheat then */
      if (vln == 0 && i < pptw) {
! 	if (lpptlen == pptw)
! 	    zwrite(lpptbuf + i, lpptlen - i, 1, shout);
! 	else if (tccan(TCRIGHT) && (tclen[TCRIGHT] * ct <= lpptlen))
  	    /* it is cheaper to send TCRIGHT than reprint the whole prompt */
  	    for ( ; ct--; )
  		tcout(TCRIGHT);
!         else {
! 	    if (i != 0)
! 		zputc('\r', shout);
! 	    zwrite(lpptbuf, lpptlen, 1, shout);
  	}
  	i = pptw;
  	ct = cl - i;
      }
  
      if (nbuf[vln]) {
  	for (j = 0, t = nbuf[vln]; *t && (j < i); j++, t++);
  	if (j == i)
  	    for ( ; *t && ct; ct--, t++)
! 		zputc(*t, shout);
      }
      while (ct--)
! 	zputc(' ', shout);	/* not my fault your terminal can't go right */
  }
  
  /**/
***************
*** 858,867 ****
      int ret = 0;
  
      if (ct && !tcmultout(TCDOWN, TCMULTDOWN, ct)) {
- 	SELECT_ADD_COST(ct + 1);
  	while (ct--)
! 	    putc('\n', shout);
! 	putc('\r', shout), ret = -1;
      }
      return ret;
  }
--- 844,852 ----
      int ret = 0;
  
      if (ct && !tcmultout(TCDOWN, TCMULTDOWN, ct)) {
  	while (ct--)
! 	    zputc('\n', shout);
! 	zputc('\r', shout), ret = -1;
      }
      return ret;
  }
***************
*** 871,883 ****
  tcout(int cap)
  {
      tputs(tcstr[cap], 1, putshout);
  }
  
  /**/
  void
  tcoutarg(int cap, int arg)
  {
!     tputs(tgoto(tcstr[cap], arg, arg), 1, putshout);
  }
  
  /**/
--- 856,873 ----
  tcout(int cap)
  {
      tputs(tcstr[cap], 1, putshout);
+     SELECT_ADD_COST(tclen[cap]);
  }
  
  /**/
  void
  tcoutarg(int cap, int arg)
  {
!     char *result;
! 
!     result = tgoto(tcstr[cap], arg, arg);
!     tputs(result, 1, putshout);
!     SELECT_ADD_COST(strlen(result));
  }
  
  /**/
***************
*** 894,900 ****
  redisplay(void)
  {
      moveto(0, pptw);
!     putc('\r', shout);
      resetneeded = 1;
      clearflag = 0;
  }
--- 884,890 ----
  redisplay(void)
  {
      moveto(0, pptw);
!     zputc('\r', shout);
      resetneeded = 1;
      clearflag = 0;
  }
***************
*** 980,986 ****
  
  	if (!*refreshop) {
  	    if ((t0 = strlen(vp)))
! 		fwrite(vp, t0, 1, shout);
  	    vcs += t0;
  	    break;
  	}
--- 970,976 ----
  
  	if (!*refreshop) {
  	    if ((t0 = strlen(vp)))
! 		zwrite(vp, t0, 1, shout);
  	    vcs += t0;
  	    break;
  	}
***************
*** 989,998 ****
  		tcout(TCCLEAREOL);
  	    else
  		for (; *refreshop++; vcs++)
! 		    putc(' ', shout);
  	    break;
  	}
! 	putc(*vp, shout);
  	vcs++, t0++;
  	vp++, refreshop++;
      }
--- 979,988 ----
  		tcout(TCCLEAREOL);
  	    else
  		for (; *refreshop++; vcs++)
! 		    zputc(' ', shout);
  	    break;
  	}
! 	zputc(*vp, shout);
  	vcs++, t0++;
  	vp++, refreshop++;
      }
***************
*** 1012,1018 ****
      if (pos == vcs)
  	return;
      if (pos <= vcs / 2) {
! 	putc('\r', shout);
  	vcs = 0;
      }
      if (pos < vcs) {
--- 1002,1008 ----
      if (pos == vcs)
  	return;
      if (pos <= vcs / 2) {
! 	zputc('\r', shout);
  	vcs = 0;
      }
      if (pos < vcs) {
***************
*** 1024,1030 ****
  	    vcs = pos;
  	else
  	    while (pos > vcs) {
! 		putc(nbuf[0][vcs], shout);
  		vcs++;
  	    }
      }
--- 1014,1020 ----
  	    vcs = pos;
  	else
  	    while (pos > vcs) {
! 		zputc(nbuf[0][vcs], shout);
  		vcs++;
  	    }
      }

-- 
Geoff Wing [gwing@primenet.com.au]   Technical Manager
  Phone    : +61-3-9818 2977	     PrimeNet - Internet Consultancy
  Facsimile: +61-3-9819 3788	     Web : <URL:http://www.primenet.com.au/>
  Mobile   : 0412 162 441


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

* Re: 4 bugs (1 more fixed)
  1996-11-08 12:24 ` 4 bugs (1 more fixed) Geoff Wing
@ 1996-11-08 16:33   ` Bart Schaefer
  1996-11-09  4:52     ` Geoff Wing
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 1996-11-08 16:33 UTC (permalink / raw)
  To: Geoff Wing, zsh-workers

On Nov 8, 11:24pm, Geoff Wing wrote:
} Subject: Re: 4 bugs (1 more fixed)
}
} 2b) Hard tabs are used next if the tty settings aren't set to expand tabs as
}     spaces - this could use some checking by people who have old sgtty stuff.

This may be a bad idea on terminals with programmable tabstops.  I guess
it's safe to assume that anyone who has reset tab stops has `stty -tabs`
as well, but it might be nice to have a(nother) way to tell zsh not to
use this particular motion optimization.


-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: 4 bugs (1 more fixed)
  1996-11-08 16:33   ` Bart Schaefer
@ 1996-11-09  4:52     ` Geoff Wing
  0 siblings, 0 replies; 6+ messages in thread
From: Geoff Wing @ 1996-11-09  4:52 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
:} 2b) Hard tabs are used next if the tty settings aren't set to expand tabs as
:}     spaces - this could use some checking by people who have old sgtty stuff.
:This may be a bad idea on terminals with programmable tabstops.  I guess
:it's safe to assume that anyone who has reset tab stops has `stty -tabs`
:as well, but it might be nice to have a(nother) way to tell zsh not to
:use this particular motion optimization.

Zsh has been using tabs since 2.5 - the change now is not to use them if they
are destructive.  There have been a few things I would have liked to make
options for, but people haven't wanted too many setopt's so I've avoided them.

One is for using tabs.
Another is scrolling of the screen, which is now linked to BAUD.
I can't think of the others at the moment, but they were probably linked to
automargin stuff.
-- 
Geoff Wing [gwing@primenet.com.au]   Technical Manager
  Phone    : +61-3-9818 2977	     PrimeNet - Internet Consultancy
  Facsimile: +61-3-9819 3788	     Web : <URL:http://www.primenet.com.au/>
  Mobile   : 0412 162 441


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

* Re: 4 bugs
  1996-10-30  0:48 4 bugs Geoff Wing
  1996-10-31  1:28 ` Zoltan Hidvegi
  1996-11-08 12:24 ` 4 bugs (1 more fixed) Geoff Wing
@ 1996-11-09  5:24 ` Geoff Wing
  2 siblings, 0 replies; 6+ messages in thread
From: Geoff Wing @ 1996-11-09  5:24 UTC (permalink / raw)
  To: zsh-workers

I wrote:
:4. I'm sitting here trying to think of the fourth bug I found.......
:   just a minute... I'm sure it'll come back to me....... typing doesn't
:   help you remember......oh yes, it was:
:% $(cat nothing)<TAB>
:produces
:% $(cat nothing)cat: nothing: No such file or directory
: <--- cursor here

The question here is, is there a case where we need the command's output
(in this case ``cat'') from stderr?
If there is, should some attempt to made to format it, ie. call trashzle()
and put the stderr below and then below that refresh the line?
If there isn't, then we should discard stderr.
-- 
Geoff Wing [gwing@primenet.com.au]   Technical Manager
  Phone    : +61-3-9818 2977	     PrimeNet - Internet Consultancy
  Facsimile: +61-3-9819 3788	     Web : <URL:http://www.primenet.com.au/>
  Mobile   : 0412 162 441


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

end of thread, other threads:[~1996-11-09  5:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-30  0:48 4 bugs Geoff Wing
1996-10-31  1:28 ` Zoltan Hidvegi
1996-11-08 12:24 ` 4 bugs (1 more fixed) Geoff Wing
1996-11-08 16:33   ` Bart Schaefer
1996-11-09  4:52     ` Geoff Wing
1996-11-09  5:24 ` 4 bugs Geoff Wing

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