zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: signed chars without multibyte support
@ 2006-12-19 12:55 Peter Stephenson
  2006-12-19 20:37 ` Wayne Davison
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2006-12-19 12:55 UTC (permalink / raw)
  To: Zsh hackers list

More confusion with signed chars, which I didn't notice because I
haven't tested for a while on a system with both signed characters and
no multibyte support.  This caused a failure in D04parameter.ztst.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.147
diff -u -r1.147 utils.c
--- Src/utils.c	8 Dec 2006 18:52:04 -0000	1.147
+++ Src/utils.c	19 Dec 2006 12:51:06 -0000
@@ -4146,15 +4146,20 @@
 
 /**/
 mod_export int
-metacharlenconv(char *x, int *c)
+metacharlenconv(const char *x, int *c)
 {
+    /*
+     * Here we don't use STOUC() on the chars since they
+     * may be compared against other chars and this will fail
+     * if chars are signed and the high bit is set.
+     */
     if (*x == Meta) {
 	if (c)
-	    *c = STOUC(x[1]) ^ 32;
+	    *c = x[1] ^ 32;
 	return 2;
     }
     if (c)
-	*c = STOUC(*x);
+	*c = (char)*x;
     return 1;
 }
 

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


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

* Re: PATCH: signed chars without multibyte support
  2006-12-19 12:55 PATCH: signed chars without multibyte support Peter Stephenson
@ 2006-12-19 20:37 ` Wayne Davison
  2006-12-19 21:20   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Wayne Davison @ 2006-12-19 20:37 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list

On Tue, Dec 19, 2006 at 12:55:38PM +0000, Peter Stephenson wrote:
> +	    *c = x[1] ^ 32;
[...]
> +	*c = (char)*x;

I don't really like this, as it means that the int value returned can be
a -1 (EOF) when *x is 0xFF.  It would be better to change the code that
is comparing a char against an int to use STOUC() on the char value in
the comparison.

..wayne..


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

* Re: PATCH: signed chars without multibyte support
  2006-12-19 20:37 ` Wayne Davison
@ 2006-12-19 21:20   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2006-12-19 21:20 UTC (permalink / raw)
  To: Zsh hackers list, pws

Wayne Davison wrote:
> On Tue, Dec 19, 2006 at 12:55:38PM +0000, Peter Stephenson wrote:
> > +	    *c = x[1] ^ 32;
> [...]
> > +	*c = (char)*x;
> 
> I don't really like this, as it means that the int value returned can be
> a -1 (EOF) when *x is 0xFF.  It would be better to change the code that
> is comparing a char against an int to use STOUC() on the char value in
> the comparison.

Unfortunately all the tokens in zsh.h are defined as ((char) 0x83)
etc. etc., so it's a huge amount of work to make it use unsigned
characters; virtually every use of tokens in the shell requires that
something that began as a char *not* be cast to unsigned.

Historically, the integer value at this point was a simple char; it's
only because of the need to use functions for multibyte characters that
it got changed.  It's probably easy enough to put convchar_t back to
char instead of int when there's no multibyte code, but that doesn't
really gain anything.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

end of thread, other threads:[~2006-12-19 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-19 12:55 PATCH: signed chars without multibyte support Peter Stephenson
2006-12-19 20:37 ` Wayne Davison
2006-12-19 21:20   ` Peter Stephenson

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