diff options
author | Grissiom <chaos.proton@gmail.com> | 2010-09-18 09:51:16 +0800 |
---|---|---|
committer | Grissiom <chaos.proton@gmail.com> | 2010-09-18 09:51:16 +0800 |
commit | c6372a1b3f56d7022f135b8f1baeaff44816ec7c (patch) | |
tree | 1e274b07fc1942d7f39d334771c7d621a164b15f /env.c | |
parent | 41b8db063c032c673e366d81bccf37022b9c1d4f (diff) |
remove trailing spaces
This is done by `sed -i -e 's/[ \t]*$//' *.[c,h]`, which should not
introduce any functionality change.
Diffstat (limited to 'env.c')
-rw-r--r-- | env.c | 444 |
1 files changed, 222 insertions, 222 deletions
@@ -83,11 +83,11 @@ extern char **__environ; */ typedef struct env_node { - /** - Variable table + /** + Variable table */ hash_table_t env; - /** + /** Does this node imply a new variable scope? If yes, all non-global variables below this one in the stack are invisible. If new_scope is set for the global variable node, @@ -98,8 +98,8 @@ typedef struct env_node Does this node contain any variables which are exported to subshells */ int export; - - /** + + /** Pointer to next level */ struct env_node *next; @@ -115,7 +115,7 @@ typedef struct var_entry { int export; /**< Whether the variable should be exported */ size_t size; /**< The maximum length (excluding the NULL) that will fit into this var_entry_t */ - + #if __STDC_VERSION__ < 199901L wchar_t val[1]; /**< The value of the variable */ #else @@ -206,12 +206,12 @@ static const wchar_t *locale_variable[] = */ static void clear_hash_entry( void *key, void *data ) { - var_entry_t *entry = (var_entry_t *)data; + var_entry_t *entry = (var_entry_t *)data; if( entry->export ) { has_changed = 1; } - + free( (void *)key ); free( (void *)data ); } @@ -227,20 +227,20 @@ static void start_fishd() { string_buffer_t cmd; struct passwd *pw; - + sb_init( &cmd ); pw = getpwuid(getuid()); - + debug( 3, L"Spawning new copy of fishd" ); - + if( !pw ) { debug( 0, _( L"Could not get user information" ) ); return; } - + sb_printf( &cmd, FISHD_CMD, pw->pw_name ); - + eval( (wchar_t *)cmd.buff, 0, TOP ); @@ -287,10 +287,10 @@ static void handle_locale() /* Array of locale constants corresponding to the local variable names defined in locale_variable */ - static const int cat[] = + static const int cat[] = { - 0, - LC_ALL, + 0, + LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, @@ -299,7 +299,7 @@ static void handle_locale() LC_TIME } ; - + if( lc_all ) { wsetlocale( LC_ALL, lc_all ); @@ -311,7 +311,7 @@ static void handle_locale() { wsetlocale( LC_ALL, lang ); } - + for( i=2; locale_variable[i]; i++ ) { const wchar_t *val = env_get( locale_variable[i] ); @@ -322,11 +322,11 @@ static void handle_locale() } } } - + if( wcscmp( wsetlocale( LC_MESSAGES, (void *)0 ), old ) != 0 ) { - /* + /* Try to make change known to gettext. Both changing _nl_msg_cat_cntr and calling dcgettext might potentially tell some gettext implementation that the translation @@ -338,14 +338,14 @@ static void handle_locale() _nl_msg_cat_cntr++; dcgettext( "fish", "Changing language to English", LC_MESSAGES ); - + if( is_interactive ) { debug( 0, _(L"Changing language to English") ); } } free( old ); - + } @@ -354,16 +354,16 @@ static void handle_locale() proper events are triggered when an event occurs. */ static void universal_callback( int type, - const wchar_t *name, + const wchar_t *name, const wchar_t *val ) { wchar_t *str=0; - + if( is_locale( name ) ) { handle_locale(); } - + switch( type ) { case SET: @@ -372,29 +372,29 @@ static void universal_callback( int type, str=L"SET"; break; } - + case ERASE: { str=L"ERASE"; break; } } - + if( str ) { event_t ev; - + has_changed=1; - + ev.type=EVENT_VARIABLE; ev.param1.variable=name; ev.function_name=0; - + al_init( &ev.arguments ); al_push( &ev.arguments, L"VARIABLE" ); al_push( &ev.arguments, str ); al_push( &ev.arguments, name ); - event_fire( &ev ); + event_fire( &ev ); al_destroy( &ev.arguments ); } } @@ -405,11 +405,11 @@ static void universal_callback( int type, static void setup_path() { wchar_t *path; - + int i, j; array_list_t l; - const wchar_t *path_el[] = + const wchar_t *path_el[] = { L"/bin", L"/usr/bin", @@ -419,19 +419,19 @@ static void setup_path() ; path = env_get( L"PATH" ); - + al_init( &l ); - + if( path ) { tokenize_variable_array( path, &l ); } - + for( j=0; path_el[j]; j++ ) { int has_el=0; - + for( i=0; i<al_get_count( &l); i++ ) { wchar_t * el = (wchar_t *)al_get( &l, i ); @@ -442,13 +442,13 @@ static void setup_path() len--; } - if( (wcslen( path_el[j] ) == len) && + if( (wcslen( path_el[j] ) == len) && (wcsncmp( el, path_el[j], len)==0) ) { has_el = 1; } } - + if( !has_el ) { string_buffer_t b; @@ -460,22 +460,22 @@ static void setup_path() { sb_append( &b, path ); } - + sb_append( &b, ARRAY_SEP_STR, path_el[j] ); - + env_set( L"PATH", (wchar_t *)b.buff, ENV_GLOBAL | ENV_EXPORT ); - + sb_destroy( &b ); - + al_foreach( &l, &free ); path = env_get( L"PATH" ); al_truncate( &l, 0 ); - tokenize_variable_array( path, &l ); + tokenize_variable_array( path, &l ); } } - + al_foreach( &l, &free ); al_destroy( &l ); } @@ -513,12 +513,12 @@ static void env_set_defaults() struct passwd *pw = getpwnam( unam_narrow ); wchar_t *dir = str2wcs( pw->pw_dir ); env_set( L"HOME", dir, ENV_GLOBAL ); - free( dir ); + free( dir ); free( unam_narrow ); - } + } env_set_pwd(); - + } void env_init() @@ -527,15 +527,15 @@ void env_init() struct passwd *pw; wchar_t *uname; wchar_t *version; - + sb_init( &dyn_var ); b_init( &export_buffer ); - + /* These variables can not be altered directly by the user */ hash_init( &env_read_only, &hash_wcs_func, &hash_wcs_cmp ); - + hash_put( &env_read_only, L"status", L"" ); hash_put( &env_read_only, L"history", L"" ); hash_put( &env_read_only, L"version", L"" ); @@ -543,7 +543,7 @@ void env_init() hash_put( &env_read_only, L"LINES", L"" ); hash_put( &env_read_only, L"COLUMNS", L"" ); hash_put( &env_read_only, L"PWD", L"" ); - + /* Names of all dynamically calculated variables */ @@ -561,20 +561,20 @@ void env_init() hash_put( &env_read_only, L"HOME", L"" ); hash_put( &env_read_only, L"USER", L"" ); } - + top = malloc( sizeof(env_node_t) ); top->next = 0; top->new_scope = 0; top->export=0; hash_init( &top->env, &hash_wcs_func, &hash_wcs_cmp ); global_env = top; - global = &top->env; - + global = &top->env; + /* Now the environemnt variable handling is set up, the next step is to insert valid data */ - + /* Import environment variables */ @@ -582,14 +582,14 @@ void env_init() { wchar_t *key, *val; wchar_t *pos; - + key = str2wcs(*p); if( !key ) { continue; } - + val = wcschr( key, L'=' ); if( val == 0 ) @@ -597,7 +597,7 @@ void env_init() env_set( key, L"", ENV_EXPORT ); } else - { + { *val = L'\0'; val++; pos=val; @@ -612,10 +612,10 @@ void env_init() } env_set( key, val, ENV_EXPORT | ENV_GLOBAL ); - } + } free(key); } - + /* Set up the PATH variable */ @@ -638,8 +638,8 @@ void env_init() version = str2wcs( PACKAGE_VERSION ); env_set( L"version", version, ENV_GLOBAL ); free( version ); - - env_universal_init( env_get( L"FISHD_SOCKET_DIR"), + + env_universal_init( env_get( L"FISHD_SOCKET_DIR"), env_get( L"USER" ), &start_fishd, &universal_callback ); @@ -653,26 +653,26 @@ void env_init() void env_destroy() { env_universal_destroy(); - + sb_destroy( &dyn_var ); b_destroy( &export_buffer ); - + while( &top->env != global ) { env_pop(); } - + hash_destroy( &env_read_only ); hash_destroy( &env_electric ); - + hash_foreach( global, &clear_hash_entry ); hash_destroy( global ); free( top ); - + free( export_arr ); - + } /** @@ -687,7 +687,7 @@ static env_node_t *env_get_node( const wchar_t *key ) while( env != 0 ) { - res = (var_entry_t *) hash_get( &env->env, + res = (var_entry_t *) hash_get( &env->env, key ); if( res != 0 ) { @@ -698,17 +698,17 @@ static env_node_t *env_get_node( const wchar_t *key ) { env = global_env; } - else + else { env = env->next; } } - + return 0; } -int env_set( const wchar_t *key, - const wchar_t *val, +int env_set( const wchar_t *key, + const wchar_t *val, int var_mode ) { int free_val = 0; @@ -716,14 +716,14 @@ int env_set( const wchar_t *key, env_node_t *node; int has_changed_old = has_changed; int has_changed_new = 0; - var_entry_t *e=0; + var_entry_t *e=0; int done=0; event_t ev; - int is_universal = 0; - + int is_universal = 0; + CHECK( key, ENV_INVALID ); - + if( val && contains( key, L"PWD", L"HOME" ) ) { void *context = halloc( 0, 0 ); @@ -737,12 +737,12 @@ int env_set( const wchar_t *key, halloc_free( context ); } - if( (var_mode & ENV_USER ) && + if( (var_mode & ENV_USER ) && hash_get( &env_read_only, key ) ) { return ENV_PERM; } - + if( wcscmp( key, L"umask" ) == 0) { wchar_t *end; @@ -752,10 +752,10 @@ int env_set( const wchar_t *key, Set the new umask */ if( val && wcslen(val) ) - { + { errno=0; mask = wcstol( val, &end, 8 ); - + if( !errno && (!*end) && (mask <= 0777) && (mask >= 0) ) { umask( mask ); @@ -776,7 +776,7 @@ int env_set( const wchar_t *key, { val = ENV_NULL; } - + if( var_mode & ENV_UNIVERSAL ) { int export = 0; @@ -786,31 +786,31 @@ int env_set( const wchar_t *key, { env_universal_get_export( key ); } - else + else { export = (var_mode & ENV_EXPORT ); } - + env_universal_set( key, val, export ); is_universal = 1; } else { - + node = env_get_node( key ); if( node && &node->env != 0 ) { - e = (var_entry_t *) hash_get( &node->env, + e = (var_entry_t *) hash_get( &node->env, key ); - + if( e->export ) { has_changed_new = 1; } } - if( (var_mode & ENV_LOCAL) || + if( (var_mode & ENV_LOCAL) || (var_mode & ENV_GLOBAL) ) { node = ( var_mode & ENV_GLOBAL )?global_env:top; @@ -821,7 +821,7 @@ int env_set( const wchar_t *key, { if( !(var_mode & ENV_EXPORT ) && !(var_mode & ENV_UNEXPORT ) ) - { + { var_mode = e->export?ENV_EXPORT:0; } } @@ -832,26 +832,26 @@ int env_set( const wchar_t *key, proc_had_barrier=1; env_universal_barrier(); } - + if( env_universal_get( key ) ) { int export = 0; - + if( !(var_mode & ENV_EXPORT ) && !(var_mode & ENV_UNEXPORT ) ) { env_universal_get_export( key ); } - else + else { export = (var_mode & ENV_EXPORT ); } - + env_universal_set( key, val, export ); is_universal = 1; - + done = 1; - + } else { @@ -859,7 +859,7 @@ int env_set( const wchar_t *key, New variable with unspecified scope. The default scope is the innermost scope that is shadowing, which will be either the current function or the - global scope. + global scope. */ node = top; while( node->next && !node->new_scope ) @@ -869,7 +869,7 @@ int env_set( const wchar_t *key, } } } - + if( !done ) { void *k, *v; @@ -885,46 +885,46 @@ int env_set( const wchar_t *key, { k = wcsdup(key); } - + old_entry = (var_entry_t *)v; if( old_entry && old_entry->size >= val_len ) { entry = old_entry; - + if( !!(var_mode & ENV_EXPORT) || entry->export ) { entry->export = !!(var_mode & ENV_EXPORT); - has_changed_new = 1; + has_changed_new = 1; } } else { free( v ); - entry = malloc( sizeof( var_entry_t ) + + entry = malloc( sizeof( var_entry_t ) + sizeof(wchar_t )*(val_len+1)); - + if( !entry ) { DIE_MEM(); } - + entry->size = val_len; - + if( var_mode & ENV_EXPORT) { entry->export = 1; - has_changed_new = 1; + has_changed_new = 1; } else { entry->export = 0; } - + } wcscpy( entry->val, val ); - + hash_put( &node->env, k, entry ); if( entry->export ) @@ -936,10 +936,10 @@ int env_set( const wchar_t *key, { free((void *)val); } - + has_changed = has_changed_old || has_changed_new; } - + } if( !is_universal ) @@ -947,16 +947,16 @@ int env_set( const wchar_t *key, ev.type=EVENT_VARIABLE; ev.param1.variable = key; ev.function_name = 0; - + al_init( &ev.arguments ); al_push( &ev.arguments, L"VARIABLE" ); al_push( &ev.arguments, L"SET" ); al_push( &ev.arguments, key ); - -// debug( 1, L"env_set: fire events on variable %ls", key ); + +// debug( 1, L"env_set: fire events on variable %ls", key ); event_fire( &ev ); -// debug( 1, L"env_set: return from event firing" ); - al_destroy( &ev.arguments ); +// debug( 1, L"env_set: return from event firing" ); + al_destroy( &ev.arguments ); } if( is_locale( key ) ) @@ -985,15 +985,15 @@ static int try_remove( env_node_t *n, { return 0; } - - hash_remove( &n->env, + + hash_remove( &n->env, key, - &old_key_void, + &old_key_void, &old_val_void ); old_key = (wchar_t *)old_key_void; old_val = (wchar_t *)old_val_void; - + if( old_key != 0 ) { var_entry_t * v = (var_entry_t *)old_val; @@ -1001,7 +1001,7 @@ static int try_remove( env_node_t *n, { has_changed = 1; } - + free(old_key); free(old_val); return 1; @@ -1011,7 +1011,7 @@ static int try_remove( env_node_t *n, { return 0; } - + if( n->new_scope ) { return try_remove( global_env, key, var_mode ); @@ -1027,48 +1027,48 @@ int env_remove( const wchar_t *key, int var_mode ) { env_node_t *first_node; int erased = 0; - + CHECK( key, 1 ); - - if( (var_mode & ENV_USER ) && + + if( (var_mode & ENV_USER ) && hash_get( &env_read_only, key ) ) { return 2; } - + first_node = top; - + if( ! (var_mode & ENV_UNIVERSAL ) ) { - + if( var_mode & ENV_GLOBAL ) { first_node = global_env; } - + if( try_remove( first_node, key, var_mode ) ) - { + { event_t ev; - + ev.type=EVENT_VARIABLE; ev.param1.variable=key; ev.function_name=0; - + al_init( &ev.arguments ); al_push( &ev.arguments, L"VARIABLE" ); al_push( &ev.arguments, L"ERASE" ); al_push( &ev.arguments, key ); - - event_fire( &ev ); - + + event_fire( &ev ); + al_destroy( &ev.arguments ); erased = 1; } } - - if( !erased && + + if( !erased && !(var_mode & ENV_GLOBAL) && - !(var_mode & ENV_LOCAL) ) + !(var_mode & ENV_LOCAL) ) { erased = !env_universal_remove( key ); } @@ -1077,8 +1077,8 @@ int env_remove( const wchar_t *key, int var_mode ) { handle_locale(); } - - return !erased; + + return !erased; } @@ -1087,23 +1087,23 @@ wchar_t *env_get( const wchar_t *key ) var_entry_t *res; env_node_t *env = top; wchar_t *item; - + CHECK( key, 0 ); if( wcscmp( key, L"history" ) == 0 ) { wchar_t *current; - int i; + int i; int add_current=0; - sb_clear( &dyn_var ); - + sb_clear( &dyn_var ); + current = reader_get_buffer(); if( current && wcslen( current ) ) { add_current=1; sb_append( &dyn_var, current ); } - + for( i=add_current;; i++ ) { wchar_t *next = history_get( i-add_current ); @@ -1111,7 +1111,7 @@ wchar_t *env_get( const wchar_t *key ) { break; } - + if( i!=0) { sb_append( &dyn_var, ARRAY_SEP_STR ); @@ -1124,45 +1124,45 @@ wchar_t *env_get( const wchar_t *key ) } else if( wcscmp( key, L"COLUMNS" )==0 ) { - sb_clear( &dyn_var ); - sb_printf( &dyn_var, L"%d", common_get_width() ); - return (wchar_t *)dyn_var.buff; - } + sb_clear( &dyn_var ); + sb_printf( &dyn_var, L"%d", common_get_width() ); + return (wchar_t *)dyn_var.buff; + } else if( wcscmp( key, L"LINES" )==0 ) { - sb_clear( &dyn_var ); - sb_printf( &dyn_var, L"%d", common_get_height() ); + sb_clear( &dyn_var ); + sb_printf( &dyn_var, L"%d", common_get_height() ); return (wchar_t *)dyn_var.buff; } else if( wcscmp( key, L"status" )==0 ) { - sb_clear( &dyn_var ); - sb_printf( &dyn_var, L"%d", proc_get_last_status() ); - return (wchar_t *)dyn_var.buff; + sb_clear( &dyn_var ); + sb_printf( &dyn_var, L"%d", proc_get_last_status() ); + return (wchar_t *)dyn_var.buff; } else if( wcscmp( key, L"umask" )==0 ) { - sb_clear( &dyn_var ); - sb_printf( &dyn_var, L"0%0.3o", get_umask() ); - return (wchar_t *)dyn_var.buff; + sb_clear( &dyn_var ); + sb_printf( &dyn_var, L"0%0.3o", get_umask() ); + return (wchar_t *)dyn_var.buff; } - + while( env != 0 ) { - res = (var_entry_t *) hash_get( &env->env, + res = (var_entry_t *) hash_get( &env->env, key ); if( res != 0 ) { - if( wcscmp( res->val, ENV_NULL )==0) + if( wcscmp( res->val, ENV_NULL )==0) { return 0; } else { - return res->val; + return res->val; } } - + if( env->new_scope ) { env = global_env; @@ -1171,15 +1171,15 @@ wchar_t *env_get( const wchar_t *key ) { env = env->next; } - } + } if( !proc_had_barrier) { proc_had_barrier=1; env_universal_barrier(); } - + item = env_universal_get( key ); - + if( !item || (wcscmp( item, ENV_NULL )==0)) { return 0; @@ -1197,7 +1197,7 @@ int env_exist( const wchar_t *key, int mode ) wchar_t *item=0; CHECK( key, 0 ); - + /* Read only variables all exist, and they are all global. A local version can not exist. @@ -1213,21 +1213,21 @@ int env_exist( const wchar_t *key, int mode ) if( ! (mode & ENV_UNIVERSAL) ) { env = (mode & ENV_GLOBAL)?global_env:top; - + while( env != 0 ) { - res = (var_entry_t *) hash_get( &env->env, + res = (var_entry_t *) hash_get( &env->env, key ); if( res != 0 ) { return 1; } - + if( mode & ENV_LOCAL ) { break; } - + if( env->new_scope ) { env = global_env; @@ -1236,9 +1236,9 @@ int env_exist( const wchar_t *key, int mode ) { env = env->next; } - } + } } - + if( ! (mode & ENV_LOCAL) && ! (mode & ENV_GLOBAL) ) { if( !proc_had_barrier) @@ -1246,9 +1246,9 @@ int env_exist( const wchar_t *key, int mode ) proc_had_barrier=1; env_universal_barrier(); } - + item = env_universal_get( key ); - + } return item != 0; @@ -1259,16 +1259,16 @@ int env_exist( const wchar_t *key, int mode ) */ static int local_scope_exports( env_node_t *n ) { - + if( n==global_env ) return 0; - + if( n->export ) return 1; - + if( n->new_scope ) return 0; - + return local_scope_exports( n->next ); } @@ -1283,7 +1283,7 @@ void env_push( int new_scope ) { has_changed |= local_scope_exports(top); } - top = node; + top = node; } @@ -1294,7 +1294,7 @@ void env_pop() { int i; int locale_changed = 0; - + env_node_t *killme = top; for( i=0; locale_variable[i]; i++ ) @@ -1310,7 +1310,7 @@ void env_pop() { has_changed |= killme->export || local_scope_exports( killme->next ); } - + top = top->next; hash_foreach( &killme->env, &clear_hash_entry ); hash_destroy( &killme->env ); @@ -1318,14 +1318,14 @@ void env_pop() if( locale_changed ) handle_locale(); - + } else { debug( 0, _( L"Tried to pop empty environment stack." ) ); sanity_lose(); - } + } } @@ -1333,12 +1333,12 @@ void env_pop() Function used with hash_foreach to insert keys of one table into another */ -static void add_key_to_hash( void *key, +static void add_key_to_hash( void *key, void *data, void *aux ) { var_entry_t *e = (var_entry_t *)data; - if( ( e->export && get_names_show_exported) || + if( ( e->export && get_names_show_exported) || ( !e->export && get_names_show_unexported) ) { hash_put( (hash_table_t *)aux, key, 0 ); @@ -1358,8 +1358,8 @@ static void add_to_hash( void *k, void *aux ) /** Add key to list */ -static void add_key_to_list( void * key, - void * val, +static void add_key_to_list( void * key, + void * val, void *aux ) { al_push( (array_list_t *)aux, key ); @@ -1376,10 +1376,10 @@ void env_get_names( array_list_t *l, int flags ) env_node_t *n=top; CHECK( l, ); - - get_names_show_exported = + + get_names_show_exported = flags & ENV_EXPORT|| (!(flags & ENV_UNEXPORT)); - get_names_show_unexported = + get_names_show_unexported = flags & ENV_UNEXPORT|| (!(flags & ENV_EXPORT)); if( !show_local && !show_global && !show_universal ) @@ -1388,58 +1388,58 @@ void env_get_names( array_list_t *l, int flags ) } hash_init( &names, &hash_wcs_func, &hash_wcs_cmp ); - + if( show_local ) { while( n ) { if( n == global_env ) break; - - hash_foreach2( &n->env, + + hash_foreach2( &n->env, add_key_to_hash, &names ); if( n->new_scope ) - break; + break; else n = n->next; } } - + if( show_global ) { - hash_foreach2( &global_env->env, + hash_foreach2( &global_env->env, add_key_to_hash, &names ); if( get_names_show_unexported ) hash_foreach2( &env_electric, &add_key_to_list, l ); - + if( get_names_show_exported ) { al_push( l, L"COLUMNS" ); al_push( l, L"LINES" ); } - + } - + if( show_universal ) { array_list_t uni_list; al_init( &uni_list ); - - env_universal_get_names( &uni_list, + + env_universal_get_names( &uni_list, get_names_show_exported, get_names_show_unexported ); al_foreach2( &uni_list, &add_to_hash, &names ); al_destroy( &uni_list ); } - + hash_get_keys( &names, l ); - hash_destroy( &names ); + hash_destroy( &names ); } /** @@ -1453,10 +1453,10 @@ static void export_func1( void *k, void *v, void *aux ) hash_remove( h, k, 0, 0 ); if( val_entry->export && wcscmp( val_entry->val, ENV_NULL ) ) - { + { hash_put( h, k, val_entry->val ); } - + } /** @@ -1466,14 +1466,14 @@ static void get_exported( env_node_t *n, hash_table_t *h ) { if( !n ) return; - + if( n->new_scope ) get_exported( global_env, h ); else get_exported( n->next, h ); - hash_foreach2( &n->env, &export_func1, h ); -} + hash_foreach2( &n->env, &export_func1, h ); +} /** @@ -1483,10 +1483,10 @@ static void export_func2( void *k, void *v, void *aux ) { wchar_t *key = (wchar_t *)k; wchar_t *val = (wchar_t *)v; - + char *ks = wcs2str( key ); char *vs = wcs2str( val ); - + char *pos = vs; buffer_t *out = (buffer_t *)aux; @@ -1495,18 +1495,18 @@ static void export_func2( void *k, void *v, void *aux ) { DIE_MEM(); } - + /* Make arrays into colon-separated lists */ while( *pos ) { if( *pos == ARRAY_SEP ) - *pos = ':'; + *pos = ':'; pos++; } int nil = 0; - + b_append( out, ks, strlen(ks) ); b_append( out, "=", 1 ); b_append( out, vs, strlen(vs) ); @@ -1523,21 +1523,21 @@ char **env_export_arr( int recalc ) proc_had_barrier=1; env_universal_barrier(); } - + if( has_changed ) { array_list_t uni; hash_table_t vals; int prev_was_null=1; - int pos=0; + int pos=0; int i; debug( 4, L"env_export_arr() recalc" ); - + hash_init( &vals, &hash_wcs_func, &hash_wcs_cmp ); - + get_exported( top, &vals ); - + al_init( &uni ); env_universal_get_names( &uni, 1, 0 ); for( i=0; i<al_get_count( &uni ); i++ ) @@ -1550,13 +1550,13 @@ char **env_export_arr( int recalc ) al_destroy( &uni ); export_buffer.used=0; - + hash_foreach2( &vals, &export_func2, &export_buffer ); hash_destroy( &vals ); - + export_arr = realloc( export_arr, sizeof(char *)*(hash_get_count( &vals) + 1) ); - + for( i=0; i<export_buffer.used; i++ ) { if( prev_was_null ) @@ -1570,5 +1570,5 @@ char **env_export_arr( int recalc ) has_changed=0; } - return export_arr; + return export_arr; } |