MINOR: sample/acl: use is_idchar() to locate the fetch/conv name
Instead of scanning a string looking for an end of line, ')' or ',',
let's only accept characters which are actually valid identifier
characters. This will let the parser know that in %[src], only "src"
is the sample fetch name, not "src]". This was done both for samples
and ACLs since they are the same here.
diff --git a/src/acl.c b/src/acl.c
index 209580a..bef3d4e 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -90,7 +90,7 @@
struct acl_kw_list *kwl;
kwend = kw;
- while (*kwend && *kwend != '(' && *kwend != ',')
+ while (is_idchar(*kwend))
kwend++;
list_for_each_entry(kwl, &acl_keywords.list, list) {
@@ -190,7 +190,8 @@
smp->arg_p = empty_arg_list;
/* look for the beginning of the subject arguments */
- for (arg = args[0]; *arg && *arg != '(' && *arg != ','; arg++);
+ for (arg = args[0]; is_idchar(*arg); arg++)
+ ;
endt = arg;
if (*endt == '(') {
@@ -263,7 +264,8 @@
/* none ? end of converters */
break;
- for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
+ for (endw = begw; is_idchar(*endw); endw++)
+ ;
free(ckw);
ckw = my_strndup(begw, endw - begw);
diff --git a/src/sample.c b/src/sample.c
index 820fa47..d9439fb 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -839,7 +839,8 @@
int err_arg;
begw = str[*idx];
- for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
+ for (endw = begw; is_idchar(*endw); endw++)
+ ;
if (endw == begw) {
memprintf(err_msg, "missing fetch method");
@@ -949,7 +950,8 @@
break;
}
- for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
+ for (endw = begw; is_idchar(*endw); endw++)
+ ;
free(ckw);
ckw = my_strndup(begw, endw - begw);