filter_param_t param;
param.type = param_tokenize(key, key_len);
if (param.type != ATK_UNKNOWN) {
- param.value = m_strdup(value);
+ param.value = p_dupstr(value, value_len);
+ param.value_len = value_len;
array_add(config->params, param);
}
}
void filter_set_name(filter_t *filter, const char *name, ssize_t len)
{
- filter->name = p_new(char, len + 1);
- memcpy(filter->name, name, len);
- filter->name[len] = '\0';
+ filter->name = p_dupstr(name, len);
}
bool filter_set_type(filter_t *filter, const char *type, ssize_t len)
atokens[param.type], ftokens[filter->type]);
return false;
}
- param.value = m_strdup(value);
+ param.value = p_dupstr(value, value_len);
+ param.value_len = value_len;
array_add(filter->params, param);
return true;
}
typedef struct filter_param_t {
filter_param_id_t type;
- char *value;
+ char *value;
+ ssize_t value_len;
} filter_param_t;
ARRAY(filter_param_t)
case ATK_ ## Param: { \
char *next; \
(Dest) = strtol(param->value, &next, 10); \
- PARSE_CHECK(!*next, "invalid %s value %s", atokens[ATK_ ## Param], \
- param->value); \
+ PARSE_CHECK(!*next, "invalid %s value %.*s", atokens[ATK_ ## Param], \
+ param->value_len, param->value); \
} break
#define FILTER_PARAM_PARSE_BOOLEAN(Param, Dest) \
case ATK_ ## Param: { \
- if (param->value[0] == '1' && param->value[1] == '\0') { \
+ if (param->value_len == 1 && param->value[0] == '1') { \
(Dest) = true; \
- } else if (param->value[0] == '0' && param->value[1] == '\0') { \
+ } else if (param->value_len == 1 && param->value[0] == '0') { \
(Dest) = false; \
- } else if (ascii_tolower(param->value[0]) == 't') { \
+ } else if (param->value_len == 4 \
+ && ascii_tolower(param->value[0]) == 't') { \
(Dest) = ascii_tolower(param->value[1]) == 'r' \
&& ascii_tolower(param->value[2]) == 'u' \
- && ascii_tolower(param->value[3]) == 'e' \
- && !param->value[4]; \
- } else if (ascii_tolower(param->value[0]) == 'f') { \
+ && ascii_tolower(param->value[3]) == 'e'; \
+ } else if (param->value_len == 5 \
+ && ascii_tolower(param->value[0]) == 'f') { \
(Dest) = ascii_tolower(param->value[1]) == 'a' \
&& ascii_tolower(param->value[2]) == 'l' \
&& ascii_tolower(param->value[3]) == 's' \
- && ascii_tolower(param->value[4]) == 'e' \
- && !param->value[5]; \
+ && ascii_tolower(param->value[4]) == 'e'; \
} else { \
- PARSE_CHECK(false, "invalid %s value %s", atokens[ATK_ ## Param], \
- param->value); \
+ PARSE_CHECK(false, "invalid %s value %.*s", atokens[ATK_ ## Param],\
+ param->value_len, param->value); \
} \
} break
array_add(data->weights, weight);
break;
}
- current = p + 1;
- p = m_strchrnul(current, ':');
+ if (i != 2) {
+ current = p + 1;
+ p = m_strchrnul(current, ':');
+ }
}
} break;
trie = strlist_create(current, reverse, lock);
PARSE_CHECK(trie != NULL,
"cannot load string list from %s", current);
+ trie_inspect(trie, false);
array_add(config->tries, trie);
array_add(config->weights, weight);
array_add(config->reverses, reverse);
break;
}
- current = p + 1;
- p = m_strchrnul(current, ':');
+ if (i != 3) {
+ current = p + 1;
+ p = m_strchrnul(current, ':');
+ }
}
} break;