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

Très pratique fonction de crash

This commit is contained in:
Antoine Bartuccio 2017-05-15 14:08:10 +02:00
parent a826969c3e
commit 4228071f6d
5 changed files with 27 additions and 9 deletions

View File

@ -4,5 +4,5 @@ project(fish)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "-Wall -Werror -pedantic -fpic -Wextra")
set(SOURCE_FILES main.c fish_shell/fish_core.c fish_shell/fish_core.h fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_types.h)
set(SOURCE_FILES main.c fish_shell/fish_core.c fish_shell/fish_core.h fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_types.h fish_shell/fish_utils.c fish_shell/fish_utils.h)
add_executable(fish ${SOURCE_FILES})

View File

@ -62,8 +62,7 @@ WordArray * split(char *string, char *separator){
}
if (tokens == NULL || to_delete == NULL || tokens->words == NULL){
fprintf(stderr, "fish: Error allocating fucking pointer !");
exit(EXIT_FAILURE);
crash();
}
while((token = strsep(&to_delete, separator)) != NULL){
@ -95,8 +94,7 @@ char *fishReadLine() {
int c;
if (line == NULL){
fprintf(stderr, "fish: Error allocating fucking buffer shit !");
exit(EXIT_FAILURE);
crash();
}
while (1){
@ -118,8 +116,7 @@ char *fishReadLine() {
bufferSize+=bufferSize;
line = realloc(line, bufferSize);
if (line == NULL){
fprintf(stderr, "fish: Error allocating fucking buffer shit !");
exit(EXIT_FAILURE);
crash();
}
}
}
@ -135,8 +132,7 @@ char *fishExpand(char *line) {
Settings *getSettings() {
Settings *s = (Settings*) malloc(sizeof(Settings));
if (s == NULL){
fprintf(stderr, "fish: Error allocating fucking settings");
exit(EXIT_FAILURE);
crash();
}
s->PS1 = strdup("\n~>");

View File

@ -8,6 +8,7 @@
#include "fish_types.h"
#include "fish_commands.h"
#include "fish_utils.h"
/* WordArray functions */

11
fish_shell/fish_utils.c Normal file
View File

@ -0,0 +1,11 @@
//
// Created by Antoine Bartuccio on 15/05/2017.
//
#include <stdio.h>
#include <stdlib.h>
void crash(){
fprintf(stderr, "fish: Error allocating fucking pointer !");
exit(EXIT_FAILURE);
}

10
fish_shell/fish_utils.h Normal file
View File

@ -0,0 +1,10 @@
//
// Created by Antoine Bartuccio on 15/05/2017.
//
#ifndef FISH_FISH_UTILS_H
#define FISH_FISH_UTILS_H
void crash();
#endif //FISH_FISH_UTILS_H