From 869fef6bfafd8958e68075c3404612c5884b7fb7 Mon Sep 17 00:00:00 2001 From: Mark Grondona <mgrondona@llnl.gov> Date: Fri, 2 Apr 2004 00:27:58 +0000 Subject: [PATCH] o incorporate fixes from latest hostlist.c in lsd-tools --- src/common/hostlist.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/hostlist.c b/src/common/hostlist.c index af897a93992..0722be7785b 100644 --- a/src/common/hostlist.c +++ b/src/common/hostlist.c @@ -804,7 +804,7 @@ static int hostrange_width_combine(hostrange_t h0, hostrange_t h1) static int hostrange_empty(hostrange_t hr) { assert(hr != NULL); - return hr->hi < hr->lo; + return ((hr->hi < hr->lo) || (hr->hi == (unsigned long) -1)); } /* return the string representation of the last host in hostrange hr @@ -2214,9 +2214,11 @@ static void _iterator_advance(hostlist_iterator_t i) { assert(i != NULL); assert(i->magic == HOSTLIST_MAGIC); + if (i->idx > i->hl->nranges - 1) return; - if (++(i->depth) > i->hr->hi - i->hr->lo) { + + if (++(i->depth) > (i->hr->hi - i->hr->lo)) { i->depth = 0; i->hr = i->hl->hr[++i->idx]; } @@ -2300,12 +2302,12 @@ int hostlist_remove(hostlist_iterator_t i) if (new) { hostlist_insert_range(i->hl, new, i->idx + 1); hostrange_destroy(new); - i->hr = i->hl->hr[i->idx]; + i->hr = i->hl->hr[++i->idx]; i->depth = -1; } else if (hostrange_empty(i->hr)) { hostlist_delete_range(i->hl, i->idx); - i->hr = i->hl->hr[i->idx]; - i->depth = -1; + /* i->hr = i->hl->hr[i->idx]; + i->depth = -1; */ } else i->depth--; -- GitLab