1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2025-07-11 04:09:22 +00:00

Début de l'intégration des tests

This commit is contained in:
2017-05-16 00:08:07 +02:00
parent 9b6e5c7bc5
commit 209c36e7fd
11 changed files with 171 additions and 31 deletions

View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.7)
project(fish_shell)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "-Wall -Werror -pedantic -fpic -Wextra -Wshadow")
set(SOURCE_FILES main.c fish_core.c fish_core.h fish_commands.c fish_commands.h fish_types.h fish_utils.c fish_utils.h fish_globbing.c fish_globbing.h)
add_executable(fish ${SOURCE_FILES})

View File

@ -7,9 +7,9 @@
/* Necessary global variables */
char * builtinCommandsStr[] = {
"cd",
"help",
"exit"
(char *) "cd",
(char *) "help",
(char *) "exit"
};

View File

@ -23,7 +23,7 @@ void fishLoop(Settings * settings){
printf("%s", settings->PS1);
line = fishReadLine();
splited = split(line, FISH_TOKENS);
splited = split(line, (char*) FISH_TOKENS);
splited = fishExpand(splited);
array = wordListToWordArray(splited);
@ -72,7 +72,7 @@ WordList * split(char *string, char *separator){
char *fishReadLine() {
size_t bufferSize = FISH_BUFFER_SIZE;
int position = 0;
char *line = malloc(sizeof(char*) * bufferSize);
char *line = (char*) malloc(sizeof(char*) * bufferSize);
int c;
if (line == NULL){
@ -96,7 +96,7 @@ char *fishReadLine() {
if ((size_t) position > bufferSize){
bufferSize+=bufferSize;
line = realloc(line, bufferSize);
line = (char*) realloc(line, bufferSize);
if (line == NULL){
crash();
}

View File

@ -10,10 +10,10 @@
void crash(){
char *crashErrors[] = {
"fish: Fucking malloc always returning NULL pointer !",
"fish: Error allocating fucking pointer !",
"fish: C language exploding again",
"fish: It's not you're fault for this time"
(char *) "fish: Fucking malloc always returning NULL pointer !",
(char *) "fish: Error allocating fucking pointer !",
(char *) "fish: C language exploding again",
(char *) "fish: It's not you're fault for this time"
};
int picked = 0;
@ -28,9 +28,9 @@ char *getInsult(){
static int init = 0;
int picked = 0;
char *insults[] = {
"Apprend à écrire crétin !",
"Bolos !",
"Mois aussi je sais écrire de la merde, pourtant je le fait pas !"
(char *) "Apprend à écrire crétin !",
(char *) "Bolos !",
(char *) "Mois aussi je sais écrire de la merde, pourtant je le fait pas !"
};
if (!init){
srand((unsigned int) time(NULL));
@ -67,19 +67,19 @@ WordList *createWordList() {
}
void addWordList(WordList *list, char *word) {
WordListElement *new = (WordListElement*) malloc(sizeof(WordListElement));
if (new == NULL) crash();
WordListElement *newElement = (WordListElement*) malloc(sizeof(WordListElement));
if (newElement == NULL) crash();
else {
new->next = NULL;
new->previous = list->last;
newElement->next = NULL;
newElement->previous = list->last;
if (list->size == 0){
list->first = new;
list->last = new;
list->first = newElement;
list->last = newElement;
} else {
list->last->next = new;
list->last = new;
list->last->next = newElement;
list->last = newElement;
}
new->word = strdup(word);
newElement->word = strdup(word);
list->size++;
}
}

12
fish_shell/main.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdlib.h>
#include "fish_core.h"
#include "fish_types.h"
int main() {
/* todo load config file */
Settings *s = getSettings();
fishLoop(s);
freeSettings(s);
return EXIT_SUCCESS;
}