From 3b5a28ca21ed0ee3f56b58828eee78f26402f7af Mon Sep 17 00:00:00 2001
From: Martin Hecht <mrbaseman@gmx.de>
Date: Fri, 15 Jun 2018 10:08:18 +0200
Subject: [PATCH] remove iswhitespace_like in favorite of isspace

see discussion in #334
---
 configure.ac | 2 +-
 src/config.c | 8 ++++----
 src/config.h | 6 ------
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index ee525da..e85ee0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AC_TYPE_UINT8_T
 # Checks for library functions.
 AC_FUNC_MALLOC
 AC_FUNC_REALLOC
-AC_CHECK_FUNCS([atoi close connect execv exit _exit fclose fcntl fflush fopen forkpty fprintf fputs free freeaddrinfo freeifaddrs freopen fwrite getaddrinfo getchar getenv getopt_long htons index inet_addr inet_ntoa isatty malloc memcpy memmem memmove memset ntohs open openlog pclose popen printf pthread_cancel pthread_cond_init pthread_cond_signal pthread_cond_wait pthread_join pthread_mutexattr_init pthread_mutex_destroy pthread_mutex_init pthread_mutex_lock pthread_mutex_unlock pthread_sigmask puts read realloc rewind select setenv sigaddset sigemptyset signal snprintf socket sprintf strcasestr strcat strchr strcmp strcpy strdup strerror strlen strncasecmp strncat strncpy strsignal strstr strtok strtok_r strtol syslog system tcsetattr usleep vprintf vsnprintf vsyslog write], [], AC_MSG_ERROR([Required function not present]))
+AC_CHECK_FUNCS([atoi close connect execv exit _exit fclose fcntl fflush fopen forkpty fprintf fputs free freeaddrinfo freeifaddrs freopen fwrite getaddrinfo getchar getenv getopt_long htons index inet_addr inet_ntoa isatty isdigit isspace malloc memcpy memmem memmove memset ntohs open openlog pclose popen printf pthread_cancel pthread_cond_init pthread_cond_signal pthread_cond_wait pthread_join pthread_mutexattr_init pthread_mutex_destroy pthread_mutex_init pthread_mutex_lock pthread_mutex_unlock pthread_sigmask puts read realloc rewind select setenv sigaddset sigemptyset signal snprintf socket sprintf strcasestr strcat strchr strcmp strcpy strdup strerror strlen strncasecmp strncat strncpy strsignal strstr strtok strtok_r strtol syslog system tcsetattr usleep vprintf vsnprintf vsyslog write], [], AC_MSG_ERROR([Required function not present]))
 AC_CHECK_FUNCS([pthread_mutexattr_setrobust])
 # Use PKG_CHECK_MODULES compiler/linker flags
 save_openssl_CPPFLAGS="${CPPFLAGS}"
diff --git a/src/config.c b/src/config.c
index e6a40e7..61d15f1 100644
--- a/src/config.c
+++ b/src/config.c
@@ -135,19 +135,19 @@ int load_config(struct vpn_config *cfg, const char *filename)
 		val = equals + 1;
 
 		// Remove heading spaces
-		while (iswhitespace_like(key[0]))
+		while (isspace(key[0]))
 			key++;
-		while (iswhitespace_like(val[0]))
+		while (isspace(val[0]))
 			val++;
 		// Remove trailing spaces
 		for (i = strlen(key) - 1; i > 0; i--) {
-			if (iswhitespace_like(key[i]))
+			if (isspace(key[i]))
 				key[i] = '\0';
 			else
 				break;
 		}
 		for (i = strlen(val) - 1; i > 0; i--) {
-			if (iswhitespace_like(val[i]))
+			if (isspace(val[i]))
 				val[i] = '\0';
 			else
 				break;
diff --git a/src/config.h b/src/config.h
index ab0eedb..b0fae83 100644
--- a/src/config.h
+++ b/src/config.h
@@ -91,10 +91,4 @@ int strtob(const char *str);
 
 int load_config(struct vpn_config *cfg, const char *filename);
 
-inline int iswhitespace_like(const char character)
-{
-	return (character != '\0' \
-	        && (character == ' ' || character == '\t' || character == '\r'));
-}
-
 #endif
-- 
GitLab