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

EL GENIUS ORI ORA

This commit is contained in:
Aethor 2017-05-29 15:19:52 +02:00
parent 82e9e10895
commit 2c73d461fb
4 changed files with 65 additions and 2 deletions

View File

@ -41,6 +41,11 @@ WordList * fishExpand(WordList *wordList) {
} }
freeWordList(wordList); freeWordList(wordList);
//TODO : move this in recursion in case multiples commands are in the same line
if(newWordList->size == 1){
addEndWordList(newWordList, (char*) ERROR_STRING);
}
return newWordList; return newWordList;
} }
@ -59,6 +64,10 @@ WordList* expandWord(char* word){
else{ else{
WordList* testList = splitWordIntoList(word, '/');
printWordList(testList);
freeWordList(testList);
return getFiles(word, (char*) "*");//temporary return getFiles(word, (char*) "*");//temporary
//return(); //return();
@ -161,7 +170,7 @@ int wildcardedStringMatches(char* string1, char* string2){//TODO
else{ else{
printf("warning : fuck you, strings are considered null"); printf("fish : Warning : fuck you, strings are considered null");
crash(); crash();
return 0; return 0;
@ -169,4 +178,55 @@ int wildcardedStringMatches(char* string1, char* string2){//TODO
} }
//beware : will purposedly ignore the first occurence of the character
WordList* splitWordIntoList(char* string, char splitChar){
if(stringContains(string, '/')){
int i = 0;
int mark = 0;
int finished = 0;
int firstEncounter = 0;
WordList* newWordList = createWordList();
while(!finished){
if(string[i] == splitChar || string[i] == '\0'){
if(!firstEncounter){
firstEncounter = 1;
}
else{
char* tempStr = strndup(string + mark, i - mark);
if(tempStr == NULL){
crash();
}
addEndWordList(newWordList, tempStr);
free(tempStr);
mark = i;
if(string[i] == '\0'){
finished = 1;
}
}
}
i++;
}
return newWordList;
}
else{
WordList* newWordList = createWordList();
addEndWordList(newWordList, string);
return newWordList;
}
}

View File

@ -12,4 +12,6 @@ WordList* expandWord(char* word);
int wildcardedStringMatches(char* string1, char* string2); int wildcardedStringMatches(char* string1, char* string2);
WordList* splitWordIntoList(char* string, char splitchar);
#endif //FISH_FISH_GLOBBING_H #endif //FISH_FISH_GLOBBING_H

View File

@ -6,6 +6,7 @@
#define FISH_FISH_TYPES_H #define FISH_FISH_TYPES_H
#define EXIT_SIGNAL -100 #define EXIT_SIGNAL -100
#define ERROR_STRING "\n"
/* Custom types */ /* Custom types */
@ -35,6 +36,7 @@ typedef struct {
WordListElement * last; WordListElement * last;
} WordList; } WordList;
typedef struct { typedef struct {
char *PS1; char *PS1;
} Settings; } Settings;

View File

@ -331,4 +331,3 @@ int stringContains(char * string, char charToTest){
return 0; return 0;
} }