[pcre-dev] '-g mode' return code at end of loop

Página Principal
Apagar esta mensagem
Autor: jonetsu
Data:  
Para: pcre-dev
Assunto: [pcre-dev] '-g mode' return code at end of loop
Hello,

pcredemo -g, upon a normal run, reports:

./pcredemo -g "rate (?'rate'\d+)Kbit"
"quantum 12500 rate 300000Kbit ceil 540000Kbit"

Match succeeded at offset 14
0: rate 300000Kbit
1: 300000
Named substrings
(1) rate: 300000
Matching error -24

Which is ending in:

  if (rc < 0)
    {
    printf("Matching error %d\n", rc);
    pcre_free(re);
    return 1;
    }


rc at that moment being PCRE_ERROR_BADOFFSET.

So far I see it as a bit unclear what to report to the caller. Unless
-24 is always how an otherwise successful run ends and can be counted
upon.

It would be nice to return tot he caller a status that says clearly that
all that there was to mine in the string according to the regex was
mined and that's OK. As opposed as returning a systemic error of any
kind. Is there a way to do that ? I'm still getting inspiration off
pcredemo.

Thanks.