mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-21 16:23:20 +00:00
NOT ON MY WATCH
This commit is contained in:
parent
99545a8d41
commit
2b5ad06977
@ -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
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -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; 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 i = 0;
|
||||
@ -303,3 +331,4 @@ int stringContains(char * string, char charToTest){
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user