diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2015-11-09 18:43:40 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-11-11 14:03:49 +1000 |
commit | 947dfda515505f937eac5b388384dd6df0278e40 (patch) | |
tree | f5c7202addd03318a26c90b2804c6a0c2cd3fbbb | |
parent | 9e22e75fa195b17efb6ad911e0e9910330e8a30a (diff) |
Refactor strtrim function
Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/common/util-common.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/common/util-common.c b/src/common/util-common.c index 542dcfde..0b67d85a 100644 --- a/src/common/util-common.c +++ b/src/common/util-common.c @@ -144,17 +144,13 @@ size_t strtrim(char *str) } if(pch != str) { size_t len = strlen(pch); - if(len) { - memmove(str, pch, len + 1); - pch = str; - } else { + /* check if there wasn't anything but whitespace in the string. */ + if(len == 0) { *str = '\0'; + return 0; } - } - - /* check if there wasn't anything but whitespace in the string. */ - if(*str == '\0') { - return 0; + memmove(str, pch, len + 1); + pch = str; } end = (str + strlen(str) - 1); |