bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'regex-quote'


From: Eric Blake
Subject: Re: new module 'regex-quote'
Date: Mon, 20 Sep 2010 08:32:00 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.3

On 09/18/2010 04:05 PM, Bruno Haible wrote:
/* regex_quote converts a literal string to a regular expression that will
    look for this literal string.
    cflags can be 0 or REG_EXTENDED.
    If it is 0, the result is a Basic Regular Expression (BRE)
    
<http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03>.
    If it is REG_EXTENDED, the result is an Extended Regular Expression (ERE)
    
<http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04>.
    The result is not anchored;  if you want it to match only complete lines,
    you need to add "^" at the beginning of the result and "$" at the end of the
    result.
  */

/* Returns the number of bytes needed for the quoted string.  */
extern size_t regex_quote_length (const char *string, int cflags);

Since we're already passing a flag, can we add another flag that adds the ^ and $ anchors? It's more convenient to do just one malloc (via the regex_quote) that also adds the anchors, than it is to have to manually call regex_quote_length, increment the result, malloc the space, insert the anchors, then call regex_quote_copy.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]