mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
26 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf0d2aac15 | ||
|
|
cc3ea7c99f | ||
|
|
2afd912ce5 | ||
|
|
a8737499b5 | ||
|
|
5d133efc26 | ||
|
|
fae5972a38 | ||
|
|
b17fce4fa4 | ||
|
|
c582df59bf | ||
|
|
4451bd8a9f | ||
|
|
493d736f7d | ||
|
|
782f4e9842 | ||
|
|
8fb784af90 | ||
|
|
fa9d5f6445 | ||
|
|
e55708d43c | ||
|
|
b628469832 | ||
|
|
e222fda574 | ||
|
|
2e1f0f43f0 | ||
|
|
d9a0e2c715 | ||
|
|
7394867950 | ||
|
|
f27f72bd6d | ||
|
|
2fb7f1e3c1 | ||
|
|
b9a9796da6 | ||
|
|
519b707b4e | ||
|
|
2d0f3f2e74 | ||
|
|
f553273be8 | ||
|
|
096c85ad5f |
1
THANKS
1
THANKS
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
88
src/cksum.c
88
src/cksum.c
@@ -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)
|
||||
|
||||
12
src/dd.c
12
src/dd.c
@@ -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;
|
||||
}
|
||||
|
||||
6
src/ls.c
6
src/ls.c
@@ -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:
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -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
59
tests/ls/no-arg
Executable 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
|
||||
Reference in New Issue
Block a user