[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] fix infocmp/tic hang
From: |
Thomas Dickey |
Subject: |
Re: [PATCH] fix infocmp/tic hang |
Date: |
Thu, 22 Jun 2017 21:00:30 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Thu, Jun 22, 2017 at 11:48:31PM +0300, Emanuele Giaquinta wrote:
> Hello,
>
> starting with ncurses-6.0-20170506, infocmp and tic -c hang with
> terminal descriptions specifying pairs#7744. The problem is that
> dump_entry.c:number_format does not terminate if the input number
> does not belong to any of the tested intervals, because the
> expression (mm = (1UL << nn)) never becomes zero. The behaviour is
> undefined for nn equal to 32 (or 64), and on x86 the SHL instruction
> considers only the lowest 5 (or 6) bits of the shift count so the
> expression wraps to 1. The attached patch fixes the issue.
that's odd: your explanation sounds reasonable, since (I see...) that
it's been a couple of months since I'd built with 32-bit Linux.
Mostly (aside from Solaris), it's been 64-bit configurations.
However - what's odd is that in a test-build now (using 20170617),
I don't see a problem (building on 32-bit Linux). tic works for
xterm-88color (pairs#7744) and so does infocmp.
> Emanuele
> --- progs/dump_entry.c.orig 2017-06-22 23:06:28.000000000 +0300
> +++ progs/dump_entry.c 2017-06-22 23:46:42.000000000 +0300
> @@ -807,8 +807,10 @@ number_format(int value)
> if ((outform != F_TERMCAP) && (value > 255)) {
> unsigned long lv = (unsigned long) value;
> unsigned long mm;
> + int bits = sizeof(unsigned long) * 8;
> int nn;
> - for (nn = 8; (mm = (1UL << nn)) != 0; ++nn) {
> + for (nn = 8; nn < bits; ++nn) {
> + mm = 1UL << nn;
> if ((mm - 16) <= lv && (mm + 16) > lv) {
> result = "%#x";
> break;
--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature