mirror of
https://github.com/troglobit/editline.git
synced 2025-05-06 04:21:24 +08:00
Move strdup() fallback implementation to platform code.
This commit is contained in:
parent
ceb1995733
commit
a848011073
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user