From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16198 invoked by alias); 10 Jun 2015 09:05:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35431 Received: (qmail 8360 invoked from network); 10 Jun 2015 09:05:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f4-f79c56d0000012ee-2c-5577fb7c92cc Date: Wed, 10 Jun 2015 09:55:21 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Strange behavior of [[ Message-id: <20150610095521.35e3e4e9@pwslap01u.europe.root.pri> In-reply-to: <150609223156.ZM29890@torch.brasslantern.com> References: <5577AE8F.6060902@arthaud.me> <150609223156.ZM29890@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsVy+t/xK7o1v8tDDf5MY7I42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGdMvTWAtmMZdcf38JMYGxuccXYycHBICJhIXPp1nhLDFJC7c W88GYgsJLGWUOHjDsIuRC8iewSSx/+BXRghnG6PEoeMr2EGqWARUJV5enAPWzSZgKDF102ww W0RAXOLs2vMsILawgLLEs5s3wabyCthLzJjxCCzOKWAlsbLrIyPEtkiJKydOgMX5BfQlrv79 xARxkb3EzCtnGCF6BSV+TL4HVsMsoCWxeVsTK4QtL7F5zVtmiDnqEjfu7mafwCg0C0nLLCQt s5C0LGBkXsUomlqaXFCclJ5rqFecmFtcmpeul5yfu4kRErRfdjAuPmZ1iFGAg1GJh3dGbnmo EGtiWXFl7iFGCQ5mJRHeU1+BQrwpiZVVqUX58UWlOanFhxilOViUxHnn7nofIiSQnliSmp2a WpBaBJNl4uCUamAU9pKOawsq4Gi+Jy5YGrNYXuin2GO5CKfAe85RmR5npkSqH8jolFnHfzi4 22zx2tN7TlrEsTmE3xXPmLLy5MLXdx52fl19+c7xqs5622PhyrVndu2X2/N42kwLtmaPkDub BMw2TnnvsnqCx0OPCZNOL58p8Kdc9mLvWS+TojW3TOMk7l5g62NTYinOSDTUYi4qTgQALd+p DFYCAAA= On Tue, 9 Jun 2015 22:31:56 -0700 Bart Schaefer wrote: > On Jun 9, 8:27pm, Maxime Arthaud wrote: > } Subject: Strange behavior of [[ > } > } Hi everybody! > } > } I just found a very strange behavior in zsh (v5.0.8). > } > } % [[ " X" =~ "X" ]] > } where in " X" the first character is a non-breaking space (0xa0). > } My shell gets stuck, and Ctrl-C is not working. With bash, no problem. > } > } Does anyone have an explanation? I think it's a bug. > > MB_METACHARLEN() is returning that 0xa0 is a zero-width character, so > "ptr" in the "while (ptr < lhstr + m->rm_so)" loop in regex.c never > advances. That macro ultimately resolves to mb_metacharlenconv_r() > from utils.c, which returns zero here: > > 4861 return 0; /* Probably shouldn't happen */ > > This means that imeta() is (incorrectly?) returning true for 0xa0, which > might mean that we're passing an unmetafied string where a metafied > string is expected. Yes, that's obvious from the context. You can see lhstr being metafied above to go into a variable, but the unmetafied variant is then handled as if it was metafied. The problem is the match offsets are all in unmetafied form from the regexp library. Rather than attempt to metafy with those, It probably needs to change to use mbrtowc() based on unmetafied chracters, with simple code for the case of no MULTIBYTE_SUPPORT. pws