mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
69 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 | ||
|
|
1743aa2657 | ||
|
|
24e7d36a6a | ||
|
|
9404b5a3fb | ||
|
|
f6a99b1551 | ||
|
|
5f8d1a3d0b | ||
|
|
957b608418 | ||
|
|
2fca663e2f | ||
|
|
8c65bdf194 | ||
|
|
9c52203523 | ||
|
|
7f9d95c41d | ||
|
|
9074a69e21 | ||
|
|
2768c3dfc4 | ||
|
|
500ac13ddf | ||
|
|
e1e14bdb38 | ||
|
|
9ea67a3c6f | ||
|
|
30b3f9a1c1 | ||
|
|
48456d1d61 | ||
|
|
45c6397848 | ||
|
|
50d41186a4 | ||
|
|
4b9aaf267e | ||
|
|
9d3cbe12bd | ||
|
|
868e467701 | ||
|
|
dfbabfe758 | ||
|
|
21049673a0 | ||
|
|
3de0ead1ef | ||
|
|
66b1f79fb0 | ||
|
|
f9b3e59ae5 | ||
|
|
b7cd544ce5 | ||
|
|
8e94dcc2c6 | ||
|
|
c73e54a8ad | ||
|
|
5bd7ca3781 | ||
|
|
f164f70523 | ||
|
|
b22ba791cb | ||
|
|
4435f69035 | ||
|
|
46e9ed6beb | ||
|
|
3c0e576c6d | ||
|
|
e1aa041f5e | ||
|
|
924bbfab87 | ||
|
|
f9b5d8621a | ||
|
|
7982727372 | ||
|
|
29a8fa8694 | ||
|
|
d8f340e664 | ||
|
|
bda130b531 |
3
THANKS
3
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
|
||||
@@ -118,6 +119,7 @@ Hans Verkuil hans@wyst.hobby.nl
|
||||
Harry Liu rliu@lek.ugcs.caltech.edu
|
||||
Herbert Xu herbert@gondor.apana.org.au
|
||||
Holger Berger hberger@ess.nec.de
|
||||
Hon-Yin Kok hkok@yoda.unl.edu
|
||||
Hugh Daniel hugh@xanadu.com
|
||||
Ian Jackson ijackson@chiark.greenend.org.uk
|
||||
Ian Lance Taylor ian@cygnus.com
|
||||
@@ -275,6 +277,7 @@ Sander van Malssen svm@kozmix.ow.nl
|
||||
Santiago Vila Doncel sanvila@unex.es
|
||||
Savochkin Andrey Vladimirovich saw@msu.ru
|
||||
Scott Lurndal slurn@griffin.engr.sgi.com
|
||||
Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr
|
||||
Stephen Gildea gildea@x.org
|
||||
Stephen Smoogen ??????????
|
||||
Steve McConnel steve@acadcomp.sil.org
|
||||
|
||||
@@ -427,9 +427,10 @@ pipeline.
|
||||
@dfn{failure}. It can be used as a place holder in shell scripts
|
||||
where an unsuccessful command is needed.
|
||||
|
||||
@code{false} ignores @emph{all} command line arguments, even @samp{--help}
|
||||
and @samp{--version}, since to do otherwise would change expected
|
||||
behavior that some programmers may be relying on.
|
||||
By default, @code{false} honors the @samp{--help} and @samp{--version}
|
||||
options. However, that is contrary to @sc{POSIX}, so when the environment
|
||||
variable @env{POSIXLY_CORRECT} is set, @code{false} ignores @emph{all}
|
||||
command line arguments, including @samp{--help} and @samp{--version}.
|
||||
|
||||
This version of @code{false} is implemented as a C program, and is thus
|
||||
more secure and faster than a shell script implementation, and may safely
|
||||
@@ -448,11 +449,15 @@ be used as a dummy shell for the purpose of disabling accounts.
|
||||
@code{true} does nothing except return an exit status of 0, meaning
|
||||
@dfn{success}. It can be used as a place holder in shell scripts
|
||||
where a successful command is needed, although the shell built-in
|
||||
command @code{:} (colon) does the same thing faster.
|
||||
command @code{:} (colon) may do the same thing faster.
|
||||
In most modern shells, @code{true} is built-in command, so when
|
||||
you use @samp{true} in a script, you're probably using the built-in
|
||||
command, not the one documented here.
|
||||
|
||||
@code{true} ignores @emph{all} command line arguments, even @samp{--help}
|
||||
and @samp{--version}, since to do otherwise would change expected
|
||||
behavior that some programmers may be relying on.
|
||||
By default, @code{true} honors the @samp{--help} and @samp{--version}
|
||||
options. However, that is contrary to @sc{POSIX}, so when the environment
|
||||
variable @env{POSIXLY_CORRECT} is set, @code{true} ignores @emph{all}
|
||||
command line arguments, including @samp{--help} and @samp{--version}.
|
||||
|
||||
This version of @code{true} is implemented as a C program, and is thus
|
||||
more secure and faster than a shell script implementation, and may safely
|
||||
|
||||
@@ -237,6 +237,14 @@ writing identical descriptions for each of the programs, they are
|
||||
described here. (In fact, every @sc{gnu} program accepts (or should accept)
|
||||
these options.)
|
||||
|
||||
@vindex POSIXLY_CORRECT
|
||||
Normally options and operands can appear in any order, and programs act
|
||||
as if all the options appear before any operands. For example,
|
||||
@samp{sort -r passwd -t :} acts like @samp{sort -r -t : passwd}, since
|
||||
@samp{:} is an option-argument of @option{-t}. However, if the
|
||||
@env{POSIXLY_CORRECT} environment variable is set, options must appear
|
||||
before operands, unless otherwise specified for a particular command.
|
||||
|
||||
Some of these programs recognize the @samp{--help} and @samp{--version}
|
||||
options only when one of them is the sole command line argument.
|
||||
|
||||
@@ -252,8 +260,24 @@ Print a usage message listing all available options, then exit successfully.
|
||||
@cindex version number, finding
|
||||
Print the version number, then exit successfully.
|
||||
|
||||
@item --
|
||||
@opindex --
|
||||
@cindex option delimiter
|
||||
Delimit the option list. Later arguments, if any, are treated as
|
||||
operands even if they begin with @samp{-}. For example, @samp{sort --
|
||||
-r} reads from the file named @file{-r}.
|
||||
|
||||
@end table
|
||||
|
||||
@cindex standard input
|
||||
@cindex standard output
|
||||
A single @samp{-} is not really an option, though it looks like one. It
|
||||
stands for standard input, or for standard output if that is clear from
|
||||
the context, and it can be used either as an operand or as an
|
||||
option-argument. For example, @samp{sort -o - -} outputs to standard
|
||||
output and reads from standard input, and is equivalent to plain
|
||||
@samp{sort}. Unless otherwise specified, @samp{-} can appear in any
|
||||
context that requires a file name.
|
||||
|
||||
@node Output of entire files
|
||||
@chapter Output of entire files
|
||||
@@ -1051,8 +1075,8 @@ If a line is too long to fit in a column, it is truncated.
|
||||
@opindex -c
|
||||
@opindex --show-control-chars
|
||||
Print control characters using hat notation (e.g., @samp{^G}); print
|
||||
other unprintable characters in octal backslash notation. By default,
|
||||
unprintable characters are not changed.
|
||||
other nonprinting characters in octal backslash notation. By default,
|
||||
nonprinting characters are not changed.
|
||||
|
||||
@item -d
|
||||
@itemx --double-space
|
||||
@@ -1258,7 +1282,7 @@ set in the input files.
|
||||
@itemx --show-nonprinting
|
||||
@opindex -v
|
||||
@opindex --show-nonprinting
|
||||
Print unprintable characters in octal backslash notation.
|
||||
Print nonprinting characters in octal backslash notation.
|
||||
|
||||
@item -w @var{page_width}
|
||||
@itemx --width=@var{page_width}
|
||||
@@ -2109,14 +2133,18 @@ mode:
|
||||
@table @samp
|
||||
|
||||
@item -c
|
||||
@itemx --check
|
||||
@opindex -c
|
||||
@opindex --check
|
||||
@cindex checking for sortedness
|
||||
Check whether the given files are already sorted: if they are not all
|
||||
sorted, print an error message and exit with a status of 1.
|
||||
Otherwise, exit successfully.
|
||||
|
||||
@item -m
|
||||
@itemx --merge
|
||||
@opindex -m
|
||||
@opindex --merge
|
||||
@cindex merging sorted files
|
||||
Merge the given files by sorting them as a group. Each input file must
|
||||
always be individually sorted. It always works to sort instead of
|
||||
@@ -2133,17 +2161,19 @@ options, until a difference is found or no fields are left.
|
||||
Unless otherwise specified, all comparisons use the character
|
||||
collating sequence specified by the @env{LC_COLLATE} locale.
|
||||
|
||||
If any of the global options @samp{Mbdfinr} are given but no key fields
|
||||
If any of the global options @samp{bdfgiMnr} are given but no key fields
|
||||
are specified, @code{sort} compares the entire lines according to the
|
||||
global options.
|
||||
|
||||
Finally, as a last resort when all keys compare equal (or if no
|
||||
ordering options were specified at all), @code{sort} compares the entire
|
||||
lines. The last resort comparison
|
||||
honors the @samp{-r} global option. The @samp{-s} (stable) option
|
||||
honors the @option{--reverse} (@option{-r}) global option.
|
||||
The @option{--stable} (@option{-s}) option
|
||||
disables this last-resort comparison so that lines in which all fields
|
||||
compare equal are left in their original relative order. If no fields
|
||||
or global options are specified, @samp{-s} has no effect.
|
||||
or global options are specified, @option{--stable} (@option{-s}) has no
|
||||
effect.
|
||||
|
||||
@sc{gnu} @code{sort} (as specified for all @sc{gnu} utilities) has no limits on
|
||||
input line length or restrictions on bytes allowed within lines. In
|
||||
@@ -2160,8 +2190,8 @@ Upon any error, @code{sort} exits with a status of @samp{2}.
|
||||
@vindex TMPDIR
|
||||
If the environment variable @env{TMPDIR} is set, @code{sort} uses its
|
||||
value as the directory for temporary files instead of @file{/tmp}. The
|
||||
@samp{-T @var{tempdir}} option in turn overrides the environment
|
||||
variable.
|
||||
@option{--temporary-directory} (@option{-T}) option in turn overrides
|
||||
the environment variable.
|
||||
|
||||
The following options affect the ordering of output lines. They may be
|
||||
specified globally or as part of a specific key field. If no key
|
||||
@@ -2174,14 +2204,19 @@ so portable shell scripts should specify global options first.
|
||||
@table @samp
|
||||
|
||||
@item -b
|
||||
@itemx --ignore-leading-blanks
|
||||
@opindex -b
|
||||
@opindex --ignore-leading-blanks
|
||||
@cindex blanks, ignoring leading
|
||||
@vindex LC_CTYPE
|
||||
Ignore leading blanks when finding sort keys in each line.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -d
|
||||
@itemx --dictionary-order
|
||||
@opindex -d
|
||||
@opindex --dictionary-order
|
||||
@cindex dictionary order
|
||||
@cindex phone directory order
|
||||
@cindex telephone directory order
|
||||
@vindex LC_CTYPE
|
||||
@@ -2190,15 +2225,20 @@ letters, digits and blanks when sorting.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -f
|
||||
@itemx --ignore-case
|
||||
@opindex -f
|
||||
@opindex --ignore-case
|
||||
@cindex ignoring case
|
||||
@cindex case folding
|
||||
@vindex LC_CTYPE
|
||||
Fold lowercase characters into the equivalent uppercase characters when
|
||||
sorting so that, for example, @samp{b} and @samp{B} sort as equal.
|
||||
comparing so that, for example, @samp{b} and @samp{B} sort as equal.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -g
|
||||
@itemx --general-numeric-sort
|
||||
@opindex -g
|
||||
@opindex --general-numeric-sort
|
||||
@cindex general numeric sort
|
||||
@vindex LC_NUMERIC
|
||||
Sort numerically, using the standard C function @code{strtod} to convert
|
||||
@@ -2224,17 +2264,23 @@ Plus infinity.
|
||||
@end itemize
|
||||
|
||||
Use this option only if there is no alternative; it is much slower than
|
||||
@samp{-n} and it can lose information when converting to floating point.
|
||||
@option{--numeric-sort} (@option{-n}) and it can lose information when
|
||||
converting to floating point.
|
||||
|
||||
@item -i
|
||||
@itemx --ignore-nonprinting
|
||||
@opindex -i
|
||||
@opindex --ignore-nonprinting
|
||||
@cindex nonprinting characters, ignoring
|
||||
@cindex unprintable characters, ignoring
|
||||
@vindex LC_CTYPE
|
||||
Ignore unprintable characters.
|
||||
Ignore nonprinting characters.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -M
|
||||
@itemx --month-sort
|
||||
@opindex -M
|
||||
@opindex --month-sort
|
||||
@cindex months, sorting by
|
||||
@vindex LC_TIME
|
||||
An initial string, consisting of any amount of whitespace, followed
|
||||
@@ -2244,7 +2290,9 @@ Invalid names compare low to valid names. The @env{LC_TIME} locale
|
||||
determines the month spellings.
|
||||
|
||||
@item -n
|
||||
@itemx --numeric-sort
|
||||
@opindex -n
|
||||
@opindex --numeric-sort
|
||||
@cindex numeric sort
|
||||
@vindex LC_NUMERIC
|
||||
Sort numerically: the number begins each line; specifically, it consists
|
||||
@@ -2253,10 +2301,11 @@ digits possibly separated by thousands separators, optionally followed
|
||||
by a decimal-point character and zero or more digits. The @env{LC_NUMERIC}
|
||||
locale specifies the decimal-point character and thousands separator.
|
||||
|
||||
@code{sort -n} uses what might be considered an unconventional method
|
||||
Numeric sort uses what might be considered an unconventional method
|
||||
to compare strings representing floating point numbers. Rather than
|
||||
first converting each string to the C @code{double} type and then
|
||||
comparing those values, sort aligns the decimal-point characters in the two
|
||||
comparing those values, @command{sort} aligns the decimal-point
|
||||
characters in the two
|
||||
strings and compares the strings a character at a time. One benefit
|
||||
of using this approach is its speed. In practice this is much more
|
||||
efficient than performing the two corresponding string-to-double (or even
|
||||
@@ -2266,10 +2315,13 @@ there is no corresponding loss of precision. Converting each string to
|
||||
on most systems.
|
||||
|
||||
Neither a leading @samp{+} nor exponential notation is recognized.
|
||||
To compare such strings numerically, use the @samp{-g} option.
|
||||
To compare such strings numerically, use the
|
||||
@option{--general-numeric-sort} (@option{-g}) option.
|
||||
|
||||
@item -r
|
||||
@itemx --reverse
|
||||
@opindex -r
|
||||
@opindex --reverse
|
||||
@cindex reverse sorting
|
||||
Reverse the result of comparison, so that lines with greater key values
|
||||
appear earlier in the output instead of later.
|
||||
@@ -2281,15 +2333,26 @@ Other options are:
|
||||
@table @samp
|
||||
|
||||
@item -o @var{output-file}
|
||||
@itemx --output=@var{output-file}
|
||||
@opindex -o
|
||||
@opindex --output
|
||||
@cindex overwriting of input, allowed
|
||||
Write output to @var{output-file} instead of standard output.
|
||||
If necessary, @command{sort} reads input before opening
|
||||
@var{output-file}, so you can safely sort a file in place by using
|
||||
commands like @code{sort F -o F} and @code{cat F | sort -o F}.
|
||||
commands like @code{sort -o F F} and @code{cat F | sort -o F}.
|
||||
|
||||
@vindex POSIXLY_CORRECT
|
||||
If @option{-c} is not also specified, @option{-o} may appear after an
|
||||
input file even if @env{POSIXLY_CORRECT} is set, e.g., @samp{sort F -o
|
||||
F}. Warning: this usage is obsolescent. Future versions of @sc{posix}
|
||||
will require that support for it be withdrawn. Portable scripts should
|
||||
specify @samp{-o @var{output-file}} before any input files.
|
||||
|
||||
@item -S @var{size}
|
||||
@itemx --buffer-size=@var{size}
|
||||
@opindex -S
|
||||
@opindex --buffer-size
|
||||
@cindex size for main memory sorting
|
||||
Use a main-memory sort buffer of the given @var{size}. By default,
|
||||
@var{size} is in units of 1,024 bytes. Appending @samp{%} causes
|
||||
@@ -2307,7 +2370,9 @@ grows beyond @var{size} if @command{sort} encounters input lines larger
|
||||
than @var{size}.
|
||||
|
||||
@item -t @var{separator}
|
||||
@itemx --field-separator=@var{separator}
|
||||
@opindex -t
|
||||
@opindex --field-separator
|
||||
@cindex field separator character
|
||||
Use character @var{separator} as the field separator when finding the
|
||||
sort keys in each line. By default, fields are separated by the empty
|
||||
@@ -2320,7 +2385,9 @@ as @samp{-k 2}, or sort fields consisting of a range, as @samp{-k 2,3},
|
||||
retain the field separators present between the endpoints of the range.
|
||||
|
||||
@item -T @var{tempdir}
|
||||
@itemx --temporary-directory=@var{tempdir}
|
||||
@opindex -T
|
||||
@opindex --temporary-directory
|
||||
@cindex temporary directory
|
||||
@vindex TMPDIR
|
||||
Use directory @var{tempdir} to store temporary files, overriding the
|
||||
@@ -2331,24 +2398,31 @@ performance by using this option to specify directories on different
|
||||
disks and controllers.
|
||||
|
||||
@item -u
|
||||
@itemx --unique
|
||||
@opindex -u
|
||||
@opindex --unique
|
||||
@cindex uniquifying output
|
||||
For the default case or the @samp{-m} option, only output the first
|
||||
of a sequence of lines that compare equal. For the @samp{-c} option,
|
||||
|
||||
Normally, output only the first of a sequence of lines that compare
|
||||
equal. For the @option{--check} (@option{-c}) option,
|
||||
check that no pair of consecutive lines compares equal.
|
||||
|
||||
@item -k @var{pos1}[,@var{pos2}]
|
||||
@itemx --key=@var{pos1}[,@var{pos2}]
|
||||
@opindex -k
|
||||
@opindex --key
|
||||
@cindex sort field
|
||||
The recommended, @sc{posix}, option for specifying a sort field. The field
|
||||
Specify a sort field that
|
||||
consists of the part of the line between @var{pos1} and @var{pos2} (or the
|
||||
end of the line, if @var{pos2} is omitted), @emph{inclusive}.
|
||||
Fields and character positions are numbered starting with 1.
|
||||
So to sort on the second field, you'd use @samp{-k 2,2}
|
||||
So to sort on the second field, you'd use @samp{--key=2,2} (@samp{-k 2,2}).
|
||||
See below for more examples.
|
||||
|
||||
@item -z
|
||||
@itemx --zero-terminated
|
||||
@opindex -z
|
||||
@opindex --zero-terminated
|
||||
@cindex sort zero-terminated lines
|
||||
Treat the input as a set of lines, each terminated by a zero byte (@sc{ascii}
|
||||
@sc{nul} (Null) character) instead of an @sc{ascii} @sc{lf} (Line Feed).
|
||||
@@ -2357,22 +2431,18 @@ This option can be useful in conjunction with @samp{perl -0} or
|
||||
reliably handle arbitrary pathnames (even those which contain Line Feed
|
||||
characters.)
|
||||
|
||||
@item +@var{pos1}[-@var{pos2}]
|
||||
@item +@var{pos1} [-@var{pos2}]
|
||||
The obsolescent, traditional option for specifying a sort field. The field
|
||||
consists of the line between @var{pos1} and up to but @emph{not including}
|
||||
@var{pos2} (or the end of the line if @var{pos2} is omitted). Fields
|
||||
and character positions are numbered starting with 0. See below.
|
||||
|
||||
Warning: the @samp{+@var{pos}} usage is obsolescent. Future versions of
|
||||
Warning: the @samp{+@var{pos1}} usage is obsolescent. Future versions of
|
||||
@sc{posix} will require that support for it be withdrawn. Use
|
||||
@option{-k} instead.
|
||||
@option{--key} (@option{-k}) instead.
|
||||
|
||||
@end table
|
||||
|
||||
In addition, when @sc{gnu} @code{sort} is invoked with exactly one argument,
|
||||
options @samp{--help} and @samp{--version} are recognized. @xref{Common
|
||||
options}.
|
||||
|
||||
Historical (BSD and System V) implementations of @code{sort} have
|
||||
differed in their interpretation of some options, particularly
|
||||
@samp{-b}, @samp{-f}, and @samp{-n}. @sc{gnu} sort follows the @sc{posix}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2001-04-08 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* getdate.y (get_date): Set tm_isdst to -1 to ensure that it is
|
||||
recomputed; that's necessary when the offset spans a DST transition.
|
||||
Patch by David J. MacKenzie. Reported by Hon-Yin Kok.
|
||||
|
||||
2001-04-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* regex.h, regex.c: Update from GNU libc.
|
||||
|
||||
2001-03-19 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/version-etc.c (version_etc_copyright): Update to 2001.
|
||||
|
||||
@@ -990,7 +990,8 @@ get_date (const char *p, const time_t *now)
|
||||
|
||||
/* Let mktime deduce tm_isdst if we have an absolute time stamp,
|
||||
or if the relative time stamp mentions days, months, or years. */
|
||||
if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day | pc.rel_month | pc.rel_year)
|
||||
if (pc.dates_seen | pc.days_seen | pc.times_seen | pc.rel_day
|
||||
| pc.rel_month | pc.rel_year)
|
||||
tm.tm_isdst = -1;
|
||||
|
||||
/* But if the input explicitly specifies local time with or without
|
||||
@@ -1037,6 +1038,7 @@ get_date (const char *p, const time_t *now)
|
||||
{
|
||||
tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7
|
||||
+ 7 * (pc.day_ordinal - (0 < pc.day_ordinal)));
|
||||
tm.tm_isdst = -1;
|
||||
Start = mktime (&tm);
|
||||
if (Start == (time_t) -1)
|
||||
return Start;
|
||||
|
||||
139
lib/regex.c
139
lib/regex.c
@@ -65,7 +65,7 @@
|
||||
# define CHAR_CLASS_SIZE ((__alignof__(wctype_t)+sizeof(wctype_t))/sizeof(CHAR_TYPE)+1)
|
||||
# define PUT_CHAR(c) \
|
||||
do { \
|
||||
if (MC_CUR_MAX == 1) \
|
||||
if (MB_CUR_MAX == 1) \
|
||||
putchar (c); \
|
||||
else \
|
||||
printf ("%C", (wint_t) c); /* Should we use wide stream?? */ \
|
||||
@@ -2137,21 +2137,21 @@ typedef struct
|
||||
|
||||
|
||||
/* Get the next unsigned number in the uncompiled pattern. */
|
||||
#define GET_UNSIGNED_NUMBER(num) \
|
||||
{ if (p != pend) \
|
||||
{ \
|
||||
PATFETCH (c); \
|
||||
while ('0' <= c && c <= '9') \
|
||||
{ \
|
||||
if (num < 0) \
|
||||
num = 0; \
|
||||
num = num * 10 + c - '0'; \
|
||||
if (p == pend) \
|
||||
break; \
|
||||
PATFETCH (c); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define GET_UNSIGNED_NUMBER(num) \
|
||||
{ \
|
||||
while (p != pend) \
|
||||
{ \
|
||||
PATFETCH (c); \
|
||||
if (c < '0' || c > '9') \
|
||||
break; \
|
||||
if (num <= RE_DUP_MAX) \
|
||||
{ \
|
||||
if (num < 0) \
|
||||
num = 0; \
|
||||
num = num * 10 + c - '0'; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#if defined _LIBC || WIDE_CHAR_SUPPORT
|
||||
/* The GNU C library provides support for user-defined character classes
|
||||
@@ -2325,14 +2325,6 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
/* Address of beginning of regexp, or inside of last group. */
|
||||
US_CHAR_TYPE *begalt;
|
||||
|
||||
/* Place in the uncompiled pattern (i.e., the {) to
|
||||
which to go back if the interval is invalid. */
|
||||
#ifdef MBS_SUPPORT
|
||||
const US_CHAR_TYPE *beg_interval;
|
||||
#else
|
||||
const char *beg_interval;
|
||||
#endif /* MBS_SUPPORT */
|
||||
|
||||
/* Address of the place where a forward jump should go to the end of
|
||||
the containing expression. Each alternative of an `or' -- except the
|
||||
last -- ends with a forward jump of this sort. */
|
||||
@@ -2345,23 +2337,24 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
#ifdef MBS_SUPPORT
|
||||
/* Initialize the wchar_t PATTERN and offset_buffer. */
|
||||
p = pend = pattern = TALLOC(csize, CHAR_TYPE);
|
||||
p = pend = pattern = TALLOC(csize + 1, CHAR_TYPE);
|
||||
mbs_offset = TALLOC(csize + 1, int);
|
||||
is_binary = TALLOC(csize + 1, char);
|
||||
if (pattern == NULL || mbs_offset == NULL || is_binary == NULL)
|
||||
{
|
||||
if (pattern) free(pattern);
|
||||
if (mbs_offset) free(mbs_offset);
|
||||
if (is_binary) free(is_binary);
|
||||
free(pattern);
|
||||
free(mbs_offset);
|
||||
free(is_binary);
|
||||
return REG_ESPACE;
|
||||
}
|
||||
pattern[csize] = L'\0'; /* sentinel */
|
||||
size = convert_mbs_to_wcs(pattern, cpattern, csize, mbs_offset, is_binary);
|
||||
pend = p + size;
|
||||
if (size < 0)
|
||||
{
|
||||
if (pattern) free(pattern);
|
||||
if (mbs_offset) free(mbs_offset);
|
||||
if (is_binary) free(is_binary);
|
||||
free(pattern);
|
||||
free(mbs_offset);
|
||||
free(is_binary);
|
||||
return REG_BADPAT;
|
||||
}
|
||||
#endif
|
||||
@@ -2383,9 +2376,9 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
if (compile_stack.stack == NULL)
|
||||
{
|
||||
#ifdef MBS_SUPPORT
|
||||
if (pattern) free(pattern);
|
||||
if (mbs_offset) free(mbs_offset);
|
||||
if (is_binary) free(is_binary);
|
||||
free(pattern);
|
||||
free(mbs_offset);
|
||||
free(is_binary);
|
||||
#endif
|
||||
return REG_ESPACE;
|
||||
}
|
||||
@@ -3826,25 +3819,19 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
|
||||
/* At least (most) this many matches must be made. */
|
||||
int lower_bound = -1, upper_bound = -1;
|
||||
beg_interval = p - 1;
|
||||
|
||||
/* Place in the uncompiled pattern (i.e., just after
|
||||
the '{') to go back to if the interval is invalid. */
|
||||
const CHAR_TYPE *beg_interval = p;
|
||||
|
||||
if (p == pend)
|
||||
{
|
||||
if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
goto unfetch_interval;
|
||||
else
|
||||
FREE_STACK_RETURN (REG_EBRACE);
|
||||
}
|
||||
goto invalid_interval;
|
||||
|
||||
GET_UNSIGNED_NUMBER (lower_bound);
|
||||
|
||||
if (c == ',')
|
||||
{
|
||||
GET_UNSIGNED_NUMBER (upper_bound);
|
||||
if ((!(syntax & RE_NO_BK_BRACES) && c != '\\')
|
||||
|| ((syntax & RE_NO_BK_BRACES) && c != '}'))
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
|
||||
if (upper_bound < 0)
|
||||
upper_bound = RE_DUP_MAX;
|
||||
}
|
||||
@@ -3852,36 +3839,24 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
/* Interval such as `{1}' => match exactly once. */
|
||||
upper_bound = lower_bound;
|
||||
|
||||
if (lower_bound < 0 || upper_bound > RE_DUP_MAX
|
||||
|| lower_bound > upper_bound)
|
||||
{
|
||||
if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
goto unfetch_interval;
|
||||
else
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
}
|
||||
if (! (0 <= lower_bound && lower_bound <= upper_bound))
|
||||
goto invalid_interval;
|
||||
|
||||
if (!(syntax & RE_NO_BK_BRACES))
|
||||
{
|
||||
if (c != '\\') FREE_STACK_RETURN (REG_EBRACE);
|
||||
|
||||
if (c != '\\' || p == pend)
|
||||
goto invalid_interval;
|
||||
PATFETCH (c);
|
||||
}
|
||||
|
||||
if (c != '}')
|
||||
{
|
||||
if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
|
||||
goto unfetch_interval;
|
||||
else
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
}
|
||||
|
||||
/* We just parsed a valid interval. */
|
||||
goto invalid_interval;
|
||||
|
||||
/* If it's invalid to have no preceding re. */
|
||||
if (!laststart)
|
||||
{
|
||||
if (syntax & RE_CONTEXT_INVALID_OPS)
|
||||
if (syntax & RE_CONTEXT_INVALID_OPS
|
||||
&& !(syntax & RE_INVALID_INTERVAL_ORD))
|
||||
FREE_STACK_RETURN (REG_BADRPT);
|
||||
else if (syntax & RE_CONTEXT_INDEP_OPS)
|
||||
laststart = b;
|
||||
@@ -3889,6 +3864,11 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
goto unfetch_interval;
|
||||
}
|
||||
|
||||
/* We just parsed a valid interval. */
|
||||
|
||||
if (RE_DUP_MAX < upper_bound)
|
||||
FREE_STACK_RETURN (REG_BADBR);
|
||||
|
||||
/* If the upper bound is zero, don't want to succeed at
|
||||
all; jump from `laststart' to `b + 3', which will be
|
||||
the end of the buffer after we insert the jump. */
|
||||
@@ -3974,25 +3954,20 @@ regex_compile (pattern, size, syntax, bufp)
|
||||
}
|
||||
}
|
||||
pending_exact = 0;
|
||||
beg_interval = NULL;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
unfetch_interval:
|
||||
/* If an invalid interval, match the characters as literals. */
|
||||
assert (beg_interval);
|
||||
p = beg_interval;
|
||||
beg_interval = NULL;
|
||||
|
||||
/* normal_char and normal_backslash need `c'. */
|
||||
PATFETCH (c);
|
||||
|
||||
if (!(syntax & RE_NO_BK_BRACES))
|
||||
{
|
||||
if (p > pattern && p[-1] == '\\')
|
||||
goto normal_backslash;
|
||||
}
|
||||
goto normal_char;
|
||||
invalid_interval:
|
||||
if (!(syntax & RE_INVALID_INTERVAL_ORD))
|
||||
FREE_STACK_RETURN (p == pend ? REG_EBRACE : REG_BADBR);
|
||||
unfetch_interval:
|
||||
/* Match the characters as literals. */
|
||||
p = beg_interval;
|
||||
c = '{';
|
||||
if (syntax & RE_NO_BK_BRACES)
|
||||
goto normal_char;
|
||||
else
|
||||
goto normal_backslash;
|
||||
}
|
||||
|
||||
#ifdef emacs
|
||||
/* There is no way to specify the before_dot and after_dot
|
||||
|
||||
@@ -160,6 +160,11 @@ typedef unsigned long int reg_syntax_t;
|
||||
this bit set, and it won't affect anything in the normal case. */
|
||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
||||
|
||||
/* If this bit is set, a syntactically invalid interval is treated as
|
||||
a string of ordinary characters. For example, the ERE 'a{1' is
|
||||
treated as 'a\{1'. */
|
||||
#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
|
||||
|
||||
/* This global variable defines the particular regexp syntax to use (for
|
||||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
@@ -199,7 +204,8 @@ extern reg_syntax_t re_syntax_options;
|
||||
| RE_NO_BK_VBAR)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EGREP \
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
|
||||
| RE_INVALID_INTERVAL_ORD)
|
||||
|
||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
19
m4/ChangeLog
19
m4/ChangeLog
@@ -1,3 +1,22 @@
|
||||
2001-04-21 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* rmdir-errno.m4: Write to a new file, so that a restrictive umask
|
||||
doesn't interfere.
|
||||
|
||||
2001-04-21 Alexandre Duret-Lutz <duret_g@epita.fr>
|
||||
|
||||
* ftruncate.m4: Check for chsize.
|
||||
Link with ftruncate.o unconditionally if ftruncate is missing.
|
||||
This was required when cross-compiling to i586-mingw32msvc.
|
||||
|
||||
2001-03-24 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* jm-macros.m4: Require autoconf-2.49d.
|
||||
|
||||
2001-03-20 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* iconv.m4 (jm_ICONV): Recommend GNU libiconv.
|
||||
|
||||
2001-03-17 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* memcmp.m4 (jm_AC_FUNC_MEMCMP): Remove my copy of AC_FUNC_MEMCMP,
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
# See if we need to emulate a missing ftruncate function using fcntl.
|
||||
# See if we need to emulate a missing ftruncate function using fcntl or chsize.
|
||||
|
||||
AC_DEFUN(jm_FUNC_FTRUNCATE,
|
||||
[
|
||||
AC_CHECK_FUNCS(ftruncate, , [ftruncate_missing=yes])
|
||||
|
||||
if test "$ftruncate_missing" = yes; then
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
AC_MSG_CHECKING([fcntl emulation of ftruncate])
|
||||
AC_CACHE_VAL(fu_cv_sys_ftruncate_emulation,
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>], [
|
||||
#if !defined(F_CHSIZE) && !defined(F_FREESP)
|
||||
chsize();
|
||||
#endif
|
||||
],
|
||||
fu_cv_sys_ftruncate_emulation=yes,
|
||||
fu_cv_sys_ftruncate_emulation=no)])
|
||||
AC_MSG_RESULT($fu_cv_sys_ftruncate_emulation)
|
||||
if test $fu_cv_sys_ftruncate_emulation = yes; then
|
||||
AC_LIBOBJ(ftruncate)
|
||||
fi
|
||||
AC_CHECK_HEADERS([unistd.h])
|
||||
AC_CHECK_FUNCS([chsize])
|
||||
AC_LIBOBJ(ftruncate)
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
AC_DEFUN(jm_ICONV,
|
||||
[
|
||||
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
|
||||
dnl those with the standalone portable libiconv installed).
|
||||
dnl those with the standalone portable GNU libiconv installed).
|
||||
AC_CACHE_CHECK(for iconv, jm_cv_func_iconv, [
|
||||
jm_cv_func_iconv="no, consider installing libiconv"
|
||||
jm_cv_func_iconv="no, consider installing GNU libiconv"
|
||||
jm_cv_lib_iconv=no
|
||||
AC_TRY_LINK([#include <stdlib.h>
|
||||
#include <iconv.h>],
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#serial 34 -*- autoconf -*-
|
||||
#serial 35 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
AC_DEFUN(jm_MACROS,
|
||||
[
|
||||
AC_PREREQ(2.14d)
|
||||
AC_PREREQ(2.49d)
|
||||
|
||||
GNU_PACKAGE="GNU $PACKAGE"
|
||||
AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
# When rmdir fails because the specified directory is not empty, it sets
|
||||
# errno to some value, usually ENOTEMPTY. However, on some AIX systems,
|
||||
@@ -25,12 +25,12 @@ extern int errno;
|
||||
int val;
|
||||
rmdir ("confdir2");
|
||||
val = errno;
|
||||
s = fopen ("confdir2/file", "w");
|
||||
s = fopen ("confdir2/errno", "w");
|
||||
fprintf (s, "%d\n", val);
|
||||
exit (0);
|
||||
}
|
||||
],
|
||||
fetish_cv_func_rmdir_errno_not_empty=`cat confdir2/file`,
|
||||
fetish_cv_func_rmdir_errno_not_empty=`cat confdir2/errno`,
|
||||
fetish_cv_func_rmdir_errno_not_empty='configure error in rmdir-errno.m4',
|
||||
fetish_cv_func_rmdir_errno_not_empty=ENOTEMPTY
|
||||
)
|
||||
|
||||
@@ -1,3 +1,67 @@
|
||||
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.
|
||||
|
||||
* configure, aclocal.m4, etc.: Regenerate using autoconf-2.49e.
|
||||
|
||||
* doc/fileutils.texi (touch invocation): Discuss ctime.
|
||||
Based on suggestions and contributions from Aharon Robbins
|
||||
and Dan Jacobson.
|
||||
|
||||
* src/ls.c (main): 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, `mkdir d; ls no-dir d 2>/dev/null' would act like
|
||||
`ls d' and produce no output. Now, it prints `d:'.
|
||||
Report and patch from Stéphane Chazelas.
|
||||
* tests/ls-2/tests: New tests, for the above fix.
|
||||
|
||||
2001-04-08 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* depcomp: New version, from automake.
|
||||
|
||||
2000-10-31 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* ls.c: Don't inspect MB_LEN_MAX. Paul Eggert says it's
|
||||
not always defined correctly.
|
||||
|
||||
2001-04-03 John David Anglin <dave@hiauly1.hia.nrc.ca>
|
||||
|
||||
* tests/chgrp/basic: Ensure that initial group id's are properly set
|
||||
for `d' and `d/f3'.
|
||||
|
||||
2001-04-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/mv/setup: Skip nonexistent directories so we don't get
|
||||
diagnostics from df about e.g., `/usr/tmp not found'.
|
||||
|
||||
2001-03-24 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* configure.in: Don't require autoconf version here -- it's done in m4/.
|
||||
|
||||
2001-03-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0.43.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
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,
|
||||
`mkdir d; ls no-dir d 2>/dev/null' would act like `ls d' and produce
|
||||
no output. Now, it prints `d:'.
|
||||
* touch -d 'last friday' would use a time stamp that was one hour off
|
||||
(e.g., 23:00 on *thursday* rather than 00:00 of the preceding friday)
|
||||
when run such that the current time and the target date/time fall on
|
||||
opposite sides of a daylight savings time transition.
|
||||
This problem arises only with relative date strings like `last monday'.
|
||||
It is not a problem with strings that include absolute dates.
|
||||
[4.0.43]
|
||||
* regenerate configure-related files using autoconf-2.49d
|
||||
[4.0.42]
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2001-04-20 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* doc/sh-utils.texi (false invocation): Describe how --help and
|
||||
--version are treated with and without POSIXLY_CORRECT.
|
||||
(true invocation): Likewise. Forwarded by Michael Stone.
|
||||
|
||||
2001-03-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/Fetish.pm: If the $DJDIR envvar is defined, set SHELL
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
Changes in release 2.1
|
||||
[2.0.12]
|
||||
* date -d 'last friday' print a date/time that was one hour off
|
||||
(e.g., 23:00 on *thursday* rather than 00:00 of the preceding friday)
|
||||
when run such that the current time and the target date/time fall on
|
||||
opposite sides of a daylight savings time transition.
|
||||
This problem arises only with relative date strings like `last monday'.
|
||||
It is not a problem with strings that include absolute dates.
|
||||
[2.0.11]
|
||||
* setting the date now works properly, even when using -u
|
||||
* `date -f - < /dev/null' no longer dumps core
|
||||
|
||||
@@ -1,3 +1,72 @@
|
||||
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.
|
||||
Suggestion from Solar Designer.
|
||||
|
||||
2001-04-14 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/wc.c (usage): Tweak --help output: s/line,/newline,/
|
||||
|
||||
2001-04-13 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sort.c (main): Add a comment justifying the use of
|
||||
`multi-character' rather than `multibyte' in a diagnostic.
|
||||
From Paul Eggert.
|
||||
|
||||
2001-04-12 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sort.c (RLIMIT_AS): Do not define; just use conditional
|
||||
code, since RLIMIT_RSS is similar (and is not standardized).
|
||||
(default_sort_size): Don't allocate more than the RSS limit,
|
||||
if this host has such a limit.
|
||||
|
||||
2001-03-20 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* NEWS, doc/textutils.texi: sort now accepts long options and
|
||||
checks POSIX option syntax.
|
||||
|
||||
* doc/textutils.texi: Document --, -, sort long options, and
|
||||
sort -o after files.
|
||||
|
||||
* src/sort.c: Include <getopt.h>.
|
||||
(usage, main): Add support for long options, and check option
|
||||
syntax as POSIX requires, though (as usual for GNU apps)
|
||||
options can follow file names unless POSIXLY_CORRECT is set.
|
||||
Many diagnostic revamped.
|
||||
(long_options): New constant.
|
||||
(badfieldspec): New arg MSGID. Mark as noreturn.
|
||||
(parse_field_count): New arg MSGID; if null, just return null on error.
|
||||
(new_key): Renamed from key_init. All callers changed. Now allocates
|
||||
the new key.
|
||||
|
||||
2001-03-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0.13.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
29
src/ls.c
29
src/ls.c
@@ -70,11 +70,6 @@
|
||||
#include <pwd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
/* Get MB_LEN_MAX. */
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Get MB_CUR_MAX. */
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
@@ -345,16 +340,13 @@ char *program_name;
|
||||
`files_index' is the number actually in use. */
|
||||
|
||||
/* Address of block containing the files that are described. */
|
||||
|
||||
static struct fileinfo *files;
|
||||
static struct fileinfo *files; /* FIXME: rename this to e.g. cwd_file */
|
||||
|
||||
/* Length of block that `files' points to, measured in files. */
|
||||
|
||||
static int nfiles;
|
||||
static int nfiles; /* FIXME: rename this to e.g. cwd_n_alloc */
|
||||
|
||||
/* Index of first unused in `files'. */
|
||||
|
||||
static int files_index;
|
||||
static int files_index; /* FIXME: rename this to e.g. cwd_n_used */
|
||||
|
||||
/* When nonzero, in a color listing, color each symlink name according to the
|
||||
type of file it points to. Otherwise, color them according to the `ln'
|
||||
@@ -854,6 +846,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
register int i;
|
||||
register struct pending *thispend;
|
||||
unsigned int n_files;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -901,8 +894,10 @@ main (int argc, char **argv)
|
||||
|
||||
clear_files ();
|
||||
|
||||
if (i < argc)
|
||||
n_files = argc - i;
|
||||
if (0 < n_files)
|
||||
dir_defaulted = 0;
|
||||
|
||||
for (; i < argc; i++)
|
||||
{
|
||||
gobble_file (argv[i], unknown, 1, "");
|
||||
@@ -929,7 +924,7 @@ main (int argc, char **argv)
|
||||
if (pending_dirs)
|
||||
DIRED_PUTCHAR ('\n');
|
||||
}
|
||||
else if (pending_dirs && pending_dirs->next == 0)
|
||||
else if (n_files <= 1 && pending_dirs && pending_dirs->next == 0)
|
||||
print_dir_name = 0;
|
||||
|
||||
while (pending_dirs)
|
||||
@@ -1274,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:
|
||||
@@ -2644,7 +2641,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options)
|
||||
|
||||
if (qmark_funny_chars)
|
||||
{
|
||||
#if HAVE_MBRTOWC && (MB_LEN_MAX > 1)
|
||||
#if HAVE_MBRTOWC
|
||||
if (MB_CUR_MAX > 1)
|
||||
{
|
||||
const char *p = buf;
|
||||
@@ -2765,7 +2762,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options)
|
||||
else
|
||||
{
|
||||
/* Assume unprintable characters have a displayed_width of 1. */
|
||||
#if HAVE_MBRTOWC && (MB_LEN_MAX > 1)
|
||||
#if HAVE_MBRTOWC
|
||||
if (MB_CUR_MAX > 1)
|
||||
displayed_width = mbsnwidth (buf, len,
|
||||
(MBSW_ACCEPT_INVALID
|
||||
|
||||
562
src/sort.c
562
src/sort.c
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -45,9 +46,6 @@
|
||||
struct rlimit { size_t rlim_cur; };
|
||||
# define getrlimit(Resource, Rlp) (-1)
|
||||
#endif
|
||||
#ifndef RLIMIT_AS
|
||||
# define RLIMIT_AS RLIMIT_DATA
|
||||
#endif
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "sort"
|
||||
@@ -291,29 +289,36 @@ Usage: %s [OPTION]... [FILE]...\n\
|
||||
printf (_("\
|
||||
Write sorted concatenation of all FILE(s) to standard output.\n\
|
||||
\n\
|
||||
-b ignore leading blanks in sort fields or keys\n\
|
||||
-c check if given files already sorted, do not sort\n\
|
||||
-d consider only blanks and alphanumeric characters in keys\n\
|
||||
-f fold lower case to upper case characters in keys\n\
|
||||
-g compare according to general numerical value, imply -b\n\
|
||||
-i consider only printable characters in keys\n\
|
||||
-k POS1[,POS2] start a key at POS1, end it *at* POS2 (origin 1)\n\
|
||||
-m merge already sorted files, do not sort\n\
|
||||
-M compare (unknown) < `JAN' < ... < `DEC', imply -b\n\
|
||||
-n compare according to string numerical value, imply -b\n\
|
||||
-o FILE write result on FILE instead of standard output\n\
|
||||
-r reverse the result of comparisons\n\
|
||||
-s stabilize sort by disabling last resort comparison\n\
|
||||
-S SIZE use SIZE for main memory sorting\n\
|
||||
-t SEP use SEParator instead of non- to whitespace transition\n\
|
||||
-T DIRECTORY use DIRECTORY for temporary files, not $TMPDIR or %s\n\
|
||||
multiple -T options specify multiple directories\n\
|
||||
-u with -c, check for strict ordering;\n\
|
||||
with -m, only output the first of an equal sequence\n\
|
||||
-z end lines with 0 byte, not newline, for find -print0\n\
|
||||
+POS1 [-POS2] start a key at POS1, end it *before* POS2 (origin 0)\n\
|
||||
Warning: this option is obsolescent and support for it\n\
|
||||
will be withdrawn. Use -k instead.\n\
|
||||
Ordering options:\n\
|
||||
\n\
|
||||
-b, --ignore-leading-blanks ignore leading blanks\n\
|
||||
-d, --dictionary-order consider only blanks and alphanumeric characters\n\
|
||||
-f, --ignore-case fold lower case to upper case characters\n\
|
||||
-g, --general-numeric-sort compare according to general numerical value\n\
|
||||
-i, --ignore-nonprinting consider only printable characters\n\
|
||||
-M, --month-sort compare (unknown) < `JAN' < ... < `DEC'\n\
|
||||
-n, --numeric-sort compare according to string numerical value\n\
|
||||
-r, --reverse reverse the result of comparisons\n\
|
||||
\n\
|
||||
")
|
||||
);
|
||||
printf (_("\
|
||||
Other options:\n\
|
||||
\n\
|
||||
-c, --check check whether input is sorted; do not sort\n\
|
||||
-k, --key=POS1[,POS2] start a key at POS1, end it at POS 2 (origin 1)\n\
|
||||
-m, --merge merge already sorted files; do not sort\n\
|
||||
-o, --output=FILE write result to FILE instead of standard output\n\
|
||||
-s, --stable stabilize sort by disabling last-resort comparison\n\
|
||||
-S, --buffer-size=SIZE use SIZE for main memory buffer\n\
|
||||
-t, --field-separator=SEP use SEP instead of non- to whitespace transition\n\
|
||||
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or %s\n\
|
||||
multiple options specify multiple directories\n\
|
||||
-u, --unique with -c: check for strict ordering\n\
|
||||
otherwise: output only the first of an equal run\n\
|
||||
-z, --zero-terminated end lines with 0 byte, not newline\n\
|
||||
+POS1 [-POS2] start a key at POS1, end it before POS2 (origin 0)\n\
|
||||
Warning: this option is obsolescent\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
@@ -322,9 +327,9 @@ Write sorted concatenation of all FILE(s) to standard output.\n\
|
||||
printf (_("\
|
||||
POS is F[.C][OPTS], where F is the field number and C the character position\n\
|
||||
in the field, both counted from one with -k, from zero with the obsolescent\n\
|
||||
form. OPTS is made up of one or more of Mbdfinr; this effectively disables\n\
|
||||
global -Mbdfinr settings for that key. If no key is given, use the entire\n\
|
||||
line as the key.\n\
|
||||
form. OPTS is made up of one or more single-letter ordering options, which\n\
|
||||
override global ordering options for that key. If no key is given, use the\n\
|
||||
entire line as the key.\n\
|
||||
\n\
|
||||
SIZE may be followed by the following multiplicative suffixes:\n\
|
||||
%% 1%% of memory, b 1, k 1024 (default), and so on for M, G, T, P, E, Z, Y.\n\
|
||||
@@ -345,6 +350,31 @@ Set LC_ALL=C to get the traditional sort order that uses native byte values.\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"ignore-leading-blanks", no_argument, NULL, 'b'},
|
||||
{"check", no_argument, NULL, 'c'},
|
||||
{"dictionary-order", no_argument, NULL, 'd'},
|
||||
{"ignore-case", no_argument, NULL, 'f'},
|
||||
{"general-numeric-sort", no_argument, NULL, 'g'},
|
||||
{"ignore-nonprinting", no_argument, NULL, 'i'},
|
||||
{"key", required_argument, NULL, 'k'},
|
||||
{"merge", no_argument, NULL, 'm'},
|
||||
{"month-sort", no_argument, NULL, 'M'},
|
||||
{"numeric-sort", no_argument, NULL, 'n'},
|
||||
{"output", required_argument, NULL, 'o'},
|
||||
{"reverse", no_argument, NULL, 'r'},
|
||||
{"stable", no_argument, NULL, 's'},
|
||||
{"buffer-size", required_argument, NULL, 'S'},
|
||||
{"field-separator", required_argument, NULL, 't'},
|
||||
{"temporary-directory", required_argument, NULL, 'T'},
|
||||
{"unique", no_argument, NULL, 'u'},
|
||||
{"zero-terminated", no_argument, NULL, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
/* The set of signals that are caught. */
|
||||
static sigset_t caught_signals;
|
||||
|
||||
@@ -632,11 +662,24 @@ default_sort_size (void)
|
||||
size = mem;
|
||||
if (getrlimit (RLIMIT_DATA, &rlimit) == 0 && rlimit.rlim_cur < size)
|
||||
size = rlimit.rlim_cur;
|
||||
#ifdef RLIMIT_AS
|
||||
if (getrlimit (RLIMIT_AS, &rlimit) == 0 && rlimit.rlim_cur < size)
|
||||
size = rlimit.rlim_cur;
|
||||
#endif
|
||||
|
||||
/* Use half of SIZE, but no less than the minimum. */
|
||||
return MAX (size / 2, MIN_SORT_SIZE);
|
||||
/* Leave a large safety margin for the above limits, as failure can
|
||||
occur when they are exceeded. */
|
||||
size /= 2;
|
||||
|
||||
#ifdef RLIMIT_RSS
|
||||
/* Leave a 1/16 margin for RSS to leave room for code, stack, etc.
|
||||
Exceeding RSS is not fatal, but can be quite slow. */
|
||||
if (getrlimit (RLIMIT_RSS, &rlimit) == 0 && rlimit.rlim_cur / 16 * 15 < size)
|
||||
size = rlimit.rlim_cur / 16 * 15;
|
||||
#endif
|
||||
|
||||
/* Use no less than the minimum. */
|
||||
return MAX (size, MIN_SORT_SIZE);
|
||||
}
|
||||
|
||||
/* Return the sort buffer size to use with the input files identified
|
||||
@@ -1975,21 +2018,26 @@ insertkey (struct keyfield *key)
|
||||
key->next = NULL;
|
||||
}
|
||||
|
||||
/* Report a bad field specification SPEC, with extra info MSGID. */
|
||||
|
||||
static void badfieldspec PARAMS ((char const *, char const *))
|
||||
ATTRIBUTE_NORETURN;
|
||||
static void
|
||||
badfieldspec (const char *s)
|
||||
badfieldspec (char const *spec, char const *msgid)
|
||||
{
|
||||
error (SORT_FAILURE, 0, _("invalid field specification `%s'"), s);
|
||||
error (SORT_FAILURE, 0, _("%s: invalid field specification `%s'"),
|
||||
_(msgid), spec);
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Parse the leading integer in STRING and store the resulting value
|
||||
(which must fit into size_t) into *VAL. Return the address of the
|
||||
suffix after the integer. */
|
||||
suffix after the integer. If MSGID is NULL, return NULL after
|
||||
failure; otherwise, report MSGID and exit on failure. */
|
||||
|
||||
static char const *
|
||||
parse_field_count (char const *string, size_t *val)
|
||||
parse_field_count (char const *string, size_t *val, char const *msgid)
|
||||
{
|
||||
/* '@' can't possibly be a valid suffix; return &invalid_suffix so that
|
||||
the caller will eventually invoke badfieldspec. */
|
||||
static char const invalid_suffix = '@';
|
||||
char *suffix;
|
||||
uintmax_t n;
|
||||
|
||||
@@ -2002,13 +2050,16 @@ parse_field_count (char const *string, size_t *val)
|
||||
break;
|
||||
/* Fall through. */
|
||||
case LONGINT_OVERFLOW:
|
||||
error (0, 0, _("count `%.*s' too large"),
|
||||
(int) (suffix - string), string);
|
||||
return &invalid_suffix;
|
||||
if (msgid)
|
||||
error (SORT_FAILURE, 0, _("%s: count `%.*s' too large"),
|
||||
_(msgid), (int) (suffix - string), string);
|
||||
return NULL;
|
||||
|
||||
case LONGINT_INVALID:
|
||||
error (0, 0, _("invalid count at start of `%s'"), string);
|
||||
return &invalid_suffix;
|
||||
if (msgid)
|
||||
error (SORT_FAILURE, 0, _("%s: invalid count at start of `%s'"),
|
||||
_(msgid), string);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return suffix;
|
||||
@@ -2089,20 +2140,24 @@ set_ordering (register const char *s, struct keyfield *key,
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
static void
|
||||
key_init (struct keyfield *key)
|
||||
static struct keyfield *
|
||||
new_key (void)
|
||||
{
|
||||
memset (key, 0, sizeof (*key));
|
||||
struct keyfield *key = (struct keyfield *) xcalloc (1, sizeof *key);
|
||||
key->eword = -1;
|
||||
return key;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct keyfield *key = NULL, gkey;
|
||||
struct keyfield *key;
|
||||
struct keyfield gkey;
|
||||
char const *s;
|
||||
int i;
|
||||
int c = 0;
|
||||
int checkonly = 0, mergeonly = 0, nfiles = 0;
|
||||
int posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL);
|
||||
char *minus = "-", **files;
|
||||
char const *outfile = minus;
|
||||
static int const sigs[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM };
|
||||
@@ -2143,9 +2198,6 @@ main (int argc, char **argv)
|
||||
|
||||
#endif /* NLS */
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
have_read_stdin = 0;
|
||||
inittables ();
|
||||
|
||||
@@ -2183,236 +2235,201 @@ main (int argc, char **argv)
|
||||
|
||||
files = (char **) xmalloc (sizeof (char *) * argc);
|
||||
|
||||
for (i = 1; i < argc; ++i)
|
||||
for (;;)
|
||||
{
|
||||
if (argv[i][0] == '+')
|
||||
/* Parse an operand as a file after "--" was seen; or if
|
||||
pedantic and a file was seen, unless -c was not seen and the
|
||||
operand is "-o FILE" or "-oFILE". POSIX 1003.1-200x d5
|
||||
removes the exception for the -o options; when it becomes
|
||||
official the code will need to be changed. */
|
||||
|
||||
if (c == -1
|
||||
|| (posix_pedantic && nfiles != 0
|
||||
&& ! (! checkonly
|
||||
&& optind != argc
|
||||
&& argv[optind][0] == '-' && argv[optind][1] == 'o'
|
||||
&& (argv[optind][2] || optind + 1 != argc)))
|
||||
|| ((c = getopt_long (argc, argv,
|
||||
"-bcdfgik:mMno:rsS:t:T:uy::z",
|
||||
long_options, NULL))
|
||||
== -1))
|
||||
{
|
||||
if (key)
|
||||
insertkey (key);
|
||||
key = (struct keyfield *) xmalloc (sizeof (struct keyfield));
|
||||
key_init (key);
|
||||
s = argv[i] + 1;
|
||||
if (! (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1]))))
|
||||
badfieldspec (argv[i]);
|
||||
s = parse_field_count (s, &key->sword);
|
||||
if (optind == argc)
|
||||
break;
|
||||
files[nfiles++] = argv[optind++];
|
||||
}
|
||||
else switch (c)
|
||||
{
|
||||
case 1:
|
||||
/* Treat +POS1 [-POS2] as a key if possible; but silently
|
||||
treat an operand as a file if it is not a valid +POS1.
|
||||
POSIX 1003.1-200x d5 does not allow support for +POS1, so
|
||||
when it becomes official this code will need to be
|
||||
changed. */
|
||||
key = NULL;
|
||||
if (optarg[0] == '+')
|
||||
{
|
||||
key = new_key ();
|
||||
s = parse_field_count (optarg + 1, &key->sword, NULL);
|
||||
if (s && *s == '.')
|
||||
s = parse_field_count (s + 1, &key->schar, NULL);
|
||||
if (! (key->sword | key->schar))
|
||||
key->sword = -1;
|
||||
if (! s || *set_ordering (s, key, bl_start))
|
||||
{
|
||||
free (key);
|
||||
key = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (optind != argc && argv[optind][0] == '-'
|
||||
&& ISDIGIT (argv[optind][1]))
|
||||
{
|
||||
char const *optarg1 = argv[optind++];
|
||||
s = parse_field_count (optarg1 + 1, &key->eword,
|
||||
N_("invalid number after `-'"));
|
||||
if (*s == '.')
|
||||
s = parse_field_count (s + 1, &key->echar,
|
||||
N_("invalid number after `.'"));
|
||||
if (*set_ordering (s, key, bl_end))
|
||||
badfieldspec (optarg1,
|
||||
N_("stray character in field spec"));
|
||||
}
|
||||
insertkey (key);
|
||||
}
|
||||
}
|
||||
if (! key)
|
||||
files[nfiles++] = optarg;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
case 'd':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'i':
|
||||
case 'M':
|
||||
case 'n':
|
||||
case 'r':
|
||||
{
|
||||
char str[2];
|
||||
str[0] = c;
|
||||
str[1] = '\0';
|
||||
set_ordering (str, &gkey, bl_both);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
checkonly = 1;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
key = new_key ();
|
||||
|
||||
/* Get POS1. */
|
||||
s = parse_field_count (optarg, &key->sword,
|
||||
N_("invalid number at field start"));
|
||||
if (! key->sword--)
|
||||
{
|
||||
/* Provoke with `sort -k0' */
|
||||
badfieldspec (optarg, N_("field number is zero"));
|
||||
}
|
||||
if (*s == '.')
|
||||
s = parse_field_count (s + 1, &key->schar);
|
||||
{
|
||||
s = parse_field_count (s + 1, &key->schar,
|
||||
N_("invalid number after `.'"));
|
||||
if (! key->schar--)
|
||||
{
|
||||
/* Provoke with `sort -k1.0' */
|
||||
badfieldspec (optarg, N_("character offset is zero"));
|
||||
}
|
||||
}
|
||||
if (! (key->sword | key->schar))
|
||||
key->sword = -1;
|
||||
s = set_ordering (s, key, bl_start);
|
||||
if (*s)
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
else if (argv[i][0] == '-' && argv[i][1])
|
||||
{
|
||||
s = argv[i] + 1;
|
||||
if (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1])))
|
||||
if (*s != ',')
|
||||
{
|
||||
if (!key)
|
||||
{
|
||||
/* Provoke with `sort -9'. */
|
||||
error (0, 0, _("when using the old-style +POS and -POS \
|
||||
key specifiers,\nthe +POS specifier must come first"));
|
||||
usage (SORT_FAILURE);
|
||||
}
|
||||
s = parse_field_count (s, &key->eword);
|
||||
if (*s == '.')
|
||||
s = parse_field_count (s + 1, &key->echar);
|
||||
s = set_ordering (s, key, bl_end);
|
||||
if (*s)
|
||||
badfieldspec (argv[i]);
|
||||
insertkey (key);
|
||||
key = NULL;
|
||||
key->eword = -1;
|
||||
key->echar = 0;
|
||||
}
|
||||
else
|
||||
while (*s)
|
||||
{
|
||||
s = set_ordering (s, &gkey, bl_both);
|
||||
switch (*s)
|
||||
{
|
||||
case '\0':
|
||||
break;
|
||||
case 'c':
|
||||
checkonly = 1;
|
||||
break;
|
||||
case 'k':
|
||||
if (s[1])
|
||||
++s;
|
||||
else
|
||||
{
|
||||
if (i == argc - 1)
|
||||
error (SORT_FAILURE, 0,
|
||||
_("option `-k' requires an argument"));
|
||||
else
|
||||
s = argv[++i];
|
||||
}
|
||||
if (key)
|
||||
insertkey (key);
|
||||
key = (struct keyfield *)
|
||||
xmalloc (sizeof (struct keyfield));
|
||||
key_init (key);
|
||||
/* Get POS1. */
|
||||
if (!ISDIGIT (*s))
|
||||
badfieldspec (argv[i]);
|
||||
s = parse_field_count (s, &key->sword);
|
||||
if (! key->sword--)
|
||||
{
|
||||
/* Provoke with `sort -k0' */
|
||||
error (0, 0, _("the starting field number argument \
|
||||
to the `-k' option must be positive"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
if (*s == '.')
|
||||
{
|
||||
if (!ISDIGIT (s[1]))
|
||||
{
|
||||
/* Provoke with `sort -k1.' */
|
||||
error (0, 0, _("starting field spec has `.' but \
|
||||
lacks following character offset"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
s = parse_field_count (s + 1, &key->schar);
|
||||
if (! key->schar--)
|
||||
{
|
||||
/* Provoke with `sort -k1.0' */
|
||||
error (0, 0, _("starting field character offset \
|
||||
argument to the `-k' option must be positive"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
}
|
||||
if (! (key->sword | key->schar))
|
||||
key->sword = -1;
|
||||
s = set_ordering (s, key, bl_start);
|
||||
if (*s == 0)
|
||||
{
|
||||
key->eword = -1;
|
||||
key->echar = 0;
|
||||
}
|
||||
else if (*s != ',')
|
||||
badfieldspec (argv[i]);
|
||||
else if (*s == ',')
|
||||
{
|
||||
/* Skip over comma. */
|
||||
++s;
|
||||
if (*s == 0)
|
||||
{
|
||||
/* Provoke with `sort -k1,' */
|
||||
error (0, 0, _("field specification has `,' but \
|
||||
lacks following field spec"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
/* Get POS2. */
|
||||
s = parse_field_count (s, &key->eword);
|
||||
if (! key->eword--)
|
||||
{
|
||||
/* Provoke with `sort -k1,0' */
|
||||
error (0, 0, _("ending field number argument \
|
||||
to the `-k' option must be positive"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
if (*s == '.')
|
||||
{
|
||||
if (!ISDIGIT (s[1]))
|
||||
{
|
||||
/* Provoke with `sort -k1,1.' */
|
||||
error (0, 0, _("ending field spec has `.' \
|
||||
but lacks following character offset"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
s = parse_field_count (s + 1, &key->echar);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* `-k 2,3' is equivalent to `+1 -3'. */
|
||||
key->eword++;
|
||||
}
|
||||
s = set_ordering (s, key, bl_end);
|
||||
if (*s)
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
insertkey (key);
|
||||
key = NULL;
|
||||
goto outer;
|
||||
case 'm':
|
||||
mergeonly = 1;
|
||||
break;
|
||||
case 'o':
|
||||
if (s[1])
|
||||
outfile = s + 1;
|
||||
else
|
||||
{
|
||||
if (i == argc - 1)
|
||||
error (SORT_FAILURE, 0,
|
||||
_("option `-o' requires an argument"));
|
||||
else
|
||||
outfile = argv[++i];
|
||||
}
|
||||
goto outer;
|
||||
case 's':
|
||||
stable = 1;
|
||||
break;
|
||||
case 'S':
|
||||
if (s[1])
|
||||
specify_sort_size (++s);
|
||||
else if (i < argc - 1)
|
||||
specify_sort_size (argv[++i]);
|
||||
else
|
||||
error (SORT_FAILURE, 0,
|
||||
_("option `-S' requires an argument"));
|
||||
goto outer;
|
||||
case 't':
|
||||
if (s[1])
|
||||
tab = *++s;
|
||||
else if (i < argc - 1)
|
||||
{
|
||||
tab = *argv[++i];
|
||||
goto outer;
|
||||
}
|
||||
else
|
||||
error (SORT_FAILURE, 0,
|
||||
_("option `-t' requires an argument"));
|
||||
break;
|
||||
case 'T':
|
||||
if (s[1])
|
||||
add_temp_dir (++s);
|
||||
else
|
||||
{
|
||||
if (i < argc - 1)
|
||||
add_temp_dir (argv[++i]);
|
||||
else
|
||||
error (SORT_FAILURE, 0,
|
||||
_("option `-T' requires an argument"));
|
||||
}
|
||||
goto outer;
|
||||
/* break; */
|
||||
case 'u':
|
||||
unique = 1;
|
||||
break;
|
||||
case 'z':
|
||||
eolchar = 0;
|
||||
break;
|
||||
case 'y':
|
||||
/* Accept and ignore e.g. -y0 for compatibility with
|
||||
Solaris 2. */
|
||||
goto outer;
|
||||
default:
|
||||
fprintf (stderr, _("%s: unrecognized option `-%c'\n"),
|
||||
argv[0], *s);
|
||||
usage (SORT_FAILURE);
|
||||
}
|
||||
if (*s)
|
||||
++s;
|
||||
}
|
||||
}
|
||||
else /* Not an option. */
|
||||
{
|
||||
files[nfiles++] = argv[i];
|
||||
}
|
||||
outer:;
|
||||
}
|
||||
{
|
||||
/* Get POS2. */
|
||||
s = parse_field_count (s + 1, &key->eword,
|
||||
N_("invalid number after `,'"));
|
||||
if (! key->eword--)
|
||||
{
|
||||
/* Provoke with `sort -k1,0' */
|
||||
badfieldspec (optarg, N_("field number is zero"));
|
||||
}
|
||||
if (*s == '.')
|
||||
s = parse_field_count (s + 1, &key->echar,
|
||||
N_("invalid number after `.'"));
|
||||
else
|
||||
{
|
||||
/* `-k 2,3' is equivalent to `+1 -3'. */
|
||||
key->eword++;
|
||||
}
|
||||
s = set_ordering (s, key, bl_end);
|
||||
}
|
||||
if (*s)
|
||||
badfieldspec (optarg, N_("stray character in field spec"));
|
||||
insertkey (key);
|
||||
break;
|
||||
|
||||
if (key)
|
||||
insertkey (key);
|
||||
case 'm':
|
||||
mergeonly = 1;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
outfile = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
stable = 1;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
specify_sort_size (optarg);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
tab = optarg[0];
|
||||
if (tab && optarg[1])
|
||||
{
|
||||
/* Provoke with `sort -txx'. Complain about
|
||||
"multi-character tab" instead of "multibyte tab", so
|
||||
that the diagnostic's wording does not need to be
|
||||
changed once multibyte characters are supported. */
|
||||
error (SORT_FAILURE, 0, _("multi-character tab `%s'"), optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
add_temp_dir (optarg);
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
unique = 1;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
/* Accept and ignore e.g. -y0 for compatibility with Solaris
|
||||
2.x through Solaris 7. -y is marked as obsolete starting
|
||||
with Solaris 8. */
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
eolchar = 0;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
|
||||
default:
|
||||
usage (SORT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Inheritance of global options to individual keys. */
|
||||
for (key = keylist; key; key = key->next)
|
||||
@@ -2451,9 +2468,8 @@ but lacks following character offset"));
|
||||
if (checkonly)
|
||||
{
|
||||
if (nfiles > 1)
|
||||
error (SORT_FAILURE, 0,
|
||||
_("too many arguments; with -c, there may be at most\
|
||||
one file argument"));
|
||||
error (SORT_FAILURE, 0, _("extra operand `%s' not allowed with -c"),
|
||||
files[1]);
|
||||
|
||||
/* POSIX requires that sort return 1 IFF invoked with -c and the
|
||||
input is not properly sorted. */
|
||||
|
||||
2
src/wc.c
2
src/wc.c
@@ -126,7 +126,7 @@ Usage: %s [OPTION]... [FILE]...\n\
|
||||
"),
|
||||
program_name);
|
||||
printf (_("\
|
||||
Print line, word, and byte counts for each FILE, and a total line if\n\
|
||||
Print newline, word, and byte counts for each FILE, and a total line if\n\
|
||||
more than one FILE is specified. With no FILE, or when FILE is -,\n\
|
||||
read standard input.\n\
|
||||
-c, --bytes print the byte counts\n\
|
||||
|
||||
@@ -34,6 +34,7 @@ touch f f2 d/f3
|
||||
chgrp $g1 f || fail=1
|
||||
chgrp $g2 f || fail=1
|
||||
chgrp $g2 f2 || fail=1
|
||||
chgrp -R $g1 d || fail=1
|
||||
|
||||
(
|
||||
chgrp -c $g1 f
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -22,6 +22,11 @@ use strict;
|
||||
my $mkdir = {PRE => sub {mkdir 'd',0755 or die "d: $!\n"}};
|
||||
my $rmdir = {POST => sub {rmdir 'd' or die "d: $!\n"}};
|
||||
|
||||
my $mkdir2 = {PRE => sub {mkdir 'd',0755 or die "d: $!\n";
|
||||
mkdir 'd/e',0755 or die "d/e: $!\n" }};
|
||||
my $rmdir2 = {POST => sub {rmdir 'd/e' or die "d/e: $!\n";
|
||||
rmdir 'd' or die "d: $!\n" }};
|
||||
|
||||
my $slink_d = {PRE => sub {symlink '/', 'd' or die "d: $!\n"}};
|
||||
my $unlink_d = {POST => sub {unlink 'd' or die "d: $!\n"}};
|
||||
|
||||
@@ -58,6 +63,14 @@ my @Tests =
|
||||
|
||||
# FIXME: uncomment the following once ls has been fixed
|
||||
# ['slink-dir2', '-F d', {OUT => "d\@/\n"}, $slink_d, $unlink_d],
|
||||
|
||||
# From Stéphane Chazelas.
|
||||
['no-a-isdir-b', 'no-dir d',
|
||||
{OUT => "d:\n"},
|
||||
{ERR => "ls: no-dir: No such file or directory\n"},
|
||||
$mkdir, $rmdir, {EXIT => 1}],
|
||||
|
||||
['recursive-2', '-R d', {OUT => "d:\ne\n\nd/e:\n"}, $mkdir2, $rmdir2],
|
||||
);
|
||||
|
||||
my $save_temps = $ENV{SAVE_TEMPS};
|
||||
|
||||
@@ -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
|
||||
@@ -17,6 +17,10 @@ other_partition_tmpdir=
|
||||
# if the mount point name contains `% '.
|
||||
dot_mount_point=`df --no-sync -P . | sed -n '2s/.*% *//p'`
|
||||
for d in $CANDIDATE_TMP_DIRS; do
|
||||
|
||||
# Skip nonexistent directories.
|
||||
test -d $d || continue
|
||||
|
||||
d_mount_point=`df --no-sync -P $d | sed -n '2s/.*% *//p'`
|
||||
|
||||
# Same partition? Skip it.
|
||||
|
||||
Reference in New Issue
Block a user