From: Karel Zak Date: Tue, 6 Mar 2007 12:14:52 +0000 (+0100) Subject: look: fix problem with !isalnum() words X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dab737cc42a844e439b58562804f4ce60689c792;p=util-linux look: fix problem with !isalnum() words for example "$ look apple-pie" Signed-off-by: Karel Zak --- 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