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=DKIM_SIGNED,DKIM_VALID autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12912 invoked from network); 28 Sep 2023 07:07:18 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 28 Sep 2023 07:07:18 -0000 Received: from pb-smtp2.pobox.com ([64.147.108.71]) by 9front; Thu Sep 28 03:02:47 -0400 2023 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 7C06F1A159F for <9front@9front.org>; Thu, 28 Sep 2023 03:02:47 -0400 (EDT) (envelope-from unobe@cpan.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id :to:subject:date:from:in-reply-to:mime-version:content-type :content-transfer-encoding; s=sasl; bh=C93wsdLU07rnhasaET/w1sK4l C0SS6iN5huYlJmsxr0=; b=C/W9e6QCiOIAAClTXE44g0FXY2Vc+F4/Rq4fToHyF +81+GVoDPoolcTTdMpPrkB+RFyu7jmp8i3UZgVER5wckFPSurieG6w2n1W70UOHt 3ilAYS/yVszL2XlR2gqVvXkb8n/xejo3GD9fN6fB1BTQZ5x6F2PtTnXzkrUMKxEd vQ= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 743171A159E for <9front@9front.org>; Thu, 28 Sep 2023 03:02:47 -0400 (EDT) (envelope-from unobe@cpan.org) Received: from strider.localdomain (unknown [75.237.252.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id CAFC21A159D for <9front@9front.org>; Thu, 28 Sep 2023 03:02:46 -0400 (EDT) (envelope-from unobe@cpan.org) Message-ID: <7D2134B76398FE01FD5C6C8F5313565F@smtp.pobox.com> To: 9front@9front.org Date: Thu, 28 Sep 2023 00:02:45 -0700 From: unobe@cpan.org In-Reply-To: <1868372285A59D67087D51999A641B33@smtp.pobox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: 076FAE92-5DCD-11EE-ADBF-25B3960A682E-09620299!pb-smtp2.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: proven callback content-driven base session hypervisor Subject: Re: [9front] [PATCH 4/6] walk: quote name and path using N and P; use quotefmt and free() Reply-To: 9front@9front.org Precedence: bulk I had sent an earlier version of this around August 10. Moody helped me on gridchat with some finer points, and figured I'd send it out again along with the other patches I've been accumulating. Quoth Romano : > --- > diff 47ddd324c0c118ca5d6662e82b094e94a1cfb771 c9c5d6455a6502ffb0f5490d5602396852261f4c > --- a/sys/man/1/walk > +++ b/sys/man/1/walk > @@ -81,8 +81,14 @@ > .B n > final path element (name) > .TP > +.B N > +final path element (name), rc (1) quoted when necessary > +.TP > .B p > path > +.TP > +.B P > +path, rc (1) quoted when necessary > .TP > .B q > qid path.version.type (see > --- a/sys/src/cmd/walk.c > +++ b/sys/src/cmd/walk.c > @@ -43,7 +43,7 @@ > void > dofile(char *path, Dir *f, int pathonly) > { > - char *p; > + char *p, *q; > > if( > (f == dotdir) > @@ -60,6 +60,7 @@ > case 'a': Bprint(bout, "%uld", f->atime); break; > case 'm': Bprint(bout, "%uld", f->mtime); break; > case 'n': Bwrite(bout, f->name, strlen(f->name)); break; > + case 'N': Bprint(bout, "%q", f->name); break; > case 'p': > if(path != dotpath) > Bwrite(bout, path, strlen(path)); > @@ -69,6 +70,14 @@ > Bwrite(bout, f->name, strlen(f->name)); > } > break; > + case 'P': > + if(!pathonly && path != dotpath && ! (f->qid.type & QTDIR)){ > + q = smprint("%s/%s", path, f->name); > + Bprint(bout, "%q", q); > + free(q); > + } else if(path != dotpath) > + Bprint(bout, "%q", path); > + break; > case 'q': Bprint(bout, "%ullx.%uld.%.2uhhx", f->qid.path, f->qid.vers, f->qid.type); break; > case 's': Bprint(bout, "%lld", f->length); break; > case 'x': Bprint(bout, "%M", f->mode); break; > @@ -243,7 +252,7 @@ > if((stfmt = s_reset(stfmt)) == nil) > sysfatal("s_reset: %r"); > s_append(stfmt, EARGF(usage())); > - i = strspn(s_to_c(stfmt), "UGMamnpqsxDT"); > + i = strspn(s_to_c(stfmt), "UGMamnNpPqsxDT"); > if(i != s_len(stfmt)) > sysfatal("bad stfmt: %s", s_to_c(stfmt)); > break; > @@ -252,6 +261,7 @@ > }ARGEND; > > fmtinstall('M', dirmodefmt); > + quotefmtinstall(); > > if((bout = Bfdopen(1, OWRITE)) == nil) > sysfatal("Bfdopen: %r"); > @@ -316,7 +326,7 @@ > dir->dev == dp->dev) > return 1; > if(c->n == c->max){ > - if (c->max == 0) > + if(c->max == 0) > c->max = 8; > else > c->max += c->max/2; > >