diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-28 12:28:25 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-28 12:28:25 -0500 |
commit | 5a754bcdc0f5e432c1d7cd358c74dfb2d6f0f1ea (patch) | |
tree | a60ffaacdaa394f8a9772220b50a47d5f51bddc6 /src/strings.c | |
parent | a267f8258162fdab350944676b2e71f858c3de51 (diff) | |
download | spmc-5a754bcdc0f5e432c1d7cd358c74dfb2d6f0f1ea.tar.gz |
Fixes:
* doxygen config
* doxygen @file directives
* corrected stupid strip() implemention
* corrected strip usage by config parser. wrong pointer.
Diffstat (limited to 'src/strings.c')
-rw-r--r-- | src/strings.c | 18 |
1 files changed, 15 insertions, 3 deletions
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 */ |