diff --git a/fish_shell/fish_globbing.c b/fish_shell/fish_globbing.c index 2964ebd..da697a6 100644 --- a/fish_shell/fish_globbing.c +++ b/fish_shell/fish_globbing.c @@ -1,4 +1,4 @@ -// Created by Aethor +// Created by Arthur Amalvy #include #include #include @@ -8,7 +8,7 @@ WordList * fishExpand(WordList *wordList) { - if(wordList->size > 1){ + /*if(wordList->size > 1){ int i; WordList* newWordList = createWordList();// creating the list to return @@ -45,7 +45,8 @@ WordList * fishExpand(WordList *wordList) { } - else return wordList; + else return wordList;*/ + return wordList; } @@ -61,14 +62,14 @@ WordList* expandWord(char* word){ -WordArray * getFiles(char* path){ +WordList* getFiles(char* path){ DIR* directory; dirent* dir; int i = 0; - WordArray* files = (WordArray*) malloc(sizeof(WordArray)); + WordList* files = createWordList(); if((directory = opendir(path)) != NULL){ @@ -79,8 +80,6 @@ WordArray * getFiles(char* path){ } - files->words = (char **) malloc(sizeof(char*) * (i + 1)); - closedir(directory); directory = opendir(path); i = 0; @@ -89,13 +88,13 @@ WordArray * getFiles(char* path){ if(!strcmp(dir->d_name, ".") && !strcmp(dir->d_name, "..")){ - printf("%s\n", dir->d_name); - files->words[i] = dir->d_name; + printf("%s\n", dir->d_name);//test + addEndWordList(files, dir->d_name); i++; files->size++; } - + } diff --git a/fish_shell/fish_globbing.h b/fish_shell/fish_globbing.h index e473981..e226a19 100644 --- a/fish_shell/fish_globbing.h +++ b/fish_shell/fish_globbing.h @@ -6,7 +6,7 @@ typedef struct dirent dirent; WordList * fishExpand(WordList *wordArray); -WordArray* getFiles(char* path); +WordList* getFiles(char* path); WordList* expandWord(char* word); diff --git a/fish_shell/fish_utils.c b/fish_shell/fish_utils.c index ba8ae8b..efff4b1 100644 --- a/fish_shell/fish_utils.c +++ b/fish_shell/fish_utils.c @@ -117,7 +117,7 @@ void freeWordList(WordList *list) { free(list); } -void concatWordList(WordList* list1, WordList* list2){//return a sing list containing all elements of both lists +void concatWordList(WordList* list1, WordList* list2){//return a single list containing all elements of both lists if(list1 == NULL || list2 == NULL){ crash();