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_adjust (char **p)
24 p_realloc(p, m_strlen(*p) + 1);
27 /* convert all characters in the string to lowercase */
28 char *str_tolower (char *s)
33 *p = tolower ((unsigned char) *p);
40 /* NULL-pointer aware string comparison functions */
42 char *str_substrcpy (char *dest, const char *beg, const char *end,
48 if (len > destlen - 1)
50 memcpy (dest, beg, len);
55 char *str_substrdup(const char *begin, const char *end)
57 return p_dupstr(begin, (end ? end - begin : strlen(begin)));
60 const char *str_isstr (const char *haystack, const char *needle)
69 while (*(p = haystack)) {
72 tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
81 int str_eq (const char* s1, const char* s2) {
84 if (l != m_strlen(s2))
86 return (m_strncmp(s1, s2, l) == 0);
89 void str_skip_trailws (char *s) {
92 for (p = s + m_strlen(s) - 1; p >= s && ISSPACE (*p); p--)