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=-1.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, NICE_REPLY_A,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6135 invoked from network); 22 May 2022 18:46:21 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 22 May 2022 18:46:21 -0000 Received: from mail.posixcafe.org ([45.76.19.58]) by 9front; Sun May 22 14:45:20 -0400 2022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posixcafe.org; s=20200506; t=1653245116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VZ/lLTgcwejdKphCaRxVrL5B64QW0OFENiX1SxK6We0=; b=ThcgMS/i5jiJE43Wg+MTuj3iZ4C9Mo1o9mcXo+0mGvsO38I3gVxjK1mbnO5hwhtC7CNtfh o9I7sReRm6s37JvqFW90nqWvl4MmVuKZv6CXdHyKt5HY6vmCns1XPe0u7tz6GBqYlcOwyT Gf5bEaHkPq29IcobfpA4/kPUcMv62rs= Received: from [192.168.168.200] (161-97-228-135.lpcnextlight.net [161.97.228.135]) by mail.posixcafe.org (OpenSMTPD) with ESMTPSA id 706893dd (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <9front@9front.org>; Sun, 22 May 2022 13:45:16 -0500 (CDT) Message-ID: <399c430d-65da-0c60-e046-38c19f7c6305@posixcafe.org> Date: Sun, 22 May 2022 12:45:07 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-US To: 9front@9front.org References: <2FD13CB117DFE6893A17A959B97B8C03@eigenstate.org> From: Jacob Moody In-Reply-To: <2FD13CB117DFE6893A17A959B97B8C03@eigenstate.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: asynchronous deep-learning-aware blockchain DOM-scale locator Subject: Re: [9front] [PATCH] diff: retain original file names Reply-To: 9front@9front.org Precedence: bulk On 5/22/22 10:41, Ori Bernstein wrote: > > When diffing non-regular files, like /dev/null, > pipes, and similar, diff will generate a temp > file to diff against. This is the right thing > to do, but the temp file leaks into the diff. > > This patch retains the original file name all > the way through to diff output. This has been a pet peeve of mine, glad to see I wasn't the only one. Looks good to me! One small comment inline that I could take or leave. > --- > diff 4649189126e1ad98f9a07afd078096227668bfd1 23f8872bc10fbe9ffd2b0067db1f91d8eaaabb40 > --- a/sys/src/cmd/diff/diff.h Sun May 22 12:34:33 2022 > +++ b/sys/src/cmd/diff/diff.h Sun May 22 12:41:47 2022 > @@ -23,8 +23,8 @@ > void *erealloc(void *, unsigned); > void diff(char *, char *, int); > void diffdir(char *, char *, int); > -void diffreg(char *, char *); > -Biobuf *prepare(int, char *); > +void diffreg(char *, char *, char *, char *); > +Biobuf *prepare(int, char *, char *); > void panic(int, char *, ...); > void check(Biobuf *, Biobuf *); > void change(int, int, int, int); > --- a/sys/src/cmd/diff/diffio.c Sun May 22 12:34:33 2022 > +++ b/sys/src/cmd/diff/diffio.c Sun May 22 12:41:47 2022 > @@ -104,7 +104,7 @@ > } > > Biobuf * > -prepare(int i, char *arg) > +prepare(int i, char *arg, char *orig) > { > Line *p; > int j, h; > @@ -143,11 +143,10 @@ > file[i] = p; > input[i] = bp; /*fix*/ > if (i == 0) { /*fix*/ Is there any context for why these /*fix*/ comments are here? Could we just delete them? > - file1 = arg; > + file1 = orig; > firstchange = 0; > - } > - else > - file2 = arg; > + } else > + file2 = orig; > return bp; > } > > --- a/sys/src/cmd/diff/diffreg.c Sun May 22 12:34:33 2022 > +++ b/sys/src/cmd/diff/diffreg.c Sun May 22 12:41:47 2022 > @@ -363,16 +363,16 @@ > } > > void > -diffreg(char *f, char *t) > +diffreg(char *f, char *fo, char *t, char *to) > { > Biobuf *b0, *b1; > int k; > > binary = 0; > - b0 = prepare(0, f); > + b0 = prepare(0, f, fo); > if (!b0) > return; > - b1 = prepare(1, t); > + b1 = prepare(1, t, to); > if (!b1) { > Bterm(b0); > return; > --- a/sys/src/cmd/diff/main.c Sun May 22 12:34:33 2022 > +++ b/sys/src/cmd/diff/main.c Sun May 22 12:41:47 2022 > @@ -149,7 +149,7 @@ > Bprint(&stdout, "Common subdirectories: %s and %s\n", fp, tp); > } > else if (REGULAR_FILE(fsb) && REGULAR_FILE(tsb)) > - diffreg(fp, tp); > + diffreg(fp, f, tp, t); > else { > if (REGULAR_FILE(fsb)) { > if ((p = utfrrune(f, '/')) == 0) > @@ -157,14 +157,14 @@ > else > p++; > if (mkpathname(tb, tp, p) == 0) > - diffreg(fp, tb); > + diffreg(fp, f, tb, t); > } else { > if ((p = utfrrune(t, '/')) == 0) > p = t; > else > p++; > if (mkpathname(fb, fp, p) == 0) > - diffreg(fb, tp); > + diffreg(fb, f, tp, t); > } > } > free(fsb);