patchgrep - Patches: patch #6027, Fix '\s' when using single byte...

 
 

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

patch #6027: Fix '\s' when using single byte string

Submitter:  Flavio <fleitner>
Submitted:  Tue 19 Jun 2007 03:04:23 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Invalid Privacy:  Public
Assigned to:  kasal Open/Closed:  Closed

Sat 21 Jul 2007 02:38:25 PM UTC, comment #1: 

Hello Flavio,
'\s' is equivalent to character class [:space:] in Perl regular expressions.
So it is valid only with the experimental "grep -P" (or pcregrep, if you have it installed).

With "grep" (or "grep -E"), you have to use [:space:], e.g., "^[[:space:]]*root" in your example.

In POSIX, regular expression '\s' is undefined, both as a BRE and ERE, see
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03_02
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04_02

I believe that the traditional interpretation was that this regular expression matched the character 's', which still happens in C locale.

(Your example proves that the traditional behaviour is broken for the multibyte character sets.  But we are in the fields of undefined behaviour anyway...)

Stepan Kasal <kasal>
Group Member
Tue 19 Jun 2007 03:04:23 AM UTC, original submission:  

Hi,

When using multibyte string egrep uses re_compile() and re_search()
from glibc to deal with regex and glibc accepts '\s' as equivalent
to '[:blank:]'.

When using single byte string egrep uses dfacomp() and dfaexec()
which does not implement '\s'.

How to reproduce it:
$ echo "     root=/dev/sda" > /tmp/input
$ LANG=en_US.UTF8 grep -E "^\s*root" /tmp/input
     root=/dev/sda
$ LANG=C grep -E "^\s*root" /tmp/input
$

Attached a patch to implement '\s' handler.

-Flavio Leitner

Flavio <fleitner>

 

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

Attached Files
file #13098:  grep-cvs-add-backslash-s-support.patch added by fleitner (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kasal (Posted a comment)
  • -email is unavailable- added by fleitner (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-07-21 kasal StatusNone Invalid
        Assigned toNone kasal
        Open/ClosedOpen Closed
        SummaryFix \'\\s\' when using single byte string Fix '\s' when using single byte string
    2007-06-19 fleitner Attached File- Added grep-cvs-add-backslash-s-support.patch, #13098

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code