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   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to