};
const struct var_expand_test tests[] = {
+ /* syntax */
+ { .in = "%{}", .out = "", .ret = 0 },
+ {
+ .in = "%{",
+ .out = "syntax error, unexpected end of file, expecting "
+ "CCBRACE or PIPE or NAME",
+ .ret = -1
+ },
+ { .in = "hello%{}world", .out = "helloworld", .ret = 0 },
/* basic lookup */
{ .in = "%{first}", .out = "hello", .ret = 0 },
{ .in = "%{lookup('first')}", .out = "hello", .ret = 0 },
static void make_new_program(VAR_EXPAND_PARSER_STYPE *pstate)
{
- struct var_expand_program *p =
+ struct var_expand_program *plast, *pp, *p =
p_new(pstate->plist->pool, struct var_expand_program, 1);
p->pool = pstate->plist->pool;
- pstate->pp->next = p;
+ pp = pstate->plist;
+ plast = NULL;
+ while (pp != NULL) {
+ plast = pp;
+ pp = pp->next;
+ }
+ if (plast != NULL)
+ plast->next = p;
+ else
+ pstate->plist = p;
pstate->p = p;
}