[libvirt] [PATCH 1/4] conf: Convert ParseString to use STRPREFIX

Eric Blake eblake at redhat.com
Fri Nov 19 20:00:56 UTC 2010


On 11/19/2010 09:15 AM, Cole Robinson wrote:
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  src/util/conf.c |   19 +++++++++++--------
>  1 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/src/util/conf.c b/src/util/conf.c
> index ba1a384..a31bbc4 100644
> --- a/src/util/conf.c
> +++ b/src/util/conf.c
> @@ -394,17 +394,20 @@ virConfParseString(virConfParserCtxtPtr ctxt)
>              return NULL;
>          }
>          NEXT;
> -    } else if ((ctxt->cur + 6 < ctxt->end) && (ctxt->cur[0] == '"') &&
> -               (ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {
> +    } else if ((ctxt->cur + 6 < ctxt->end) &&
> +               (STRPREFIX(ctxt->cur, "\"\"\""))) {
> +        /* String starts with python-style triple quotes """ */
>          ctxt->cur += 3;
>          base = ctxt->cur;
> -        while ((ctxt->cur + 2 < ctxt->end) && (ctxt->cur[0] == '"') &&
> -               (ctxt->cur[1] == '"') && (ctxt->cur[2] == '"')) {

How did the old code ever find the closing quotes?  If there is anything
except """ at ctxt->cur after the opening """, then the body of the
while loop is never entered and NEXT is never called.
> +
> +        while ((ctxt->cur + 2 < ctxt->end) &&
> +               (STRPREFIX(ctxt->cur, "\"\"\""))) {

Your rewrite faithfully matches the old code, which means its still
looks buggy.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101119/93222d8b/attachment-0001.sig>


More information about the libvir-list mailing list