diff --git a/configure.ac b/configure.ac index 05e5f64..f2773b1 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,9 @@ LT_INIT AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +dnl Check that compiler understands inline +AC_C_INLINE + # # Gettext # diff --git a/src/psl.c b/src/psl.c index 4bc6e53..6fe0633 100644 --- a/src/psl.c +++ b/src/psl.c @@ -497,6 +497,11 @@ const char *psl_registrable_domain(const psl_ctx_t *psl, const char *domain) return regdom; } +static inline int _isspace_ascii(const char c) +{ + return c == ' ' || c == '\t' || c == '\r' || c == '\n'; +} + static int _str_is_ascii(const char *s) { while (*s && *((unsigned char *)s) < 128) s++; @@ -680,14 +685,14 @@ psl_ctx_t *psl_load_fp(FILE *fp) psl->suffix_exceptions = _vector_alloc(64, _suffix_compare_array); while ((linep = fgets(buf, sizeof(buf), fp))) { - while (isspace(*linep)) linep++; /* ignore leading whitespace */ + while (_isspace_ascii(*linep)) linep++; /* ignore leading whitespace */ if (!*linep) continue; /* skip empty lines */ if (*linep == '/' && linep[1] == '/') continue; /* skip comments */ /* parse suffix rule */ - for (p = linep; *linep && !isspace(*linep);) linep++; + for (p = linep; *linep && !_isspace_ascii(*linep);) linep++; *linep = 0; if (*p == '!') { diff --git a/tests/test-is-public-all.c b/tests/test-is-public-all.c index 743004c..eb95e0e 100644 --- a/tests/test-is-public-all.c +++ b/tests/test-is-public-all.c @@ -46,6 +46,11 @@ static int ok, failed; +static inline int _isspace_ascii(const char c) +{ + return c == ' ' || c == '\t' || c == '\r' || c == '\n'; +} + static void test_psl(void) { FILE *fp; @@ -59,14 +64,14 @@ static void test_psl(void) if ((fp = fopen(PSL_FILE, "r"))) { while ((linep = fgets(buf, sizeof(buf), fp))) { - while (isspace(*linep)) linep++; /* ignore leading whitespace */ + while (_isspace_ascii(*linep)) linep++; /* ignore leading whitespace */ if (!*linep) continue; /* skip empty lines */ if (*linep == '/' && linep[1] == '/') continue; /* skip comments */ /* parse suffix rule */ - for (p = linep; *linep && !isspace(*linep);) linep++; + for (p = linep; *linep && !_isspace_ascii(*linep);) linep++; *linep = 0; if (*p == '!') { /* an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) */ diff --git a/tests/test-registrable-domain.c b/tests/test-registrable-domain.c index 1d4b68d..cb6ae9b 100644 --- a/tests/test-registrable-domain.c +++ b/tests/test-registrable-domain.c @@ -35,7 +35,6 @@ #include #include #include -#include #ifdef HAVE_ALLOCA_H # include #endif