Much more sane matches allocation, beep when multiple matches found, or none...
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@273 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
b684805da7
commit
7d97ce7baf
20
files.c
20
files.c
|
@ -532,12 +532,12 @@ char **username_tab_completion(char *buf, int *num_matches)
|
||||||
|
|
||||||
char **cwd_tab_completion(char *buf, int *num_matches)
|
char **cwd_tab_completion(char *buf, int *num_matches)
|
||||||
{
|
{
|
||||||
char *dirName, *tmp = NULL;
|
char *dirName, *tmp = NULL, *tmp2 = NULL;
|
||||||
char **matches = (char **) NULL;
|
char **matches = (char **) NULL;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *next;
|
struct dirent *next;
|
||||||
|
|
||||||
matches = malloc(sizeof(char *) * 50);
|
matches = nmalloc(1024);
|
||||||
|
|
||||||
/* Stick a wildcard onto the buf, for later use */
|
/* Stick a wildcard onto the buf, for later use */
|
||||||
strcat(buf, "*");
|
strcat(buf, "*");
|
||||||
|
@ -587,11 +587,15 @@ char **cwd_tab_completion(char *buf, int *num_matches)
|
||||||
#endif
|
#endif
|
||||||
/* See if this matches */
|
/* See if this matches */
|
||||||
if (check_wildcard_match(next->d_name, tmp) == TRUE) {
|
if (check_wildcard_match(next->d_name, tmp) == TRUE) {
|
||||||
/* Cool, found a match. Add it to the list */
|
|
||||||
matches[*num_matches] = malloc(strlen(next->d_name) + 1);
|
/* Cool, found a match. Add it to the list
|
||||||
strcpy(matches[*num_matches], next->d_name);
|
* This makes a lot more sense to me (Chris) this way...
|
||||||
|
*/
|
||||||
|
tmp2 = NULL;
|
||||||
|
tmp2 = nmalloc(strlen(next->d_name) + 1);
|
||||||
|
strcpy(tmp2, next->d_name);
|
||||||
|
matches[*num_matches] = tmp2;
|
||||||
++*num_matches;
|
++*num_matches;
|
||||||
//matches = realloc( matches, sizeof(char*)*(*num_matches));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,6 +637,7 @@ int input_tab(char *buf, int place, int lastWasTab)
|
||||||
if (matches != NULL) {
|
if (matches != NULL) {
|
||||||
free(matches);
|
free(matches);
|
||||||
matches = (char **) NULL;
|
matches = (char **) NULL;
|
||||||
|
num_matches = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the word starts with `~' and there is no slash in the word,
|
/* If the word starts with `~' and there is no slash in the word,
|
||||||
|
@ -735,8 +740,7 @@ int input_tab(char *buf, int place, int lastWasTab)
|
||||||
}
|
}
|
||||||
free(foo);
|
free(foo);
|
||||||
wrefresh(edit);
|
wrefresh(edit);
|
||||||
num_matches = 0;
|
}
|
||||||
} else
|
|
||||||
beep();
|
beep();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2000-11-05 21:59-0500\n"
|
"POT-Creation-Date: 2000-11-05 23:04-0500\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -107,7 +107,7 @@ msgstr ""
|
||||||
msgid "File exists, OVERWRITE ?"
|
msgid "File exists, OVERWRITE ?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: files.c:730
|
#: files.c:735
|
||||||
msgid "(more)"
|
msgid "(more)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue