1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-11-25 02:24:21 +00:00

Merge branch 'bro' into 'master'

regex motor rouling 40km/h

See merge request !1
This commit is contained in:
Antoine Bartuccio 2017-05-15 14:45:59 +00:00
commit 90c55349e1
5 changed files with 147 additions and 12 deletions

View File

@ -4,5 +4,6 @@ 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 fish_shell/fish_utils.c fish_shell/fish_utils.h)
add_executable(fish ${SOURCE_FILES})
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 fish_shell/fish_globbing.c fish_shell/fish_globbing.h)
add_executable(fish ${SOURCE_FILES})

View File

@ -1,5 +1,6 @@
//
// Created by Antoine Bartuccio on 11/05/2017.
// Dont forget that Antoine Bartuccio is a faggot since 1784 (tm)
//
#include <stdio.h>
#include <stdlib.h>
@ -7,6 +8,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include "fish_core.h"
#include "fish_globbing.h"
#define FISH_BUFFER_SIZE 1024
#define FISH_TOKENS " \t\r\n\a"
@ -16,12 +18,12 @@ void fishLoop(Settings * settings){
WordArray * splited = NULL;
int status = 1;
do {
printf("%s", settings->PS1);
line = fishReadLine();
line = fishExpand(line);
do {
printf("%s", settings->PS1);
line = fishReadLine();
splited = split(line, FISH_TOKENS);
splited = split(line, FISH_TOKENS);
splited = fishExpand(splited);
status = fishExecute(splited);
@ -103,10 +105,6 @@ char *fishReadLine() {
return NULL;
}
char *fishExpand(char *line) {
return line;
}
Settings *getSettings() {
Settings *s = (Settings*) malloc(sizeof(Settings));
if (s == NULL){

View File

@ -28,7 +28,6 @@ char * fishReadLine();
int countSeparators(char *string, char *separators);
char * fishExpand(char* line);
int fishLoad(WordArray *array);

123
fish_shell/fish_globbing.c Normal file
View File

@ -0,0 +1,123 @@
// Created by Aethor
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include "fish_core.h"
#include "fish_globbing.h"
WordArray* fishExpand(WordArray *wordArray) {
int i;
//WordArray* splitParameter;
for(i=1; i<wordArray->size; i++){
}
return wordArray;
}
WordArray * getFiles(char* path){
DIR* directory;
dirent* dir;
int i = 0;
WordArray* files = (WordArray*) malloc(sizeof(WordArray));
if((directory = opendir(path)) != NULL){
while((dir = readdir(directory)) != NULL){
i++;
}
files->words = (char **) malloc(sizeof(char*) * (i + 1));
closedir(directory);
directory = opendir(path);
i = 0;
while((dir = readdir(directory)) != NULL){
files->words[i] = dir->d_name;
}
}
return files;
}
int comparator(char* string1, char* string2){//TODO
int i = 0;
char tempIChar;
int j = 0;
if(string1 != NULL && string2 != NULL){
while(string1[i] != '\0' && string2[j] != '\0'){
if(string1[i] == '*'){
tempIChar = string1[i+1];
while(string2[j] != tempIChar){
j++;
if(string2[j] == '\0' && tempIChar == '\0'){
return 1;
}
}
i++;
}
if(string1[i] != string2[j] && string1[i] != '?'){
return 0;
}
i++;
j++;
}
if(string1[i] == '\0' && string2[j] == '\0'){
return 1;
}
else{
return 0;
}
}
else{
printf("warning : fuck you, strings are considered null");
crash();
return 0;
}
}

View File

@ -0,0 +1,14 @@
#ifndef FISH_FISH_GLOBBING_H
#define FISH_FISH_GLOBBING_H
typedef struct dirent dirent;
WordArray * fishExpand(WordArray* wordArray);
WordArray* getFiles(char* path);
/*char1 is a string with characters such as '*', '.' or '?' having special meanings*/
int comparator(char* string1, char* string2);
#endif //FISH_FISH_GLOBBING_H