From 96148386827f7aa831865dc877a06034679422cc Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 25 Jun 2020 08:31:00 -0500 Subject: anything isspace() things is space is allowed as whitespace instead of just 0x20 --- src/hackvr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hackvr.c b/src/hackvr.c index b789dbe..6dea5b9 100644 --- a/src/hackvr.c +++ b/src/hackvr.c @@ -1,4 +1,5 @@ #define _POSIX_C_SOURCE 200809L //for fileno and strdup +#include //isspace #include #include #include @@ -92,21 +93,21 @@ char **line_splitter(char *line,int *rlen) { char **a; int len,i=0; len=1;//we're just counting how much we'll need the first loop through. - for(i=0;line[i] && line[i] == ' ';i++);//skip leading space + for(i=0;line[i] && isspace(line[i]);i++);//skip leading space for(;line[i];len++) { - for(;line[i] && line[i] != ' ';i++);//skip rest of data - for(;line[i] && line[i] == ' ';i++);//skip rest of space + for(;line[i] && !isspace(line[i]);i++);//skip rest of data + for(;line[i] && isspace(line[i]);i++);//skip rest of space } a=malloc(sizeof(char *) * len+1); a[len]=0; len=0;//reuse! - for(i=0;line[i] && line[i] == ' ';i++);//skip leading space + for(i=0;line[i] && isspace(line[i]);i++);//skip leading space a[len]=line+i; for(;;) { - for(;line[i] && line[i] != ' ';i++);//skip rest of data + for(;line[i] && !isspace(line[i]);i++);//skip rest of data if(!line[i]) break; line[i++]=0; - for(;line[i] && line[i] == ' ';i++);//skip rest of space + for(;line[i] && isspace(line[i]);i++);//skip rest of space if(!line[i]) break; a[++len]=line+i; } -- cgit v1.2.3