From 4ee0c42dcc63eef8b12f58a4be20cdac4c5ffa0c Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Thu, 30 Jan 2003 20:43:57 +0000 Subject: [PATCH] Made GIB var substitution use cvars as a last resort. --- libs/gib/gib_process.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/gib/gib_process.c b/libs/gib/gib_process.c index f27e0edda..22e6df3d1 100644 --- a/libs/gib/gib_process.c +++ b/libs/gib/gib_process.c @@ -56,6 +56,7 @@ GIB_Process_Variable (dstring_t *token, unsigned int *i) hashtab_t *one = GIB_DATA(cbuf_active)->locals, *two = GIB_DATA(cbuf_active)->globals; unsigned int n = *i, j, k, start = *i, index = 0, len, len2; gib_var_t *var = 0; + cvar_t *cvar; char c; const char *str; @@ -97,7 +98,11 @@ GIB_Process_Variable (dstring_t *token, unsigned int *i) str = va("%u", var->size - index); else str = var->array[index]->str; - } else + } else if (token->str[start] == '#') + str = "0"; + else if ((cvar = Cvar_FindVar (token->str+k))) + str = cvar->string; + else str = ""; token->str[n] = c; len += n-start; @@ -129,6 +134,7 @@ GIB_Process_Embedded (gib_tree_t *node, cbuf_args_t *args) { unsigned int n, j; gib_var_t *var; + cvar_t *cvar; gib_tree_t *cur; unsigned int index, prev = 0; const char *str = node->str; @@ -166,7 +172,10 @@ GIB_Process_Embedded (gib_tree_t *node, cbuf_args_t *args) dstring_appendstr (args->argv[args->argc-1], var->array[index]->str); else dasprintf (args->argv[args->argc-1], "%u", var->size - index); - } + } else if (cur->delim == '#') + dstring_appendstr (args->argv[args->argc-1], "0"); + else if ((cvar = Cvar_FindVar (cur->str))) + dstring_appendstr (args->argv[args->argc-1], cvar->string); } if (str[prev]) dstring_appendstr (args->argv[args->argc-1], str+prev);