From 7d97ce7baf54835c38ca257ce389a9fd01676cc0 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Mon, 6 Nov 2000 04:04:15 +0000 Subject: [PATCH] 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-d3aeb78583b8 --- files.c | 22 +++++++++++++--------- po/nano.pot | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/files.c b/files.c index 38646239..97084093 100644 --- a/files.c +++ b/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 *dirName, *tmp = NULL; + char *dirName, *tmp = NULL, *tmp2 = NULL; char **matches = (char **) NULL; DIR *dir; struct dirent *next; - matches = malloc(sizeof(char *) * 50); + matches = nmalloc(1024); /* Stick a wildcard onto the buf, for later use */ strcat(buf, "*"); @@ -587,11 +587,15 @@ char **cwd_tab_completion(char *buf, int *num_matches) #endif /* See if this matches */ 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); - strcpy(matches[*num_matches], next->d_name); + + /* Cool, found a match. Add it to the list + * 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; - //matches = realloc( matches, sizeof(char*)*(*num_matches)); } } @@ -633,6 +637,7 @@ int input_tab(char *buf, int place, int lastWasTab) if (matches != NULL) { free(matches); matches = (char **) NULL; + num_matches = 0; } /* If the word starts with `~' and there is no slash in the word, @@ -735,9 +740,8 @@ int input_tab(char *buf, int place, int lastWasTab) } free(foo); wrefresh(edit); - num_matches = 0; - } else - beep(); + } + beep(); } diff --git a/po/nano.pot b/po/nano.pot index 69a030aa..736b7daf 100644 --- a/po/nano.pot +++ b/po/nano.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -107,7 +107,7 @@ msgstr "" msgid "File exists, OVERWRITE ?" msgstr "" -#: files.c:730 +#: files.c:735 msgid "(more)" msgstr "" -- 2.39.5