if (!p)
p = lines[k];
+ ngroup = 0;
for (i = 0; i < nregex; i++) {
if (regexec(®[i], p, nvars[i]+1, vars, 0) != 0)
break;
- if (i == 0)
- ngroup = 0;
-
/* NULL terminate each captured group in the line */
for (j = 0; j < nvars[i]; j++) {
/* NB vars[0] is the full pattern, so we offset j by 1 */
goto cleanup;
}
- /* We're matching on the last regex, so callback time */
- if (i == (nregex-1)) {
- if (((*func)(groups, data)) < 0)
- goto cleanup;
+ }
+ /* We've matched on the last regex, so callback time */
+ if (i == nregex) {
+ if (((*func)(groups, data)) < 0)
+ goto cleanup;
- /* Release matches & restart to matching the first regex */
- for (j = 0; j < totgroups; j++)
- VIR_FREE(groups[j]);
- ngroup = 0;
- }
+ for (j = 0; j < totgroups; j++)
+ VIR_FREE(groups[j]);
}
}