Refactor cmp(1) code and manpage

The algorithm had some areas which had potential for improvement.
This should make cmp(1) faster.
There have been changes to behaviour as well:

1) If argv[0] and argv[1] are the same, cmp(1) returns Same.
2) POSIX specifies the format of the difference-message to be:
      "%s %s differ: char %d, line %d\n", file1, file2,
      <byte number>, <line number>
   However, as cmp(1) operates on bytes, not characters, I changed
   it to
      "%s %s differ: byte %d, line %d\n", file1, file2,
      <byte number>, <line number>
   This is one example where the standard just keeps the old format
   for backwards-compatibility. As this is harmful, this change
   makes sense in the sense of consistentcy (and because we take
   the difference of char and byte very seriously in sbase, as
   opposed to GNU coreutils).

The manpage has been annotated, reflecting the second change, and
sections shortened where possible.
Thus I marked cmp(1) as finished in README.
This commit is contained in:
FRIGN
2015-02-07 21:05:33 +01:00
parent d5d686e9f6
commit 79e45395e5
3 changed files with 48 additions and 43 deletions

2
README
View File

@@ -17,7 +17,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
= chown no -h, -H, -L, -P
=* chroot non-posix none
=* cksum yes none
cmp yes none
=* cmp yes none
#* cols non-posix none
=* comm yes none
= cp no -H, (-i), -L