version 1.4, 1997/03/14 04:32:13 |
version 1.5, 1997/03/21 20:59:28 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: complete.c,v 1.3 1997/03/13 06:23:13 lukem Exp $ */ |
/* $NetBSD: complete.c,v 1.6 1997/03/16 14:24:16 lukem Exp $ */ |
|
|
/*- |
/*- |
* Copyright (c) 1997 The NetBSD Foundation, Inc. |
* Copyright (c) 1997 The NetBSD Foundation, Inc. |
|
|
* POSSIBILITY OF SUCH DAMAGE. |
* POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
|
#ifndef SMALL |
#ifndef lint |
#ifndef lint |
static char rcsid[] = "$OpenBSD$"; |
static char rcsid[] = "$OpenBSD$"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
return (CC_ERROR); /* no choices available */ |
return (CC_ERROR); /* no choices available */ |
|
|
if (words->sl_cur == 1) { /* only once choice available */ |
if (words->sl_cur == 1) { /* only once choice available */ |
strcpy(insertstr, words->sl_str[0]); |
(void)strcpy(insertstr, words->sl_str[0]); |
if (el_insertstr(el, insertstr + wordlen) == -1) |
if (el_insertstr(el, insertstr + wordlen) == -1) |
return (CC_ERROR); |
return (CC_ERROR); |
else |
else |
|
|
matchlen = j; |
matchlen = j; |
} |
} |
if (matchlen > wordlen) { |
if (matchlen > wordlen) { |
strncpy(insertstr, lastmatch, matchlen); |
(void)strncpy(insertstr, lastmatch, matchlen); |
insertstr[matchlen] = '\0'; |
insertstr[matchlen] = '\0'; |
if (el_insertstr(el, insertstr + wordlen) == -1) |
if (el_insertstr(el, insertstr + wordlen) == -1) |
return (CC_ERROR); |
return (CC_ERROR); |
|
|
unsigned char rv; |
unsigned char rv; |
|
|
if ((file = strrchr(word, '/')) == NULL) { |
if ((file = strrchr(word, '/')) == NULL) { |
strcpy(dir, "."); |
dir[0] = '.'; |
|
dir[1] = '\0'; |
file = word; |
file = word; |
} else { |
} else { |
if (file == word) |
if (file == word) { |
strcpy(dir, "/"); |
dir[0] = '/'; |
else { |
dir[1] = '\0'; |
strncpy(dir, word, file - word); |
} else { |
|
(void)strncpy(dir, word, file - word); |
dir[file - word] = '\0'; |
dir[file - word] = '\0'; |
} |
} |
++file; |
file++; |
} |
} |
|
|
if ((dd = opendir(dir)) == NULL) |
if ((dd = opendir(dir)) == NULL) |
|
|
char *dummyargv[] = { "complete", dir, NULL }; |
char *dummyargv[] = { "complete", dir, NULL }; |
|
|
if ((file = strrchr(word, '/')) == NULL) { |
if ((file = strrchr(word, '/')) == NULL) { |
(void)strcpy(dir, "."); |
dir[0] = '.'; |
|
dir[1] = '\0'; |
file = word; |
file = word; |
} else { |
} else { |
cp = file; |
cp = file; |
|
|
len = lf->lastchar - lf->buffer; |
len = lf->lastchar - lf->buffer; |
if (len >= sizeof(line)) |
if (len >= sizeof(line)) |
return (CC_ERROR); |
return (CC_ERROR); |
strncpy(line, lf->buffer, len); |
(void)strncpy(line, lf->buffer, len); |
line[len] = '\0'; |
line[len] = '\0'; |
cursor_pos = line + (lf->cursor - lf->buffer); |
cursor_pos = line + (lf->cursor - lf->buffer); |
lastc_argc = cursor_argc; /* remember last cursor pos */ |
lastc_argc = cursor_argc; /* remember last cursor pos */ |
|
|
&& strncmp(word, margv[cursor_argc], cursor_argo) == 0) |
&& strncmp(word, margv[cursor_argc], cursor_argo) == 0) |
dolist = 1; |
dolist = 1; |
else |
else |
strncpy(word, margv[cursor_argc], cursor_argo); |
(void)strncpy(word, margv[cursor_argc], cursor_argo); |
word[cursor_argo] = '\0'; |
word[cursor_argo] = '\0'; |
|
|
if (cursor_argc == 0) |
if (cursor_argc == 0) |
|
|
|
|
return (CC_ERROR); |
return (CC_ERROR); |
} |
} |
|
#endif |