From 8502c4961930cadb56f5d9f6062839aa558a8026 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 21 Mar 2022 00:00:00 -0500 Subject: [PATCH] top: why not maximize usage of some manifest constants Signed-off-by: Jim Warner --- top/top.c | 6 +++--- top/top.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/top/top.c b/top/top.c index d8889bbc..04cf084b 100644 --- a/top/top.c +++ b/top/top.c @@ -2307,8 +2307,8 @@ static void fields_utility (void) { #endif #define swapEM { int c; unSCRL; c = w->rc.fieldscur[i]; \ w->rc.fieldscur[i] = *p; *p = c; p = &w->rc.fieldscur[i]; } - #define spewFI { int *t; f = w->rc.sortindx; t = msch(w->rc.fieldscur, ENUcvt(f, ENUon), EU_MAXPFLGS); \ - if (!t) t = msch(w->rc.fieldscur, ENUcvt(f, ENUoff), EU_MAXPFLGS); \ + #define spewFI { int *t; f = w->rc.sortindx; t = msch(w->rc.fieldscur, ENUcvt(f, FLDon), EU_MAXPFLGS); \ + if (!t) t = msch(w->rc.fieldscur, ENUcvt(f, FLDoff), EU_MAXPFLGS); \ i = (t) ? (int)(t - w->rc.fieldscur) : 0; } WIN_t *w = Curwin; // avoid gcc bloat with a local copy const char *h = NULL; @@ -3666,7 +3666,7 @@ static int cfg_xform (WIN_t *q, char *flds, const char *defs) { for (i = 0; i < x; i++) { f = ((unsigned char)flds[i] & 0x7f); f = f << 1; - if ((unsigned char)flds[i] & 0x80) f |= 0x01; + if ((unsigned char)flds[i] & 0x80) f |= FLDon; *(pn + i) = f; } diff --git a/top/top.h b/top/top.h index 5e499d92..40fe0ecb 100644 --- a/top/top.h +++ b/top/top.h @@ -399,14 +399,14 @@ typedef struct WIN_t { #define VIZTOGw(q,f) (VIZISw(q)) ? TOGw(q,(f)) : win_warn(Warn_VIZ) // Used to test/manipulte fieldscur values +#define FLDon 0x01 +#define FLDoff 0x00 #define FLDget(q,i) ( (((q)->rc.fieldscur[i]) >> 1) - FLD_OFFSET ) -#define FLDtog(q,i) ( (q)->rc.fieldscur[i] ^= 0x01 ) -#define FLDviz(q,i) ( (q)->rc.fieldscur[i] & 0x01 ) +#define FLDtog(q,i) ( (q)->rc.fieldscur[i] ^= FLDon ) +#define FLDviz(q,i) ( (q)->rc.fieldscur[i] & FLDon ) #define ENUviz(w,E) ( NULL != msch((w)->procflgs, E, w->maxpflgs) ) #define ENUpos(w,E) ( (int)(msch((w)->pflgsall, E, (w)->totpflgs) - (w)->pflgsall) ) -#define ENUcvt(E,x) ( (int)(((E + FLD_OFFSET) << 1) | x) ) -#define ENUon 0x01 -#define ENUoff 0x00 +#define ENUcvt(E,x) ( (int)((E + FLD_OFFSET) << 1) | x ) // Support for variable width columns (and potentially scrolling too) #define VARcol(E) (-1 == Fieldstab[E].width)