1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-11-22 00:33:20 +00:00

NOT ON MY WATCH

This commit is contained in:
Aethor 2017-05-28 17:25:04 +02:00
parent 99545a8d41
commit 2b5ad06977
3 changed files with 43 additions and 24 deletions

View File

@ -8,7 +8,7 @@
WordList * fishExpand(WordList *wordList) { WordList * fishExpand(WordList *wordList) {
/*if(wordList->size > 1){ if(wordList->size > 1){
int i; int i;
WordList* newWordList = createWordList();// creating the list to return WordList* newWordList = createWordList();// creating the list to return
@ -45,17 +45,18 @@ WordList * fishExpand(WordList *wordList) {
} }
else return wordList;*/ else return wordList;
return wordList;
} }
WordList* expandWord(char* word){ WordList* expandWord(char* word){
WordList* wordList = createWordList(); printf("\n%s\n", word);
addEndWordList(wordList, word);
return wordList; WordList* testList = getFiles((char*) "../");
printWordList(testList);
return testList;
} }
@ -66,8 +67,6 @@ WordList* getFiles(char* path){
DIR* directory; DIR* directory;
dirent* dir; dirent* dir;
int i = 0;
WordList* files = createWordList(); WordList* files = createWordList();
@ -76,27 +75,17 @@ WordList* getFiles(char* path){
while((dir = readdir(directory)) != NULL){ while((dir = readdir(directory)) != NULL){
i++; if(strcmp(dir->d_name, ".") && strcmp(dir->d_name, "..")){//sorry strcmp but I dont like you :(
}
closedir(directory);
directory = opendir(path);
i = 0;
while((dir = readdir(directory)) != NULL){
if(!strcmp(dir->d_name, ".") && !strcmp(dir->d_name, "..")){
printf("%s\n", dir->d_name);//test printf("%s\n", dir->d_name);//test
addEndWordList(files, dir->d_name); addEndWordList(files, dir->d_name);
i++;
files->size++;
} }
} }
closedir(directory); //YY U LEAK MEMORY ? NOT ON MY WATCH
} }

View File

@ -288,6 +288,34 @@ WordList *splitWordList(WordList *list, char *regex) {
return new_list; 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; i<list->size; 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 stringContains(char * string, char charToTest){
int i = 0; int i = 0;
@ -303,3 +331,4 @@ int stringContains(char * string, char charToTest){
return 0; return 0;
} }

View File

@ -37,8 +37,9 @@ char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tes
void concatWordList(WordList* list1, WordList* list2); void concatWordList(WordList* list1, WordList* list2);
int stringContains(char* string, char charToTest); void printWordList(WordList* list);
int stringContains(char* string, char charToTest); int stringContains(char* string, char charToTest);
#endif //FISH_FISH_UTILS_H #endif //FISH_FISH_UTILS_H