Converted ifs to switches, added Rocco's optmiization
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@247 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
462a1997e9
Коммит
9c371a24e3
@ -20,6 +20,11 @@ CVS Code -
|
||||
do_replace()
|
||||
- Added code for Gotoline key after entering the search term.
|
||||
Fixes bug #46.
|
||||
- Removed redundant code involving processing replacemenet string.
|
||||
Converted if statements to switch statements.
|
||||
- Optimizations by Rocco Corsi.
|
||||
do_search()
|
||||
- Converted if statements to one switch statement.
|
||||
- winio.c
|
||||
nanogetstr()
|
||||
- Added check for 343 in while loop to get rid of getting "locked"
|
||||
|
24
po/nano.pot
24
po/nano.pot
@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2000-10-27 01:32-0400\n"
|
||||
"POT-Creation-Date: 2000-10-27 01:45-0400\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"
|
||||
@ -765,52 +765,52 @@ msgstr ""
|
||||
msgid "Search Wrapped"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:256
|
||||
#: search.c:258
|
||||
#, c-format
|
||||
msgid "Replaced %d occurences"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:258
|
||||
#: search.c:260
|
||||
msgid "Replaced 1 occurence"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:392 search.c:424
|
||||
#: search.c:396 search.c:429
|
||||
msgid "Replace Cancelled"
|
||||
msgstr ""
|
||||
|
||||
#. They used ^N in the search field, shame on them.
|
||||
#. Any Dungeon fans out there?
|
||||
#: search.c:409
|
||||
#: search.c:413
|
||||
msgid "Nothing Happens"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:417
|
||||
#: search.c:421
|
||||
#, c-format
|
||||
msgid "Replace with [%s]"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:419
|
||||
#: search.c:423
|
||||
msgid "Replace with"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:467
|
||||
#: search.c:474
|
||||
msgid "Replace this instance?"
|
||||
msgstr ""
|
||||
|
||||
#. Ask for it
|
||||
#: search.c:528
|
||||
#: search.c:535
|
||||
msgid "Enter line number"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:530
|
||||
#: search.c:537
|
||||
msgid "Aborted"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:550
|
||||
#: search.c:557
|
||||
msgid "Come on, be reasonable"
|
||||
msgstr ""
|
||||
|
||||
#: search.c:555
|
||||
#: search.c:562
|
||||
#, c-format
|
||||
msgid "Only %d lines available, skipping to last line"
|
||||
msgstr ""
|
||||
|
43
search.c
43
search.c
@ -229,17 +229,19 @@ int do_search(void)
|
||||
filestruct *fileptr = current;
|
||||
|
||||
wrap_reset();
|
||||
if ((i = search_init(0)) == -1) {
|
||||
i = search_init(0);
|
||||
switch (i) {
|
||||
case -1:
|
||||
current = fileptr;
|
||||
search_abort();
|
||||
return 0;
|
||||
} else if (i == -3) {
|
||||
case -3:
|
||||
search_abort();
|
||||
return 0;
|
||||
} else if (i == -2) {
|
||||
case -2:
|
||||
do_replace();
|
||||
return 0;
|
||||
} else if (i == 1) {
|
||||
case 1:
|
||||
do_search();
|
||||
search_abort();
|
||||
return 1;
|
||||
@ -388,17 +390,19 @@ int do_replace(void)
|
||||
filestruct *fileptr, *begin;
|
||||
char *copy, prevanswer[132] = "";
|
||||
|
||||
if ((i = search_init(1)) == -1) {
|
||||
i = search_init(1);
|
||||
switch (i) {
|
||||
case -1:
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
} else if (i == 1) {
|
||||
case 1:
|
||||
do_replace();
|
||||
return 1;
|
||||
} else if (i == -2) {
|
||||
case -2:
|
||||
do_search();
|
||||
return 0;
|
||||
} else if (i == -3) {
|
||||
case -3:
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
@ -418,17 +422,20 @@ int do_replace(void)
|
||||
else
|
||||
i = statusq(replace_list, REPLACE_LIST_LEN, "", _("Replace with"));
|
||||
|
||||
if (i == -1) { /* Aborted enter */
|
||||
switch (i) {
|
||||
case -1: /* Aborted enter */
|
||||
if (strcmp(last_replace, ""))
|
||||
strncpy(answer, last_replace, 132);
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
} else if (i == 0) /* They actually entered something */
|
||||
case 0: /* They actually entered something */
|
||||
strncpy(last_replace, answer, 132);
|
||||
else if (i == NANO_NULL_KEY) /* They actually entered something */
|
||||
break;
|
||||
case NANO_NULL_KEY: /* They want the null string */
|
||||
strcpy(last_replace, "");
|
||||
else if (i == NANO_CASE_KEY) { /* They asked for case sensitivity */
|
||||
break;
|
||||
case NANO_CASE_KEY: /* They asked for case sensitivity */
|
||||
if (ISSET(CASE_SENSITIVE))
|
||||
UNSET(CASE_SENSITIVE);
|
||||
else
|
||||
@ -436,14 +443,16 @@ int do_replace(void)
|
||||
|
||||
do_replace();
|
||||
return 0;
|
||||
} else if (i == NANO_FROMSEARCHTOGOTO_KEY) { /* oops... */
|
||||
case NANO_FROMSEARCHTOGOTO_KEY: /* Oops, they want goto line... */
|
||||
do_gotoline_void();
|
||||
return 0;
|
||||
} else if (i != -2) { /* First page, last page, for example
|
||||
default:
|
||||
if (i != -2) { /* First page, last page, for example
|
||||
could get here */
|
||||
do_early_abort();
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* save where we are */
|
||||
@ -453,10 +462,8 @@ int do_replace(void)
|
||||
|
||||
while (1) {
|
||||
|
||||
if (replaceall)
|
||||
fileptr = findnextstr(1, begin, beginx, prevanswer);
|
||||
else
|
||||
fileptr = findnextstr(0, begin, beginx, prevanswer);
|
||||
/* Sweet optimization by Rocco here */
|
||||
fileptr = findnextstr(replaceall, begin, beginx, prevanswer);
|
||||
|
||||
/* No more matches. Done! */
|
||||
if (!fileptr)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user