From 3a87b110b6627947c78cbd41e02450f953fad045 Mon Sep 17 00:00:00 2001 From: Aethor Date: Mon, 15 May 2017 15:03:36 +0200 Subject: [PATCH] string regex comparator with "?" --- fish_shell/fish_globbing.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/fish_shell/fish_globbing.c b/fish_shell/fish_globbing.c index 56b5af8..489b841 100644 --- a/fish_shell/fish_globbing.c +++ b/fish_shell/fish_globbing.c @@ -59,7 +59,43 @@ WordArray * getFiles(char* path){ bool comparator(char* string1, char* string2){//TODO - return true; + int i = 0; + + if(string1 != NULL && string2 != NULL){ + + while(string1[i] != '\0' && string2[i] != '\0'){ + + if(string1[i] != string2[i] && string1[i] != '?'){ + + return false; + + } + + i++; + + } + + if(string1[i] == '\0' && string2[i] == '\0'){ + + return true; + + } + else{ + + return false; + + } + + + } + + else{ + + printf("warning : fuck you, strings are considered null"); + crash(); + return false; + + } }