Hi, there seems to be a subtle problem with setting the substring match variables like %{1} etc. when an optionally matching subexpression does not match, but the expression as a whole does. Example: The expression ^(a|b)?(.)$ will match for example 'ax', 'bx', and 'x'. The first two cases will work like expected setting %{1} = 'a', %{2} = 'x' and so on. In the last case, the first substring is actually empty with rxmatch[1].rm_so == -1, but the second substring contains 'x' (rxmatch[2].rm_so == 0, rxmatch[2].rm_eo == 1). The code setting the substring match variables stops on the first rxmatch[].rm_so == -1 unless the variable has an old value(?), so %{2} might be never set in the last example. Is this expected behaviour? If not, how can this be fixed? Just leave out the 'break' in the for loop? (Code from valuepair.c)
/* * Add %{0}, %{1}, etc. */ for (i = 0; i <= REQUEST_MAX_REGEX; i++) { char *p; char buffer[sizeof(check->vp_strvalue)];
/* * Didn't match: delete old * match, if it existed. */ if ((compare != 0) || (rxmatch[i].rm_so == -1)) { p = request_data_get(request, request, REQUEST_DATA_REGEX | i); if (p) { free(p); continue; }
/* * No previous match * to delete, stop. */ break; } ...; }
Enrik