From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11382 invoked from network); 5 Jun 1999 21:01:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Jun 1999 21:01:53 -0000 Received: (qmail 13810 invoked by alias); 5 Jun 1999 21:01:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6476 Received: (qmail 13803 invoked from network); 5 Jun 1999 21:01:46 -0000 Date: Sat, 5 Jun 1999 14:01:43 -0700 (PDT) From: Wayne Davison To: Bart Schaefer cc: zsh-workers@sunsite.auc.dk Subject: PATCH: 3.0.6-pre-4: whitespace-ignoring strcmp for history In-Reply-To: <990605171123.ZM8632@candle.brasslantern.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Here's a minor improvement for 3.0.6-pre-4: When the histcmp() function is comparing a line that wasn't lexed, it now ignores whitespace differences (I took my whitespace-ignoring strcmp() code from my recent history changes and integrated it into the histcmp() function). ..wayne.. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8--- Index: Src/hist.c --- zsh-3.0.6-pre-4/Src/hist.c Sat Jun 5 12:41:11 1999 +++ ./Src/hist.c Sat Jun 5 12:46:31 1999 @@ -592,11 +592,30 @@ int kword, lword; int nwords = chwordpos/2; - /* If the history entry came from a file, the words were not - * divided by the lexer so we have to resort to strcmp. + /* If the history entry came from a file, the words were not divided by + * the lexer so we have to resort to a whitespace-ignoring compare. */ - if (he->flags & HIST_READ) - return strcmp(he->text, chline); + if (he->flags & HIST_READ) { + char *str1 = he->text, *str2 = chline; + + while (inblank(*str1)) str1++; + while (inblank(*str2)) str2++; + while (*str1 && *str2) { + if (inblank(*str1)) { + if (!inblank(*str2)) + break; + do str1++; while (inblank(*str1)); + do str2++; while (inblank(*str2)); + } + else { + if (*str1 != *str2) + break; + str1++; + str2++; + } + } + return *str1 - *str2; + } if (nwords != he->nwords) return 1; ---8<------8<------8<------8<---cut here--->8------>8------>8------>8---