AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
-AC_REPLACE_FUNCS([setenv strcasecmp strdup strndup strnlen strsep strtok_r wcscasecmp])
+AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp])
AC_REPLACE_FUNCS([strcasestr mkdtemp])
AC_CHECK_FUNC(getopt)
e = strchr(p, '?');
- *filename = e ? e == p ? NULL : strndup(p, e - p) : safe_strdup(p);
+ *filename = e ? e == p ? NULL : mutt_substrdup(p, e) : safe_strdup(p);
if (!e)
return 0; /* only filename */
e = strchr(p, '=');
if (!e)
e = strchr(p, '&');
- tag->name = e ? strndup(p, e - p) : safe_strdup(p);
+ tag->name = e ? mutt_substrdup(p, e) : safe_strdup(p);
if (!tag->name || url_pct_decode(tag->name) < 0)
goto err;
if (!e)
continue;
e = strchr(p, '&');
- tag->value = e ? strndup(p, e - p) : safe_strdup(p);
+ tag->value = e ? mutt_substrdup(p, e) : safe_strdup(p);
if (!tag->value || url_pct_decode(tag->value) < 0)
goto err;
if (!e)
for (; p > path && *(p - 1) == '/'; p--);
- data->folder = strndup(path, p - path);
+ data->folder = mutt_substrdup(path, p);
dprint(2, (debugfile, "nm: folder='%s', file='%s'\n", data->folder, h->path));
return 0;
p -= 3;
for (; p > path && *(p - 1) == '/'; p--);
- return strndup(path, p - path);
+ return mutt_substrdup(path, p);
}
return NULL;
char *mkdtemp (char *tmpl);
#endif
-#ifndef HAVE_STRNLEN
-size_t strnlen(const char *s, size_t maxlen);
-#endif
-
-#ifndef strndup
-char *strndup(const char *s, size_t n);
-#endif
+++ /dev/null
-/*
- * Copyright (C) 2013 Karel Zak <kzak@redhat.com>
- */
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "mutt.h"
-
-char *strndup(const char *s, size_t n)
-{
- size_t len = strnlen(s, n);
- char *new = malloc((len + 1) * sizeof(char)); /* __MEM_CHECKED__ */
- if (!new)
- return NULL;
- new[len] = '\0';
- return (char *) memcpy(new, s, len);
-}
+++ /dev/null
-/*
- * Copyright (C) 2013 Karel Zak <kzak@redhat.com>
- */
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "mutt.h"
-
-size_t strnlen(const char *s, size_t maxlen)
-{
- int i;
-
- for (i = 0; i < maxlen; i++) {
- if (s[i] == '\0')
- return i + 1;
- }
- return maxlen;
-}