8-9/10... inconsistent book tests persist

This commit is contained in:
t
2025-02-07 01:10:55 +01:00
parent ad7cae413f
commit f856a4fa82
258 changed files with 1127257 additions and 33883 deletions
+45
View File
@@ -17,4 +17,49 @@ typedef enum
UNSUPPORTED,
} TYPE;
char *sanitize_input(char *input){
if(!input) return NULL;
int i = 0;
char *ret = malloc(sizeof(char));
if(!ret){
// perror("[MAIN - sanitize_input] Failed to allocate memory for ret");
return NULL;
}
*ret = '\0';
char *it = input;
while(*it && !isalpha(*it)) it++;
bool writeSpace = false;
while(*it){
if(isalpha(*it)){
char *tmp = NULL;
if(writeSpace){
tmp = realloc(ret, i + 3);
}
else{
tmp = realloc(ret, i + 2);
}
if(!tmp){
// perror("[MAIN - sanitize_input] Failed to realloc memory for ret");
free(ret);
return NULL;
}
ret = tmp;
if(writeSpace) ret[i++] = ' ';
ret[i++] = tolower(*it++);
writeSpace = false;
}
else{
it++;
writeSpace = true;
}
}
ret[i] = '\0';
return ret;
}
#endif //TRANSFER_DEFINES_H