diff --git a/files.c b/files.c index 3864623996dca0f7aad2e316c6919cf4f491a450..97084093480427b54e8077453722a9f3f336c4e7 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 69a030aa9497614934fb98fb79490d9ce1d0767b..736b7dafaf369931fa9aeaf22c1329e39bae1629 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 <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -107,7 +107,7 @@ msgstr "" msgid "File exists, OVERWRITE ?" msgstr "" -#: files.c:730 +#: files.c:735 msgid "(more)" msgstr ""