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

Re: [mpol@xxxxxxxxxxxxxxxxxxx: Bug#306346: zsh: replacement seems broken in prompt]



Bart Schaefer wrote:
> What I don't know, though, is whether the Nularg test should be copied
> into both igetmatch() and down to by the ztrsub() call in pattryrefs(),
> or whether it should simply be
> 
>     /* inherited from domatch, but why, exactly? */
>     if (*string == Nularg)
> 	string++, unmetalen--;

I'd be inclined to keep it local and use this fix.  (This can end up
with unmetalen being -2, but that doesn't matter.)  Here's a test, too.

Index: Src/pattern.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/pattern.c,v
retrieving revision 1.25
diff -u -r1.25 pattern.c
--- Src/pattern.c	24 Apr 2005 00:38:15 -0000	1.25
+++ Src/pattern.c	26 Apr 2005 09:40:40 -0000
@@ -1552,8 +1552,10 @@
 	*nump = 0;
     }
     /* inherited from domatch, but why, exactly? */
-    if (*string == Nularg)
+    if (*string == Nularg) {
 	string++;
+	unmetalen--;
+    }
 
     if (stringlen < 0)
 	stringlen = strlen(string);
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.9
diff -u -r1.9 D04parameter.ztst
--- Test/D04parameter.ztst	21 May 2003 16:21:01 -0000	1.9
+++ Test/D04parameter.ztst	26 Apr 2005 09:40:40 -0000
@@ -599,3 +599,8 @@
 >said
 >i
 >willJOYCE
+
+  foo=
+  print "${${foo}/?*/replacement}"
+0:Quoted zero-length strings are handled properly
+>

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************



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