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

Submitted by:  Jean-Baptiste Lallement <jblallement>
Submitted on:  Sat Oct 4 20:48:51 2008  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

(Jump to the original submission Jump to the original submission)

Wed Jun 29 06:33:54 2011, 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?'
$ echo x | grep -w 'a?'

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

Paolo Bonzini <bonzini>
Tue Jun 28 22:37:47 2011, comment #5:

Related issue: https://savannah.gnu.org/bugs/index.php?32337

Slava Zanko <slavazanko>
Tue Jun 28 22:35:26 2011, 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.


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.

Slava Zanko <slavazanko>
Tue Jun 28 08:28:29 2011, comment #3:

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

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

See latest attach. This patch should fix this issue.

(file #23552)

Slava Zanko <slavazanko>
Fri Nov 5 09:02:04 2010, 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)

Slava Zanko <slavazanko>
Sat Oct 4 20:48:51 2008, original submission:

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

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

2) rusty@vivaldi:~$ apt-cache policy 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:~/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

Sample file is attached.

Jean-Baptiste Lallement <jblallement>



Depends on the following items: None found

Items that depend on this one: None found


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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri Jun 24 10:24:02 2011slavazankoAttached File-=>Added 0001-Fixed-issue-24452-grep-w-doesn-t-always-grab-whole-w.patch, #23552
    Fri Nov 5 09:02:04 2010slavazankoAttached File-=>Added 0001-Fixed-issue-24452-grep-w-doesn-t-always-grab-whole-w.patch, #21931
    Sat Oct 4 20:48:51 2008jblallementAttached File-=>Added pid.c, #16607

    Back to the top

    Powered by Savane 3.1-cleanup1