search: find, and thus delete, only exact matches from history
This reverts commit df8c3de
from six years ago, which prevented a crash
on the Armel/Maemo platforms but causes nano to lose history items.
The strncmp() function on those platforms treats size_t numbers with
the high bit set as if they were zero. To avoid that, use a number
that cannot be seen as negative, as suggested by <alpha@qzx.com>.
This fixes https://savannah.gnu.org/bugs/?48048.
Tested-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
master
parent
e198c85053
commit
660584c1ea
|
@ -600,6 +600,9 @@ enum
|
||||||
/* The maximum number of bytes buffered at one time. */
|
/* The maximum number of bytes buffered at one time. */
|
||||||
#define MAX_BUF_SIZE 128
|
#define MAX_BUF_SIZE 128
|
||||||
|
|
||||||
|
/* The largest size_t number that doesn't have the high bit set. */
|
||||||
|
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
|
||||||
|
|
||||||
#ifdef REVISION
|
#ifdef REVISION
|
||||||
#define BRANDING PACKAGE_VERSION"-git "REVISION
|
#define BRANDING PACKAGE_VERSION"-git "REVISION
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1221,7 +1221,7 @@ void update_history(filestruct **h, const char *s)
|
||||||
assert(hage != NULL && hbot != NULL);
|
assert(hage != NULL && hbot != NULL);
|
||||||
|
|
||||||
/* See if this string is already in the history. */
|
/* See if this string is already in the history. */
|
||||||
thesame = find_history(*hbot, *hage, s, strlen(s));
|
thesame = find_history(*hbot, *hage, s, HIGHEST_POSITIVE);
|
||||||
|
|
||||||
/* If an identical string was found, delete that item. */
|
/* If an identical string was found, delete that item. */
|
||||||
if (thesame != NULL) {
|
if (thesame != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue