GNU patch only allows s/.// as a regular expression in substitutions. Our diff implementation writes s/^\.\././ which is basically the same, because they are used to change ".." lines into ".".
This is required if an ed-formatted diff tries to create a line that only has a dot in it. Normally, that means end of line input for ed commands. Inserting ".." and then changing it to "." is a common trick here. Compatibility with restrictive GNU patch is a good reason already, but the stronger reason for this is my current work to support ed-style diffs in patch directly. If we limit support of substitutions to s/.//, then it is easily transformed into code, e.g. p++. No need for any form of regexp support, at all... and we are GNU patch compatible. ;) Okay? Index: diffreg.c =================================================================== RCS file: /cvs/src/usr.bin/diff/diffreg.c,v retrieving revision 1.88 diff -u -p -u -p -r1.88 diffreg.c --- diffreg.c 5 Oct 2015 20:15:00 -0000 1.88 +++ diffreg.c 10 Oct 2015 23:17:58 -0000 @@ -1084,7 +1084,7 @@ proceed: * back and restart where we left off. */ diff_output(".\n"); - diff_output("%ds/^\\.\\././\n", a); + diff_output("%ds/.//\n", a); a += i; c += i; goto restart;