mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-22 00:33:20 +00:00
Refactor avec des listes
This commit is contained in:
parent
90c55349e1
commit
9b6e5c7bc5
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
void fishLoop(Settings * settings){
|
void fishLoop(Settings * settings){
|
||||||
char * line = NULL;
|
char * line = NULL;
|
||||||
WordArray * splited = NULL;
|
WordList* splited = NULL;
|
||||||
|
WordArray* array = NULL;
|
||||||
int status = 1;
|
int status = 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -25,9 +26,10 @@ void fishLoop(Settings * settings){
|
|||||||
splited = split(line, FISH_TOKENS);
|
splited = split(line, FISH_TOKENS);
|
||||||
splited = fishExpand(splited);
|
splited = fishExpand(splited);
|
||||||
|
|
||||||
status = fishExecute(splited);
|
array = wordListToWordArray(splited);
|
||||||
|
status = fishExecute(array);
|
||||||
|
|
||||||
freeWordArray(splited);
|
freeWordArray(array);
|
||||||
free(line);
|
free(line);
|
||||||
} while(status);
|
} while(status);
|
||||||
}
|
}
|
||||||
@ -49,7 +51,7 @@ int countSeparators(char *string, char *separators) {
|
|||||||
return nb;
|
return nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordArray * split(char *string, char *separator){
|
WordList * split(char *string, char *separator){
|
||||||
WordList *list = createWordList();
|
WordList *list = createWordList();
|
||||||
char *to_delete = strdup(string);
|
char *to_delete = strdup(string);
|
||||||
char *to_delete_bak = to_delete;
|
char *to_delete_bak = to_delete;
|
||||||
@ -64,7 +66,7 @@ WordArray * split(char *string, char *separator){
|
|||||||
|
|
||||||
free(to_delete_bak);
|
free(to_delete_bak);
|
||||||
|
|
||||||
return wordListToWordArray(list);
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fishReadLine() {
|
char *fishReadLine() {
|
||||||
@ -109,8 +111,9 @@ Settings *getSettings() {
|
|||||||
Settings *s = (Settings*) malloc(sizeof(Settings));
|
Settings *s = (Settings*) malloc(sizeof(Settings));
|
||||||
if (s == NULL){
|
if (s == NULL){
|
||||||
crash();
|
crash();
|
||||||
|
} else {
|
||||||
|
s->PS1 = strdup("\n~>");
|
||||||
}
|
}
|
||||||
s->PS1 = strdup("\n~>");
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/* WordArray functions */
|
/* WordArray functions */
|
||||||
|
|
||||||
WordArray * split(char *string, char *separator);
|
WordList * split(char *string, char *separator);
|
||||||
|
|
||||||
/* Settings functions */
|
/* Settings functions */
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "fish_core.h"
|
#include "fish_core.h"
|
||||||
#include "fish_globbing.h"
|
#include "fish_globbing.h"
|
||||||
|
|
||||||
WordArray* fishExpand(WordArray *wordArray) {
|
WordList * fishExpand(WordList *wordArray) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
//WordArray* splitParameter;
|
//WordArray* splitParameter;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
typedef struct dirent dirent;
|
typedef struct dirent dirent;
|
||||||
|
|
||||||
|
|
||||||
WordArray * fishExpand(WordArray* wordArray);
|
WordList * fishExpand(WordList *wordArray);
|
||||||
|
|
||||||
WordArray* getFiles(char* path);
|
WordArray* getFiles(char* path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user