[TUHS] Diff and Patch on v7

Richard Salz rich.salz at gmail.com
Sun Jul 26 01:45:06 AEST 2020


> -#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; }

;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20200725/61f3ad5f/attachment.htm>


More information about the TUHS mailing list