]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Support for aliases to aliases too.
authorDale Weiler <killfieldengine@gmail.com>
Wed, 6 Feb 2013 08:43:11 +0000 (08:43 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 6 Feb 2013 08:43:11 +0000 (08:43 +0000)
parser.c

index 7e86b23df1bafb92cf01f80cfa0817b80772d520..3eaef0c5d87f835dc0b9da3d5d53a3ced016261c 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -5275,9 +5275,18 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
                             }
                         }
                     } else {
-                        ast_expression *find = parser_find_var(parser, var->desc);
+                        void           *entry = (void*)var->desc;
+                        ast_expression *find  = parser_find_var(parser, var->desc);
+
+                        /* aliases to aliases are also allowed */
+                        if (!find) {
+                            char *name = NULL;
+                            if ((find = parser_find_var(parser, (const char *)(name = util_htget(parser->aliases, var->desc)))))
+                                entry = (void*)name;
+                        }
+
                         if (!find) {
-                            compile_error(parser_ctx(parser), "undeclared variable `%s` for alias `%s", var->desc, var->name);
+                            compile_error(parser_ctx(parser), "undeclared variable `%s` for alias `%s`", var->desc, var->name);
                             return false;
                         }
 
@@ -5294,7 +5303,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
                             return false;
                         }
 
-                        util_htset(parser->aliases, var->name, (void*)var->desc);
+                        util_htset(parser->aliases, var->name, entry);
                         /*
                          * TODO: vector, find . or _ (last of), and build
                          * [._]x, [._]y, [._]z  aliases too.