diff --git a/CMakeLists.txt b/CMakeLists.txt index 704702c..4c52234 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,10 @@ include_directories( "${source_dir}/googlemock/include" ) + set(CMAKE_C_STANDARD 99) set(CMAKE_C_FLAGS "-Wall -Werror -pedantic -fpic -Wextra -Wshadow") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FALGS} -g") set(SOURCE_FILES fish_shell/main.c fish_shell/fish_types.h fish_shell/fish_core.h fish_shell/fish_core.c fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_globbing.c fish_shell/fish_globbing.h fish_shell/fish_utils.c fish_shell/fish_utils.h) add_executable(fish ${SOURCE_FILES}) diff --git a/fish_shell/fish_utils.c b/fish_shell/fish_utils.c index b76511a..078bd20 100644 --- a/fish_shell/fish_utils.c +++ b/fish_shell/fish_utils.c @@ -110,12 +110,11 @@ WordArray *wordListToWordArray(WordList *list) { if (array->words == NULL) crash(); while (current != NULL){ - array->words[i] = current->word; - current->word = NULL; + array->words[i] = strdup(current->word); current = current->next; i++; } - array->words[i] = NULL; + array->words[array->size] = NULL; } freeWordList(list); @@ -125,7 +124,7 @@ WordArray *wordListToWordArray(WordList *list) { WordList *wordArrayToWordList(WordArray *array) { WordList *list = createWordList(); - int i = 0; + int i; for (i=0; isize; i++) addWordList(list, array->words[i]);