zsh-workers
 help / color / mirror / code / Atom feed
* Re: Patch available for 3.0.6-pre-0
@ 1999-04-23 14:13 Sven Wischnowsky
  0 siblings, 0 replies; 14+ messages in thread
From: Sven Wischnowsky @ 1999-04-23 14:13 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> I seem to remember that one of the
> patches I sent after 4988 (which is the last entry with my name in it
> in the ChangeLog) fixed something that might be buggy in
> 3.0.[56]. Unfortunately I forgot to write myself a note about this and
> I can't remember what it was.

I found /them/:

 - Completion inside $((...)) didn't work -- see message 5799.
 - The other fix was hidden in 5564: at the end of makecomplist(),
   `addmatches' is set and then a couple of `dumphashtable()'s may be
   called and also some `addmatch()'es directly. Since
   `dumphashtable()' sets `addwhat' but doesn't restore it this may
   sometimes have the wrong value. Most significantly, if you have
   `compctl -vb foo', `foo <TAB>' seg-faults.

The patch also avoids some `suggest brace around ambiguous else'
messages.

Bye
 Sven

--- Src/zle_tricky.c.old	Thu Apr 22 09:04:42 1999
+++ Src/zle_tricky.c	Fri Apr 23 16:05:34 1999
@@ -578,7 +578,7 @@
 	    if (*q == Equals) {
 		/* The word starts with `=', see if we can expand it. */
 		q = s + 1;
-		if (cmdnamtab->getnode(cmdnamtab, q) || hashcmd(q, pathchecked))
+		if (cmdnamtab->getnode(cmdnamtab, q) || hashcmd(q, pathchecked)) {
 		    if (isset(RECEXACT))
 			lst = COMP_EXPAND;
 		    else {
@@ -600,6 +600,7 @@
 			if (n == 1)
 			    lst = COMP_EXPAND;
 		    }
+		}
 	    }
 	    if (lst == COMP_EXPAND_COMPLETE)
 		do {
@@ -708,11 +709,12 @@
 		if (*p == Tilde || *p == Equals)
 		    p++;
 		for (; *p; p++)
-		    if (itok(*p))
+		    if (itok(*p)) {
 			if (*p != String && *p != Qstring)
 			    *p = ztokens[*p - Pound];
 			else if (p[1] == Inbrace)
 			    p++, skipparens(Inbrace, Outbrace, &p);
+		    }
 		docompletion(s, lst, lincmd, 1);
 	    }
 	} else
@@ -1017,12 +1019,16 @@
 	    if (parend >= 0 && !tmp)
 		line = (unsigned char *) dupstring(tmp = (char *)line);
 	    linptr = (char *) line + ll + addedx - parbegin + 1;
-	    if (parend >= 0) {
-		ll -= parend;
-		line[ll + addedx] = '\0';
+
+	    if ((linptr - (char *) line) < 2 ||
+		linptr[-1] != '(' || linptr[-2] != '$') {
+		if (parend >= 0) {
+		    ll -= parend;
+		    line[ll + addedx] = '\0';
+		}
+		lexrestore();
+		goto start;
 	    }
-	    lexrestore();
-	    goto start;
 	}
 
 	if (inwhat == IN_MATH)
@@ -1272,7 +1278,7 @@
 			   *u == (char)bangchar) ||
 	     (instring == 2 &&
 	      (*u == '$' || *u == '`' || *u == '\"')) ||
-	     (instring == 1 && *u == '\'')))
+	     (instring == 1 && *u == '\''))) {
 	    if (*u == '\n' || (instring == 1 && *u == '\'')) {
 		if (unset(RCQUOTES)) {
 		    *v++ = '\'';
@@ -1287,6 +1293,7 @@
 		continue;
 	    } else
 		*v++ = '\\';
+	}
 	if(*u == Meta)
 	    *v++ = *u++;
 	*v++ = *u;
@@ -1923,14 +1930,14 @@
 dumphashtable(HashTable ht, int what)
 {
     HashNode hn;
-    int i;
+    int i, aw = addwhat;
 
     addwhat = what;
 
     for (i = 0; i < ht->hsize; i++)
 	for (hn = ht->nodes[i]; hn; hn = hn->next)
 	    addmatch(hn->nam, (char *) hn);
-
+    addwhat = aw;
 }
 
 /* ScanFunc used by maketildelist() et al. */
@@ -3342,7 +3349,7 @@
 	    menuend = ll;
 	if (menuend && ((((char)line[menuend - 1]) != singlec) ||
 	    (menuend > 1 && singlec == ' ' &&
-	      (line[menuend - 2] == '\\' || line[menuend - 2] == STOUC(Meta)))))
+	     (line[menuend - 2] == '\\' || line[menuend - 2] == STOUC(Meta))))) {
 	    if (parampre && singlec == '/' && ((char)line[menuend]) == '/')
 		addedsuffix = 0;
 	    /* Now insert the slash or space if there is none already. */
@@ -3357,6 +3364,7 @@
 		if (!menuwe)
 		    cs = ccs;
 	    }
+	}
     }
     /* Move to the end of the word if requested. */
     if (isset(ALWAYSTOEND) || menuwe)
@@ -3664,7 +3672,7 @@
 	if (t1 != colsz - 1 || !clearflag)
 	    putc('\n', shout);
     }
-    if (clearflag)
+    if (clearflag) {
 	/* Move the cursor up to the prompt, if always_last_prompt *
 	 * is set and all that...                                  */
 	if (up < lines) {
@@ -3672,6 +3680,7 @@
 	    showinglist = -1;
 	} else
 	    clearflag = 0, putc('\n', shout);
+    }
 }
 
 /* This is used to print expansions. */

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-26 15:22           ` Tatsuo Furukawa
@ 1999-04-27 16:24             ` Bart Schaefer
  0 siblings, 0 replies; 14+ messages in thread
From: Bart Schaefer @ 1999-04-27 16:24 UTC (permalink / raw)
  To: Tatsuo Furukawa; +Cc: zsh-workers

On Apr 27, 12:22am, Tatsuo Furukawa wrote:
} Subject: Re: Patch available for 3.0.6-pre-0
}
} Geoff> It's against virgin 3.0.5 sources.
} 
} Now, the newest is 3.0.6-pre-1.  So, I made Geoff's patch againt
} 3.0.6-pre-1 version.  I hope that it will help reducing maintainer's
} work.

Thanks; normally it would have, but in this particular case I was already
maintaining three parallel CVS sandboxes to track overlapping patches, so
I'd already taken care of this with a merge.

Hold on to the thought for next time, though.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-25  6:57         ` Geoff Wing
@ 1999-04-26 15:22           ` Tatsuo Furukawa
  1999-04-27 16:24             ` Bart Schaefer
  0 siblings, 1 reply; 14+ messages in thread
From: Tatsuo Furukawa @ 1999-04-26 15:22 UTC (permalink / raw)
  To: mason, schaefer; +Cc: zsh-workers


Hi, Bart & Geoff.

Bart> In particular, emitting the ch capability may require up to six
Bart> or seven bytes, where a relative horizontal or vertical move
Bart> might require fewer (depending on distance).

I didn't know that...

Geoff> This is a replacement for the zle_refresh.c patch (not the
Geoff> globals.h or zsh.h patch parts) moving a couple of things
Geoff> around and moving comments back to their appropriate spot.
Geoff> I've compiled it but haven't tested it a lot yet.

Geoff> Comments welcome.

I tested on hpterm, and (of course!) it worked well.  No problem!

So, I hope that Geoff's patch will be applied new zsh.


Geoff> It's against virgin 3.0.5 sources.

Now, the newest is 3.0.6-pre-1.  So, I made Geoff's patch againt
3.0.6-pre-1 version.  I hope that it will help reducing maintainer's
work.



diff -ur zsh-3.0.6-pre1-orig/Src/globals.h zsh-3.0.6-pre1-new/Src/globals.h
--- zsh-3.0.6-pre1-orig/Src/globals.h	Wed Apr 21 18:53:47 1999
+++ zsh-3.0.6-pre1-new/Src/globals.h	Mon Apr 26 20:33:08 1999
@@ -614,7 +614,7 @@
 {
     "cl", "le", "LE", "nd", "RI", "up", "UP", "do",
     "DO", "dc", "DC", "ic", "IC", "cd", "ce", "al", "dl", "ta",
-    "md", "so", "us", "me", "se", "ue"
+    "md", "so", "us", "me", "se", "ue", "ch"
 };
 #else
 extern char *tccapnams[TC_COUNT];
diff -ur zsh-3.0.6-pre1-orig/Src/zle_refresh.c zsh-3.0.6-pre1-new/Src/zle_refresh.c
--- zsh-3.0.6-pre1-orig/Src/zle_refresh.c	Mon Apr 26 20:21:08 1999
+++ zsh-3.0.6-pre1-new/Src/zle_refresh.c	Mon Apr 26 20:31:26 1999
@@ -810,20 +810,8 @@
 	}
     }
 
-    if (cl == vcs)
-	return;
-
-/* 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)
-	tc_rightcurs(cl);
-    else if (vcs > cl)
-	tc_leftcurs(vcs - cl);
-    vcs = cl;
+    if (cl != vcs)
+       singmoveto(cl);
 }
 
 /**/
@@ -841,16 +829,17 @@
     return 0;
 }
 
+/* ct: number of characters to move across */
 /**/
 void
-tc_rightcurs(int cl)
+tc_rightcurs(int ct)
 {
-    int ct,			/* number of characters to move across	    */
+    int cl,			/* ``desired'' absolute horizontal position */
 	i = vcs,		/* cursor position after initial movements  */
 	j;
     char *t;
 
-    ct = cl - vcs;
+    cl = ct + vcs;
 
 /* do a multright if we can - it's the most reliable */
     if (tccan(TCMULTRIGHT)) {
@@ -858,6 +847,13 @@
 	return;
     }
 
+/* do an absolute horizontal position if we can */
+    if (tccan(TCHORIZPOS)) {
+	tcoutarg(TCHORIZPOS, cl);
+	return;
+    }
+
+/* XXX: should really check "it" in termcap and use / and % */
 /* try tabs if tabs are non destructive and multright is not possible */
     if (!oxtabs && tccan(TCNEXTTAB) && ((vcs | 7) < cl)) {
 	i = (vcs | 7) + 1;
@@ -1062,23 +1058,21 @@
 {
     if (pos == vcs)
 	return;
-    if (pos <= vcs / 2) {
+
+/* choose cheapest movements for ttys without multiple movement capabilities -
+   do this now because it's easier (to code) */
+
+    if ((!tccan(TCMULTLEFT) || pos == 0) && (pos <= vcs / 2)) {
 	zputc('\r', shout);
 	vcs = 0;
     }
-    if (pos < vcs) {
+
+    if (pos < vcs)
 	tc_leftcurs(vcs - pos);
-	vcs = pos;
-    }
-    if (pos > vcs) {
-	if (tcmultout(TCRIGHT, TCMULTRIGHT, pos - vcs))
-	    vcs = pos;
-	else
-	    while (pos > vcs) {
-		zputc(nbuf[0][vcs], shout);
-		vcs++;
-	    }
-    }
+    else if (pos > vcs)
+	tc_rightcurs(pos - vcs);
+
+    vcs = pos;
 }
 
 /* generate left and right prompts */
diff -ur zsh-3.0.6-pre1-orig/Src/zsh.h zsh-3.0.6-pre1-new/Src/zsh.h
--- zsh-3.0.6-pre1-orig/Src/zsh.h	Wed Apr 21 18:53:49 1999
+++ zsh-3.0.6-pre1-new/Src/zsh.h	Mon Apr 26 20:33:54 1999
@@ -1249,7 +1249,8 @@
 #define TCALLATTRSOFF  21
 #define TCSTANDOUTEND  22
 #define TCUNDERLINEEND 23
-#define TC_COUNT       24
+#define TCHORIZPOS     24
+#define TC_COUNT       25
 
 #define tccan(X) (tclen[X])

-- 
Tatsuo Furukawa (frkwtto@osk3.3web.ne.jp)


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-24  5:53       ` Bart Schaefer
@ 1999-04-25  6:57         ` Geoff Wing
  1999-04-26 15:22           ` Tatsuo Furukawa
  0 siblings, 1 reply; 14+ messages in thread
From: Geoff Wing @ 1999-04-25  6:57 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer@brasslantern.com> typed:
:On Apr 23, 12:07am, Tatsuo Furukawa wrote:
:I'd like at least Geoff's opinion before I commit to doing anything with
:this patch.  In particular, emitting the ch capability may require up to
:six or seven bytes, where a relative horizontal or vertical move might
:require fewer (depending on distance).  I'm not sure just how optimized
:this code is supposed to be.  Also, the "if (pos <= vcs / 2)" test may be
:optimizing for an absolute move by tc_rightcurs(), and may not be as good
:any longer if tc_rightcurs() makes a relative motion.  Geoff's the expert
:on what's supposed to be happening in here.

OK, I tried to find my notes here on a couple of items but failed - the
stacks of paper were just too big :-(  - so a couple of comments here are
from memory.
* tab output is more of a last resort type thing though it has taken
  precendence over outputing the rest of the line.  The reason it's not
  preferred is that I'm not sure we can presume we know the absolute
  position of the cursor and the prompt within the prompt line. 
  Why?  ``setopt nopromptcr''
* I've moved the outputing of absolute cursor movement to just before tab
  movement which probably needs enhancing anyway since it's presuming
  tab positions of 8 which while not unreasonable is not necessarily
  correct (on maybe 0.0001% of terminals)
* On another topic, I've still got to look through Sven's CLEAREOD solution
  which I _really_ dislike the look of.  Of course, if it is necessary ....

This is a replacement for the zle_refresh.c patch (not the globals.h or
zsh.h patch parts) moving a couple of things around and moving comments
back to their appropriate spot.  I've compiled it but haven't tested it
a lot yet.  It's against virgin 3.0.5 sources.  Comments welcome.


*** zle_refresh.c.~1~	Fri Sep 26 11:42:19 1997
--- zle_refresh.c	Sun Apr 25 16:34:26 1999
***************
*** 808,827 ****
  	}
      }
  
!     if (cl == vcs)
! 	return;
! 
! /* 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)
! 	tc_rightcurs(cl);
!     else if (vcs > cl)
! 	tc_leftcurs(vcs - cl);
!     vcs = cl;
  }
  
  /**/
--- 808,815 ----
  	}
      }
  
!     if (cl != vcs)
!        singmoveto(cl);
  }
  
  /**/
***************
*** 839,854 ****
      return 0;
  }
  
  /**/
  void
! tc_rightcurs(int cl)
  {
!     int ct,			/* number of characters to move across	    */
  	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)) {
--- 827,843 ----
      return 0;
  }
  
+ /* ct: number of characters to move across */
  /**/
  void
! tc_rightcurs(int ct)
  {
!     int cl,			/* ``desired'' absolute horizontal position */
  	i = vcs,		/* cursor position after initial movements  */
  	j;
      char *t;
  
!     cl = ct + vcs;
  
  /* do a multright if we can - it's the most reliable */
      if (tccan(TCMULTRIGHT)) {
***************
*** 856,861 ****
--- 845,857 ----
  	return;
      }
  
+ /* do an absolute horizontal position if we can */
+     if (tccan(TCHORIZPOS)) {
+ 	tcoutarg(TCHORIZPOS, cl);
+ 	return;
+     }
+ 
+ /* XXX: should really check "it" in termcap and use / and % */
  /* try tabs if tabs are non destructive and multright is not possible */
      if (!oxtabs && tccan(TCNEXTTAB) && ((vcs | 7) < cl)) {
  	i = (vcs | 7) + 1;
***************
*** 1060,1082 ****
  {
      if (pos == vcs)
  	return;
!     if (pos <= vcs / 2) {
  	zputc('\r', shout);
  	vcs = 0;
      }
!     if (pos < vcs) {
  	tc_leftcurs(vcs - pos);
! 	vcs = pos;
!     }
!     if (pos > vcs) {
! 	if (tcmultout(TCRIGHT, TCMULTRIGHT, pos - vcs))
! 	    vcs = pos;
! 	else
! 	    while (pos > vcs) {
! 		zputc(nbuf[0][vcs], shout);
! 		vcs++;
! 	    }
!     }
  }
  
  /* generate left and right prompts */
--- 1056,1076 ----
  {
      if (pos == vcs)
  	return;
! 
! /* choose cheapest movements for ttys without multiple movement capabilities -
!    do this now because it's easier (to code) */
! 
!     if ((!tccan(TCMULTLEFT) || pos == 0) && (pos <= vcs / 2)) {
  	zputc('\r', shout);
  	vcs = 0;
      }
! 
!     if (pos < vcs)
  	tc_leftcurs(vcs - pos);
!     else if (pos > vcs)
! 	tc_rightcurs(pos - vcs);
! 
!     vcs = pos;
  }
  
  /* generate left and right prompts */


-- 
Geoff Wing   <gcw@pobox.com>            Mobile : (Australia) 0413 431 874 <<<new
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-24  4:32   ` Bart Schaefer
@ 1999-04-24  7:12     ` Wayne Davison
  0 siblings, 0 replies; 14+ messages in thread
From: Wayne Davison @ 1999-04-24  7:12 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

"Bart Schaefer" writes:
> Exactly what warning were you silencing in this case?

The "ambiguous else" warning.  A brace-less "if" that has an "if"
macro after it gets turned into "if (...) if (...) ... else ...",
which causes the warning.  My solution was to add the braces to the
calling "if", which turns it into "if (...) { if (...) ... else ... }".

> The reason most of those macros look like
>     #define thing() if (! testthing) {;} else dothing
> and *not*
>     #define thing() if (testthing) dothing
> is to prevent ambiguous/erroneous "else" situations.

Yeah, I'm familiar with the dangers of adding such else-less ifs via
a macro.  My statement was mainly meant to explain why some ifs that
are followed by a single line needed braces added to them (since it
would be easy for you to look at what I'd done and think that I was
just not following the current coding style).

I personally don't think that we need to change the macros for the
release of 3.0.6, but I figured I'd mention it in case you felt
otherwise.  Long term, I think that we should consolidate all the
multi-line macros into a single style that avoids ambiguous-else
warnings, but that work may not affect the 3.0.* code base.

I also agree with you that the "do { ... } while (0)" style is one
of the best when a macro includes multiple lines of code (since I
personally dislike omitting semi-colons from the macro references).
I hadn't noticed that this was used in the code -- I just saw some
defines being called without semi-colons, and I assumed that that
was the zsh style.

..wayne..


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-22 15:07     ` Tatsuo Furukawa
@ 1999-04-24  5:53       ` Bart Schaefer
  1999-04-25  6:57         ` Geoff Wing
  0 siblings, 1 reply; 14+ messages in thread
From: Bart Schaefer @ 1999-04-24  5:53 UTC (permalink / raw)
  To: zsh-workers

On Apr 23, 12:07am, Tatsuo Furukawa wrote:
} Subject: Re: Patch available for 3.0.6-pre-0
}
} I think that most of users is NOT affected by this patch.  Because
} NORMAL terminal has RI= entry.  If the terminal has RI= entry, zsh
} will use it.  If it doesn't, zsh will use another method (TAB will be
} used).  So, maybe, I think you will not affect any more.
} 
} But, I am begining to think that it is not interesting to apply
} degrade patch.  So, I wrote a new patch. :-)
} 
} I added the code that zsh supports 'ch=' entry.
} And I found that zle_refresh.c has two similar function.
} (tc_rightcurs() and singmoveto()).  I modified tc_rightcurs().

I'd like at least Geoff's opinion before I commit to doing anything with
this patch.  In particular, emitting the ch capability may require up to
six or seven bytes, where a relative horizontal or vertical move might
require fewer (depending on distance).  I'm not sure just how optimized
this code is supposed to be.  Also, the "if (pos <= vcs / 2)" test may be
optimizing for an absolute move by tc_rightcurs(), and may not be as good
any longer if tc_rightcurs() makes a relative motion.  Geoff's the expert
on what's supposed to be happening in here.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-21 23:52 ` Wayne Davison
@ 1999-04-24  4:32   ` Bart Schaefer
  1999-04-24  7:12     ` Wayne Davison
  0 siblings, 1 reply; 14+ messages in thread
From: Bart Schaefer @ 1999-04-24  4:32 UTC (permalink / raw)
  To: Wayne Davison; +Cc: zsh-workers

On Apr 21,  4:52pm, Wayne Davison wrote:
} Subject: Re: Patch available for 3.0.6-pre-0
}
} Some of the added braces were to enclose some one-line macros that
} consist of an "if ... else ..."  block.  This makes it look like some
} of the ifs have braces that are enclosing only one line.

Exactly what warning were you silencing in this case?  The reason most
of those macros look like

    #define thing() if (! testthing) {;} else dothing

and *not*

    #define thing() if (testthing) dothing

is to prevent ambiguous/erroneous "else" situations.

My favorite approach is to write these kind of macros as

    #define thing() do { if (testthing) dothing; } while (0)

because that forms a semicolon-terminable statement yet still wraps the
macro body in braces.  The PERMALLOC { ... } LASTALLOC; blocks make use
of this trick, for example.  However, a previous maintainer chose not to
adopt that for macros that could be written as if (...) {;} else ..., so
I'd like to have a clear reason for changing them.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: Patch available for 3.0.6-pre-0
@ 1999-04-23 12:48 Sven Wischnowsky
  0 siblings, 0 replies; 14+ messages in thread
From: Sven Wischnowsky @ 1999-04-23 12:48 UTC (permalink / raw)
  To: zsh-workers


[ *This* is the one I wanted to sent here. ]

Bart Schaefer wrote:

> I've made up a preliminary patch for 3.0.6, which carries the version number
> 3.0.6-pre-0.  It's available at
> 	ftp://ftp.brasslantern.com/pub/zsh/zsh-3.0.5-3.0.6-pre-0.diff

I've played with this a bit, trying to remember the things we fixed in 
the completion code in 3.1.5. I seem to remember that one of the
patches I sent after 4988 (which is the last entry with my name in it
in the ChangeLog) fixed something that might be buggy in
3.0.[56]. Unfortunately I forgot to write myself a note about this and
I can't remember what it was.
Hm, maybe everyone who sent a bug-report about old-style completion to 
the list could try it with Bart's pre-3.0.6 version?

I'll continue to search, too.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-21 16:05   ` Bart Schaefer
@ 1999-04-22 15:07     ` Tatsuo Furukawa
  1999-04-24  5:53       ` Bart Schaefer
  0 siblings, 1 reply; 14+ messages in thread
From: Tatsuo Furukawa @ 1999-04-22 15:07 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-workers

Hello, Bart,  Thank you for quick response.

Bart> There are other programs than zsh that would be confused by this
Bart> behavior.

Yes.  (But I didn't know yesterday.)  According "termcap & terminfo"
book, UNIX assumes that tab stop are assigned to 8, 16, 24, 32, ....
So, I don't have to think that TAB stop is valiable.

Bart> Am I wrong in thinking the fix for this is `stty -tabs` ?  

I tried it.  And this works completely well!  So, `stty -tabs` are
good solution.  But it is not a perfect solution for perfomance.


Bart> but as a frequent ssh-over-28.8-PPP-link user, I'm sensitive to
Bart> issues with speed of screen refresh and I'd rather not be
Bart> needlessly penalized.

I think that most of users is NOT affected by this patch.  Because
NORMAL terminal has RI= entry.  If the terminal has RI= entry, zsh
will use it.  If it doesn't, zsh will use another method (TAB will be
used).  So, maybe, I think you will not affect any more.

But, I am begining to think that it is not interesting to apply
degrade patch.  So, I wrote a new patch. :-)


Hpterm does not have RI= entry. (RI is relative horizontal cursor
move).  But hpterm has ch= entry.  (ch is absolute horizontal cursor
move).  I added the code that zsh supports 'ch=' entry.

And I found that zle_refresh.c has two similar function.
(tc_rightcurs() and singmoveto()).  I modified tc_rightcurs().
tc_rightcurs() is originally absolute cursor move.  Now,
tc_rightcurs() is relative cursor move.  Because tc_leftcurs() is
relative, they are a couple now.  (If you want to move absolutely, use
 singmoveto()).


Here is the patch:

diff -ur zsh-3.0.6-pre0/Src/globals.h zsh-3.0.6-pre0-new/Src/globals.h
--- zsh-3.0.6-pre0/Src/globals.h	Wed Apr 21 18:53:47 1999
+++ zsh-3.0.6-pre0-new/Src/globals.h	Thu Apr 22 10:57:01 1999
@@ -614,7 +614,7 @@
 {
     "cl", "le", "LE", "nd", "RI", "up", "UP", "do",
     "DO", "dc", "DC", "ic", "IC", "cd", "ce", "al", "dl", "ta",
-    "md", "so", "us", "me", "se", "ue"
+    "md", "so", "us", "me", "se", "ue", "ch"
 };
 #else
 extern char *tccapnams[TC_COUNT];
diff -ur zsh-3.0.6-pre0/Src/zle_refresh.c zsh-3.0.6-pre0-new/Src/zle_refresh.c
--- zsh-3.0.6-pre0/Src/zle_refresh.c	Fri Sep 26 10:42:19 1997
+++ zsh-3.0.6-pre0-new/Src/zle_refresh.c	Thu Apr 22 20:47:04 1999
@@ -808,20 +808,8 @@
 	}
     }
 
-    if (cl == vcs)
-	return;
-
-/* 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)
-	tc_rightcurs(cl);
-    else if (vcs > cl)
-	tc_leftcurs(vcs - cl);
-    vcs = cl;
+    if (cl != vcs)
+       singmoveto(cl);
 }
 
 /**/
@@ -841,14 +829,16 @@
 
 /**/
 void
-tc_rightcurs(int cl)
+tc_rightcurs(int ct)
 {
-    int ct,			/* number of characters to move across	    */
-	i = vcs,		/* cursor position after initial movements  */
+/* ct: number of characters to move across      */
+/*     cursor position after initial movements  */
+    int cl,			
+	i = vcs,		
 	j;
     char *t;
 
-    ct = cl - vcs;
+    cl = ct + vcs;
 
 /* do a multright if we can - it's the most reliable */
     if (tccan(TCMULTRIGHT)) {
@@ -1060,23 +1050,29 @@
 {
     if (pos == vcs)
 	return;
+
+/* do a horizontal position if we can */
+    if (tccan(TCHORIZPOS)) {
+	tcoutarg(TCHORIZPOS, pos);
+	vcs = pos;
+	return;
+    }
+
+
+/* choose cheapest movements for ttys without multiple movement capabilities -
+   do this now because it's easier (to code) */
+
     if (pos <= vcs / 2) {
 	zputc('\r', shout);
 	vcs = 0;
     }
-    if (pos < vcs) {
-	tc_leftcurs(vcs - pos);
+
+    if (pos < vcs)
+       tc_leftcurs(vcs - pos);
+    else if (pos > vcs)
+       tc_rightcurs(pos - vcs);
+
 	vcs = pos;
-    }
-    if (pos > vcs) {
-	if (tcmultout(TCRIGHT, TCMULTRIGHT, pos - vcs))
-	    vcs = pos;
-	else
-	    while (pos > vcs) {
-		zputc(nbuf[0][vcs], shout);
-		vcs++;
-	    }
-    }
 }
 
 /* generate left and right prompts */
diff -ur zsh-3.0.6-pre0/Src/zsh.h zsh-3.0.6-pre0-new/Src/zsh.h
--- zsh-3.0.6-pre0/Src/zsh.h	Wed Apr 21 18:53:49 1999
+++ zsh-3.0.6-pre0-new/Src/zsh.h	Thu Apr 22 11:07:22 1999
@@ -1249,7 +1249,8 @@
 #define TCALLATTRSOFF  21
 #define TCSTANDOUTEND  22
 #define TCUNDERLINEEND 23
-#define TC_COUNT       24
+#define TCHORIZPOS     24
+#define TC_COUNT       25
 
 #define tccan(X) (tclen[X])
 

-- 
Tatsuo Furukawa  (frkwtto@osk3.3web.ne.jp)


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-21  8:15 Bart Schaefer
  1999-04-21  8:47 ` Peter Stephenson
  1999-04-21 14:14 ` Tatsuo Furukawa
@ 1999-04-21 23:52 ` Wayne Davison
  1999-04-24  4:32   ` Bart Schaefer
  2 siblings, 1 reply; 14+ messages in thread
From: Wayne Davison @ 1999-04-21 23:52 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

"Bart Schaefer" writes:
> I'd appreciate feedback from anyone who grabs it and applies it.

I've compiled it and am checking it out now.  So far so good.

One thing I think would be nice to achieve for the 3.0.6 release is
to remove all the warnings when building zsh with gcc 2.8.1.  To
this end, I have tweaked the source and generated a diff from your
pre-0 release.  The patch is about 22k, so I won't include it here.
Anyone who wants it can grab it via the web:

    http://www.clari.net/~wayne/zsh-3.0.6-pre-0.patch

The changes were simply adding a bunch of braces to various if
blocks, and changing a few character-subscript values into unsigned-
character subscripts.

Some of the added braces were to enclose some one-line macros that
consist of an "if ... else ..."  block.  This makes it look like some
of the ifs have braces that are enclosing only one line.  I suppose
I'd prefer to see these macros get changed from this:

    if (...) {
        cmdpop();
    }

into this:

    if (...)
        CMDPOP

(so that CMDPOP could be written using curly braces), but that was
beyond the scope of my simple patch.

You may also notice that I added a few extra brace sets to some
indented-code blocks that were right near where I was already adding
braces.  I did this because I think that the code reads better when
multi-line blocks of indented code are enclosed in braces (even when
they aren't absolutely required), and because it seemed to me that
this is consistent with the latest coding style (e.g. the while loop
in the new read1char() function).

> * I haven't decided what to do with RCS $Id$ keywords.

I for one would not miss them if they were removed, but I don't
feel strongly about this.

..wayne..


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-21 14:14 ` Tatsuo Furukawa
@ 1999-04-21 16:05   ` Bart Schaefer
  1999-04-22 15:07     ` Tatsuo Furukawa
  0 siblings, 1 reply; 14+ messages in thread
From: Bart Schaefer @ 1999-04-21 16:05 UTC (permalink / raw)
  To: Tatsuo Furukawa; +Cc: zsh-workers

On Apr 21, 11:14pm, Tatsuo Furukawa wrote:
} Subject: Re: Patch available for 3.0.6-pre-0
}
} Hi!  I am glad to meet new stable zsh. (^_^)

I'm sure it's glad to meet you, too.

} I have a small dissatisfaction for zsh.  Zsh can NOT treat RPROMPT
} to right place with some (special) terminal.
[...] 
} If terminal does not have RI= entry, zsh uses TAB character for
} horizontal cursor move.  And zsh assumes that TAB stop is 8, 16, 24,
} 32, ..  But TAB stop is user definable, so this assumption is not

Am I wrong in thinking the fix for this is `stty -tabs` ?  There are
other programs than zsh that would be confused by this behavior.

} I think that it is NOT hpterm's defect.  Because the standard for TAB
} stop behavior is NOT exist, zsh should NOT assume such TAB stop.

I'll put this patch in if I see a couple of other messages in support
of it; but as a frequent ssh-over-28.8-PPP-link user, I'm sensitive to
issues with speed of screen refresh and I'd rather not be needlessly
penalized.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-21  8:15 Bart Schaefer
  1999-04-21  8:47 ` Peter Stephenson
@ 1999-04-21 14:14 ` Tatsuo Furukawa
  1999-04-21 16:05   ` Bart Schaefer
  1999-04-21 23:52 ` Wayne Davison
  2 siblings, 1 reply; 14+ messages in thread
From: Tatsuo Furukawa @ 1999-04-21 14:14 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-workers


Hi!  I am glad to meet new stable zsh. (^_^)

I have a small dissatisfaction for zsh.  Zsh can NOT treat RPROMPT
to right place with some (special) terminal.

The terminal is as follows:

1. It does not have RI= entry for termcap database.

2. TAB stop is not set automatically when terminal size is changed.

The 'hpterm' is one of such terminal.


If terminal does not have RI= entry, zsh uses TAB character for
horizontal cursor move.  And zsh assumes that TAB stop is 8, 16, 24,
32, ..  But TAB stop is user definable, so this assumption is not
good.  And, generally, TAB stop is not set automatically when terminal
size is changed.  For example, the terminal width is 80, and TAB stop
is as follows:
    8, 16, 24, 32, 40, 48, 56, 64, 72, 80

Then terminal size is changed to 100.  Zsh assumes that TAB stop will
be set as follows:
    8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96

But hpterm's is as follows:
    8, 16, 24, 32, 40, 48, 56, 64, 72, 80

So, RPROMPT is not display right place with hpterm.  when I use zsh
with hpterm, I must set TAB stop manually when I change terminal size.

I think that it is NOT hpterm's defect.  Because the standard for TAB
stop behavior is NOT exist, zsh should NOT assume such TAB stop.

Here is the patch for this problem.  This is for zsh-3.0.6-pre0.

diff -ur zsh-3.0.6-pre0/Src/zle_refresh.c zsh-3.0.6-pre0-new/Src/zle_refresh.c
--- zsh-3.0.6-pre0/Src/zle_refresh.c    Fri Sep 26 10:42:19 1997
+++ zsh-3.0.6-pre0-new/Src/zle_refresh.c        Wed Apr 21 19:59:45 1999
@@ -856,16 +856,6 @@
        return;
     }

-/* try tabs if tabs are non destructive and multright is not possible */
-    if (!oxtabs && tccan(TCNEXTTAB) && ((vcs | 7) < cl)) {
-       i = (vcs | 7) + 1;
-       tcout(TCNEXTTAB);
-       for ( ; i + 8 <= cl; i += 8)
-           tcout(TCNEXTTAB);
-       if ((ct = cl - i) == 0) /* number of chars still to move across */
-           return;
-    }
-
 /* otherwise _carefully_ write the contents of the video buffer.
    if we're anywhere in the prompt, goto the left column and write the whole
    prompt out unless lpptlen == pptw : we can cheat then */

-- 
Tatsuo Furukawa  (frkwtto@wnn.club.or.jp)


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

* Re: Patch available for 3.0.6-pre-0
  1999-04-21  8:15 Bart Schaefer
@ 1999-04-21  8:47 ` Peter Stephenson
  1999-04-21 14:14 ` Tatsuo Furukawa
  1999-04-21 23:52 ` Wayne Davison
  2 siblings, 0 replies; 14+ messages in thread
From: Peter Stephenson @ 1999-04-21  8:47 UTC (permalink / raw)
  To: zsh-workers

"Bart Schaefer" wrote:
> I've made up a preliminary patch for 3.0.6, which carries the version number
> 3.0.6-pre-0.  It's available at
> 	ftp://ftp.brasslantern.com/pub/zsh/zsh-3.0.5-3.0.6-pre-0.diff

First point: there's a followup to 5281, which attempted to handle an EINTR
during a query, in 5364.  The problem was you couldn't ^C a query.  I've
included it again below.

Second point: the mechanism for avoiding too many settyinfo()'s looks OK.
However, the configure test for clobbers_typeahead wouldn't work for the
last two cases.  Unless there's a good reason for not testing $host_vendor
--- in which case the sni-sysv4* test won't work --- there's a hunk to put
it back.

That was all I noticed.  I should perhaps say I haven't played around as
thoroughly with the typeset patch in 4914 as with the equivalent for 3.1,
but I have no particular worries.

--- Src/utils.c.eintr	Wed Apr 21 10:29:07 1999
+++ Src/utils.c	Wed Apr 21 10:29:47 1999
@@ -1185,7 +1185,7 @@
     char c;
 
     while (read(SHTTY, &c, 1) != 1) {
-	if (errno != EINTR)
+	if (errno != EINTR || errflag)
 	    return -1;
     }
     return STOUC(c);
--- configure.in.irix	Wed Apr 21 10:48:26 1999
+++ configure.in	Wed Apr 21 10:50:31 1999
@@ -654,8 +654,8 @@
 dnl system names directly.
 dnl The doubled square brackets are necessary because autoconf uses m4.
 AC_CACHE_CHECK(if typeahead needs FIONREAD, zsh_cv_sys_clobbers_typeahead,
-[case x-$host_os in
-    x-ultrix* | x-dgux* | x-sni-sysv4* | x-*-irix*)
+[case x-$host_vendor-$host_os in
+    x-*-ultrix* | x-*-dgux* | x-sni-sysv4* | x-*-irix*)
 	zsh_cv_sys_clobbers_typeahead=yes;;
     *)
 	zsh_cv_sys_clobbers_typeahead=no;;

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

* Patch available for 3.0.6-pre-0
@ 1999-04-21  8:15 Bart Schaefer
  1999-04-21  8:47 ` Peter Stephenson
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Bart Schaefer @ 1999-04-21  8:15 UTC (permalink / raw)
  To: zsh-workers

I've made up a preliminary patch for 3.0.6, which carries the version number
3.0.6-pre-0.  It's available at
	ftp://ftp.brasslantern.com/pub/zsh/zsh-3.0.5-3.0.6-pre-0.diff

Checksums:

(BSD)  19136    91
(SYSV) 57735 182 zsh-3.0.5-3.0.6-pre-0.diff

I'd appreciate feedback from anyone who grabs it and applies it.  Check for
anything that looks like it shouldn't be there (I had to excise a few of my
own local changes before generating the diff); and, in particular, if PWS
is listening and has a chance to check my adaptation of his zleread() fix
for IRIX cut'n'paste, that'd be great.

See the ChangeLog file for details of what's included; patch coverage goes
back to November 1997.  I didn't precisely preserve the ChangeLog format
because I generated the new entries with the cvs2cl Perl script posted to
the info-cvs mailing list a few weeks ago.  If anybody thinks this is a
problem, holler at me and I'll see about tweaking the script to spit out
the previous format.

Things that aren't done yet:

* The documentation isn't up to date with all the code changes.

* The texinfo documentation is out of sync with the man pages.

* I haven't done anything with Greg Badros's color completion patches.  I
  wasn't certain there was a consensus for including them, and there was
  some discussion of altering the implementation to be more 3.1.5-friendly.

* I haven't decided what to do with RCS $Id$ keywords.  I don't have the
  "original" RCS or CVS archives from Zoltan, and expanding those from my
  own CVS repository will set them back to the 1.somethings.  I'm tempted
  to simply remove them.  Any comments or suggestions?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1999-04-27 16:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-23 14:13 Patch available for 3.0.6-pre-0 Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-04-23 12:48 Sven Wischnowsky
1999-04-21  8:15 Bart Schaefer
1999-04-21  8:47 ` Peter Stephenson
1999-04-21 14:14 ` Tatsuo Furukawa
1999-04-21 16:05   ` Bart Schaefer
1999-04-22 15:07     ` Tatsuo Furukawa
1999-04-24  5:53       ` Bart Schaefer
1999-04-25  6:57         ` Geoff Wing
1999-04-26 15:22           ` Tatsuo Furukawa
1999-04-27 16:24             ` Bart Schaefer
1999-04-21 23:52 ` Wayne Davison
1999-04-24  4:32   ` Bart Schaefer
1999-04-24  7:12     ` Wayne Davison

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