From 69a2852e1d5661bc042dcc90c16e9aa7777c7340 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 11 Oct 2012 21:47:26 +0200 Subject: [PATCH] src/ 2012-10-11 Jan Kratochvil * readelf.c (handle_core_item) : Make run an outer block variable. Increase run only if LASTBIT != 0. Print last element only if RUN > 0. Signed-off-by: Jan Kratochvil --- src/readelf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index 5d167ebc7..470af4d9c 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -7515,19 +7515,19 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc, } unsigned int lastbit = 0; + unsigned int run = 0; for (const unsigned int *i = data; (void *) i < data + count * size; ++i) { unsigned int bit = ((void *) i - data) * 8; unsigned int w = negate ? ~*i : *i; - unsigned int run = 0; while (w != 0) { int n = ffs (w); w >>= n; bit += n; - if (lastbit + 1 == bit) + if (lastbit != 0 && lastbit + 1 == bit) ++run; else { @@ -7543,8 +7543,8 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc, lastbit = bit; } } - if (lastbit > 0 && lastbit + 1 != nbits) - p += sprintf (p, "-%u", nbits - bias); + if (lastbit > 0 && run > 0 && lastbit + 1 != nbits) + p += sprintf (p, "-%u", lastbit - bias); colno = print_core_item (colno, ',', ITEM_WRAP_COLUMN, 0, item->name, 4 + nbits * 4, -- 2.47.2