From: Chris Allegretta Date: Thu, 16 Nov 2000 06:01:10 +0000 (+0000) Subject: Updated BUGS, optimized search_init a little, fixed bug #47 X-Git-Tag: v0.9.20~11 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5bf51d3872b442da4473fa55c78132ffbba1265a;p=nano.git 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 --- diff --git a/BUGS b/BUGS index bf5a54fc..fec77c0b 100644 --- a/BUGS +++ b/BUGS @@ -2,7 +2,9 @@ certain col values. (9) [FIXED] - edit_refresh() and update_line() do not handle selecting text when the 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 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) @@ -71,14 +73,15 @@ when called from inside mutt (among other settings) (45). [FIXED] - In replace, hitting the Goto line shortcut key does nothing after a 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 ** - 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 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). $Id$ diff --git a/ChangeLog b/ChangeLog index 0beeafae..85722265 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,9 @@ CVS Code - hacked them a lot, changes to nanogetstr(). nanogetstr() and statusq() now take an arg for whether or not to allow tab 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: do_writeout() - Change strcpy to answer to mallocstrcpy. diff --git a/po/nano.pot b/po/nano.pot index 429ac2de..f9a74242 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-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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -32,7 +32,7 @@ msgstr "" msgid "Read %d lines" msgstr "" -#: files.c:219 search.c:164 +#: files.c:219 search.c:188 #, c-format msgid "\"%s\" not found" msgstr "" @@ -384,7 +384,7 @@ msgid "Case Sens" msgstr "" #: 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" msgstr "" @@ -727,87 +727,87 @@ msgstr "" msgid "I got Alt-%c! (%d)\n" msgstr "" -#: search.c:99 +#: search.c:118 #, c-format msgid "Case Sensitive Regexp Search%s%s" msgstr "" -#: search.c:101 +#: search.c:120 #, c-format msgid "Regexp Search%s%s" msgstr "" -#: search.c:103 +#: search.c:122 #, c-format msgid "Case Sensitive Search%s%s" msgstr "" -#: search.c:105 +#: search.c:124 #, c-format msgid "Search%s%s" msgstr "" -#: search.c:108 +#: search.c:127 msgid " (to replace)" msgstr "" -#: search.c:121 search.c:290 +#: search.c:136 search.c:318 msgid "Search Cancelled" msgstr "" -#: search.c:168 +#: search.c:194 #, c-format msgid "\"%s...\" not found" msgstr "" -#: search.c:215 +#: search.c:243 msgid "Search Wrapped" msgstr "" -#: search.c:304 +#: search.c:340 #, c-format msgid "Replaced %d occurences" msgstr "" -#: search.c:306 +#: search.c:342 msgid "Replaced 1 occurence" msgstr "" -#: search.c:443 search.c:536 search.c:552 +#: search.c:479 search.c:572 search.c:588 msgid "Replace Cancelled" msgstr "" -#: search.c:486 +#: search.c:522 msgid "Replace this instance?" msgstr "" -#: search.c:494 +#: search.c:530 msgid "Replace failed: unknown subexpression!" msgstr "" -#: search.c:569 +#: search.c:613 #, c-format msgid "Replace with [%s]" msgstr "" -#: search.c:573 search.c:577 +#: search.c:617 search.c:621 msgid "Replace with" msgstr "" #. Ask for it -#: search.c:612 +#: search.c:656 msgid "Enter line number" msgstr "" -#: search.c:614 +#: search.c:658 msgid "Aborted" msgstr "" -#: search.c:634 +#: search.c:678 msgid "Come on, be reasonable" msgstr "" -#: search.c:639 +#: search.c:683 #, c-format msgid "Only %d lines available, skipping to last line" msgstr "" @@ -817,67 +817,67 @@ msgstr "" msgid "actual_x_from_start for xplus=%d returned %d\n" msgstr "" -#: winio.c:424 +#: winio.c:427 #, c-format msgid "input '%c' (%d)\n" msgstr "" -#: winio.c:462 +#: winio.c:465 msgid "New Buffer" msgstr "" -#: winio.c:465 +#: winio.c:468 msgid " File: ..." msgstr "" -#: winio.c:473 +#: winio.c:476 msgid "Modified" msgstr "" -#: winio.c:925 +#: winio.c:928 #, c-format msgid "Moved to (%d, %d) in edit buffer\n" msgstr "" -#: winio.c:936 +#: winio.c:939 #, c-format msgid "current->data = \"%s\"\n" msgstr "" -#: winio.c:981 +#: winio.c:984 #, c-format msgid "I got \"%s\"\n" msgstr "" -#: winio.c:1006 +#: winio.c:1009 msgid "Yes" msgstr "" -#: winio.c:1008 +#: winio.c:1011 msgid "All" msgstr "" -#: winio.c:1010 +#: winio.c:1013 msgid "No" msgstr "" -#: winio.c:1147 +#: winio.c:1150 #, c-format msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgstr "" -#: winio.c:1151 +#: winio.c:1154 msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgstr "" -#: winio.c:1279 +#: winio.c:1282 msgid "Dumping file buffer to stderr...\n" msgstr "" -#: winio.c:1281 +#: winio.c:1284 msgid "Dumping cutbuffer to stderr...\n" msgstr "" -#: winio.c:1283 +#: winio.c:1286 msgid "Dumping a buffer to stderr...\n" msgstr "" diff --git a/search.c b/search.c index df58fc40..2f26bc4f 100644 --- a/search.c +++ b/search.c @@ -74,12 +74,29 @@ int search_init(int replacing) int i = 0; char *buf; char *prompt, *reprompt = ""; + static char *backupstring = NULL; search_init_globals(); buf = nmalloc(strlen(last_search) + 5); 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 (ISSET(PICO_MSGS)) { if (last_search[0]) { @@ -94,6 +111,8 @@ int search_init(int replacing) buf[0] = '\0'; } } + else + strcpy(buf, ""); if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE)) prompt = _("Case Sensitive Regexp Search%s%s"); @@ -107,36 +126,38 @@ int search_init(int replacing) if (replacing) reprompt = _(" (to replace)"); - if (ISSET(PICO_MSGS)) - i = statusq(0, replacing ? replace_list : whereis_list, - replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "", - prompt, reprompt, buf); - else - i = statusq(0, replacing ? replace_list : whereis_list, - replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, last_search, - prompt, reprompt, ""); + /* This is now one simple call. It just does a lot */ + i = statusq(0, replacing ? replace_list : whereis_list, + replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, backupstring, + prompt, reprompt, ""); /* Cancel any search, or just return with no previous search */ if ((i == -1) || (i < 0 && !last_search[0])) { statusbar(_("Search Cancelled")); reset_cursor(); + free(backupstring); + backupstring = NULL; return -1; } else if (i == -2) { /* Same string */ - answer = mallocstrcpy(answer, last_search); #ifdef HAVE_REGEX_H if (ISSET(USE_REGEXP)) regexp_init(answer); +#else + ; #endif } else if (i == 0) { /* They entered something new */ - last_search = mallocstrcpy(last_search, answer); #ifdef HAVE_REGEX_H if (ISSET(USE_REGEXP)) regexp_init(answer); #endif - /* Blow away last_replace because they entered a new search - string....uh, right? =) */ + free(backupstring); + backupstring = NULL; last_replace[0] = '\0'; } else if (i == NANO_CASE_KEY) { /* They want it case sensitive */ + free(backupstring); + backupstring = NULL; + backupstring = mallocstrcpy(backupstring, answer); + if (ISSET(CASE_SENSITIVE)) UNSET(CASE_SENSITIVE); else @@ -144,12 +165,17 @@ int search_init(int replacing) return 1; } else if (i == NANO_OTHERSEARCH_KEY) { + backupstring = mallocstrcpy(backupstring, answer); return -2; /* Call the opposite search function */ } else if (i == NANO_FROMSEARCHTOGOTO_KEY) { + free(backupstring); + backupstring = NULL; do_gotoline_void(); return -3; } else { /* First line key, etc. */ do_early_abort(); + free(backupstring); + backupstring = NULL; return -3; } @@ -288,12 +314,20 @@ int do_search(void) } /* The sneaky user deleted the previous search string */ - if (!strcmp(answer, "")) { + if (!ISSET(PICO_MSGS) && !strcmp(answer, "")) { statusbar(_("Search Cancelled")); search_abort(); 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; findnextstr(0, current, current_x, answer); search_abort(); @@ -446,7 +480,6 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, replace_abort(); return 0; case 0: /* They actually entered something */ - last_replace = mallocstrcpy(last_replace, answer); break; default: if (*i != -2) { /* First page, last page, for example @@ -457,6 +490,7 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, } } + last_replace = mallocstrcpy(last_replace, answer); while (1) { /* Sweet optimization by Rocco here */ @@ -550,13 +584,21 @@ int do_replace(void) } /* 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")); replace_abort(); return 0; } - prevanswer = mallocstrcpy(prevanswer, answer); + /* 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); + } if (ISSET(PICO_MSGS)) { buf = nmalloc(strlen(last_replace) + 5); diff --git a/utils.c b/utils.c index 4b248053..e38d88f1 100644 --- a/utils.c +++ b/utils.c @@ -129,6 +129,11 @@ void *mallocstrcpy(void *dest, void *src) if (dest != NULL) free(dest); + if (src == NULL) { + dest = NULL; + return(dest); + } + dest = nmalloc(strlen(src) + 1); strcpy(dest, src); diff --git a/winio.c b/winio.c index f31e0f92..edd54a54 100644 --- a/winio.c +++ b/winio.c @@ -268,7 +268,10 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, while ((kbinput = wgetch(bottomwin)) != 13) { for (j = 0; j <= slen - 1; j++) { 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); return s[j].val; }