Skip to content

Commit

Permalink
nested alias lookup
Browse files Browse the repository at this point in the history
best explained with an example:

one = two ; two = three ; three = four
echo $one
> two
echo $$one
> three
echo $$$one
> four
  • Loading branch information
ac-stef committed Feb 23, 2015
1 parent 47f71f1 commit ec13fd7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/src/command.cpp
Expand Up @@ -389,6 +389,16 @@ char *parseexp(const char *&p, int right) // parse any nested set of

char *lookup(char *n) // find value of ident referenced with $ in exp
{
if(n[1] == '$') // nested ("$$var")
{
char *nn = lookup(newstring(n + 1));
delete[] n;
int nnl = strlen(nn);
n = newstring(nnl + 1);
n[0] = '$';
copystring(n + 1, nn, nnl + 1);
delete[] nn;
}
ident *id = idents->access(n+1);
if(id) switch(id->type)
{
Expand Down

0 comments on commit ec13fd7

Please sign in to comment.