Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

3rd zle_refresh.c patch (Was: That infinite loop in Geoff's second zle_refresh patch)



Bart Schaefer wrote:
:On Jul 17, 12:03pm, Peter Stephenson wrote:
:> schaefer@xxxxxxxxxxxxxxxxxxxxxxx wrote:
:> > The patch below changes starting count from 0 to 1, which stops the
:> > infinite loop, but feels wrong to me.
:> This has a bad effect:  inserting or deleting on a continued line
:> before the end of the line redisplays the rest of line wrongly.
:I still don't understand (a) why the code worked before, as it was
:calling tcdelcost(0) long ago; nor (b) what made it break this time.
:Any insight, Geoff?

Mysterious are the ways of the C compilers.

:On Jul 18, 12:21am, Geoff Wing wrote:
:> Looks fine to me.  I give it my blessing :-)  

Whoops, just a bit fast about that.  I hurriedly wrote this because I
was about to leave work, then thought of a problem driving home from work
(OK, OK, it was past midnight, forgive me please :-)

:And there's no problem with the fact that `for (...; *p1; p1++, i++)'
:now has i indexing one position farther into p1?  (That looked OK to
:me -- in fact, it made more sense than what was there before, as i
:is now the length of the substring that gets printed out of p1 -- but
:I don't deeply understand the surrounding code, so ....)

Um, yes, it's a problem. i  is wrong.  For delete stuff - if we match two
chars ahead, then we've incremented p1 twice and i should equal 2. (Well,
that's my logic anyway).  Similarly for insert stuff.
However, given there's implicitly never a match on the first char anyway,
we can start with  i = 1.

This is a patch on my previous two patches (not including Bart Schaefer's
patch in 1674, nor zefram's patch in 1678)  (This better be right, it's 
4 am and I'm going to go to sleep!!)


*** zle_refresh.c.~2~	Mon Jul 15 22:05:16 1996
--- zle_refresh.c	Thu Jul 18 03:59:23 1996
***************
*** 620,626 ****
  	   eg. oldline: hifoobar } hopefully cheaper here to delete two
  	       newline: foobar	 } characters, then we have six matches */
  	    if (tccan(TCDEL)) {
! 		for (i = 0, p1 = ol; *p1; p1++, i++)
  		    if (tcdelcost(i) < pfxlen(p1, nl)) {
  			tc_delchars(i);
  			SELECT_ADD_COST(i);
--- 620,626 ----
  	   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);
***************
*** 636,642 ****
  	   undesired scrolling occurs due to `illegal' characters on screen */
  
  	    if (tccan(TCINS) && (vln != lines - 1)) {	/* not on last line */
! 		for (i = 0, p1 = nl; *p1; p1++, i++)
  		    if (tcinscost(i) < pfxlen(p1, ol)) {
  			tc_inschars(i);
  			SELECT_ADD_COST(2 * i);
--- 636,642 ----
  	   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);






-- 
Mason [G.C.W]  mason@xxxxxxxxxxxxxxxxxx    "Hurt...Agony...Pain...LOVE-IT"




Messages sorted by: Reverse Date, Date, Thread, Author