1
1

Change num_matches check from if to switch, fix check for num_matches == 0, fix allocation for matchBuf. Ugh.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@274 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
Chris Allegretta 2000-11-06 05:40:03 +00:00
родитель 7d97ce7baf
Коммит e118acc068
2 изменённых файлов: 11 добавлений и 6 удалений

13
files.c
Просмотреть файл

@ -625,7 +625,8 @@ int input_tab(char *buf, int place, int lastWasTab)
/* Make a local copy of the string -- up to the position of the /* Make a local copy of the string -- up to the position of the
cursor */ cursor */
matchBuf = (char *) calloc(strlen(buf), sizeof(char)); matchBuf = (char *) calloc(strlen(buf) + 2, sizeof(char));
strncpy(matchBuf, buf, place); strncpy(matchBuf, buf, place);
tmp = matchBuf; tmp = matchBuf;
@ -656,14 +657,17 @@ int input_tab(char *buf, int place, int lastWasTab)
free(matchBuf); free(matchBuf);
/* Did we find exactly one match? */ /* Did we find exactly one match? */
if (matches && num_matches == 1) { switch(num_matches) {
case 0:
break;
case 1:
buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) - pos + 1); buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) - pos + 1);
/* write out the matched command */ /* write out the matched command */
strncpy(buf + pos, matches[0] + pos, strncpy(buf + pos, matches[0] + pos,
strlen(matches[0]) - pos); strlen(matches[0]) - pos);
newplace += strlen(matches[0]) - pos; newplace += strlen(matches[0]) - pos;
} break;
else { default:
/* Check to see if all matches share a beginning, and if so /* Check to see if all matches share a beginning, and if so
tack it onto buf and then beep */ tack it onto buf and then beep */
@ -689,6 +693,7 @@ int input_tab(char *buf, int place, int lastWasTab)
break; break;
} }
} }
break;
} }
} else { } else {
/* Ok -- the last char was a TAB. Since they /* Ok -- the last char was a TAB. Since they

Просмотреть файл

@ -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 23:04-0500\n" "POT-Creation-Date: 2000-11-06 00:38-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:735 #: files.c:740
msgid "(more)" msgid "(more)"
msgstr "" msgstr ""