Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Pattern matching operations produces incorrect results when MULTIBYTE is not set
- X-seq: zsh-users 22760
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Pattern matching operations produces incorrect results when MULTIBYTE is not set
- Date: Sun, 2 Jul 2017 18:17:40 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1499015862; bh=yrV6l/SrVyDGOikjSXQCLb+5eOreVApVK9CyIBxmMbU=; h=Date:From:To:Subject:In-Reply-To:References; b=2a/GaUI4rOcsALz4jmHe+kcpFB4hcac5rsd56EU7qM3pa/r3FlvE02aKifobEQ5Od +ZAxBs3gaAGRfDmzSCIJarwt0GKCvrGqpGHFCcCPVVc3CjAZj8ej/i+2ss5jLZYXGH q7Bw/7bGZfPGrmQV153suRsPmcYF1tJ743JIC4HexaWc5PFq86EB+VX3iHTFUsX9TY iivDlWtEAhtoxon1iVxF+gCV9pu/da4j6HwLdQAKjJ/deRx/lShjtiJsxqHvQ2vbly TB9TUwiLlzpJU0hjNML75evr9JiypnVIW79wEPmRMD8pVHEQobR2pfmY8SUzI1xMK1 MfUlwEpeKwbvg==
- In-reply-to: <46dd5cbeb10314f0988c9d8c9c703985.squirrel@giyzk7o6dcunb2ry.onion>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <46dd5cbeb10314f0988c9d8c9c703985.squirrel@giyzk7o6dcunb2ry.onion>
On Fri, 30 Jun 2017 19:35:01 -0700
guuu@xxxxxxxxxxx wrote:
> When MULTIBYTE support turned off, all the indexing and counting of pattern
> matching operations becomes wrong.
Umm, if I didn't know better I'd think you were saying that was a bad
thing...
This was an oversight when extending the capabilities of a function; the
NO_MULITBYTE case got overlooked. I've added tests.
pws
diff --git a/Src/utils.c b/Src/utils.c
index acb891d..1b80e8c 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5417,7 +5417,7 @@ mb_metastrlenend(char *ptr, int width, char *eptr)
int num, num_in_char, complete;
if (!isset(MULTIBYTE))
- return ztrlen(ptr);
+ return eptr ? (int)(eptr - ptr) : ztrlen(ptr);
laststart = ptr;
ret = MB_INVALID;
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index d5798b5..3c93990 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -783,16 +783,36 @@
0:${(R)...}
>is the ,
+ # Although there's no reliance on multibyte here, the
+ # code exercised is different, so test both paths in the following group.
+ # If the shell isn't multibyte capable the tests are the same;
+ # that's not a problem.
# This (1) doesn't work with // or /
# (2) perhaps ought to be 18, to be consistent with normal zsh
# substring indexing and with backreferences.
print ${(BES)string##white}
+ (unsetopt multibyte; print ${(BES)string##white})
0:${(BE...)...}
>14 19
+>14 19
print ${(NS)string##white}
+ (unsetopt multibyte; print ${(NS)string##white})
0:${(N)...}
>5
+>5
+
+ fn() {
+ emulate -L zsh
+ local a=abcdef
+ print ${(SNBE)a#abcd}
+ unsetopt multibyte
+ print ${(SNBE)a#abcd}
+ }
+ fn
+0:${(BEN)...} again, with match
+>1 5 4
+>1 5 4
string='abcdefghijklmnopqrstuvwxyz'
print ${${string%[aeiou]*}/(#m)?(#e)/${(U)MATCH}}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author