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=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4470 invoked from network); 5 Dec 2020 17:35:43 -0000 Received: from ewsd.inri.net (107.191.116.128) by inbox.vuxu.org with ESMTPUTF8; 5 Dec 2020 17:35:43 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by ewsd; Sat Dec 5 12:33:07 -0500 2020 Received: from abbatoir.fios-router.home (pool-74-101-2-6.nycmny.fios.verizon.net [74.101.2.6]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 4ad9eb0a (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO); Sat, 5 Dec 2020 09:32:58 -0800 (PST) Message-ID: <0236D9AD4D5FBA15B144E815E3EBCC47@eigenstate.org> To: kvik@a-b.xyz To: 9front@9front.org Date: Sat, 05 Dec 2020 09:32:56 -0800 From: ori@eigenstate.org In-Reply-To: <7FEC8FB4A961AC2CBF0FB20FA1FBCDDB@hog> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: full-stack event Subject: Re: [9front] [PATCH] ptrap: implement attribute filters Reply-To: 9front@9front.org Precedence: bulk Quoth kvik@a-b.xyz: > > This adds support for filtering plumbs based on message > attributes. An example use case is to make a specific > acme instance display the manual pages produced by > man -b or plumbing the manual reference words: > > ptrap edit '.*' +action '^showdata' +filename '^/man/' > > --- > + > +next: > + p = argv[i++]; > + if(p == nil || p[0] != '+'){ > + i--; > + continue; > + } > + p++; > + fa = emalloc9p(sizeof(FAttr)); > + fa->name = estrdup9p(p); > + p = argv[i++]; > + if(p[0] == '!'){ > + p++; > + fa->invert = 1; > + } > + if((fa->filt = regcomp(p)) == nil) > + sysfatal("regcomp: %r"); > + fa->next = f->attr; > + f->attr = fa; > + > + goto next; > } > threadpostmountsrv(&ptrapsrv, nil, "/mnt/plumb", MREPL | MCREATE); > > Testing now, though I don't use the filtering *that* heavily, I mainly use it to prevent acme from becoming an editor. Looking over the code, only thought is that this bit may read better as a nested loop, like: for(; i < argc; i++){ ... } Other than that, I think this looks good.