[Libguestfs] [PATCH 4/5] inspect: Don't assume number of captures in match functions

Matthew Booth mbooth at redhat.com
Tue Oct 18 12:44:41 UTC 2011


It is possible for the pcre library to return a variable number of captures for
a single regular expression. e.g.:

  ^/dev/(cciss/c\d+d\d+)(?:p(\d+))?$

This will return either 1 or 2 captures depending on whether the device has a
partition suffix. The current match wrappers don't allow for this, and require
that a predictable number of matches are returned.

This change updates match, match1, match2, and match3 to ignore the specific
number of matches returned. Instead, any returned captures are assigned to the
given arguments, and any remaining arguments are set to NULL.
---
 src/match.c |   43 +++++++++++++------------------------------
 1 files changed, 13 insertions(+), 30 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-inspect-Don-t-assume-number-of-captures-in-match-fun.patch
Type: text/x-patch
Size: 2901 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20111018/cd78584c/attachment.bin>


More information about the Libguestfs mailing list