From dab737cc42a844e439b58562804f4ce60689c792 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 6 Mar 2007 13:14:52 +0100 Subject: [PATCH] look: fix problem with !isalnum() words for example "$ look apple-pie" Signed-off-by: Karel Zak --- misc-utils/look.c | 5 ++++- tests/expected/ts-look-separator | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/misc-utils/look.c b/misc-utils/look.c index f7bcc16e..7ffd8a3e 100644 --- a/misc-utils/look.c +++ b/misc-utils/look.c @@ -327,9 +327,12 @@ compare(char *s2, char *s2end) { /* copy, ignoring things that should be ignored */ p = comparbuf; i = stringlen; - while(s2 < s2end && *s2 != '\n' && i--) { + while(s2 < s2end && *s2 != '\n' && i) { if (!dflag || isalnum(*s2)) + { *p++ = *s2; + i--; + } s2++; } *p = 0; diff --git a/tests/expected/ts-look-separator b/tests/expected/ts-look-separator index e69de29b..8c19d036 100644 --- a/tests/expected/ts-look-separator +++ b/tests/expected/ts-look-separator @@ -0,0 +1 @@ +apple-pie -- 2.39.5