From 41de691e385f39679db82c3cfeadf875f5aeca51 Mon Sep 17 00:00:00 2001 From: Hans Spath Date: Thu, 5 Dec 2013 02:44:55 +0100 Subject: [PATCH] get_options(): change loop style --- src/socket2unix.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/socket2unix.c b/src/socket2unix.c index 12f03f5..693892d 100644 --- a/src/socket2unix.c +++ b/src/socket2unix.c @@ -230,22 +230,24 @@ static int get_log_level(void) { return number; } static int get_options(void) { - const char *pos = getenv("SOCKET2UNIX_OPTIONS"); - if (!pos) { + const char *start = getenv("SOCKET2UNIX_OPTIONS"); + if (!start) { return OPTION_PARSED; } int options = OPTION_PARSED; - while (*pos != '\0') { + const char *end = start + strlen(start); + const char *pos, *curend; + + for (pos = start; pos < end; pos = curend + 1) { size_t length; - const char *end = strchr(pos, ','); - if (end == NULL) { - length = strlen(pos); - } else { - length = (size_t)(end - pos); + curend = strchr(pos, ','); + if (curend == NULL) { + curend = end; } + length = (size_t)(curend - pos); if (!strncmp("client_only", pos, length)) { options |= OPTION_CLIENT_ONLY; @@ -258,11 +260,6 @@ static int get_options(void) { ERROR("unknown option '%s' in SOCKET2UNIX_OPTIONS\n", option); } - - if (end == NULL) { - break; - } - pos = end + 1; } if ((options & OPTION_CLIENT_ONLY) && (options & OPTION_SERVER_ONLY)) { -- 2.45.2