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

Re: D07multibyte.ztst failure on HP-UX 11.11



On Thu, 7 May 2009 16:38:19 +0100
Peter Stephenson <pws@xxxxxxx> wrote:
>   (unsetopt multibyte; print $'\xc5') | read
> 
> returns status 1 with no output.
> 
> I'm fairly happy this isn't a shell bug...

Having said that, actually there's no good reason why "read" shouldn't just
accept any old junk and let whoever is looking at the variable handle it.
This fixes that, and adds a test for it.

This means your test still fails, however.  I'm not sure what to do about
this since clearly the test *does* fail; you don't get a valid character or
an error.  Since character set conversion isn't working on your system (as
evinced by the result of not setting the C locale), I suppose we could test
that and if so skip the test?

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.224
diff -u -r1.224 builtin.c
--- Src/builtin.c	25 Mar 2009 09:52:41 -0000	1.224
+++ Src/builtin.c	7 May 2009 15:55:58 -0000
@@ -5546,8 +5546,12 @@
 		wc = (wchar_t)c;
 	    }
 	    if (ret != MB_INCOMPLETE) {
-		if (ret == MB_INVALID)
+		if (ret == MB_INVALID) {
 		    memset(&mbs, 0, sizeof(mbs));
+		    /* Treat this as a single character */
+		    wc = (wchar_t)c;
+		    laststart = bptr;
+		}
 		/*
 		 * \ at the end of a line introduces a continuation line,
 		 * except in raw mode (-r option)
Index: Test/D07multibyte.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D07multibyte.ztst,v
retrieving revision 1.31
diff -u -r1.31 D07multibyte.ztst
--- Test/D07multibyte.ztst	30 Apr 2009 08:37:13 -0000	1.31
+++ Test/D07multibyte.ztst	7 May 2009 15:55:58 -0000
@@ -427,3 +427,9 @@
 >Ä ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ ææçè
 >Ä ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ ææçè
 >Ä ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ ææçè
+
+  setopt cbases
+  print $'\xc5' | read
+  print $(( [#16] #REPLY ))
+0:read passes through invalid multibyte characters
+>0xC5


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



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