projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
workarounds, I do not understand why it segfault, it should *NOT*
[apps/madmutt.git]
/
lib-lib
/
str.c
diff --git
a/lib-lib/str.c
b/lib-lib/str.c
index
e4616e6
..
ab603da
100644
(file)
--- a/
lib-lib/str.c
+++ b/
lib-lib/str.c
@@
-117,16
+117,12
@@
ssize_t m_strncpy(char *dst, ssize_t n, const char *src, ssize_t l)
char *m_strrtrim(char *s)
{
char *m_strrtrim(char *s)
{
- if (s) {
- char *p = s + m_strlen(s);
+ ssize_t len = m_strlen(s);
- while (p > s && ISSPACE(p[-1])) {
- *--p = '\0';
- }
- return p;
- }
+ while (len > 1 && ISSPACE(s[len - 1]))
+ s[--len] = '\0';
- return
NULL
;
+ return
s + len
;
}
const char *m_stristrn(const char *haystack, const char *needle, ssize_t nlen)
}
const char *m_stristrn(const char *haystack, const char *needle, ssize_t nlen)