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=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31801 invoked from network); 16 Apr 2022 05:52:04 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 16 Apr 2022 05:52:04 -0000 Received: from asquith.prosimetrum.com ([125.236.209.157]) by 9front; Sat Apr 16 01:50:38 -0400 2022 Message-ID: <6F48EC649501E9AB2002E81BA73801AE@prosimetrum.com> Date: Sat, 16 Apr 2022 17:49:19 +1200 From: umbraticus@prosimetrum.com To: 9front@9front.org 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: general-purpose table TOR NoSQL software grid session controller Subject: [9front] sam = cmd Reply-To: 9front@9front.org Precedence: bulk This patch makes sam's = cmd output what seems to me a more useful (plumbable) format: /full/path/to/file:addr , where addr is line(s) under = and rune(s) under =#. I don't really see how one even could depend on the original format (maybe some complicated sam -d script?) but am open to thoughts & opinions. umbraticus diff f84cf1e60427675514fb056cc1723e45da01e043 uncommitted --- a/sys/man/1/sam +++ b/sys/man/1/sam @@ -403,10 +403,10 @@ Set dot. .TP .B = -Print the line address and character address of the range. +Print the file name and line address of the range. .TP .B =# -Print just the character address of the range. +Print the file name and character address of the range. .PD .SS File commands .PD 0 --- a/sys/src/cmd/sam/sam.c +++ b/sys/src/cmd/sam/sam.c @@ -688,11 +688,25 @@ } void -printposn(File *f, int charsonly) +printposn(File *f, int chars) { Posn l1, l2; + char *s; - if(!charsonly){ + if(f->name.s[0]){ + getcurwd(); + s = Strtoc(&curwd); + dprint("%s", s); + free(s); + s = Strtoc(&f->name); + dprint("%s:", s); + free(s); + } + if(chars){ + dprint("#%lud", addr.r.p1); + if(addr.r.p2 != addr.r.p1) + dprint(",#%lud", addr.r.p2); + }else{ l1 = 1+nlcount(f, (Posn)0, addr.r.p1); l2 = l1+nlcount(f, addr.r.p1, addr.r.p2); /* check if addr ends with '\n' */ @@ -701,11 +715,7 @@ dprint("%lud", l1); if(l2 != l1) dprint(",%lud", l2); - dprint("; "); } - dprint("#%lud", addr.r.p1); - if(addr.r.p2 != addr.r.p1) - dprint(",#%lud", addr.r.p2); dprint("\n"); }