From: Jim Warner Date: Wed, 6 Mar 2013 06:00:00 +0000 (-0600) Subject: top: fine tune (ie. fix) 'other filter' negation logic X-Git-Tag: v3.3.7~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a50f39971bbf9e4e4f0cab9461cea50569a213e;p=procps-ng top: fine tune (ie. fix) 'other filter' negation logic Two too many of these '=' (cooks) spoiled top's broth. There exists an unintentional variation on the classic error: off-by-one. When a negation symbol is used with top's new relational 'other filter' provision, one too many 'matches' are excluded. This happened because top covered only 2 of the 3 potential strcmp return codes. When the strings were equal, they were simply dropped. So this patch will uninvent that particular variation! (everything is perfectly justified plus right margins) (are completely filled, but of course it must be luck) Reference(s): commit 2c2c5f5cd2f90c46c778fad6bc2e4105264cf668 Signed-off-by: Jim Warner --- diff --git a/top/top.c b/top/top.c index 04448f42..d86e5069 100644 --- a/top/top.c +++ b/top/top.c @@ -1347,11 +1347,11 @@ static inline int osel_matched (const WIN_t *q, FLG_t enu, const char *str) { switch (osel->ops) { case '<': // '<' needs the r < 0 unless r = osel->rel(str, osel->val); // '!' which needs an inverse - if ((0 <= r && osel->flg) || (0 >= r && !osel->flg)) return 0; + if ((r >= 0 && osel->flg) || (r < 0 && !osel->flg)) return 0; break; case '>': // '>' needs the r > 0 unless r = osel->rel(str, osel->val); // '!' which needs an inverse - if ((0 >= r && osel->flg) || (0 <= r && !osel->flg)) return 0; + if ((r <= 0 && osel->flg) || (r > 0 && !osel->flg)) return 0; break; default: { char *p = osel->sel(str, osel->val);