weggli
weggli copied to clipboard
support search for label
Is it possible to search label in C/C++ ?
I tried
weggli '{
abc:
}' ~/project
but it got
Error! Query parsing failed: {
abc: [MISSING ; ]
}
I understand it will overlap with the not: and strict: function.
You can search for labels but not for a label: weggli '{ abc:; }' ~/project works for example, but will return the first label in a file (not the first label named abc). Looks like this is because the label name is not used as a pattern here. Might be just an oversight, but will definitely conflict with not: etc.
example:
test.c
void func_with_label()
{
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
err = sslRawVerify(ctx,
ctx->peerPubKey,
dataToSign, /* plaintext */
dataToSignLen, /* plaintext length */
signature,
signatureLen);
fail:
SSLFreeBuffer(&signedHashes);
SSLFreeBuffer(&hashCtx);
return err;
}
void func_without_label()
{
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
err = sslRawVerify(ctx,
ctx->peerPubKey,
dataToSign, /* plaintext */
dataToSignLen, /* plaintext length */
signature,
signatureLen);
}
this matches only func_with_label
$ weggli '{
goto $x; goto $x; foo: _;
}' /tmp/test.c
/tmp/test.c:1
void func_with_label()
{
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
err = sslRawVerify(ctx,
ctx->peerPubKey,
dataToSign, /* plaintext */
dataToSignLen, /* plaintext length */
..
}
while this matches both:
$ weggli '{
goto $x; goto $x;
}' /tmp/test.c
/tmp/test.c:1
void func_with_label()
{
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
err = sslRawVerify(ctx,
ctx->peerPubKey,
dataToSign, /* plaintext */
dataToSignLen, /* plaintext length */
..
}
/tmp/test.c:21
void func_without_label()
{
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
err = sslRawVerify(ctx,
ctx->peerPubKey,
dataToSign, /* plaintext */
dataToSignLen, /* plaintext length */
..
}