From 5027f6382fc06c16cf54e7da06ef351bd45f331d Mon Sep 17 00:00:00 2001
From: Slava Zanko <slavazanko@gmail.com>
Date: Fri, 5 Nov 2010 10:57:37 +0200
Subject: [PATCH] Fixed issue #24452: grep -w doesn't always grab whole words
 - broken multibyte support

As described at http://www.regular-expressions.info/wordboundaries.html, non-latin characters isn't in word.
For fix this issue need to use '\\p{L}\\p{N}' instead of [:alnum:].

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
---
 src/dfasearch.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/dfasearch.c b/src/dfasearch.c
index 3471308..287053f 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -181,12 +181,12 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
     {
       static char const line_beg_no_bk[] = "^(";
       static char const line_end_no_bk[] = ")$";
-      static char const word_beg_no_bk[] = "(^|[^[:alnum:]_])(";
-      static char const word_end_no_bk[] = ")([^[:alnum:]_]|$)";
+      static char const word_beg_no_bk[] = "(^|[^\\p{L}\\p{N}_])(";
+      static char const word_end_no_bk[] = ")([^\\p{L}\\p{N}_]|$)";
       static char const line_beg_bk[] = "^\\(";
       static char const line_end_bk[] = "\\)$";
-      static char const word_beg_bk[] = "\\(^\\|[^[:alnum:]_]\\)\\(";
-      static char const word_end_bk[] = "\\)\\([^[:alnum:]_]\\|$\\)";
+      static char const word_beg_bk[] = "\\(^\\|[^\\p{L}\\p{N}_]\\)\\(";
+      static char const word_end_bk[] = "\\)\\([^\\p{L}\\p{N}_]\\|$\\)";
       int bk = !(syntax_bits & RE_NO_BK_PARENS);
       char *n = xmalloc (sizeof word_beg_bk - 1 + size + sizeof word_end_bk);
 
-- 
1.7.5.2

