Skip to content

Commit

Permalink
lib: Support nested keys in var_get_key_range_full
Browse files Browse the repository at this point in the history
Fixes problems with %{if...}

failed: if: requires four or five parameters, got 1
  • Loading branch information
cmouse authored and villesavolainen committed Feb 5, 2018
1 parent 92a685a commit 34676d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/var-expand.c
Expand Up @@ -639,11 +639,17 @@ var_get_key_range_full(const char *str, unsigned int *idx_r,
*size_r = str[i] == '\0' ? 0 : 1;
return FALSE;
} else {
unsigned int depth = 1;
bool escape = FALSE;
/* long key */
*idx_r = ++i;
for (; str[i] != '\0'; i++) {
if (str[i] == '}')
break;
if (str[i] == '{')
depth++;
if (str[i] == '}') {
if (--depth==0)
break;
}
}
*size_r = i - *idx_r;
return TRUE;
Expand Down

0 comments on commit 34676d2

Please sign in to comment.