summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2015-02-12 14:47:56 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-02-12 15:59:06 (GMT)
commitf06fcc848fa5a5b15d170bf5cc34986ed6164621 (patch) (side-by-side diff)
tree399b822af71efe9240bb9352465f8ab32bbc7c68
parent133e104d9efac43c0cf243207c2c5eaf0343bced (diff)
downloadvmod-variable-f06fcc848fa5a5b15d170bf5cc34986ed6164621.tar.gz
vmod-variable-f06fcc848fa5a5b15d170bf5cc34986ed6164621.tar.bz2
Rename batchset to regset
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
@@ -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;
diff --git a/src/variable.vcc b/src/variable.vcc
index b8eb8e2..7fca518 100644
--- a/src/variable.vcc
+++ b/src/variable.vcc
@@ -30,8 +30,8 @@ $Function VOID set_duration(STRING, DURATION)
$Function DURATION get_duration(STRING)
$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
@@ -38,20 +38,20 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
## ------------ ##
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
testsuite.at\
- batchset.at\
complex.at\
clear.at\
defined.at\
duration.at\
gstring.at\
int.at\
real.at\
+ regset.at\
string.at\
type_of.at\
undef.at
TESTSUITE = $(srcdir)/testsuite
M4=m4
diff --git a/tests/batchset.at b/tests/regset.at
index 506fe78..cc92578 100644
--- a/tests/batchset.at
+++ b/tests/regset.at
@@ -11,18 +11,18 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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");
set resp.http.X-Y = variable.get_int("y");
set resp.http.X-Time = variable.get_duration("time");
}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 7312433..d0cc846 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -51,10 +51,10 @@ m4_include([real.at])
m4_include([duration.at])
m4_include([complex.at])
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.