* complete.c (check_is_cd): Simplify logic, use isspace().
Этот коммит содержится в:
родитель
baa4e26cdc
Коммит
645eeb8118
@ -1,3 +1,7 @@
|
|||||||
|
2003-11-24 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* complete.c (check_is_cd): Simplify logic, use isspace().
|
||||||
|
|
||||||
2003-11-24 Andrew V. Samoilov <sav@bcs.zp.ua>
|
2003-11-24 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
* hotlist.c (add_new_group_input): Clean up.
|
* hotlist.c (add_new_group_input): Clean up.
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -608,17 +609,28 @@ completion_matches (char *text, CompletionFunction entry_function)
|
|||||||
return match_list;
|
return match_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if directory completion is needed */
|
||||||
static int
|
static int
|
||||||
check_is_cd (char *text, int start, int flags)
|
check_is_cd (const char *text, int start, int flags)
|
||||||
{
|
{
|
||||||
char *p, *q = text + start;
|
const unsigned char *p, *q;
|
||||||
|
|
||||||
for (p = text; *p && p < q && (*p == ' ' || *p == '\t'); p++);
|
if (flags & INPUT_COMPLETE_CD)
|
||||||
if (((flags & INPUT_COMPLETE_COMMANDS) &&
|
|
||||||
!strncmp (p, "cd", 2) && (p [2] == ' ' || p [2] == '\t') &&
|
|
||||||
p + 2 < q) ||
|
|
||||||
(flags & INPUT_COMPLETE_CD))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (!(flags & INPUT_COMPLETE_COMMANDS))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Skip initial spaces */
|
||||||
|
p = text;
|
||||||
|
q = text + start;
|
||||||
|
while (p < q && *p && isspace (*p))
|
||||||
|
p++;
|
||||||
|
|
||||||
|
/* Check if the command is "cd" and the cursor is after it */
|
||||||
|
if (p[0] == 'c' && p[1] == 'd' && isspace (p[2]) && (p + 2 < q))
|
||||||
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user