The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Richard Salz <rich.salz@gmail.com>
To: Will Senn <will.senn@gmail.com>
Cc: TUHS main list <tuhs@minnie.tuhs.org>, Leah Neukirchen <leah@vuxu.org>
Subject: Re: [TUHS] Diff and Patch on v7
Date: Sat, 25 Jul 2020 11:45:06 -0400	[thread overview]
Message-ID: <CAFH29tphmwv_P_8p6MiMo5WNd8oNxDbFT4DU00GAE6W2J1ni6A@mail.gmail.com> (raw)
In-Reply-To: <d0a17193-bd6d-89c3-efec-79209fd6841d@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]

> -#define ERASE    '#'
> -#define KILL    '@'
> +#define ERASE    '\177'
> +#define KILL    '\025'
>

That is a context diff.  The wikipedia page
https://en.wikipedia.org/wiki/Diff#Context_format has a reasonable
history.  Short answer is context diffs appeared in 2.8BSD in 1981 and
unified context diffs were posted to Usenet in 1990. Context diffs are more
robust if you have made local changes (patch's "fuzz" messages), and
unified are more compact version and can be more useful to see exactly
before/after lines.

A comparison of the outputs follows:
; diff a.cpp.orig a.cpp
3d2
<     int size;
6c5
< : elem{new int[s]}, size{s}
---
> : elem{new int[s]}

; diff -e a.cpp.orig a.cpp
6c
: elem{new int[s]}
.
3d

; diff -c a.cpp.orig a.cpp
*** a.cpp.orig Sat Jul 25 11:37:29 2020
--- a.cpp Sat Jul 25 11:42:21 2020
***************
*** 1,9 ****
  class x {
      int *elem;
-     int size;
  public:
      x(int s)
! : elem{new int[s]}, size{s}
      {
      }
      ~x() { delete[] elem; }
--- 1,8 ----
  class x {
      int *elem;
  public:
      x(int s)
! : elem{new int[s]}
      {
      }
      ~x() { delete[] elem; }

; diff -u a.cpp.orig a.cpp
--- a.cpp.orig 2020-07-25 11:37:29.000000000 -0400
+++ a.cpp 2020-07-25 11:42:21.000000000 -0400
@@ -1,9 +1,8 @@
 class x {
     int *elem;
-    int size;
 public:
     x(int s)
- : elem{new int[s]}, size{s}
+ : elem{new int[s]}
     {
     }
     ~x() { delete[] elem; }

;

[-- Attachment #2: Type: text/html, Size: 2066 bytes --]

      parent reply	other threads:[~2020-07-25 15:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-25 13:52 Will Senn
2020-07-25 14:03 ` Leah Neukirchen
2020-07-25 14:28   ` Will Senn
2020-07-25 14:39     ` Clem Cole
2020-07-25 15:19       ` Warner Losh
2020-07-25 15:45     ` Richard Salz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFH29tphmwv_P_8p6MiMo5WNd8oNxDbFT4DU00GAE6W2J1ni6A@mail.gmail.com \
    --to=rich.salz@gmail.com \
    --cc=leah@vuxu.org \
    --cc=tuhs@minnie.tuhs.org \
    --cc=will.senn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).