Don't use locale dependent isspace()

Fixes an issue on Solaris
Reported-by: Dagobert Michelsen <dam@opencsw.org>
This commit is contained in:
Tim Rühsen 2015-01-26 11:05:32 +01:00
parent 896f7f6ae4
commit 067f6aee9c
4 changed files with 17 additions and 5 deletions

View File

@ -14,6 +14,9 @@ LT_INIT
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl Check that compiler understands inline
AC_C_INLINE
# #
# Gettext # Gettext
# #

View File

@ -497,6 +497,11 @@ const char *psl_registrable_domain(const psl_ctx_t *psl, const char *domain)
return regdom; 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) static int _str_is_ascii(const char *s)
{ {
while (*s && *((unsigned char *)s) < 128) 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); psl->suffix_exceptions = _vector_alloc(64, _suffix_compare_array);
while ((linep = fgets(buf, sizeof(buf), fp))) { 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) continue; /* skip empty lines */
if (*linep == '/' && linep[1] == '/') if (*linep == '/' && linep[1] == '/')
continue; /* skip comments */ continue; /* skip comments */
/* parse suffix rule */ /* parse suffix rule */
for (p = linep; *linep && !isspace(*linep);) linep++; for (p = linep; *linep && !_isspace_ascii(*linep);) linep++;
*linep = 0; *linep = 0;
if (*p == '!') { if (*p == '!') {

View File

@ -46,6 +46,11 @@ static int
ok, ok,
failed; failed;
static inline int _isspace_ascii(const char c)
{
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
static void test_psl(void) static void test_psl(void)
{ {
FILE *fp; FILE *fp;
@ -59,14 +64,14 @@ static void test_psl(void)
if ((fp = fopen(PSL_FILE, "r"))) { if ((fp = fopen(PSL_FILE, "r"))) {
while ((linep = fgets(buf, sizeof(buf), fp))) { 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) continue; /* skip empty lines */
if (*linep == '/' && linep[1] == '/') if (*linep == '/' && linep[1] == '/')
continue; /* skip comments */ continue; /* skip comments */
/* parse suffix rule */ /* parse suffix rule */
for (p = linep; *linep && !isspace(*linep);) linep++; for (p = linep; *linep && !_isspace_ascii(*linep);) linep++;
*linep = 0; *linep = 0;
if (*p == '!') { /* an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) */ if (*p == '!') { /* an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) */

View File

@ -35,7 +35,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
# include <alloca.h> # include <alloca.h>
#endif #endif