From 0c874637eefe7b6e6702c232b308cf8deb5c4409 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 11 Apr 2012 04:11:12 -0500 Subject: [PATCH] top: extend case-insensitive option to include 'Locate' Signed-off-by: Jim Warner --- top/top.c | 2 +- top/top.h | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/top/top.c b/top/top.c index 9e284536..6da43bda 100644 --- a/top/top.c +++ b/top/top.c @@ -2850,7 +2850,7 @@ static void find_string (int ch) { if (str[0]) { for (i = Curwin->begtask; i < Frame_maxtask; i++) { task_show(Curwin, Curwin->ppt[i], buf); - if (strstr(buf, str)) { + if (STRSTR(buf, str)) { found = 1; if (i == Curwin->begtask) continue; Curwin->begtask = i; diff --git a/top/top.h b/top/top.h index 71644932..6f2bc30b 100644 --- a/top/top.h +++ b/top/top.h @@ -39,7 +39,7 @@ //#define PRETENDNOCAP /* use a terminal without essential caps */ //#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */ //#define RMAN_IGNORED /* don't consider auto right margin glitch */ -//#define STRCMPNOCASE /* use strcasecmp vs. strcmp when sorting */ +//#define STRINGCASENO /* case insenstive compare/locate versions */ //#define TERMIO_PROXY /* true line editing, beyond native input */ //#define TREE_NORESET /* sort keys do NOT force forest view OFF */ //#define TREE_ONEPASS /* for speed, tolerate dangling children */ @@ -73,10 +73,14 @@ #define linux_version_code LINUX_VERSION(2,5,43) #endif -#ifdef STRCMPNOCASE -#define STRSORTCMP strcasecmp +#ifdef STRINGCASENO + // pretend as if #define _GNU_SOURCE +char *strcasestr(const char *haystack, const char *needle); +#define STRSTR strcasestr +#define STRCMP strcasecmp #else -#define STRSORTCMP strcmp +#define STRSTR strstr +#define STRCMP strcmp #endif @@ -412,13 +416,13 @@ typedef struct WIN_t { #define SCB_STRS(f,s) \ static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \ if (!(*P)->s || !(*Q)->s) return SORT_eq; \ - return Frame_srtflg * STRSORTCMP((*Q)->s, (*P)->s); } + return Frame_srtflg * STRCMP((*Q)->s, (*P)->s); } #define SCB_STRV(f,b,v,s) \ static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \ if (b) { \ if (!(*P)->v || !(*Q)->v) return SORT_eq; \ - return Frame_srtflg * STRSORTCMP((*Q)->v[0], (*P)->v[0]); } \ - return Frame_srtflg * STRSORTCMP((*Q)->s, (*P)->s); } + return Frame_srtflg * STRCMP((*Q)->v[0], (*P)->v[0]); } \ + return Frame_srtflg * STRCMP((*Q)->s, (*P)->s); } #define SCB_STRX(f,s) \ int strverscmp(const char *s1, const char *s2); \ static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \ -- 2.40.0