mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-21 16:23:20 +00:00
Black mage of regex stikes again
This commit is contained in:
parent
99b847d43a
commit
c05b1fe398
@ -7,14 +7,7 @@
|
|||||||
|
|
||||||
WordList * fishExpand(WordList *wordArray) {
|
WordList * fishExpand(WordList *wordArray) {
|
||||||
|
|
||||||
int i;
|
wordArray = expandInDir("./", "*");
|
||||||
//WordArray* splitParameter;
|
|
||||||
|
|
||||||
for(i=1; i<wordArray->size; i++){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return wordArray;
|
return wordArray;
|
||||||
|
|
||||||
@ -47,8 +40,15 @@ WordArray * getFiles(char* path){
|
|||||||
|
|
||||||
while((dir = readdir(directory)) != NULL){
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,4 +11,6 @@ WordArray* getFiles(char* path);
|
|||||||
/*char1 is a string with characters such as '*', '.' or '?' having special meanings*/
|
/*char1 is a string with characters such as '*', '.' or '?' having special meanings*/
|
||||||
int comparator(char* string1, char* string2);
|
int comparator(char* string1, char* string2);
|
||||||
|
|
||||||
|
WordList* expandInDir(char*, char*);
|
||||||
|
|
||||||
#endif //FISH_FISH_GLOBBING_H
|
#endif //FISH_FISH_GLOBBING_H
|
||||||
|
@ -30,6 +30,7 @@ char *getInsult(){
|
|||||||
static int init = 0;
|
static int init = 0;
|
||||||
int picked = 0;
|
int picked = 0;
|
||||||
char *insults[] = {
|
char *insults[] = {
|
||||||
|
<<<<<<< HEAD
|
||||||
(char *) "Apprend à écrire crétin !",
|
(char *) "Apprend à écrire crétin !",
|
||||||
(char *) "Boloss !",
|
(char *) "Boloss !",
|
||||||
(char *) "Mois aussi je sais écrire de la merde, pourtant je le fait pas !",
|
(char *) "Mois aussi je sais écrire de la merde, pourtant je le fait pas !",
|
||||||
@ -37,6 +38,11 @@ char *getInsult(){
|
|||||||
(char *) "Nul !",
|
(char *) "Nul !",
|
||||||
(char *) "Pense à aller à l'école un jour",
|
(char *) "Pense à aller à l'école un jour",
|
||||||
(char *) "Et après on dit que c'est la faute de l'ordinateur..."
|
(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){
|
if (!init){
|
||||||
srand((unsigned int) time(NULL));
|
srand((unsigned int) time(NULL));
|
||||||
@ -117,6 +123,22 @@ void freeWordList(WordList *list) {
|
|||||||
free(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 *wordListToWordArray(WordList *list) {
|
||||||
WordArray *array = (WordArray*) malloc(sizeof(WordArray));
|
WordArray *array = (WordArray*) malloc(sizeof(WordArray));
|
||||||
WordListElement *current = list->first;
|
WordListElement *current = list->first;
|
||||||
|
@ -35,4 +35,6 @@ WordList * splitWordList(WordList *list, char *regex);
|
|||||||
|
|
||||||
char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tested
|
char * splitWord(char * origin, int beginning_index, int size_to_delete); // Tested
|
||||||
|
|
||||||
|
WordList* concatWordList(WordList* list1, WordList* list2);
|
||||||
|
|
||||||
#endif //FISH_FISH_UTILS_H
|
#endif //FISH_FISH_UTILS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user