From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 56BEF22BAD for ; Thu, 21 Mar 2024 06:23:46 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1710998626; b=eZOShLRt6pOvc6TxK4bjVu9WKEt5enhH6c/SGu7uEZ5jI7zVFPT1/qIjJJIT0sggHYXt/4Y6XF iEuMe9wL11krXEEVNt4R7+4+Yyc3x32B5pLe/4GtxWk7GThnqOhnaD7KSaKfFDFjVQYlMzAnbG zN4DZJkPdBFzeHr9jhArLBPpFA5pBotBGQa8u7BYFJJbXc1BX0NedgUdgkdF6qLH6z0hAHvs4e kjU7PDDDNSH/8UUWQnxMoBQSEwKM53+BFxuyRoXSt8A5hGI650ucNyhbAvW96NZnqi7z3Fv24A yT0fGKTjSU0dZo0t//+soZ7H/7vvOaNqCfEThq8b0fyVvw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta-snd-w03.biglobe.ne.jp) smtp.remote-ip=27.86.113.19; dmarc=none header.from=kba.biglobe.ne.jp; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1710998626; bh=CDUPeMmmOp2VxevL/jc9jjher/dGHkE+Ti3Uwux/rFU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Message-ID:In-Reply-To:To:References:Date:Subject: MIME-Version:Content-Transfer-Encoding:Content-Type:From:DKIM-Signature; b=N6mrR5adnFgHxZtOE3nrymrcMKvZOBoCXJYx1sThMr8XptW+WQ2CchVjyEQLhapubSzBhkG6pN gP+l+GD0lMR7rI7JikC61nhC6O/yUtgcazk3IoHNZX1tBj7JJou63IJVGGEag5wTOprpUcTkUu cNtef36OG6Pk4jOqU7iWxnqWV0YvUvkGZ/PGVku8d87CBJqYEZBKx5j2drdVHk1Bd1qaDGKgbK SocTr/UWHkC4wU1aoPrHjp+x3bQHDfRAY199/+HAlbUbqVH8MGNr1zuJPuNJ45xGqH3xmUKz/z X6mOJFMvJC7LTuzjUNkQOMiZ6JX6qvvebrF9wv4nx9CIyg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:Content-Transfer-Encoding:Content-Type:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ulxnyMAPVD9CPv+iKC4CSqa8YwCN3bDVb+Le//j/AIA=; b=PDDlW9RJakoLDfdJNrXWirGkq8 vVVB9fJ3kgqL+N1n5pJPefzKYXit0ww3q+2YocroJd+jJ9MQxQiDlbsEr0/tbCNfMbE6jZL591WK6 8Vlhm96v02c1khdolYDlXjWPp7Gvny86Yib+OY0HKT9CUDqVxk44kIZp7kICdSp4mIpa/1Hu/tZfa GBexe9xxHOZRbTFmcFls7lj/yywe7TnVZ61I1QSrfi+rj5gpXjKYOjaBxrLSU5ZsT7s6WEQFdoTxa p2LLg1l+cCES5zvJC5WI65CIaF52j991fRCh1uPaT8LbLNrcqrOvxPqDX2i3HoHICNTpKO6AB+X6J WRUb+PQA==; Received: by zero.zsh.org with local id 1rnAu2-000GeU-1H; Thu, 21 Mar 2024 05:23:46 +0000 Authentication-Results: zsh.org; iprev=pass (mta-snd-w03.biglobe.ne.jp) smtp.remote-ip=27.86.113.19; dmarc=none header.from=kba.biglobe.ne.jp; arc=none Received: from mta-snd-w03.biglobe.ne.jp ([27.86.113.19]:64865) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rnAtP-000GKi-Gi; Thu, 21 Mar 2024 05:23:10 +0000 Received: from mail.biglobe.ne.jp by omta1014.biglobe.ne.jp with ESMTP id <20240321052301027.THIC.60167.mail.biglobe.ne.jp@biglobe.ne.jp> for ; Thu, 21 Mar 2024 14:23:01 +0900 From: Jun T Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: HIST_IGNORE_DUPS also ignores command lines that differ by a space between quotes Date: Thu, 21 Mar 2024 14:22:46 +0900 References: <20240313123817.GA3492761@cventin.lip.ens-lyon.fr> <20240315125317.GC3738413@cventin.lip.ens-lyon.fr> <20240319105745.GA4811@qaa.vinc17.org> <20240319123444.GB4811@qaa.vinc17.org> To: zsh-workers@zsh.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3731.700.6) X-Biglobe-Sender: takimoto-j@kba.biglobe.ne.jp X-Seq: 52785 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: I think HIST_IGNORE_DUPS would work as expected even without HIST_REDUCCE_BLANKS if we use the information in chwords and hist_ring->words, as in the patch below, for example. we can't simply replace histstrcmp() with the one that uses the words[] array in struct histent. But I think Bart's patch is enough for HIST_IGNORE_ALL_DUPS and history searching (and recommend users to set HIST_REDUCCE_BLANKS). diff --git a/Src/hist.c b/Src/hist.c index 1a00c30ed..3a52ee038 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -1467,6 +1467,36 @@ should_ignore_line(Eprog prog) return 0; } +/* + * compare the history entry in {chline,chwords} with the previous + * one in hist_ring->{node.nam,words}. Returns 0 if the two are equal + * (except for insignificant spaces), nonzero otherwise. + */ + +/**/ +static int +hist_compare(void) +{ + int i; + + if (isset(HISTREDUCEBLANKS)) + return strcmp(chline, hist_ring->node.nam); + if (chwordpos/2 != hist_ring->nwords) + return 1; + for (i = 0; i < chwordpos; i += 2) { + const char *p = &chline[chwords[i]]; + const char *q = &hist_ring->node.nam[hist_ring->words[i]]; + int n = chwords[i+1] - chwords[i], j; + + if (n != hist_ring->words[i+1] - hist_ring->words[i]) + return 1; + for (j=0; j < n; ++j) + if (p[j] != q[j]) + return 1; + } + return 0; +} + /* say we're done using the history mechanism */ /**/ @@ -1600,7 +1630,7 @@ hend(Eprog prog) else newflags = 0; if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && save > 0 - && hist_ring && histstrcmp(chline, hist_ring->node.nam) == 0) { + && hist_ring && hist_compare() == 0) { /* This history entry compares the same as the previous. * In case minor changes were made, we overwrite the * previous one with the current one. This also gets the