From 2b5ad069770292afa2b91d6ccc85856eb9ded958 Mon Sep 17 00:00:00 2001 From: Aethor Date: Sun, 28 May 2017 17:25:04 +0200 Subject: [PATCH] NOT ON MY WATCH --- fish_shell/fish_globbing.c | 33 +++++++++++---------------------- fish_shell/fish_utils.c | 31 ++++++++++++++++++++++++++++++- fish_shell/fish_utils.h | 3 ++- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/fish_shell/fish_globbing.c b/fish_shell/fish_globbing.c index da697a6..0e46653 100644 --- a/fish_shell/fish_globbing.c +++ b/fish_shell/fish_globbing.c @@ -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,17 +45,18 @@ WordList * fishExpand(WordList *wordList) { } - else return wordList;*/ - return wordList; - + else return wordList; } WordList* expandWord(char* word){ - WordList* wordList = createWordList(); - addEndWordList(wordList, word); - return wordList; + printf("\n%s\n", word); + + WordList* testList = getFiles((char*) "../"); + + printWordList(testList); + return testList; } @@ -66,8 +67,6 @@ WordList* getFiles(char* path){ DIR* directory; dirent* dir; - int i = 0; - WordList* files = createWordList(); @@ -76,27 +75,17 @@ WordList* getFiles(char* path){ while((dir = readdir(directory)) != NULL){ - i++; - - } - - closedir(directory); - directory = opendir(path); - i = 0; - - while((dir = readdir(directory)) != NULL){ - - if(!strcmp(dir->d_name, ".") && !strcmp(dir->d_name, "..")){ + if(strcmp(dir->d_name, ".") && strcmp(dir->d_name, "..")){//sorry strcmp but I dont like you :( printf("%s\n", dir->d_name);//test addEndWordList(files, dir->d_name); - i++; - files->size++; } } + closedir(directory); //YY U LEAK MEMORY ? NOT ON MY WATCH + } diff --git a/fish_shell/fish_utils.c b/fish_shell/fish_utils.c index efff4b1..c164493 100644 --- a/fish_shell/fish_utils.c +++ b/fish_shell/fish_utils.c @@ -288,6 +288,34 @@ WordList *splitWordList(WordList *list, char *regex) { return new_list; } +//for debugging purposes +void printWordList(WordList* list){ + + + if(list != NULL){ + + printf("--- list ---\n"); + printf("size : %i\n", list->size); + + int i = 0; + WordListElement* tempElement = list->first; + + for(i=0; isize; i++){ + + printf("element %i : %s\n",i, tempElement->word); + tempElement = tempElement->next; + + } + + printf("--- end ---\n"); + + } + else{ + printf("fish : Warning : list is null. Are you stupid ?"); + } + +} + int stringContains(char * string, char charToTest){ int i = 0; @@ -301,5 +329,6 @@ int stringContains(char * string, char charToTest){ } return 0; - + } + diff --git a/fish_shell/fish_utils.h b/fish_shell/fish_utils.h index 38dd497..91f458c 100644 --- a/fish_shell/fish_utils.h +++ b/fish_shell/fish_utils.h @@ -37,8 +37,9 @@ char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tes void concatWordList(WordList* list1, WordList* list2); -int stringContains(char* string, char charToTest); +void printWordList(WordList* list); int stringContains(char* string, char charToTest); + #endif //FISH_FISH_UTILS_H