Default scope for variables is innermost function block

darcs-hash:20050926145426-ac50b-ebe8f1af0ee60728d71a8df326b89ed6575560c6.gz
This commit is contained in:
axel 2005-09-27 00:54:26 +10:00
parent 0ef22a5577
commit 0a87af38f9
2 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,8 @@
* env.c, builtin_set.c (env_exist, env_get, env_set, builtin_set): Add support for zero element arrays
* env.c (env_set): Default scope for variables is innermost function block
2005-09-25 Axel Liljencrantz <axel@liljencrantz.se>
* parser.c: (parse_job, parser_skip_arguemnts, paresr_Test): No semicolon required after else and begin

8
env.c
View File

@ -377,7 +377,7 @@ void env_set( const wchar_t *key,
}
node = env_get_node( key );
if( &node->env != 0 )
if( node && &node->env != 0 )
{
e = (var_entry_t *) hash_get( &node->env,
key );
@ -425,7 +425,13 @@ void env_set( const wchar_t *key,
}
else
{
/*
New variable with unspecified scope. The default scope is the innermost scope that is shadowing
*/
node = top;
while( node->next && !node->new_scope )
node = node->next;
}
}
}