Commit 5bf51d38 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

Updated BUGS, optimized search_init a little, fixed bug #47

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@286 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 113 additions and 57 deletions
+113 -57
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
certain col values. (9) [FIXED] certain col values. (9) [FIXED]
- edit_refresh() and update_line() do not handle selecting text when the - edit_refresh() and update_line() do not handle selecting text when the
cursor is beyond COLS (10) [FIXED] cursor is beyond COLS (10) [FIXED]
- no way to do a replace with the empty string (11). [FIXED, yay!] - no way to do a replace with the empty string (11) [FIXED, yay!]
- Spelling support is not elegant like pico's integration of the 'spell'
program. Nano only uses ispell (for now) (12) [FIXED]
- Moving to the end of a line when close to a multiple of COLS and at - Moving to the end of a line when close to a multiple of COLS and at
least COLS * 2 does not make the screen jump early like it would for least COLS * 2 does not make the screen jump early like it would for
if we were around COLS (bugs in edit_refresh, update_line) (13) if we were around COLS (bugs in edit_refresh, update_line) (13)
...@@ -71,14 +73,15 @@ ...@@ -71,14 +73,15 @@
when called from inside mutt (among other settings) (45). [FIXED] when called from inside mutt (among other settings) (45). [FIXED]
- In replace, hitting the Goto line shortcut key does nothing after a - In replace, hitting the Goto line shortcut key does nothing after a
search string is entered (discovered by Rocco Corsi) (46) [FIXED]. search string is entered (discovered by Rocco Corsi) (46) [FIXED].
- When typing in a string in serahc or replace and hitting CASE_SENSITVE
or the other search string, the current string edit is blown away in
favor of the last stored search (47) [FIXED]
** Open BUGS ** ** Open BUGS **
- Marked cutting sometimes leaves a newline in the file unintelligently, - Marked cutting sometimes leaves a newline in the file unintelligently,
such as when all of a line is selected but the mark doesn't proceed to such as when all of a line is selected but the mark doesn't proceed to
the new line. (8) { Is this an issue? compare to pico 3.5 } the new line. (8) { Is this an issue? compare to pico 3.5 }
- Spelling support is not elegant like pico's integration of the 'spell'
program. Nano only uses ispell (for now) (12).
- totsize problems still abound in do_justify (33). - totsize problems still abound in do_justify (33).
$Id$ $Id$
...@@ -25,6 +25,9 @@ CVS Code - ...@@ -25,6 +25,9 @@ CVS Code -
hacked them a lot, changes to nanogetstr(). nanogetstr() and hacked them a lot, changes to nanogetstr(). nanogetstr() and
statusq() now take an arg for whether or not to allow tab statusq() now take an arg for whether or not to allow tab
completion. completion.
- Fixed value being input in statusbar during a search or replace
and CASE_SENSITIVE or the other search is called and the
string being typed in is blown away. Reported by Ken Tyler.
- files.c: - files.c:
do_writeout() do_writeout()
- Change strcpy to answer to mallocstrcpy. - Change strcpy to answer to mallocstrcpy.
......
...@@ -6,7 +6,7 @@ ...@@ -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-14 20:33-0500\n" "POT-Creation-Date: 2000-11-16 00:59-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"
...@@ -32,7 +32,7 @@ msgstr "" ...@@ -32,7 +32,7 @@ msgstr ""
msgid "Read %d lines" msgid "Read %d lines"
msgstr "" msgstr ""
#: files.c:219 search.c:164 #: files.c:219 search.c:188
#, c-format #, c-format
msgid "\"%s\" not found" msgid "\"%s\" not found"
msgstr "" msgstr ""
...@@ -384,7 +384,7 @@ msgid "Case Sens" ...@@ -384,7 +384,7 @@ msgid "Case Sens"
msgstr "" msgstr ""
#: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401 #: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401
#: global.c:405 global.c:411 winio.c:1011 #: global.c:405 global.c:411 winio.c:1014
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
...@@ -727,87 +727,87 @@ msgstr "" ...@@ -727,87 +727,87 @@ msgstr ""
msgid "I got Alt-%c! (%d)\n" msgid "I got Alt-%c! (%d)\n"
msgstr "" msgstr ""
#: search.c:99 #: search.c:118
#, c-format #, c-format
msgid "Case Sensitive Regexp Search%s%s" msgid "Case Sensitive Regexp Search%s%s"
msgstr "" msgstr ""
#: search.c:101 #: search.c:120
#, c-format #, c-format
msgid "Regexp Search%s%s" msgid "Regexp Search%s%s"
msgstr "" msgstr ""
#: search.c:103 #: search.c:122
#, c-format #, c-format
msgid "Case Sensitive Search%s%s" msgid "Case Sensitive Search%s%s"
msgstr "" msgstr ""
#: search.c:105 #: search.c:124
#, c-format #, c-format
msgid "Search%s%s" msgid "Search%s%s"
msgstr "" msgstr ""
#: search.c:108 #: search.c:127
msgid " (to replace)" msgid " (to replace)"
msgstr "" msgstr ""
#: search.c:121 search.c:290 #: search.c:136 search.c:318
msgid "Search Cancelled" msgid "Search Cancelled"
msgstr "" msgstr ""
#: search.c:168 #: search.c:194
#, c-format #, c-format
msgid "\"%s...\" not found" msgid "\"%s...\" not found"
msgstr "" msgstr ""
#: search.c:215 #: search.c:243
msgid "Search Wrapped" msgid "Search Wrapped"
msgstr "" msgstr ""
#: search.c:304 #: search.c:340
#, c-format #, c-format
msgid "Replaced %d occurences" msgid "Replaced %d occurences"
msgstr "" msgstr ""
#: search.c:306 #: search.c:342
msgid "Replaced 1 occurence" msgid "Replaced 1 occurence"
msgstr "" msgstr ""
#: search.c:443 search.c:536 search.c:552 #: search.c:479 search.c:572 search.c:588
msgid "Replace Cancelled" msgid "Replace Cancelled"
msgstr "" msgstr ""
#: search.c:486 #: search.c:522
msgid "Replace this instance?" msgid "Replace this instance?"
msgstr "" msgstr ""
#: search.c:494 #: search.c:530
msgid "Replace failed: unknown subexpression!" msgid "Replace failed: unknown subexpression!"
msgstr "" msgstr ""
#: search.c:569 #: search.c:613
#, c-format #, c-format
msgid "Replace with [%s]" msgid "Replace with [%s]"
msgstr "" msgstr ""
#: search.c:573 search.c:577 #: search.c:617 search.c:621
msgid "Replace with" msgid "Replace with"
msgstr "" msgstr ""
#. Ask for it #. Ask for it
#: search.c:612 #: search.c:656
msgid "Enter line number" msgid "Enter line number"
msgstr "" msgstr ""
#: search.c:614 #: search.c:658
msgid "Aborted" msgid "Aborted"
msgstr "" msgstr ""
#: search.c:634 #: search.c:678
msgid "Come on, be reasonable" msgid "Come on, be reasonable"
msgstr "" msgstr ""
#: search.c:639 #: search.c:683
#, c-format #, c-format
msgid "Only %d lines available, skipping to last line" msgid "Only %d lines available, skipping to last line"
msgstr "" msgstr ""
...@@ -817,67 +817,67 @@ msgstr "" ...@@ -817,67 +817,67 @@ msgstr ""
msgid "actual_x_from_start for xplus=%d returned %d\n" msgid "actual_x_from_start for xplus=%d returned %d\n"
msgstr "" msgstr ""
#: winio.c:424 #: winio.c:427
#, c-format #, c-format
msgid "input '%c' (%d)\n" msgid "input '%c' (%d)\n"
msgstr "" msgstr ""
#: winio.c:462 #: winio.c:465
msgid "New Buffer" msgid "New Buffer"
msgstr "" msgstr ""
#: winio.c:465 #: winio.c:468
msgid " File: ..." msgid " File: ..."
msgstr "" msgstr ""
#: winio.c:473 #: winio.c:476
msgid "Modified" msgid "Modified"
msgstr "" msgstr ""
#: winio.c:925 #: winio.c:928
#, c-format #, c-format
msgid "Moved to (%d, %d) in edit buffer\n" msgid "Moved to (%d, %d) in edit buffer\n"
msgstr "" msgstr ""
#: winio.c:936 #: winio.c:939
#, c-format #, c-format
msgid "current->data = \"%s\"\n" msgid "current->data = \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:981 #: winio.c:984
#, c-format #, c-format
msgid "I got \"%s\"\n" msgid "I got \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:1006 #: winio.c:1009
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: winio.c:1008 #: winio.c:1011
msgid "All" msgid "All"
msgstr "" msgstr ""
#: winio.c:1010 #: winio.c:1013
msgid "No" msgid "No"
msgstr "" msgstr ""
#: winio.c:1147 #: winio.c:1150
#, c-format #, c-format
msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
msgstr "" msgstr ""
#: winio.c:1151 #: winio.c:1154
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "" msgstr ""
#: winio.c:1279 #: winio.c:1282
msgid "Dumping file buffer to stderr...\n" msgid "Dumping file buffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1281 #: winio.c:1284
msgid "Dumping cutbuffer to stderr...\n" msgid "Dumping cutbuffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1283 #: winio.c:1286
msgid "Dumping a buffer to stderr...\n" msgid "Dumping a buffer to stderr...\n"
msgstr "" msgstr ""
...@@ -74,12 +74,29 @@ int search_init(int replacing) ...@@ -74,12 +74,29 @@ int search_init(int replacing)
int i = 0; int i = 0;
char *buf; char *buf;
char *prompt, *reprompt = ""; char *prompt, *reprompt = "";
static char *backupstring = NULL;
search_init_globals(); search_init_globals();
buf = nmalloc(strlen(last_search) + 5); buf = nmalloc(strlen(last_search) + 5);
buf[0] = 0; buf[0] = 0;
/* Okay, fun time. backupstring is our holder for what is being
returned from the statusq call. Using answer for this would be tricky.
Here, if we're using PICO_MSGS, we only want nano to put the
old string back up as editable if it's not the same as last_search.
Otherwise, if we don't already have a backupstring, set it to
last_search. */
if (ISSET(PICO_MSGS)) {
if (backupstring == NULL || !strcmp(backupstring, last_search))
backupstring = mallocstrcpy(backupstring, "");
}
else if (backupstring == NULL)
backupstring = mallocstrcpy(backupstring, last_search);
/* If using Pico messages, we do things the old fashioned way... */ /* If using Pico messages, we do things the old fashioned way... */
if (ISSET(PICO_MSGS)) { if (ISSET(PICO_MSGS)) {
if (last_search[0]) { if (last_search[0]) {
...@@ -94,6 +111,8 @@ int search_init(int replacing) ...@@ -94,6 +111,8 @@ int search_init(int replacing)
buf[0] = '\0'; buf[0] = '\0';
} }
} }
else
strcpy(buf, "");
if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE)) if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE))
prompt = _("Case Sensitive Regexp Search%s%s"); prompt = _("Case Sensitive Regexp Search%s%s");
...@@ -107,36 +126,38 @@ int search_init(int replacing) ...@@ -107,36 +126,38 @@ int search_init(int replacing)
if (replacing) if (replacing)
reprompt = _(" (to replace)"); reprompt = _(" (to replace)");
if (ISSET(PICO_MSGS)) /* This is now one simple call. It just does a lot */
i = statusq(0, replacing ? replace_list : whereis_list, i = statusq(0, replacing ? replace_list : whereis_list,
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "", replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, backupstring,
prompt, reprompt, buf);
else
i = statusq(0, replacing ? replace_list : whereis_list,
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, last_search,
prompt, reprompt, ""); prompt, reprompt, "");
/* Cancel any search, or just return with no previous search */ /* Cancel any search, or just return with no previous search */
if ((i == -1) || (i < 0 && !last_search[0])) { if ((i == -1) || (i < 0 && !last_search[0])) {
statusbar(_("Search Cancelled")); statusbar(_("Search Cancelled"));
reset_cursor(); reset_cursor();
free(backupstring);
backupstring = NULL;
return -1; return -1;
} else if (i == -2) { /* Same string */ } else if (i == -2) { /* Same string */
answer = mallocstrcpy(answer, last_search);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) if (ISSET(USE_REGEXP))
regexp_init(answer); regexp_init(answer);
#else
;
#endif #endif
} else if (i == 0) { /* They entered something new */ } else if (i == 0) { /* They entered something new */
last_search = mallocstrcpy(last_search, answer);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) if (ISSET(USE_REGEXP))
regexp_init(answer); regexp_init(answer);
#endif #endif
/* Blow away last_replace because they entered a new search free(backupstring);
string....uh, right? =) */ backupstring = NULL;
last_replace[0] = '\0'; last_replace[0] = '\0';
} else if (i == NANO_CASE_KEY) { /* They want it case sensitive */ } else if (i == NANO_CASE_KEY) { /* They want it case sensitive */
free(backupstring);
backupstring = NULL;
backupstring = mallocstrcpy(backupstring, answer);
if (ISSET(CASE_SENSITIVE)) if (ISSET(CASE_SENSITIVE))
UNSET(CASE_SENSITIVE); UNSET(CASE_SENSITIVE);
else else
...@@ -144,12 +165,17 @@ int search_init(int replacing) ...@@ -144,12 +165,17 @@ int search_init(int replacing)
return 1; return 1;
} else if (i == NANO_OTHERSEARCH_KEY) { } else if (i == NANO_OTHERSEARCH_KEY) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function */ return -2; /* Call the opposite search function */
} else if (i == NANO_FROMSEARCHTOGOTO_KEY) { } else if (i == NANO_FROMSEARCHTOGOTO_KEY) {
free(backupstring);
backupstring = NULL;
do_gotoline_void(); do_gotoline_void();
return -3; return -3;
} else { /* First line key, etc. */ } else { /* First line key, etc. */
do_early_abort(); do_early_abort();
free(backupstring);
backupstring = NULL;
return -3; return -3;
} }
...@@ -288,12 +314,20 @@ int do_search(void) ...@@ -288,12 +314,20 @@ int do_search(void)
} }
/* The sneaky user deleted the previous search string */ /* The sneaky user deleted the previous search string */
if (!strcmp(answer, "")) { if (!ISSET(PICO_MSGS) && !strcmp(answer, "")) {
statusbar(_("Search Cancelled")); statusbar(_("Search Cancelled"));
search_abort(); search_abort();
return 0; return 0;
} }
/* If answer is now == "", then PICO_MSGS is set. So, copy
last_search into answer... */
if (!strcmp(answer, ""))
answer = mallocstrcpy(answer, last_search);
else
last_search = mallocstrcpy(last_search, answer);
search_last_line = 0; search_last_line = 0;
findnextstr(0, current, current_x, answer); findnextstr(0, current, current_x, answer);
search_abort(); search_abort();
...@@ -446,7 +480,6 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, ...@@ -446,7 +480,6 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
replace_abort(); replace_abort();
return 0; return 0;
case 0: /* They actually entered something */ case 0: /* They actually entered something */
last_replace = mallocstrcpy(last_replace, answer);
break; break;
default: default:
if (*i != -2) { /* First page, last page, for example if (*i != -2) { /* First page, last page, for example
...@@ -457,6 +490,7 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, ...@@ -457,6 +490,7 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
} }
} }
last_replace = mallocstrcpy(last_replace, answer);
while (1) { while (1) {
/* Sweet optimization by Rocco here */ /* Sweet optimization by Rocco here */
...@@ -550,13 +584,21 @@ int do_replace(void) ...@@ -550,13 +584,21 @@ int do_replace(void)
} }
/* Again, there was a previous string but they deleted it and hit enter */ /* Again, there was a previous string but they deleted it and hit enter */
if (!strcmp(answer, "")) { if (!ISSET(PICO_MSGS) && !strcmp(answer, "")) {
statusbar(_("Replace Cancelled")); statusbar(_("Replace Cancelled"));
replace_abort(); replace_abort();
return 0; return 0;
} }
/* If answer is now == "", then PICO_MSGS is set. So, copy
last_search into answer (and prevanswer)... */
if (!strcmp(answer, "")) {
answer = mallocstrcpy(answer, last_search);
prevanswer = mallocstrcpy(prevanswer, last_search);
} else {
last_search = mallocstrcpy(last_search, answer);
prevanswer = mallocstrcpy(prevanswer, answer); prevanswer = mallocstrcpy(prevanswer, answer);
}
if (ISSET(PICO_MSGS)) { if (ISSET(PICO_MSGS)) {
buf = nmalloc(strlen(last_replace) + 5); buf = nmalloc(strlen(last_replace) + 5);
......
...@@ -129,6 +129,11 @@ void *mallocstrcpy(void *dest, void *src) ...@@ -129,6 +129,11 @@ void *mallocstrcpy(void *dest, void *src)
if (dest != NULL) if (dest != NULL)
free(dest); free(dest);
if (src == NULL) {
dest = NULL;
return(dest);
}
dest = nmalloc(strlen(src) + 1); dest = nmalloc(strlen(src) + 1);
strcpy(dest, src); strcpy(dest, src);
......
...@@ -268,7 +268,10 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, ...@@ -268,7 +268,10 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
while ((kbinput = wgetch(bottomwin)) != 13) { while ((kbinput = wgetch(bottomwin)) != 13) {
for (j = 0; j <= slen - 1; j++) { for (j = 0; j <= slen - 1; j++) {
if (kbinput == s[j].val) { if (kbinput == s[j].val) {
answer = mallocstrcpy(answer, "");
/* We shouldn't discard the answer it gave, just because
we hit a keystroke, GEEZ! */
answer = mallocstrcpy(answer, inputbuf);
free(inputbuf); free(inputbuf);
return s[j].val; return s[j].val;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment