Simplify NLST parsing code in complete_remote(); just basename each of
the returned names! Fixes parsing problems caused by the differences between NLST output on BSD, Solaris, and Windows NT.
This commit is contained in:
parent
6a9f9d3292
commit
8b0030a6fc
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: complete.c,v 1.7 1997/04/14 09:09:16 lukem Exp $ */
|
||||
/* $NetBSD: complete.c,v 1.8 1997/05/24 16:34:30 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
#ifndef SMALL
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: complete.c,v 1.7 1997/04/14 09:09:16 lukem Exp $";
|
||||
static char rcsid[] = "$NetBSD: complete.c,v 1.8 1997/05/24 16:34:30 lukem Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -233,28 +233,14 @@ complete_remote(word, list)
|
|||
cp = file;
|
||||
while (*cp == '/' && cp > word)
|
||||
cp--;
|
||||
if (cp == word) {
|
||||
dir[0] = '/';
|
||||
dir[1] = '\0';
|
||||
} else {
|
||||
(void)strncpy(dir, word, cp - word + 1);
|
||||
dir[cp - word + 1] = '\0';
|
||||
}
|
||||
(void)strncpy(dir, word, cp - word + 1);
|
||||
dir[cp - word + 1] = '\0';
|
||||
file++;
|
||||
}
|
||||
|
||||
if (dirchange || strcmp(dir, lastdir) != 0) { /* dir not cached */
|
||||
char *emesg;
|
||||
int dirlen, ftpdslashbug;
|
||||
|
||||
dirlen = strlen(dir);
|
||||
ftpdslashbug = 0;
|
||||
if (strcmp(dir, "/") == 0)
|
||||
ftpdslashbug = 1;
|
||||
else if (strcmp(dir, ".") == 0)
|
||||
dirlen = 0;
|
||||
else
|
||||
dirlen++;
|
||||
if (dirlist != NULL)
|
||||
sl_free(dirlist, 1);
|
||||
dirlist = sl_init();
|
||||
|
@ -270,15 +256,12 @@ complete_remote(word, list)
|
|||
mflag = 0;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Work around ftpd(1) bug, which puts a // instead
|
||||
* of / in front of each filename returned by "NLST /".
|
||||
* Without this, remote completes of / don't work.
|
||||
* However, only do this if the bug is present.
|
||||
*/
|
||||
if (ftpdslashbug && (cp[dirlen] != '/'))
|
||||
ftpdslashbug = 0;
|
||||
tcp = strdup(cp + dirlen + ftpdslashbug);
|
||||
tcp = strrchr(cp, '/');
|
||||
if (tcp)
|
||||
tcp++;
|
||||
else
|
||||
tcp = cp;
|
||||
tcp = strdup(tcp);
|
||||
if (tcp == NULL)
|
||||
errx(1, "Can't allocate memory for remote dir");
|
||||
sl_add(dirlist, tcp);
|
||||
|
|
Loading…
Reference in New Issue