=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/complete.c,v retrieving revision 1.7 retrieving revision 1.8 diff -c -r1.7 -r1.8 *** src/usr.bin/ftp/complete.c 1997/04/23 20:33:00 1.7 --- src/usr.bin/ftp/complete.c 1997/07/25 21:56:18 1.8 *************** *** 1,5 **** ! /* $OpenBSD: complete.c,v 1.7 1997/04/23 20:33:00 deraadt Exp $ */ ! /* $NetBSD: complete.c,v 1.7 1997/04/14 09:09:16 lukem Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. --- 1,5 ---- ! /* $OpenBSD: complete.c,v 1.8 1997/07/25 21:56:18 millert Exp $ */ ! /* $NetBSD: complete.c,v 1.9 1997/07/20 09:45:43 lukem Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. *************** *** 39,45 **** #ifndef SMALL #ifndef lint ! static char rcsid[] = "$OpenBSD: complete.c,v 1.7 1997/04/23 20:33:00 deraadt Exp $"; #endif /* not lint */ /* --- 39,45 ---- #ifndef SMALL #ifndef lint ! static char rcsid[] = "$OpenBSD: complete.c,v 1.8 1997/07/25 21:56:18 millert Exp $"; #endif /* not lint */ /* *************** *** 55,60 **** --- 55,66 ---- #include "ftp_var.h" + static int comparstr __P((const void *, const void *)); + static unsigned char complete_ambiguous __P((char *, int, StringList *)); + static unsigned char complete_command __P((char *, int)); + static unsigned char complete_local __P((char *, int)); + static unsigned char complete_remote __P((char *, int)); + static int comparstr(a, b) const void *a, *b; *************** *** 80,86 **** { char insertstr[MAXPATHLEN]; char *lastmatch; ! int i, j, matchlen, wordlen; wordlen = strlen(word); if (words->sl_cur == 0) --- 86,93 ---- { char insertstr[MAXPATHLEN]; char *lastmatch; ! int i, j; ! size_t matchlen, wordlen; wordlen = strlen(word); if (words->sl_cur == 0) *************** *** 134,140 **** { struct cmd *c; StringList *words; ! int wordlen; unsigned char rv; words = sl_init(); --- 141,147 ---- { struct cmd *c; StringList *words; ! size_t wordlen; unsigned char rv; words = sl_init(); *************** *** 176,182 **** dir[0] = '/'; dir[1] = '\0'; } else { ! (void)strncpy(dir, word, file - word); dir[file - word] = '\0'; } file++; --- 183,189 ---- dir[0] = '/'; dir[1] = '\0'; } else { ! (void)strncpy(dir, word, (size_t)(file - word)); dir[file - word] = '\0'; } file++; *************** *** 234,261 **** 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'; ! } 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(); --- 241,254 ---- cp = file; while (*cp == '/' && cp > word) cp--; ! (void)strncpy(dir, word, (size_t)(cp - word + 1)); ! dir[cp - word + 1] = '\0'; file++; } if (dirchange || strcmp(dir, lastdir) != 0) { /* dir not cached */ char *emesg; if (dirlist != NULL) sl_free(dirlist, 1); dirlist = sl_init(); *************** *** 271,285 **** 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); if (tcp == NULL) errx(1, "Can't allocate memory for remote dir"); sl_add(dirlist, tcp); --- 264,275 ---- mflag = 0; continue; } ! 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); *************** *** 318,324 **** struct cmd *c; const LineInfo *lf; ! int len, celems, dolist; lf = el_line(el); len = lf->lastchar - lf->buffer; --- 308,315 ---- struct cmd *c; const LineInfo *lf; ! int celems, dolist; ! size_t len; lf = el_line(el); len = lf->lastchar - lf->buffer; *************** *** 380,383 **** return (CC_ERROR); } ! #endif --- 371,375 ---- return (CC_ERROR); } ! ! #endif /* !SMALL */