mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-10 19:58:06 +00:00
MINOR: pattern: Merge function pattern_add() with pat_ref_push().
The function Pattern_add() is only used by pat_ref_push(). This patch remove the function pattern_add() and merge his code in the function pat_ref_push().
This commit is contained in:
parent
aa222aadb6
commit
d25c842326
@ -1764,35 +1764,6 @@ int pat_ref_append(struct pat_ref *ref, char *pattern, char *sample, int line)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* return 1 if the process is ok
|
||||
* return -1 if the parser fail. The err message is filled.
|
||||
* return -2 if out of memory
|
||||
*/
|
||||
static inline
|
||||
int pattern_add(struct pattern_expr *expr, const char *arg,
|
||||
struct sample_storage *smp,
|
||||
int patflags, char **err)
|
||||
{
|
||||
int ret;
|
||||
struct pattern pattern;
|
||||
|
||||
/* initialise pattern */
|
||||
memset(&pattern, 0, sizeof(pattern));
|
||||
pattern.flags = patflags;
|
||||
pattern.smp = smp;
|
||||
|
||||
/* parse pattern */
|
||||
ret = expr->pat_head->parse(arg, &pattern, err);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
/* index pattern */
|
||||
if (!expr->pat_head->index(expr, &pattern, err))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* This function create sample found in <elt>, parse the pattern also
|
||||
* found in <elt> and insert it in <expr>. The function copy <patflags>
|
||||
* in <expr>. If the function fails, it returns0 and <err> is filled.
|
||||
@ -1802,8 +1773,8 @@ static inline
|
||||
int pat_ref_push(struct pat_ref_elt *elt, struct pattern_expr *expr,
|
||||
int patflags, char **err)
|
||||
{
|
||||
int ret;
|
||||
struct sample_storage *smp;
|
||||
struct pattern pattern;
|
||||
|
||||
/* Create sample */
|
||||
if (elt->sample && expr->pat_head->parse_smp) {
|
||||
@ -1823,12 +1794,20 @@ int pat_ref_push(struct pat_ref_elt *elt, struct pattern_expr *expr,
|
||||
else
|
||||
smp = NULL;
|
||||
|
||||
/* Index value */
|
||||
ret = pattern_add(expr, elt->pattern, smp, patflags, err);
|
||||
if (ret != 1) {
|
||||
/* initialise pattern */
|
||||
memset(&pattern, 0, sizeof(pattern));
|
||||
pattern.flags = patflags;
|
||||
pattern.smp = smp;
|
||||
|
||||
/* parse pattern */
|
||||
if (!expr->pat_head->parse(elt->pattern, &pattern, err)) {
|
||||
free(smp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* index pattern */
|
||||
if (!expr->pat_head->index(expr, &pattern, err)) {
|
||||
free(smp);
|
||||
if (ret == -2)
|
||||
memprintf(err, "out of memory");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user