From 5a754bcdc0f5e432c1d7cd358c74dfb2d6f0f1ea Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 28 Dec 2019 12:28:25 -0500 Subject: Fixes: * doxygen config * doxygen @file directives * corrected stupid strip() implemention * corrected strip usage by config parser. wrong pointer. --- src/strings.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/strings.c') diff --git a/src/strings.c b/src/strings.c index 38cc4d3..d6da7b6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,3 +1,6 @@ +/** + * @file strings.c + */ #include "spm.h" /** @@ -445,10 +448,19 @@ char *lstrip(char *sptr) { * @return truncated string */ char *strip(char *sptr) { - if (!strlen(sptr)) { + size_t len = strlen(sptr); + if (len < 1) { + *sptr = '\0'; return sptr; } - strchrdel(sptr, " \r\n"); + for (size_t i = len - 1; i >= 0; i--) { + if (isspace(sptr[i]) || isblank(sptr[i])) { + sptr[i] = '\0'; + } + else { + break; + } + } return sptr; } @@ -505,7 +517,7 @@ int isrelational(char ch) { } /** - * Repeatedly print string `s`, `len` times + * Print characters in `s`, `len` times * @param s * @param len */ -- cgit