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 /* convert all characters in the string to lowercase */
21 char *str_tolower (char *s)
26 *p = tolower ((unsigned char) *p);
33 /* NULL-pointer aware string comparison functions */
35 char *str_substrcpy (char *dest, const char *beg, const char *end,
41 if (len > destlen - 1)
43 memcpy (dest, beg, len);
48 char *str_substrdup(const char *begin, const char *end)
50 return p_dupstr(begin, (end ? end - begin : strlen(begin)));
53 const char *str_isstr (const char *haystack, const char *needle)
62 while (*(p = haystack)) {
65 tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
74 int str_eq (const char* s1, const char* s2) {
77 if (l != m_strlen(s2))
79 return (m_strncmp(s1, s2, l) == 0);
82 void str_skip_trailws (char *s) {
85 for (p = s + m_strlen(s) - 1; p >= s && ISSPACE (*p); p--)