diff options
Diffstat (limited to 'src/variable.c')
-rw-r--r-- | src/variable.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/variable.c b/src/variable.c index 9442b6b..667cfc0 100644 --- a/src/variable.c +++ b/src/variable.c @@ -614,14 +614,13 @@ bref_expand(const char *str, const char *input, pcre *re, *rptr = 0; return rbase; } VCL_VOID -vmod_batchset(VARIABLE_CTX ctx, - VCL_STRING vars, VCL_STRING rxs, VCL_STRING input) +vmod_regset(VARIABLE_CTX ctx, VCL_STRING vars, VCL_STRING rxs, VCL_STRING input) { struct symtab *vt = get_symtab(ctx); struct vardef *head = NULL, *tail = NULL, *def; size_t count = 0; size_t n; const char *v = vars; @@ -635,13 +634,13 @@ vmod_batchset(VARIABLE_CTX ctx, int *ovector; int i; int rc; pcre *re; if (!vars || !rxs || !input) { - log_error("variable.batchset: bad arguments: vars=%s, rxs=%s, input=%s", + log_error("variable.regset: bad arguments: vars=%s, rxs=%s, input=%s", S(vars), S(rxs), S(input)); return; } while (*v) { char const *nameptr = v; @@ -696,13 +695,13 @@ vmod_batchset(VARIABLE_CTX ctx, memcpy(def->repl, replptr, repllen); def->repl[repllen] = 0; } re = pcre_compile(rxs, cflags, &error_ptr, &error_offset, NULL); if (!re) { - log_error("variable.batchset: %s: compilation failed near %s: %s", + log_error("variable.regset: %s: compilation failed near %s: %s", rxs, rxs + error_offset, error_ptr); vardef_free(head); return; } rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n); @@ -710,64 +709,62 @@ vmod_batchset(VARIABLE_CTX ctx, log_error("pcre_fullinfo() failed: %d", rc); vardef_free(head); return; } if (n < count) { - log_error("variable.batchset: %s: too few subexpressions to satisfy %s", + log_error("variable.regset: %s: too few subexpressions to satisfy %s", rxs, vars); vardef_free(head); return; } ovsize = (count + 1) * 3; ovector = calloc(ovsize, sizeof(*ovector)); rc = pcre_exec(re, 0, input, strlen(input), 0, 0, ovector, ovsize); if (rc <= 0) { - if (rc == 0) - log_error("matched, but too many substrings"); - else - /*FIXME*/; + if (rc != PCRE_ERROR_NOMATCH) + log_error("variable.regset: pcre_exec failed: %d", rc); vardef_free(head); return; - } + } for (def = head; def; def = def->next, i++) { char *s = bref_expand(def->repl, input, re, ovsize, ovector); switch (def->type) { case variable_string: value.s = (char*)s; break; case variable_int: errno = 0; lval = strtol(s, &p, 10); if (*p) { - log_error("variable.batchset: %s(%s)#%d: not an integer", rxs, input, i); + log_error("variable.regset: %s(%s)#%d: not an integer", rxs, input, i); value.i = 0; } else if (errno) { - log_error("variable.batchset: %s(%s)#%d: %s", + log_error("variable.regset: %s(%s)#%d: %s", rxs, input, i, strerror(errno)); value.i = 0; } else if (lval < INT_MIN || lval > INT_MAX) { - log_error("variable.batchset: %s(%s)#%d: value out of range", + log_error("variable.regset: %s(%s)#%d: value out of range", rxs, input, i); value.i = 0; } else value.i = lval; free(s); break; case variable_real: errno = 0; value.r = strtod(s, &p); if (*p) { - log_error("variable.batchset: %s(%s)#%d: not a valid number", rxs, input, i); + log_error("variable.regset: %s(%s)#%d: not a valid number", rxs, input, i); value.r = 0; } else if (errno) { - log_error("variable.batchset: %s(%s)#%d: %s", + log_error("variable.regset: %s(%s)#%d: %s", rxs, input, i, strerror(errno)); value.r = 0; } free(s); break; |