@end example
@command{sum} prints the checksum for each @var{file} followed by the
-number of blocks in the file (rounded up). If more than one @var{file}
-is given, file names are also printed (by default). (With the
-@option{--sysv} option, corresponding file names are printed when there is
-at least one file argument.)
+number of blocks in the file (rounded up). If at least one @var{file}
+is given, file names are also printed.
By default, GNU @command{sum} computes checksums using an algorithm
compatible with BSD @command{sum} and prints file sizes in units of
/* Calculate and print the rotated checksum and the size in 1K blocks
of file FILE, or of the standard input if FILE is "-".
- If PRINT_NAME is >1, print FILE next to the checksum and size.
+ If PRINT_NAME is >0, print FILE next to the checksum and size.
The checksum varies depending on sizeof (int).
Return true if successful. */
printf ("%05d %5s", checksum,
human_readable (total_bytes, hbuf, human_ceiling, 1, 1024));
- if (print_name > 1)
+ if (print_name)
printf (" %s", file);
putchar ('\n');
my @Tests =
(
- ['1', {IN=> {f=> ''}}, {OUT=>"00000 0\n"}],
- ['2', {IN=> {f=> 'a'}}, {OUT=>"00097 1\n"}],
- ['3', {IN=> {f=> 'abc'}}, {OUT=>"16556 1\n"}],
- ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1\n"}],
- ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1\n"}],
+ ['1', {IN=> {f=> ''}}, {OUT=>"00000 0 f\n"}],
+ ['2', {IN=> {f=> 'a'}}, {OUT=>"00097 1 f\n"}],
+ ['3', {IN=> {f=> 'abc'}}, {OUT=>"16556 1 f\n"}],
+ ['4', {IN=> {f=> 'message digest'}}, {OUT=>"26423 1 f\n"}],
+ ['5', {IN=> {f=> 'abcdefghijklmnopqrstuvwxyz'}}, {OUT=>"53553 1 f\n"}],
['6', {IN=> {f=> join ('', 'A'..'Z', 'a'..'z', '0'..'9')}},
- {OUT=>"25587 1\n"}],
- ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1\n"}],
+ {OUT=>"25587 1 f\n"}],
+ ['7', {IN=> {f=> '1234567890' x 8}}, {OUT=>"21845 1 f\n"}],
- ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1\n"}],
+ ['a-r-1k', '-r', {IN=> {f=> $in_1k}}, {OUT=>"65409 1 f\n"}],
['a-s-1k', '-s', {IN=> {f=> $in_1k}}, {OUT=>"33793 2 f\n"}],
- ['b-r-2k', '-r', {IN=> {f=> $in_2k}}, {OUT=>"65223 2\n"}],
+ ['b-r-2k', '-r', {IN=> {f=> $in_2k}}, {OUT=>"65223 2 f\n"}],
['b-s-2k', '-s', {IN=> {f=> $in_2k}}, {OUT=>"4099 4 f\n"}],
['1s', '-s', {IN=> {f=> ''}}, {OUT=>"0 0 f\n"}],