2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
15 #include <lib-lib/mem.h>
16 #include <lib-lib/str.h>
20 void str_replace (char **p, const char *s)
26 void str_adjust (char **p)
30 p_realloc(p, m_strlen(*p) + 1);
33 /* convert all characters in the string to lowercase */
34 char *str_tolower (char *s)
39 *p = tolower ((unsigned char) *p);
46 /* NULL-pointer aware string comparison functions */
48 char *str_substrcpy (char *dest, const char *beg, const char *end,
54 if (len > destlen - 1)
56 memcpy (dest, beg, len);
61 char *str_substrdup(const char *begin, const char *end)
63 return p_dupstr(begin, (end ? end - begin : strlen(begin)));
66 const char *str_isstr (const char *haystack, const char *needle)
75 while (*(p = haystack)) {
78 tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
87 int str_eq (const char* s1, const char* s2) {
90 if (l != m_strlen(s2))
92 return (m_strncmp(s1, s2, l) == 0);
95 void str_skip_trailws (char *s) {
98 for (p = s + m_strlen(s) - 1; p >= s && ISSPACE (*p); p--)