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

 
 

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

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

Submitted by:  Jean-Baptiste Lallement <jblallement>
Submitted on:  Sat 04 Oct 2008 08:48:51 PM UTC  
 
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 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:

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

Slava Zanko <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.

Slava Zanko <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)

Slava Zanko <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)

Slava Zanko <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>

 

 

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 24 Jun 2011 10:24:02 AM UTCslavazankoAttached File-=>Added 0001-Fixed-issue-24452-grep-w-doesn-t-always-grab-whole-w.patch, #23552
    Fri 05 Nov 2010 09:02:04 AM UTCslavazankoAttached File-=>Added 0001-Fixed-issue-24452-grep-w-doesn-t-always-grab-whole-w.patch, #21931
    Sat 04 Oct 2008 08:48:51 PM UTCjblallementAttached File-=>Added pid.c, #16607

    Back to the top


    Powered by Savane 3.1-cleanup