summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/variable.c27
-rw-r--r--src/variable.vcc2
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/regset.at (renamed from tests/batchset.at)6
-rw-r--r--tests/testsuite.at2
5 files changed, 18 insertions, 21 deletions
diff --git a/src/variable.c b/src/variable.c
index 9442b6b..667cfc0 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -617,8 +617,7 @@ bref_expand(const char *str, const char *input, pcre *re,
}
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;
@@ -638,7 +637,7 @@ vmod_batchset(VARIABLE_CTX ctx,
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;
}
@@ -699,7 +698,7 @@ vmod_batchset(VARIABLE_CTX ctx,
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;
@@ -713,7 +712,7 @@ vmod_batchset(VARIABLE_CTX ctx,
}
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;
@@ -724,13 +723,11 @@ vmod_batchset(VARIABLE_CTX ctx,
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);
@@ -743,14 +740,14 @@ vmod_batchset(VARIABLE_CTX ctx,
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
@@ -761,10 +758,10 @@ vmod_batchset(VARIABLE_CTX ctx,
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;
}
diff --git a/src/variable.vcc b/src/variable.vcc
index b8eb8e2..7fca518 100644
--- a/src/variable.vcc
+++ b/src/variable.vcc
@@ -33,5 +33,5 @@ $Function VOID clear()
$Function INT defined(STRING)
$Function STRING type_of(STRING)
$Function VOID undef(STRING)
-$Function VOID batchset(STRING, STRING, STRING)
+$Function VOID regset(STRING, STRING, STRING)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1a81bea..99769ae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,7 +41,6 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
TESTSUITE_AT = \
testsuite.at\
- batchset.at\
complex.at\
clear.at\
defined.at\
@@ -49,6 +48,7 @@ TESTSUITE_AT = \
gstring.at\
int.at\
real.at\
+ regset.at\
string.at\
type_of.at\
undef.at
diff --git a/tests/batchset.at b/tests/regset.at
index 506fe78..cc92578 100644
--- a/tests/batchset.at
+++ b/tests/regset.at
@@ -14,12 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with vmod-variable. If not, see <http://www.gnu.org/licenses/>.
-AT_SETUP(batchset)
-AT_KEYWORDS(batchset)
+AT_SETUP(regset)
+AT_KEYWORDS(regset)
AT_VARNISHTEST([
sub vcl_recv {
- variable.batchset("y:i,x,time:d=\3s", "^/(\d+)/(.+)/(\d+)", req.url);
+ variable.regset("y:i,x,time:d=\3s", "^/(\d+)/(.+)/(\d+)", req.url);
}
sub vcl_deliver {
set resp.http.X-X = variable.get("x");
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 7312433..d0cc846 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -54,7 +54,7 @@ m4_include([clear.at])
m4_include([defined.at])
m4_include([type_of.at])
m4_include([undef.at])
-m4_include([batchset.at])
+m4_include([regset.at])
m4_include([gstring.at])
# End of testsuite.at

Return to:

Send suggestions and report system problems to the System administrator.