buggrep - Bugs: bug #24452, grep -w doesn't always grab whole...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #24452: grep -w doesn't always grab whole words - broken multibyte support

Submitter:  Jean-Baptiste Lallement <jblallement>
Submitted:  Sat 04 Oct 2008 08:48:51 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Jump to the original submission

Wed 29 Jun 2011 06:33:54 AM UTC, comment #6: 

The code you patched is for POSIX regular expression, not PCRE.  Did you test the patch?  PCRE handles this with \b, which is also buggy:

$ echo x | grep -Pw 'a?'
x
$ echo x | grep -w 'a?'
$

So I'll probably apply a variant of your patch to handle the PCRE case.

Paolo Bonzini <bonzini>
Tue 28 Jun 2011 10:37:47 PM UTC, comment #5: 
-X- <slavazanko>
Tue 28 Jun 2011 10:35:26 PM UTC, comment #4: 


> What regular expression engine are you using?


Plain PCRE and GLIB regexp (but it' just a wrapper around PCRE)

> \p is certainly not supported by grep or glibc.


well... I have compiled 'grep' from master branch... patch works as well.

BTW,

slavaz@home ~/work/grep/ROOT/bin master$ ldd ./grep
        linux-vdso.so.1 =>  (0x00007fff8d9b9000)
        libpcre.so.0 => /lib64/libpcre.so.0 (0x00000036c3400000)
        libc.so.6 => /lib64/libc.so.6 (0x00000036ad800000)
        /lib64/ld-linux-x86-64.so.2 (0x00000036ad000000)
slavaz@home ~/work/grep/ROOT/bin master$

As I see PCRE used in 'grep' utility too.

-X- <slavazanko>
Tue 28 Jun 2011 08:28:29 AM UTC, comment #3: 

What regular expression engine are you using? \p is certainly not supported by grep or glibc.

Paolo Bonzini <bonzini>
Fri 24 Jun 2011 10:24:02 AM UTC, comment #2: 

See latest attach. This patch should fix this issue.


(file #23552)

-X- <slavazanko>
Fri 05 Nov 2010 09:02:04 AM UTC, comment #1: 


> grep -w doesn't always grab whole words - broken multibyte support


We had same issue: http://midnight-commander.org/ticket/2396

See attached patch.

(file #21931)

-X- <slavazanko>
Sat 04 Oct 2008 08:48:51 PM UTC, original submission:  

I'm reporting this for a Ubuntu user.
Original report at https://bugs.edge.launchpad.net/ubuntu/+source/grep/+bug/274221

1)
rusty@vivaldi:~$ lsb_release -rd
Description: Ubuntu 8.04.1
Release: 8.04

2) rusty@vivaldi:~$ apt-cache policy grep
grep:
  Installed: 2.5.3~dfsg-3
  Candidate: 2.5.3~dfsg-3
  Version table:
 *** 2.5.3~dfsg-3 0
        500 http://au.archive.ubuntu.com hardy/main Packages
        100 /var/lib/dpkg/status

3) Only whole words returned. There were a couple of spurious results in a large grep. Example file (from Linux kernel) is enclosed, and as you can see, piping through same grep expression again "fixes" the problem.

4) rusty@vivaldi:~$ grep -w alloca devel/kernel/linux-2.6/kernel/pid.c

  • Generic pidhash and scalable, time-bounded PID allocator

rusty@vivaldi:~$ grep -w alloca devel/kernel/linux-2.6/kernel/pid.c | grep -w alloca
rusty@vivaldi:~$
rusty@vivaldi:~/devel/kernel/patches/linux-2.6$ LANG=C grep -w alloca kernel/pid.c
rusty@vivaldi:~/devel/kernel/patches/linux-2.6$ grep -w alloca kernel/pid.c

  • Generic pidhash and scalable, time-bounded PID allocator

rusty@vivaldi:~/devel/kernel/patches/linux-2.6$ locale
LANG=en_AU.UTF-8
LC_CTYPE="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_TIME="en_AU.UTF-8"
LC_COLLATE="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_PAPER="en_AU.UTF-8"
LC_NAME="en_AU.UTF-8"
LC_ADDRESS="en_AU.UTF-8"
LC_TELEPHONE="en_AU.UTF-8"
LC_MEASUREMENT="en_AU.UTF-8"
LC_IDENTIFICATION="en_AU.UTF-8"
LC_ALL=

Sample file is attached.

Jean-Baptiste Lallement <jblallement>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bonzini (Posted a comment)
  • -email is unavailable- added by slavazanko (Updated the item)
  • -email is unavailable- added by jblallement (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-06-24 slavazanko Attached File- Added 0001-Fixed-issue-24452-grep-w-doesn-t-always-grab-whole-w.patch, #23552
    2010-11-05 slavazanko Attached File- Added 0001-Fixed-issue-24452-grep-w-doesn-t-always-grab-whole-w.patch, #21931
    2008-10-04 jblallement Attached File- Added pid.c, #16607

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code