From a84801107374edfd275bafd201e5a3986a2b3382 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 24 Jul 2010 02:02:56 +0200 Subject: [PATCH] Move strdup() fallback implementation to platform code. --- src/complete.c | 15 --------------- src/sysunix.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/complete.c b/src/complete.c index 8900fa1..44ed547 100644 --- a/src/complete.c +++ b/src/complete.c @@ -23,21 +23,6 @@ #define MAX_TOTAL_MATCHES (256 << sizeof(char *)) -#ifndef HAVE_STRDUP -/* Return an allocated copy of a string. */ -char *strdup(const char *p) -{ - char *new = malloc(sizeof(char) * strlen(p)); - - if (new) { - strcpy(new, p); - return new; - } - - return NULL; -} -#endif - /* Wrap strcmp() for qsort() */ static int compare(const void *p1, const void *p2) { diff --git a/src/sysunix.c b/src/sysunix.c index 74bd1ac..4827f33 100644 --- a/src/sysunix.c +++ b/src/sysunix.c @@ -142,6 +142,21 @@ void rl_ttyset(int Reset) #error Unsupported platform, missing tcgetattr(), termio.h and sgtty.h #endif /* Neither HAVE_SGTTY_H, HAVE_TERMIO_H or HAVE_TCGETATTR */ +#ifndef HAVE_STRDUP +/* Return an allocated copy of a string. */ +char *strdup(const char *p) +{ + char *new = malloc(sizeof(char) * strlen(p)); + + if (new) { + strcpy(new, p); + return new; + } + + return NULL; +} +#endif + void rl_add_slash(char *path, char *p) { struct stat Sb;