From 3a60fc52061961ad98614c19e3e12a0e251e3777 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 21 Sep 2005 08:46:40 +1000 Subject: [PATCH] Fix broken sort on printing of variable names in set builtin darcs-hash:20050920224640-ac50b-cfa316f9a6168e582d3a6057bdda414ce5b56851.gz --- builtin_set.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/builtin_set.c b/builtin_set.c index e47ea35d3..a7c7092db 100644 --- a/builtin_set.c +++ b/builtin_set.c @@ -226,22 +226,19 @@ static void print_variables(int include_values, int escape, int scope) array_list_t names; wchar_t **names_arr; int i; - + al_init( &names ); env_get_names( &names, scope ); - names_arr = list_to_char_arr( &names ); - qsort( names_arr, - al_get_count( &names ), - sizeof(wchar_t *), - (int (*)(const void *, const void *))&wcsfilecmp ); - + + sort_list( &names ); + for( i = 0; i < al_get_count(&names); i++ ) { - wchar_t *key = names_arr[i]; + wchar_t *key = al_get( &names, i ); /* Why does expand_escape free its argument ?! */ wchar_t *e_key = escape ? expand_escape(wcsdup(key), 1) : wcsdup(key); sb_append(sb_out, e_key); - + if( include_values ) { wchar_t *value = env_get(key); @@ -249,13 +246,11 @@ static void print_variables(int include_values, int escape, int scope) sb_append2(sb_out, L" ", e_value, 0); free(e_value); } - + sb_append(sb_out, L"\n"); free(e_key); } - - free(names_arr); - al_destroy(&names); + al_destroy(&names); } /**