[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] solving a history bug in nano [patch]

From: Benno Schulenberg
Subject: Re: [Nano-devel] solving a history bug in nano [patch]
Date: Tue, 31 May 2016 10:20:55 +0200

On Mon, May 30, 2016, at 21:20, Tito wrote:
> On 05/30/2016 05:51 PM, address@hidden wrote:
> > The value might be converted to a signed int somewhere inside find_history.

I don't see how -- it gets passed directly to strncmp().

> Perhaps use the largest value possible that can never be negative?
> >
> > #define SIZE_T_HALF_MAX ((~(size_t)0)>>1)

Tito, did you try using ((~(size_t)0)>>1) instead of (size_t)-1?

> what I would do is (based on a very superficial look at the code):
> 1) when reading in search history from a history file set it to
>     the length of the longest string and not more than  SIZE_T_HALF_MAX

That means an extra global variable; there shouldn't be any need
for that.

> this would avoid in most use cases to waste memory as search strings in
> my experience are rather short.

No memory is wasted now.  The (size_t)-1 just means: compare the
whole strings.  When the strings are stored, they are mallocstrcpy'd,
so just the required space is allocated.

Did you try running nano with gdb?  I would still like to know why and
where it segfaults for you.


-- - Email service worth paying for. Try it for free

reply via email to

[Prev in Thread] Current Thread [Next in Thread]