From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25233 invoked from network); 20 Dec 2021 03:41:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Dec 2021 03:41:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1639971671; b=CHKOnkp3PaRfxXXxSIcxYs9XV/uZwG9hDM9rE6L+8Gmz4coZdZlgan7oLeQEzX3oa1GSyOWTp7 D5XKTdXPdMeXbCaUFr2jFGANhHHnyxJGw5rjsgrt9NxHzPLtIcDhvvi959ZhZkhyQlXGNLhFec pbtszTUyOao5TOm6cSC2feAfGTZqlzYaKEOP/+4TiAyAhqvArqN5dCUzLY70AZCgX2bc4DHSOw gqg5yokq7kjXhs3TxJ5V4Ms/+6vmuYwz6yFZAYy3OYz8wwhs62sezVUUaEhrMUhPWMSoWlCmon nUEm/v9geIAuy39IGCva6t7lzjSGauOhQ+7fS4FFPTjjbw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-vk1-f181.google.com) smtp.remote-ip=209.85.221.181; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1639971671; bh=8MTbEhHof8+nrDHZ/RlzPEQ+9I6rbkmbOV0jsAm5tjY=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=etdJm/q7H6NUNWoSOUimcMxk72oLE2lC8xoRyAwC7PWLoVrOzkwYJJpf1PZBCpEZ0KYVCbEr2F Sw7MyFkWdutCH2FaVvAd9PYe8rG3ng/+6RHOO0HiNAsgmh8HSJ311XUvR50LCpq44fxXIdNM0l GElCpepoasE0MBN6pZVUPMlZsqCIFXt0/q6e5vD1w6lmhUGn8Cmz9zYBOhYo1weMiTgI1ejLMb RVrF779Z8cLXxWwA9tZyf2KukYGVTyBwMi63/+q8L5zKWGcQKfwZ4nSTPLx9qILAdt3MA5Zwnh YgTd1V/D1yzWOET7EHvj+rOlnz91rrsg22uVblmjfiPyXA==; 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:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=DyemoCvOFGGHl03BppwCE0VA3O3EdDmHcW/OMZS/tj8=; b=VbxZGJwJI/OBCD/FM/mJNlJS/X ffk4RYDm4A4QIC0ovSsaqgGK12MgYFoUSyzm0s5VeG9gdDnxphxTTW0jFW9TTTDdTAfdzvu/vZ5iK 8g+gIlawRvQn/QM4LDdb+haqT8ohABdlvirB6cbe3pxIr/NKpi+8/C365gugnCT9bpWTS75I/ylIn X6pgUwZyE8qZCg7nbxUmfDcOS9+ZOHumFBoCsuwgUNlk5dSRe5vW2/suxGF47DJfR154ZhpIDVded LmI265nZHzUAl3Lkt+nxwICDGlINQpUYQym4cxg9T737YsXGy3LjoSWYolyDFyG7tHtB+HfsI8/sJ gUtGmVsw==; Received: from authenticated user by zero.zsh.org with local id 1mz9Xy-0003Pb-CR; Mon, 20 Dec 2021 03:41:10 +0000 Authentication-Results: zsh.org; iprev=pass (mail-vk1-f181.google.com) smtp.remote-ip=209.85.221.181; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-vk1-f181.google.com ([209.85.221.181]:46837) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mz9XO-00036B-4v; Mon, 20 Dec 2021 03:40:35 +0000 Received: by mail-vk1-f181.google.com with SMTP id u198so5296305vkb.13 for ; Sun, 19 Dec 2021 19:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DyemoCvOFGGHl03BppwCE0VA3O3EdDmHcW/OMZS/tj8=; b=XCrbp92ek9N9D8949eWTAHE3HH8DJkVSCffDmyEpj3T25kYwhKE9C67NEE9eeHMStB vgMgTDx8UaGgRCtgB7/0SsbBTaeNRYRWa+9Mo8jFMUobomHhhmfK1vC7wI4vXfbbXnwL 81PfO40A2WLjNpKRI61w1iKnvAGBRBmbpO1gc+80avTRyuvZD0m792LbfQG4AsI4GjXX pOPUiSkeyVriAlRgVB24jsuIhgl1bRE4enCU3FjjH5L3ZSZdG+2sf47mPgBOWB+JtS5a VEIvcukOwgoe3XbZSMHfNuiNbEIir3RdMYqpVOTv+buENJYylloouZkmF0j//8XvgSpt CCNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DyemoCvOFGGHl03BppwCE0VA3O3EdDmHcW/OMZS/tj8=; b=JokPXMrk29iz7rssn2COtYhkk1na7zh07RdFu9pp/b7SwHqHIZstvSlsK/eQd7h7G8 Ux6fot8ffxVQdHKUEbjMb8RaV9v5ciWEuqBic+1QR++ppkxzq9AOKB39xOlLEfp72HI0 uH02CjaYN982AFmhszMOJ3mqrhsyUNFEMigPCNtdV5ZczBQTGeNTtPJuUZuyG1meTCHR RiRcY7HxR3mv2g6lRy3Om6kEopfo9+SZVw8rOf7HQdIE1TvUdrRTIY4YiLAlQ2ABvs4h s6u2V2XFY4VCMg9p6vxwypb6ZJj6gBCGZDB/jt8pUhKFdnhxESzzJVuCMWpTBsGgsQTu jHOw== X-Gm-Message-State: AOAM531KisoAG8Cj6+sSpmq7C6PCQZDFtZ3LhyDwtjFKyqfeQmUW2nKU bOICETfuz89jT3PPY9ljFuGD/imQ7uZB9b30Low= X-Google-Smtp-Source: ABdhPJwH6rSbs/gFGZGPwirJKCbpgooFWshgadmksAUfS/zTY5jYCtoFVMukwt/dEVDg66sLzy3gOiSTqVnG1N5JwHI= X-Received: by 2002:a1f:d903:: with SMTP id q3mr5197725vkg.37.1639971632764; Sun, 19 Dec 2021 19:40:32 -0800 (PST) MIME-Version: 1.0 Received: by 2002:ab0:37d5:0:0:0:0:0 with HTTP; Sun, 19 Dec 2021 19:40:32 -0800 (PST) In-Reply-To: References: <26439.1209238907@pws-pc> From: Mikael Magnusson Date: Mon, 20 Dec 2021 04:40:32 +0100 Message-ID: Subject: Re: PATCH: pattern incremental search To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49657 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: [forgot to change the ml address from sunsite.dk] On 12/20/21, Mikael Magnusson wrote: > On 4/26/08, Peter Stephenson wrote: >> I think this is now good enough for some beta testing, though I'm sure >> there must be glitches. It adds >> history-incremental-pattern-search-backward and >> history-incremental-pattern-search-forkward which are ridiculously long >> names but nothing shorter really fits in with the names we have already. >> >> The limitation that only non-overlapping pattern matches on the same >> line are found comes from the parameter substitution code I hijacked to >> do this. It's not needed in this case since there's no substitution. >> If anyone can see a good reason I can alter it. >> >> I've also finished the work of the previous patch that put history >> searching back to using unmetafied strings: it was no longer necessary >> to allocate additional space for each history line at all (unless it was >> modified), so now it doesn't. This should be a significant saving for >> searching large histories. >> >> Index: Src/glob.c >> =================================================================== >> RCS file: /cvsroot/zsh/zsh/Src/glob.c,v >> retrieving revision 1.61 >> diff -u -r1.61 glob.c >> --- Src/glob.c 1 Nov 2007 17:57:57 -0000 1.61 >> +++ Src/glob.c 26 Apr 2008 19:40:43 -0000 >> @@ -2050,12 +2050,6 @@ >> /* do the ${foo%%bar}, ${foo#bar} stuff */ >> /* please do not laugh at this code. */ >> >> -struct repldata { >> - int b, e; /* beginning and end of chunk to replace */ >> - char *replstr; /* replacement string to use */ >> -}; >> -typedef struct repldata *Repldata; >> - >> /* Having found a match in getmatch, decide what part of string >> * to return. The matched part starts b characters into string s >> * and finishes e characters in: 0 <= b <= e <= strlen(s) >> @@ -2073,19 +2067,23 @@ >> char buf[80], *r, *p, *rr; >> int ll = 0, l = strlen(s), bl = 0, t = 0, i; >> >> - if (replstr) { >> + if (replstr || (fl & SUB_LIST)) { >> if (fl & SUB_DOSUBST) { >> replstr = dupstring(replstr); >> singsub(&replstr); >> untokenize(replstr); >> } >> - if ((fl & SUB_GLOBAL) && repllist) { >> + if ((fl & (SUB_GLOBAL|SUB_LIST)) && repllist) { >> /* We are replacing the chunk, just add this to the list */ >> - Repldata rd = (Repldata) zhalloc(sizeof(*rd)); >> + Repldata rd = (Repldata) >> + ((fl & SUB_LIST) ? zalloc(sizeof(*rd)) : zhalloc(sizeof(*rd))); >> rd->b = b; >> rd->e = e; >> rd->replstr = replstr; >> - addlinknode(repllist, rd); >> + if (fl & SUB_LIST) >> + zaddlinknode(repllist, rd); >> + else >> + addlinknode(repllist, rd); >> return s; >> } >> ll += strlen(replstr); > > Someone in the irc channel reported a crash on this strlen when doing > history-incremental-pattern-search-backward with any search, and they > can reproduce it with the latest git version too, they posted this > backtrace: > > Program received signal SIGSEGV, Segmentation fault. > __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65 > 65 VPCMPEQ (%rdi), %ymm0, %ymm1 > (gdb) back > #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65 > #1 0x0000000000436eaa in get_match_ret (imd=imd@entry=0x7fffffffd460, > b=, e=0) at glob.c:2571 > #2 0x000000000043742f in igetmatch (sp=sp@entry=0x7fffffffd4d8, > p=, fl=fl@entry=8710, n=, n@entry=0, > replstr=replstr@entry=0x0, repllistp=) at glob.c:3309 > #3 0x000000000043d7b0 in getmatchlist (str=, > p=, repllistp=) at glob.c:2743 > #4 0x00007ffff774d4f6 in ?? () from /usr/lib64/zsh/5.8.0.2-dev/zsh/zle.so > #5 0x0000000000000001 in ?? () > #6 0x0000000000000000 in ?? () > > I'm not very familiar with this code, but it looks like this patch > allows going into this path with a NULL replstr on purpose, but it > also looks like it shouldn't work... I never had any issues with it > before though, and I do use pattern search on ^R. > > -- > Mikael Magnusson