Compare commits

...

26 Commits

Author SHA1 Message Date
Jim Meyering
bf0d2aac15 *** empty log message *** 2001-04-23 07:38:44 +00:00
Jim Meyering
cc3ea7c99f (dd_copy): When using sync with either block or unblock,
pad with spaces.
2001-04-23 07:38:33 +00:00
Jim Meyering
2afd912ce5 *** empty log message *** 2001-04-23 07:33:37 +00:00
Jim Meyering
a8737499b5 (block-sync-1): new test, for just-fixed bug 2001-04-23 07:31:17 +00:00
Jim Meyering
5d133efc26 *** empty log message *** 2001-04-22 21:37:36 +00:00
Jim Meyering
fae5972a38 fix typo in comment 2001-04-22 21:35:11 +00:00
Jim Meyering
b17fce4fa4 (decode_switches): Ensure that -1 has no effect when it follows -l. 2001-04-22 21:34:20 +00:00
Jim Meyering
c582df59bf *** empty log message *** 2001-04-22 16:52:23 +00:00
Jim Meyering
4451bd8a9f . 2001-04-22 16:50:47 +00:00
Jim Meyering
493d736f7d fix typo in --help output 2001-04-22 11:44:56 +00:00
Jim Meyering
782f4e9842 *** empty log message *** 2001-04-22 10:14:20 +00:00
Jim Meyering
8fb784af90 *** empty log message *** 2001-04-22 10:12:59 +00:00
Jim Meyering
fa9d5f6445 *** empty log message *** 2001-04-22 10:12:25 +00:00
Jim Meyering
e55708d43c . 2001-04-22 10:09:21 +00:00
Jim Meyering
b628469832 *** empty log message *** 2001-04-22 09:16:14 +00:00
Jim Meyering
e222fda574 (main): Fix off-by-one error introduced with last change. 2001-04-22 09:15:17 +00:00
Jim Meyering
2e1f0f43f0 check -R, too 2001-04-22 09:14:14 +00:00
Jim Meyering
d9a0e2c715 *** empty log message *** 2001-04-22 09:11:08 +00:00
Jim Meyering
7394867950 *** empty log message *** 2001-04-22 09:10:29 +00:00
Jim Meyering
f27f72bd6d *** empty log message *** 2001-04-22 09:08:53 +00:00
Jim Meyering
2fb7f1e3c1 (TESTS): Add no-arg. 2001-04-22 09:08:45 +00:00
Jim Meyering
b9a9796da6 *** empty log message *** 2001-04-22 08:31:40 +00:00
Jim Meyering
519b707b4e Fix bugs when computing length of large files.
Add overflow and write error checks.  Use uint_fast32_t, not
unsigned long, to do checksum calculation, as C99 says
uint_fast32_t should be no slower and might be faster.

Include <stdio.h> and "system.h" even if CRCTAB is defined,
so that the code will compile if CRCTAB is defined.
Include "human.h" if CRCTAB is not defined.
(uint_fast32_t): Define if it appears that stdint.h didn't.
(BIT, remainder, main, crctab): Use uint_fast32_t, not unsigned long,
for checksums.
(fill_r, remainder, main): Use ANSI prototypes.
(fill_r, remainder, main): Omit duplicate code.
(main): Use uintmax_t, not unsigned long, for file lengths.
Use size_t, not long, for result of fread.
Check for overflow when computing file lengths.
Check for write error immediately after printing a line, so that
we don't write to stdout indefinitely after an error.
2001-04-22 08:31:24 +00:00
Jim Meyering
2d0f3f2e74 *** empty log message *** 2001-04-22 07:29:13 +00:00
Jim Meyering
f553273be8 (usage): Mention that sync makes dd pad with spaces (rather than NULs)
when used with block or unblock.
2001-04-22 07:28:58 +00:00
Jim Meyering
096c85ad5f *** empty log message *** 2001-04-22 07:28:11 +00:00
12 changed files with 199 additions and 52 deletions

1
THANKS
View File

@@ -64,6 +64,7 @@ Chuck Hedrick hedrick@klinzhai.rutgers.edu
Clark Morgan cmorgan@aracnet.com
Colin Plumb colin@nyx.net
Collin Rogowski collin@rogowski.de
Dale Scheetz dwarf@polaris.net
Dan Hagerty hag@gnu.ai.it.edu
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se

View File

@@ -1,3 +1,27 @@
2001-04-23 Jim Meyering <meyering@lucent.com>
* Version 4.0.45.
2001-04-22 Jim Meyering <meyering@lucent.com>
* src/ls.c (decode_switches): Ensure that -1 has no effect when it
follows -l. Reported by Ulrich Drepper.
* src/dd.c (usage): Mention that sync makes dd pad with spaces (rather
than NULs) when used with block or unblock.
(dd_copy): When using sync with either block or unblock,
pad with spaces. Reported by Dale Scheetz.
* tests/dd/skip-seek (block-sync-1): New test, for this. Based on
report from Dale Scheetz.
* doc/fileutils.texi (dd invocation): Document it here, too.
* configure: Regenerate using a patched copy of autoconf-2.49e to
work around a bug in its test for a working memcmp function.
* tests/ls/no-arg: New file.
* tests/ls/Makefile.am (TESTS): Add no-arg.
* src/ls.c (main): Fix off-by-one error introduced with last change.
2001-04-21 Jim Meyering <meyering@lucent.com>
* Version 4.0.44.

View File

@@ -1,4 +1,10 @@
Changes in release 4.1.0:
[4.0.45]
* dd conv=sync,block now pads only with spaces
* ls's -1 option no longer cancels the effect of a preceding -l
* regenerate configure using a patched version of autoconf-2.49e to work
around a bug in its test for a working memcmp function
* ls: fix off-by-one error introduced with the previous change
[4.0.44]
* ls: When given two or more arguments but the only one that exists is a
directory, don't treat it as if it were the only argument. Before,

View File

@@ -1,3 +1,31 @@
2001-04-22 Jim Meyering <meyering@lucent.com>
* Version 2.0.14.
* configure: Regenerate using a patched copy of autoconf-2.49e to
work around a bug in its test for a working memcmp function.
2001-03-28 Paul Eggert <eggert@twinsun.com>
* src/cksum.c: Fix bugs when computing length of large files.
Add overflow and write error checks. Use uint_fast32_t, not
unsigned long, to do checksum calculation, as C99 says
uint_fast32_t should be no slower and might be faster.
Include <stdio.h> and "system.h" even if CRCTAB is defined,
so that the code will compile if CRCTAB is defined.
Include "human.h" if CRCTAB is not defined.
(uint_fast32_t): Define if it appears that stdint.h didn't.
(BIT, remainder, main, crctab): Use uint_fast32_t, not unsigned long,
for checksums.
(fill_r, remainder, main): Use ANSI prototypes.
(fill_r, remainder, main): Omit duplicate code.
(main): Use uintmax_t, not unsigned long, for file lengths.
Use size_t, not long, for result of fread.
Check for overflow when computing file lengths.
Check for write error immediately after printing a line, so that
we don't write to stdout indefinitely after an error.
2001-04-14 Paul Eggert <eggert@twinsun.com>
* src/sort.c (default_sort_size): Leave a 1/16 margin for RSS.

View File

@@ -1,4 +1,13 @@
Changes in release 2.1
[2.0.14]
* sort now accepts long options like "--reverse" and "--".
* sort now checks option syntax as POSIX requires, except that (as usual
for GNU) options can follow file names unless POSIXLY_CORRECT is set.
For example, invalid positional combinations like "sort +1 -r -2" are
now rejected as per POSIX.
* The next POSIX standard will require that obsolescent 'sort'
positional options like +1 be treated as file names, not options.
Please use 'sort -k' instead.
[2.0.13]
* pr accepts new -D or --date option, to specify date format.
* The following changes are required by POSIX:

View File

@@ -47,12 +47,17 @@
#define AUTHORS "Q. Frank Xia"
#include <stdio.h>
#include "system.h"
#if !defined UINT_FAST32_MAX && !defined uint_fast32_t
# define uint_fast32_t unsigned int
#endif
#ifdef CRCTAB
# include <stdio.h>
# define BIT(x) ( (unsigned long)1 << (x) )
# define SBIT BIT(31)
# define BIT(x) ((uint_fast32_t) 1 << (x))
# define SBIT BIT (31)
/* The generating polynomial is
@@ -61,47 +66,48 @@
The i bit in GEN is set if X^i is a summand of G(X) except X^32. */
# define GEN (BIT(26)|BIT(23)|BIT(22)|BIT(16)|BIT(12)|BIT(11)|BIT(10)\
|BIT(8) |BIT(7) |BIT(5) |BIT(4) |BIT(2) |BIT(1) |BIT(0));
# define GEN (BIT (26) | BIT (23) | BIT (22) | BIT (16) | BIT (12) \
| BIT (11) | BIT (10) | BIT (8) | BIT (7) | BIT (5) \
| BIT (4) | BIT (2) | BIT (1) | BIT (0))
static unsigned long r[8];
static uint_fast32_t r[8];
static void
fill_r ()
fill_r (void)
{
int i;
r[0] = GEN;
for (i = 1; i < 8; i++)
r[i] = (r[i - 1] & SBIT) ? (r[i - 1] << 1) ^ r[0] : r[i - 1] << 1;
r[i] = (r[i - 1] << 1) ^ ((r[i - 1] & SBIT) ? GEN : 0);
}
static unsigned long
remainder (m)
int m;
static uint_fast32_t
remainder (int m)
{
unsigned long rem = 0;
uint_fast32_t rem = 0;
int i;
for (i = 0; i < 8; i++)
if (BIT (i) & m)
rem = rem ^ r[i];
rem ^= r[i];
return rem & 0xFFFFFFFF; /* Make it run on 64-bit machine. */
}
int
main ()
main (void)
{
int i;
fill_r ();
printf ("unsigned long crctab[256] = {\n 0x0");
printf ("static uint_fast32_t crctab[256] =\n{\n 0x0");
for (i = 0; i < 51; i++)
{
printf (",\n 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X",
remainder (i * 5 + 1), remainder (i * 5 + 2), remainder (i * 5 + 3),
remainder (i * 5 + 4), remainder (i * 5 + 5));
remainder (i * 5 + 1), remainder (i * 5 + 2),
remainder (i * 5 + 3), remainder (i * 5 + 4),
remainder (i * 5 + 5));
}
printf ("\n};\n");
exit (EXIT_SUCCESS);
@@ -109,13 +115,12 @@ main ()
#else /* !CRCTAB */
# include <stdio.h>
# include <getopt.h>
# include <sys/types.h>
# include "system.h"
# include "closeout.h"
# include "long-options.h"
# include "error.h"
# include "human.h"
/* Number of bytes to read at once. */
# define BUFLEN (1 << 16)
@@ -128,7 +133,7 @@ static struct option const long_options[] =
{0, 0, 0, 0}
};
static unsigned long const crctab[256] =
static uint_fast32_t crctab[256] =
{
0x0,
0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
@@ -196,10 +201,12 @@ static int
cksum (const char *file, int print_name)
{
unsigned char buf[BUFLEN];
unsigned long crc = 0;
long length = 0;
long bytes_read;
uint_fast32_t crc = 0;
uintmax_t length = 0;
size_t bytes_read;
register FILE *fp;
char hbuf[LONGEST_HUMAN_READABLE + 1];
char *hp;
if (STREQ (file, "-"))
{
@@ -223,9 +230,11 @@ cksum (const char *file, int print_name)
{
unsigned char *cp = buf;
if (length + bytes_read < length)
error (EXIT_FAILURE, 0, _("%s: file too long"), file);
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF];
crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF];
}
if (ferror (fp))
@@ -242,19 +251,20 @@ cksum (const char *file, int print_name)
return -1;
}
bytes_read = length;
while (bytes_read > 0)
{
crc = (crc << 8) ^ crctab[((crc >> 24) ^ bytes_read) & 0xFF];
bytes_read >>= 8;
}
hp = human_readable (length, hbuf, 1, 1);
for (; length; length >>= 8)
crc = (crc << 8) ^ crctab[((crc >> 24) ^ length) & 0xFF];
crc = ~crc & 0xFFFFFFFF;
printf ("%lu %ld", crc, length);
if (print_name)
printf (" %s", file);
putchar ('\n');
printf ("%u %s %s\n", (unsigned) crc, hp, file);
else
printf ("%u %s\n", (unsigned) crc, hp);
if (ferror (stdout))
error (EXIT_FAILURE, errno, "-: %s", _("write error"));
return 0;
}
@@ -313,16 +323,12 @@ main (int argc, char **argv)
}
}
if (optind >= argc)
{
if (cksum ("-", 0) < 0)
errors = 1;
}
if (optind == argc)
errors |= cksum ("-", 0);
else
{
for (i = optind; i < argc; i++)
if (cksum (argv[i], 1) < 0)
errors = 1;
errors |= cksum (argv[i], 1);
}
if (have_read_stdin && fclose (stdin) == EOF)

View File

@@ -321,7 +321,8 @@ Each KEYWORD may be:\n\
ucase change lower case to upper case\n\
swab swap every pair of input bytes\n\
noerror continue after read errors\n\
sync pad every input block with NULs to ibs-size\n\
sync pad every input block with NULs to ibs-size; when used\n\
with block or unblock, pad with spaces rather than NULs\n\
"));
puts (_("\nReport bugs to <bug-fileutils@gnu.org>."));
}
@@ -945,7 +946,7 @@ dd_copy (void)
{
/* FIXME: this loses for
% ./dd if=dd seek=1 |:
./dd: standard output: Bad file number
./dd: standard output: Bad file descriptor
0+0 records in
0+0 records out
*/
@@ -965,7 +966,9 @@ dd_copy (void)
whatever data we are able to read is followed by zeros.
This minimizes data loss. */
if ((conversions_mask & C_SYNC) && (conversions_mask & C_NOERROR))
memset ((char *) ibuf, 0, input_blocksize);
memset ((char *) ibuf,
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
input_blocksize);
nread = safe_read (STDIN_FILENO, ibuf, input_blocksize);
@@ -1004,7 +1007,8 @@ dd_copy (void)
{
if (!(conversions_mask & C_NOERROR))
/* If C_NOERROR, we zeroed the block before reading. */
memset ((char *) (ibuf + n_bytes_read), 0,
memset ((char *) (ibuf + n_bytes_read),
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
input_blocksize - n_bytes_read);
n_bytes_read = input_blocksize;
}

View File

@@ -895,7 +895,7 @@ main (int argc, char **argv)
clear_files ();
n_files = argc - i;
if (0 <= n_files)
if (0 < n_files)
dir_defaulted = 0;
for (; i < argc; i++)
@@ -1269,7 +1269,9 @@ Use `--si' for the old meaning."));
break;
case '1':
format = one_per_line;
/* -1 has no effect after -l. */
if (format != long_format)
format = one_per_line;
break;
case SORT_OPTION:

View File

@@ -27,7 +27,7 @@ my $script_name = $ENV{SCRIPT_NAME};
my @Tests =
(
[
'1', qw (bs=1 skip=1 seek=2 conv=notrunc count=3 of=@AUX@ < ),
'skip-seek-1', qw (bs=1 skip=1 seek=2 conv=notrunc count=3 of=@AUX@ < ),
{IN=> '0123456789abcdef'},
{AUX=> 'zyxwvutsrqponmlkji'},
{OUT=> ''},
@@ -35,7 +35,7 @@ my @Tests =
{CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
],
[
'3', qw (bs=5 skip=1 seek=1 conv=notrunc count=1 of=@AUX@ < ),
'skip-seek-2', qw (bs=5 skip=1 seek=1 conv=notrunc count=1 of=@AUX@ < ),
{IN=> '0123456789abcdef'},
{AUX=> 'zyxwvutsrqponmlkji'},
{OUT=> ''},
@@ -43,13 +43,21 @@ my @Tests =
{CMP=> ['zyxwv56789ponmlkji', {'@AUX@'=> undef}]},
],
[
'4', qw (bs=5 skip=1 seek=1 count=1 of=@AUX@ < ),
'skip-seek-3', qw (bs=5 skip=1 seek=1 count=1 of=@AUX@ < ),
{IN=> '0123456789abcdef'},
{AUX=> 'zyxwvutsrqponmlkji'},
{OUT=> ''},
{ERR=> "1+0 records in\n1+0 records out\n"},
{CMP=> ['zyxwv56789', {'@AUX@'=> undef}]},
],
[
# Before fileutils-4.0.45, the last 10 bytes of output
# were these "\0\0\0\0\0\0\0\0 ".
'block-sync-1', qw(ibs=10 cbs=10), 'conv=block,sync', '<',
{IN=> "01234567\nabcdefghijkl\n"},
{OUT=> "01234567 abcdefghij "},
{ERR=> "2+1 records in\n0+1 records out\n1 truncated record\n"},
],
);
my $save_temps = $ENV{DEBUG};

View File

@@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = rt-1 time-1 symlink-slash follow-slink
TESTS = rt-1 time-1 symlink-slash follow-slink no-arg
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \

View File

@@ -121,7 +121,7 @@ l = @l@
AUTOMAKE_OPTIONS = 1.2 gnits
TESTS = rt-1 time-1 symlink-slash follow-slink
TESTS = rt-1 time-1 symlink-slash follow-slink no-arg
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \

59
tests/ls/no-arg Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/sh
# make sure ls and `ls -R' do the right thing when invoked with no arguments.
if test "$VERBOSE" = yes; then
set -x
ls --version
fi
pwd=`pwd`
tmp=no-args.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
mkdir -p dir/subdir || framework_failure=1
touch dir/subdir/file2 || framework_failure=1
ln -s f symlink || framework_failure=1
cat > exp <<\EOF || framework_failure=1
dir
exp
out
symlink
EOF
if test $framework_failure = 1; then
echo 'failure in testing framework'
(exit 1); exit
fi
fail=0
ls > out || fail=1
cmp out exp || fail=1
test $fail = 1 && diff out exp 2> /dev/null
cat > exp <<\EOF
.:
dir
exp
out
symlink
./dir:
subdir
./dir/subdir:
file2
EOF
ls -R > out || fail=1
cmp out exp || fail=1
test $fail = 1 && diff out exp 2> /dev/null
(exit $fail); exit