zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] [[:blank:]] only matches on SPC and TAB
@ 2018-05-13 21:25 Stephane Chazelas
  2018-05-13 21:49 ` [PATCH v2] " Stephane Chazelas
  2018-05-14  2:27 ` [PATCH] " Sebastian Gniazdowski
  0 siblings, 2 replies; 26+ messages in thread
From: Stephane Chazelas @ 2018-05-13 21:25 UTC (permalink / raw)
  To: Zsh hackers list

I noticed that [[:blank:]] was not matching on non-ASCII blank
characters. In a typical UTF-8 GNU locale, [[:blank:]] normally
includes

 U+0009 CHARACTER TABULATION
 U+0020 SPACE
 U+1680 OGHAM SPACE MARK
 U+2000 EN QUAD
 U+2001 EM QUAD
 U+2002 EN SPACE
 U+2003 EM SPACE
 U+2004 THREE-PER-EM SPACE
 U+2005 FOUR-PER-EM SPACE
 U+2006 SIX-PER-EM SPACE
 U+2008 PUNCTUATION SPACE
 U+2009 THIN SPACE
 U+200A HAIR SPACE
 U+205F MEDIUM MATHEMATICAL SPACE
 U+3000 IDEOGRAPHIC SPACE

On FreeBSD:

 U+0009 CHARACTER TABULATION
 U+0020 SPACE
 U+00A0 NO-BREAK SPACE
 U+FEFF ZERO WIDTH NO-BREAK SPACE

(Strangely enough U+00A0 is not classified as blank in single
byte charsets like ISO8859-1 there)

The code indeed matches on SPC and TAB explicitly both in the
multibyte and singlebyte cases (the non-breaking space is one
non-ASCII character that appears in a few singlebyte charsets
and is considered as blank on some systems (not GNU ones)).

In case that was not intentional, this patch should fix it:

diff --git a/Src/pattern.c b/Src/pattern.c
index fc7c737..d3eac44 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -3605,7 +3605,7 @@ mb_patmatchrange(char *range, wchar_t ch, int zmb_ind, wint_t *indptr, int *mtp)
 		    return 1;
 		break;
 	    case PP_BLANK:
-		if (ch == L' ' || ch == L'\t')
+		if (iswblank(ch))
 		    return 1;
 		break;
 	    case PP_CNTRL:
@@ -3840,7 +3840,7 @@ patmatchrange(char *range, int ch, int *indptr, int *mtp)
 		    return 1;
 		break;
 	    case PP_BLANK:
-		if (ch == ' ' || ch == '\t')
+		if (isblank(ch))
 		    return 1;
 		break;
 	    case PP_CNTRL:

-- 
Stephane


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

end of thread, other threads:[~2018-05-17 22:05 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-13 21:25 [PATCH] [[:blank:]] only matches on SPC and TAB Stephane Chazelas
2018-05-13 21:49 ` [PATCH v2] " Stephane Chazelas
2018-05-14  2:27 ` [PATCH] " Sebastian Gniazdowski
2018-05-14  4:41   ` Sebastian Gniazdowski
2018-05-14  6:36   ` Stephane Chazelas
2018-05-14  6:44     ` Stephane Chazelas
2018-05-14  8:47       ` Peter Stephenson
2018-05-14 12:34         ` Stephane Chazelas
2018-05-14 13:50           ` Peter Stephenson
2018-05-14 15:51             ` Stephane Chazelas
2018-05-14 16:31               ` Sebastian Gniazdowski
2018-05-14 16:50                 ` Bart Schaefer
2018-05-14 19:52                   ` Daniel Tameling
2018-05-14 20:42                     ` Stephane Chazelas
2018-05-15 18:12                       ` Stephane Chazelas
2018-05-16  4:18                         ` Sebastian Gniazdowski
2018-05-15 19:06               ` Oliver Kiddle
2018-05-16 13:15                 ` Stephane Chazelas
2018-05-16 13:40                   ` Peter Stephenson
2018-05-16 16:31                     ` Stephane Chazelas
2018-05-16 21:02                       ` [PATCH v4] " Stephane Chazelas
2018-05-17  8:29                         ` Peter Stephenson
2018-05-17 22:05                       ` [PATCH] " Oliver Kiddle
2018-05-17  9:03           ` Sebastian Gniazdowski
2018-05-17 10:10             ` Sebastian Gniazdowski
2018-05-14  8:11     ` Sebastian Gniazdowski

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