Skip to content

Commit cb8908e

Browse files
authored
cmp: restore octal skip values
* The POD manual stated that octal values were supported for options skip1 and skip2, but it didn't work * Previously cmp used eval() to convert user input into a number; I suspect the octal support was broken when the eval() code was removed * Octal is supported by NetBSD's cmp %cp ar ar2 %strace perl cmp ar ar2 0X4f 0117 2> trace %fgrep '79,' trace lseek(4, 79, SEEK_SET) = 79 lseek(5, 79, SEEK_SET) = 79
1 parent 676ccde commit cb8908e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bin/cmp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ exit $saw_difference;
220220
sub skipnum {
221221
my $n = shift;
222222
return hex($n) if ($n =~ m/\A0[Xx]/);
223+
return oct($n) if ($n =~ m/\A0o?/);
223224
return int($n) if ($n =~ m/\A[0-9]+\z/);
224225
warn "$Program: invalid offset number '$n'\n";
225226
usage();
@@ -259,9 +260,9 @@ in the shorter of the two file.
259260
260261
I<skip1> and I<skip2> are optional byte offsets into I<file1> and
261262
I<file2>, respectively, that determine where the file comparison
262-
will begin. Offsets may be given in decimal, octal, or hexadecimal
263-
form. Indicate octal notation with a leading '0', and hexadecimal
264-
notation with a leading '0x' or '0X'.
263+
will begin. The offsets value is decimal by default.
264+
An octal value can be entered with a leading '0' or '0o'.
265+
A hexadecimal value can be entered with a leading '0x' or '0X'.
265266
266267
file1 or file2 may be given as '-', which reads from standard input.
267268

0 commit comments

Comments
 (0)