Commit 2598cdd8 authored by Max Kellermann's avatar Max Kellermann

buffer2array: use GLib's g_ascii_isspace()

g_ascii_isspace() includes \r and \n. This means that lines from a text file don't have to be chopped prior to buffer2array().
parent 4b3a055f
......@@ -17,14 +17,10 @@
*/
#include "buffer2array.h"
#include "os_compat.h"
static inline
int
isWhiteSpace(char c)
{
return (c == ' ' || c == '\t');
}
#include <glib.h>
#include <string.h>
int buffer2array(char *buffer, char *array[], const int max)
{
......@@ -44,19 +40,20 @@ int buffer2array(char *buffer, char *array[], const int max)
}
}
} else {
while (isWhiteSpace(*c))
++c;
array[i++] = c++;
c = g_strchug(c);
if (*c == '\0')
return i;
while (!isWhiteSpace(*c) && *c != '\0')
array[i++] = c++;
while (!g_ascii_isspace(*c) && *c != '\0')
++c;
}
if (*c == '\0')
return i;
*(c++) = '\0';
while (isWhiteSpace(*c))
++c;
c = g_strchug(c);
}
return i;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment