1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-11-13 04:13:19 +00:00

Black mage of regex stikes again

This commit is contained in:
Aethor 2017-05-15 19:10:46 +02:00 committed by Aethor
parent 99b847d43a
commit c05b1fe398
4 changed files with 56 additions and 9 deletions

View File

@ -7,14 +7,7 @@
WordList * fishExpand(WordList *wordArray) {
int i;
//WordArray* splitParameter;
for(i=1; i<wordArray->size; i++){
}
wordArray = expandInDir("./", "*");
return wordArray;
@ -47,8 +40,15 @@ WordArray * getFiles(char* path){
while((dir = readdir(directory)) != NULL){
files->words[i] = dir->d_name;
/*if(dir->d_name != "." && dir->d_name != ".."){*/
printf("%s\n", dir->d_name);
files->words[i] = dir->d_name;
i++;
files->size++;
//}
}
@ -120,4 +120,25 @@ int comparator(char* string1, char* string2){//TODO
}
WordList* expandInDir(char* dir, char* toExpand){
int i = 0;
WordList* list = createWordList();
WordArray* files = getFiles(dir);
for(i=0; i<files->size;i++){
if(comparator(toExpand, files->words[i])){
addWordList(list, files->words[i]);
}
}
return list;
}

View File

@ -11,4 +11,6 @@ WordArray* getFiles(char* path);
/*char1 is a string with characters such as '*', '.' or '?' having special meanings*/
int comparator(char* string1, char* string2);
WordList* expandInDir(char*, char*);
#endif //FISH_FISH_GLOBBING_H

View File

@ -30,6 +30,7 @@ char *getInsult(){
static int init = 0;
int picked = 0;
char *insults[] = {
<<<<<<< HEAD
(char *) "Apprend à écrire crétin !",
(char *) "Boloss !",
(char *) "Mois aussi je sais écrire de la merde, pourtant je le fait pas !",
@ -37,6 +38,11 @@ char *getInsult(){
(char *) "Nul !",
(char *) "Pense à aller à l'école un jour",
(char *) "Et après on dit que c'est la faute de l'ordinateur..."
=======
"Apprend à écrire crétin !",
"Bolos !",
"Moi aussi je sais écrire de la merde, pourtant je le fait pas !"
>>>>>>> Black mage of regex stikes again
};
if (!init){
srand((unsigned int) time(NULL));
@ -117,6 +123,22 @@ void freeWordList(WordList *list) {
free(list);
}
WordList* concatWordList(WordList* list1, WordList* list2){
if(list1->last != NULL){
list1->last->next = list2->first;
list2->first->previous = list1->last;
list1->last = list2->last;
list1->size = list1->size + list2->size;
free(list2);
return list1;
}
else{
return NULL;
}
}
WordArray *wordListToWordArray(WordList *list) {
WordArray *array = (WordArray*) malloc(sizeof(WordArray));
WordListElement *current = list->first;

View File

@ -35,4 +35,6 @@ WordList * splitWordList(WordList *list, char *regex);
char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tested
WordList* concatWordList(WordList* list1, WordList* list2);
#endif //FISH_FISH_UTILS_H