mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
39 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
500f608a4d | ||
|
|
e5eed12981 | ||
|
|
8be71eeb83 | ||
|
|
06683af3c4 | ||
|
|
38d09e7907 | ||
|
|
0e777744cb | ||
|
|
9a887e5ca4 | ||
|
|
495729b1dc | ||
|
|
75e5479220 | ||
|
|
db0dadb263 | ||
|
|
3c21ae616f | ||
|
|
ac25bd69bf | ||
|
|
87364848e2 | ||
|
|
015d9b3c3f | ||
|
|
8a3a8c7126 | ||
|
|
003cf75202 | ||
|
|
51f90506ba | ||
|
|
4a0813fecb | ||
|
|
ee991227ee | ||
|
|
4d57863e63 | ||
|
|
d6c548c783 | ||
|
|
357c999a88 | ||
|
|
6222e67d7f | ||
|
|
110bd4aa65 | ||
|
|
97d75acb2c | ||
|
|
8d598fb33d | ||
|
|
ceb02a40aa | ||
|
|
ea9ec4ab46 | ||
|
|
37f6675617 | ||
|
|
a9583f3841 | ||
|
|
fd008ba80b | ||
|
|
1eb017af63 | ||
|
|
7a545dda54 | ||
|
|
27aafa985a | ||
|
|
df9cb5d5c0 | ||
|
|
375b687738 | ||
|
|
955e21bb83 | ||
|
|
29547b55e4 | ||
|
|
15633a30c4 |
2
THANKS
2
THANKS
@@ -58,5 +58,7 @@ Stuart Kemp: skemp@peter.bmc.com
|
||||
Thomas Bushnell, n/BSG: thomas@gnu.ai.mit.edu
|
||||
Torbjorn Lindgren: tl@funcom.no
|
||||
Tony Leneis: tony@plaza.ds.adp.com
|
||||
Ulrich Drepper: drepper@cygnus.com
|
||||
Volker Borchert: bt@teknon.de
|
||||
Michael Veksler: mveksler@techunix.technion.ac.il
|
||||
Wayne Stewart: wstewa@atl.com
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
% Load plain if necessary, i.e., if running under initex.
|
||||
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
|
||||
%
|
||||
\def\texinfoversion{1998-12-19}%
|
||||
\def\texinfoversion{1999-01-05}%
|
||||
%
|
||||
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98
|
||||
% Free Software Foundation, Inc.
|
||||
@@ -2401,9 +2401,11 @@ width0pt\relax} \fi
|
||||
% (Must be a way to avoid doing expansion at all, and thus not have to
|
||||
% laboriously list every single command here.)
|
||||
\def\@{@}% will be @@ when we switch to @ as escape char.
|
||||
% need these in case \tex is in effect and \{ is a \delimiter again.
|
||||
\let\{ = \lbracecmd
|
||||
\let\} = \rbracecmd
|
||||
% Need these in case \tex is in effect and \{ is a \delimiter again.
|
||||
% But can't use \lbracecmd and \rbracecmd because texindex assumes
|
||||
% braces and backslashes are used only as delimiters.
|
||||
\let\{ = \mylbrace
|
||||
\let\} = \myrbrace
|
||||
\def\_{{\realbackslash _}}%
|
||||
\def\w{\realbackslash w }%
|
||||
\def\bf{\realbackslash bf }%
|
||||
@@ -2834,7 +2836,7 @@ width0pt\relax} \fi
|
||||
\unvbox255
|
||||
\kern-\topskip \kern\baselineskip
|
||||
}}%
|
||||
\eject
|
||||
\eject % run that output routine to set \partialpage
|
||||
%
|
||||
% Use the double-column output routine for subsequent pages.
|
||||
\output = {\doublecolumnout}%
|
||||
@@ -2895,7 +2897,7 @@ width0pt\relax} \fi
|
||||
}
|
||||
\def\enddoublecolumns{%
|
||||
\output = {%
|
||||
% Split the last of the double-column material. Leave on the
|
||||
% Split the last of the double-column material. Leave it on the
|
||||
% current page, no automatic page break.
|
||||
\balancecolumns
|
||||
%
|
||||
@@ -2907,14 +2909,15 @@ width0pt\relax} \fi
|
||||
% called on to balance too much material, but if it is, this makes
|
||||
% the output somewhat more palatable.)
|
||||
\global\output = {\onepageout{\pagecontents\PAGE}}%
|
||||
%
|
||||
% \pagegoal was set to the doubled \vsize above, since we restarted
|
||||
% the current page. We're now back to normal single-column
|
||||
% typesetting, so reset \pagegoal to the normal \vsize.
|
||||
\pagegoal = \vsize
|
||||
}%
|
||||
\eject
|
||||
\endgroup % started in \begindoublecolumns
|
||||
%
|
||||
% \pagegoal was set to the doubled \vsize above, since we restarted
|
||||
% the current page. We're now back to normal single-column
|
||||
% typesetting, so reset \pagegoal to the normal \vsize (after the
|
||||
% \endgroup where \vsize got restored).
|
||||
\pagegoal = \vsize
|
||||
}
|
||||
\def\balancecolumns{%
|
||||
% Called at the end of the double column material.
|
||||
|
||||
@@ -1392,16 +1392,47 @@ Output the last @var{bytes} bytes, instead of final lines. Appending
|
||||
by 1048576.
|
||||
|
||||
@item -f
|
||||
@itemx --follow
|
||||
@itemx --follow[=@var{how}]
|
||||
@opindex -f
|
||||
@opindex --follow
|
||||
@cindex growing files
|
||||
@vindex name @r{follow option}
|
||||
@vindex descriptor @r{follow option}
|
||||
Loop forever trying to read more characters at the end of the file,
|
||||
presumably because the file is growing. Ignored if reading from a pipe.
|
||||
presumably because the file is growing. This option is ignored when
|
||||
reading from a pipe.
|
||||
If more than one file is given, @code{tail} prints a header whenever it
|
||||
gets output from a different file, to indicate which file that output is
|
||||
from.
|
||||
|
||||
There are two ways to specify how you'd like to track files with this option,
|
||||
but that difference is noticeable only when a followed file is removed.
|
||||
If you'd like to continue to track the end of a growing file even after
|
||||
it has been unlinked, use @samp{--follow=descriptor}. This is the default
|
||||
behavior, but it is not useful if you're tracking a log file that may be
|
||||
rotated (removed and reopened). In that case, use @samp{--follow=name} to
|
||||
track the named file by reopening it periodically
|
||||
@c FIXME: cross reference to the new option name
|
||||
to see if it has been removed and recreated by some other program.
|
||||
|
||||
No matter which method you use, if the tracked file is determined to have
|
||||
shrunk, @code{tail} prints a message saying the file has been truncated
|
||||
and resumes tracking the end of the file from the newly-determined endpoint.
|
||||
|
||||
When a file is removed, @code{tail}'s behavior depends on whether it is
|
||||
following the name or the descriptor. When following by name, tail can
|
||||
detect that a file has been removed and gives a message to that effect,
|
||||
and if @samp{--allow-missing} has been specified it will continue checking
|
||||
periodically to see if the file reappears.
|
||||
When following a descriptor, tail does not detect that the file has
|
||||
been unlinked and issues no message.
|
||||
|
||||
The option values @samp{descriptor} and @samp{name} may be specified only
|
||||
with the long form of the option, not with @samp{-f}.
|
||||
|
||||
@c FIXME-describe --allow-missing [useful only with --follow]
|
||||
@c FIXME-describe --sleep-interval [useful only with --follow]
|
||||
|
||||
@itemx -n @var{n}
|
||||
@itemx --lines=@var{n}
|
||||
@opindex -n
|
||||
@@ -2298,6 +2329,17 @@ Ignore differences in case when comparing lines.
|
||||
@cindex duplicate lines, outputting
|
||||
Print only duplicate lines.
|
||||
|
||||
@item -D
|
||||
@itemx --all-repeated
|
||||
@opindex -D
|
||||
@opindex --all-repeated
|
||||
@cindex all duplicate lines, outputting
|
||||
Print all duplicate lines and only duplicate lines.
|
||||
This option is useful mainly in conjunction with other options e.g.,
|
||||
to ignore case or to compare only selected fields.
|
||||
This is a GNU extension.
|
||||
@c FIXME: give an example showing *how* it's useful
|
||||
|
||||
@item -u
|
||||
@itemx --unique
|
||||
@opindex -u
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
ARGMATCH_QUOTING_STYLE. literal_quoting_style is not good. */
|
||||
|
||||
#ifndef ARGMATCH_QUOTING_STYLE
|
||||
# define ARGMATCH_QUOTING_STYLE c_quoting_style
|
||||
# define ARGMATCH_QUOTING_STYLE escape_quoting_style
|
||||
#endif
|
||||
|
||||
extern char *program_name;
|
||||
@@ -131,25 +131,17 @@ argmatch_invalid (const char *kind, const char *value, int problem)
|
||||
{
|
||||
enum quoting_style saved_quoting_style;
|
||||
char const *format;
|
||||
char *quoted_arg;
|
||||
|
||||
/* Make sure to have a good quoting style to report errors.
|
||||
literal is insane here. */
|
||||
saved_quoting_style = get_quoting_style (NULL);
|
||||
set_quoting_style (NULL, ARGMATCH_QUOTING_STYLE);
|
||||
|
||||
/* There is an error */
|
||||
quoted_arg = quotearg (value);
|
||||
|
||||
/* Skip over the first quote character, and overwrite the last one. */
|
||||
++quoted_arg;
|
||||
quoted_arg[strlen (quoted_arg) - 1] = '\0';
|
||||
|
||||
format = (problem == -1
|
||||
? _("%s: invalid argument `%s' for `%s'\n")
|
||||
: _("%s: ambiguous argument `%s' for `%s'\n"));
|
||||
|
||||
fprintf (stderr, format, program_name, quoted_arg, kind);
|
||||
fprintf (stderr, format, program_name, quotearg (value), kind);
|
||||
|
||||
set_quoting_style (NULL, saved_quoting_style);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Host name canonicalization
|
||||
|
||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>
|
||||
|
||||
@@ -46,8 +46,7 @@
|
||||
/* Returns the canonical hostname associated with HOST (allocated in a static
|
||||
buffer), or 0 if it can't be determined. */
|
||||
char *
|
||||
canon_host (host)
|
||||
char *host;
|
||||
canon_host (const char *host)
|
||||
{
|
||||
#ifdef HAVE_GETHOSTBYNAME
|
||||
struct hostent *he = gethostbyname (host);
|
||||
@@ -79,3 +78,17 @@ canon_host (host)
|
||||
#endif /* HAVE_GETHOSTBYNAME */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef TEST_CANON_HOST
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
char *s = canon_host (argv[i]);
|
||||
printf ("%s: %s\n", argv[i], (s ? s : "<undef>"));
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
#endif /* TEST_CANON_HOST */
|
||||
|
||||
@@ -258,11 +258,6 @@ quotearg_buffer (char *buffer, size_t buffersize,
|
||||
case '\t': c = 't'; goto store_escape;
|
||||
case '\v': c = 'v'; goto store_escape;
|
||||
|
||||
case ' ':
|
||||
if (quoting_style == escape_quoting_style)
|
||||
goto store_escape;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (quoting_style == c_quoting_style)
|
||||
goto store_escape;
|
||||
|
||||
23
m4/ChangeLog
23
m4/ChangeLog
@@ -1,3 +1,26 @@
|
||||
1999-01-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* fstypename.m4: Use the new 3-arg form of AC_DEFINE instead of my
|
||||
gross kludge.
|
||||
* inttypes_h.m4: Likewise.
|
||||
* lstat.m4: Likewise.
|
||||
* malloc.m4: Likewise.
|
||||
* readdir.m4: Likewise.
|
||||
* realloc.m4: Likewise.
|
||||
* st_dm_mode.m4: Likewise.
|
||||
* stat.m4: Likewise.
|
||||
* utimbuf.m4: Likewise.
|
||||
* utimes.m4: Likewise.
|
||||
|
||||
* check-decl.m4: Use the new 3-arg form of AC_DEFINE instead of the
|
||||
AC_CHECK_FUNCS hack. Now, it's still a hack, but at least the
|
||||
comments in config.h.in are meaningful.
|
||||
|
||||
* jm-macros.m4: Require autoconf-2.13 here.
|
||||
|
||||
* regex.m4: By default, don't use the included regex.c on systems
|
||||
with glibc 2. Suggestion from Uli Drepper.
|
||||
|
||||
1999-01-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* jm-macros.m4: Replace strcasecmp and strncasecmp.
|
||||
|
||||
@@ -62,6 +62,7 @@ CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DF_PROG = @DF_PROG@
|
||||
GENCAT = @GENCAT@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
@@ -76,16 +77,17 @@ LIBOBJS = @LIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
MVDIR_PROG = @MVDIR_PROG@
|
||||
PACKAGE = @PACKAGE@
|
||||
PERL = @PERL@
|
||||
POFILES = @POFILES@
|
||||
POSUB = @POSUB@
|
||||
POW_LIBM = @POW_LIBM@
|
||||
RANLIB = @RANLIB@
|
||||
U = @U@
|
||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
|
||||
USE_NLS = @USE_NLS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
l = @l@
|
||||
|
||||
EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 check-type.m4 \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 4
|
||||
#serial 5
|
||||
|
||||
dnl This is just a wrapper function to encapsulate this kludge.
|
||||
dnl Putting it in a separate file like this helps share it between
|
||||
@@ -24,15 +24,22 @@ AC_DEFUN(jm_CHECK_DECLS,
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
'
|
||||
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put entries
|
||||
dnl for each of these symbols in the config.h.in.
|
||||
dnl Otherwise, I'd have to update acconfig.h every time I change
|
||||
dnl this list of functions.
|
||||
AC_CHECK_FUNCS(DECL_FREE DECL_LSEEK DECL_MALLOC DECL_MEMCHR DECL_REALLOC \
|
||||
DECL_STPCPY DECL_STRSTR)
|
||||
AC_DEFINE(HAVE_DECL_FREE, 1, [Define if this function is declared.])
|
||||
AC_DEFINE(HAVE_DECL_LSEEK, 1, [Define if this function is declared.])
|
||||
AC_DEFINE(HAVE_DECL_MALLOC, 1, [Define if this function is declared.])
|
||||
AC_DEFINE(HAVE_DECL_MEMCHR, 1, [Define if this function is declared.])
|
||||
AC_DEFINE(HAVE_DECL_REALLOC, 1, [Define if this function is declared.])
|
||||
AC_DEFINE(HAVE_DECL_STPCPY, 1, [Define if this function is declared.])
|
||||
AC_DEFINE(HAVE_DECL_STRSTR, 1, [Define if this function is declared.])
|
||||
fi
|
||||
|
||||
jm_CHECK_DECLARATIONS($headers, free lseek malloc \
|
||||
memchr realloc stpcpy strstr)
|
||||
])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl
|
||||
@@ -25,18 +25,8 @@ AC_DEFUN(jm_FSTYPENAME,
|
||||
)
|
||||
|
||||
if test $fu_cv_sys_f_fstypename_in_statfs = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(F_FSTYPENAME_IN_STATFS)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_F_FSTYPENAME_IN_STATFS
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_F_FSTYPENAME_IN_STATFS, 1,
|
||||
[Define if struct statfs has the f_fstypename member.])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Paul Eggert.
|
||||
|
||||
@@ -7,12 +7,6 @@ dnl From Paul Eggert.
|
||||
|
||||
AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
|
||||
[
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put an entry
|
||||
dnl for `HAVE_INTTYPES_H' in config.h.in.
|
||||
AC_CHECK_FUNCS(INTTYPES_H)
|
||||
fi
|
||||
AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
@@ -21,7 +15,8 @@ AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
|
||||
jm_ac_cv_header_inttypes_h=yes,
|
||||
jm_ac_cv_header_inttypes_h=no)])
|
||||
if test $jm_ac_cv_header_inttypes_h = yes; then
|
||||
ac_kludge=HAVE_INTTYPES_H
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
|
||||
[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
|
||||
and declares uintmax_t. ])
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
AC_DEFUN(jm_MACROS,
|
||||
[
|
||||
AC_PREREQ(2.13) dnl Minimum Autoconf version required.
|
||||
|
||||
dnl This macro actually runs replacement code. See isc-posix.m4.
|
||||
AC_REQUIRE([AC_ISC_POSIX])dnl
|
||||
|
||||
|
||||
22
m4/lstat.m4
22
m4/lstat.m4
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether lstat has the bug that it succeeds when given the
|
||||
@@ -30,22 +30,10 @@ AC_DEFUN(jm_FUNC_LSTAT,
|
||||
jm_cv_func_lstat_empty_string_bug=yes)
|
||||
])
|
||||
if test $jm_cv_func_lstat_empty_string_bug = yes; then
|
||||
|
||||
LIBOBJS="$LIBOBJS lstat.o"
|
||||
|
||||
if test $jm_cv_func_lstat_empty_string_bug = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(LSTAT_EMPTY_STRING_BUG)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_LSTAT_EMPTY_STRING_BUG
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(HAVE_LSTAT_EMPTY_STRING_BUG, 1,
|
||||
[Define if lstat has the bug that it succeeds when given the zero-length
|
||||
file name argument. The lstat from SunOS4.1.4 and the Hurd as of 1998-11-01)
|
||||
do this. ])
|
||||
fi
|
||||
])
|
||||
|
||||
12
m4/malloc.m4
12
m4/malloc.m4
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether malloc accepts 0 as its argument.
|
||||
@@ -12,16 +12,10 @@ dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_MALLOC,
|
||||
[
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put an entry
|
||||
dnl for this symbol in config.h.in.
|
||||
AC_CHECK_FUNCS(DONE_WORKING_MALLOC_CHECK)
|
||||
fi
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
|
||||
ac_kludge=HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
|
||||
[Define if the malloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
|
||||
[AC_TRY_RUN([
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl SunOS's readdir is broken in such a way that rm.c has to add extra code
|
||||
dnl to test whether a NULL return value really means there are no more files
|
||||
@@ -126,16 +126,8 @@ AC_CACHE_CHECK([for working readdir], jm_cv_func_working_readdir,
|
||||
jm_cv_func_working_readdir=no,
|
||||
jm_cv_func_working_readdir=no)])
|
||||
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put an entry
|
||||
dnl for this HAVE_-prefixed symbol in config.h.in.
|
||||
AC_CHECK_FUNCS(WORKING_READDIR)
|
||||
fi
|
||||
|
||||
|
||||
if test $jm_cv_func_working_readdir = yes; then
|
||||
ac_kludge=HAVE_WORKING_READDIR
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_WORKING_READDIR, 1,
|
||||
[Define if readdir is found to work properly in some unusual cases. ])
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether realloc works when both arguments are 0.
|
||||
@@ -12,16 +12,10 @@ dnl
|
||||
|
||||
AC_DEFUN(jm_FUNC_REALLOC,
|
||||
[
|
||||
if test x = y; then
|
||||
dnl This code is deliberately never run via ./configure.
|
||||
dnl FIXME: this is a gross hack to make autoheader put an entry
|
||||
dnl for this symbol in config.h.in.
|
||||
AC_CHECK_FUNCS(DONE_WORKING_REALLOC_CHECK)
|
||||
fi
|
||||
dnl xmalloc.c requires that this symbol be defined so it doesn't
|
||||
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
|
||||
ac_kludge=HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
|
||||
[Define if the realloc check has been performed. ])
|
||||
|
||||
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
|
||||
[AC_TRY_RUN([
|
||||
|
||||
13
m4/regex.m4
13
m4/regex.m4
@@ -1,19 +1,26 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl Derived from code in GNU grep.
|
||||
|
||||
AC_DEFUN(jm_WITH_REGEX,
|
||||
[
|
||||
AC_REQUIRE([AM_GLIBC])
|
||||
|
||||
dnl Even packages that don't use regex.c can use this macro.
|
||||
dnl Of course, for them it doesn't do anything.
|
||||
|
||||
syscmd([test -f lib/regex.c])
|
||||
ifelse(sysval, 0,
|
||||
[
|
||||
# By default, don't use the included regex.c on systems with glibc 2
|
||||
test "$ac_cv_glibc" = yes && default=no || default=yes
|
||||
|
||||
AC_ARG_WITH(included-regex,
|
||||
[ --without-included-regex don't compile regex (use with caution)],
|
||||
[ --without-included-regex don't compile regex; this is the default on
|
||||
systems with version 2 of the GNU C library
|
||||
(use with caution on other system)],
|
||||
jm_with_regex=$withval,
|
||||
jm_with_regex=yes)
|
||||
jm_with_regex=$default)
|
||||
if test "$jm_with_regex" = yes; then
|
||||
LIBOBJS="$LIBOBJS regex.o"
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#serial 2
|
||||
|
||||
# Define HAVE_ST_DM_MODE if struct stat has an st_dm_mode member.
|
||||
|
||||
AC_DEFUN(AC_STRUCT_ST_DM_MODE,
|
||||
@@ -8,18 +10,8 @@ AC_DEFUN(AC_STRUCT_ST_DM_MODE,
|
||||
ac_cv_struct_st_dm_mode=no)])
|
||||
|
||||
if test $ac_cv_struct_st_dm_mode = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to add the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(ST_DM_MODE)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_ST_DM_MODE
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_ST_DM_MODE, 1,
|
||||
[Define if struct stat has an st_dm_mode member. ])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
22
m4/stat.m4
22
m4/stat.m4
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl From Jim Meyering.
|
||||
dnl Determine whether stat has the bug that it succeeds when given the
|
||||
@@ -30,22 +30,10 @@ AC_DEFUN(jm_FUNC_STAT,
|
||||
jm_cv_func_stat_empty_string_bug=yes)
|
||||
])
|
||||
if test $jm_cv_func_stat_empty_string_bug = yes; then
|
||||
|
||||
LIBOBJS="$LIBOBJS stat.o"
|
||||
|
||||
if test $jm_cv_func_stat_empty_string_bug = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(STAT_EMPTY_STRING_BUG)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_STAT_EMPTY_STRING_BUG
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(HAVE_STAT_EMPTY_STRING_BUG, 1,
|
||||
[Define if stat has the bug that it succeeds when given the zero-length
|
||||
file name argument. The stat from SunOS4.1.4 and the Hurd as of 1998-11-01)
|
||||
do this. ])
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl From Jim Meyering
|
||||
|
||||
@@ -33,17 +33,8 @@ AC_DEFUN(jm_STRUCT_UTIMBUF,
|
||||
])
|
||||
|
||||
if test $fu_cv_sys_struct_utimbuf = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(STRUCT_UTIMBUF)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_STRUCT_UTIMBUF
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_STRUCT_UTIMBUF, 1,
|
||||
[Define if struct utimbuf is declared -- usually in <utime.h>.
|
||||
Some systems have utime.h but don't declare the struct anywhere. ])
|
||||
fi
|
||||
])
|
||||
|
||||
19
m4/utimes.m4
19
m4/utimes.m4
@@ -1,6 +1,7 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL.
|
||||
dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL,
|
||||
dnl then do case-insensitive s/utime/utimes/.
|
||||
|
||||
AC_DEFUN(jm_FUNC_UTIMES_NULL,
|
||||
[AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
|
||||
@@ -22,18 +23,8 @@ exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0
|
||||
rm -f core core.* *.core])
|
||||
|
||||
if test $ac_cv_func_utimes_null = yes; then
|
||||
if test x = y; then
|
||||
# This code is deliberately never run via ./configure.
|
||||
# FIXME: this is a hack to make autoheader put the corresponding
|
||||
# HAVE_* undef for this symbol in config.h.in. This saves me the
|
||||
# trouble of having to maintain the #undef in acconfig.h manually.
|
||||
AC_CHECK_FUNCS(UTIMES_NULL)
|
||||
fi
|
||||
# Defining it this way (rather than via AC_DEFINE) short-circuits the
|
||||
# autoheader check -- autoheader doesn't know it's already been taken
|
||||
# care of by the hack above.
|
||||
ac_kludge=HAVE_UTIMES_NULL
|
||||
AC_DEFINE_UNQUOTED($ac_kludge)
|
||||
AC_DEFINE_UNQUOTED(HAVE_UTIMES_NULL, 1,
|
||||
[Define if utimes accepts a null argument])
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
16
man/help2man
16
man/help2man
@@ -25,7 +25,7 @@ use Getopt::Long;
|
||||
use POSIX qw(strftime setlocale LC_TIME);
|
||||
|
||||
my $this_program = 'help2man';
|
||||
my $this_version = '1.006';
|
||||
my $this_version = '1.007';
|
||||
my $version_info = <<EOT;
|
||||
$this_program $this_version
|
||||
|
||||
@@ -151,22 +151,22 @@ if ($opt_output)
|
||||
#
|
||||
# <version>
|
||||
# <program> <version>
|
||||
# GNU <program> <version>
|
||||
# <program> (GNU <package>) <version>
|
||||
# <program> - GNU <package> <version>
|
||||
# {GNU,Free} <program> <version>
|
||||
# <program> ({GNU,Free} <package>) <version>
|
||||
# <program> - {GNU,Free} <package> <version>
|
||||
#
|
||||
# and seperated from any copyright/author details by a blank line.
|
||||
|
||||
$_ = shift @version;
|
||||
|
||||
if (/^(\S+)\s+\((GNU\s+[^)]+)\)\s+(.*)/ or
|
||||
/^(\S+)\s+-\s*(GNU\s+\S+)\s+(.*)/)
|
||||
if (/^(\S+)\s+\(((?:GNU|Free)\s+[^)]+)\)\s+(.*)/ or
|
||||
/^(\S+)\s+-\s*((?:GNU|Free)\s+\S+)\s+(.*)/)
|
||||
{
|
||||
$program = $1;
|
||||
$package = $2;
|
||||
$version = $3;
|
||||
}
|
||||
elsif (/^(GNU\s+)?(\S+)\s+(.*)/)
|
||||
elsif (/^((?:GNU|Free)\s+)?(\S+)\s+(.*)/)
|
||||
{
|
||||
$program = $2;
|
||||
$package = $1 ? "$1$2" : $2;
|
||||
@@ -193,7 +193,7 @@ my $PROGRAM = uc $program;
|
||||
|
||||
# Header.
|
||||
print <<EOT;
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
|
||||
.\\" DO NOT MODIFY THIS FILE! It was generated by $this_program $this_version.
|
||||
.TH $PROGRAM 1 "$date" "$package $version" "FSF"
|
||||
.SH NAME
|
||||
$include{NAME}
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
1999-01-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.1-b3.
|
||||
|
||||
* Upgrade to autoconf-2.13 and automake-1.3b.
|
||||
|
||||
* src/copy.c (copy_internal): Handle two more values of errno from
|
||||
failed rename of a directory into a subdirectory of itself.
|
||||
Thanks to Volker Borchert for testing many types and combinations
|
||||
of systems.
|
||||
|
||||
* lib/argmatch.c (ARGMATCH_QUOTING_STYLE): Change from c_quoting_style
|
||||
to escape_quoting_style.
|
||||
(argmatch_invalid): Now that the quoted quantity is no longer double
|
||||
quoted, remove the code that removed leading and trailing double quotes.
|
||||
|
||||
* src/ls.c (decode_switches): Now that escape_quoting_style no longer
|
||||
escapes the SPACE character, arrange for SPACEs to be quoted here.
|
||||
* lib/quotearg.c (quotearg_buffer): Change escape_quoting_style so that
|
||||
it no longer escapes ` '.
|
||||
Suggestion from Paul Eggert.
|
||||
|
||||
1999-01-05 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (space): Add `for' in message of statvfs check.
|
||||
From Ulrich Drepper.
|
||||
|
||||
1999-01-04 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 4.1-b2.
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
Changes in release 4.1:
|
||||
[4.1-b3]
|
||||
* portability fixes for copy.c's code to detect move-directory-into-self
|
||||
* upgrade to automake-1.3b
|
||||
* upgrade to autoconf-2.13, and...
|
||||
* remove some of the kludges in m4/*.m4 that permitted
|
||||
[4.1-b2]
|
||||
* concurrent `mkdir -p' processes no longer fail when creating the
|
||||
same hierarchy
|
||||
|
||||
@@ -1,3 +1,34 @@
|
||||
1999-01-10 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/Makefile.am (pinky_LDADD, pinky_DEPENDENCIES, who_LDADD,
|
||||
who_DEPENDENCIES): Remove definitions.
|
||||
|
||||
* lib/Makefile.am (BUILT_SOURCES): Add lstat.c and stat.c.
|
||||
(lstat.c, stat.c): New rules.
|
||||
|
||||
* lib/canon-host.c (main) [TEST_CANON_HOST]: Add a simple test driver.
|
||||
|
||||
* configure.in: Require autoconf-2.13.
|
||||
Use new AC_SEARCH_LIBS to see if we need nsl or inet libraries
|
||||
to resolve gethostbyname.
|
||||
|
||||
1998-12-22 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add chinese (zh).
|
||||
|
||||
1998-12-13 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/putenv.c: Don't include stdlib.h and declare malloc and free.
|
||||
This works around Solaris 2.7's conflicting prototype.
|
||||
Reported by Karl Berry.
|
||||
|
||||
* lib/Makefile.am (lstat.c): Add rule to generate this from xstat.in.
|
||||
(stat.c): Likewise.
|
||||
(EXTRA_DIST): Add xstat.in.
|
||||
* lib/stat.c: Remove file.
|
||||
* lib/lstat.c: Remove file.
|
||||
* lib/xstat.in (xstat@): New file.
|
||||
|
||||
1998-12-10 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
|
||||
|
||||
* src/date.c (main): Arrange to exit unsuccessfully when stime fails.
|
||||
@@ -6,11 +37,6 @@
|
||||
|
||||
* configure.in (ALL_LINGUAS): Add Russian (ru).
|
||||
|
||||
1998-12-06 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* lib/putenv.c: Redefine putenv before including stdlib.h to work
|
||||
around Solaris 2.7's conflicting prototype. Reported by Karl Berry.
|
||||
|
||||
1998-10-31 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): Add Fetish.pm.
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
1999-01-09 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22g.
|
||||
|
||||
* tests/uniq/Test.pm: Add tests from Jochen Hein.
|
||||
* src/uniq.c: New option: --all-repeated (-D).
|
||||
(output_all_repeated) [output_mode]: New enum value.
|
||||
(usage): Describe it.
|
||||
(writeline): Test for new mode.
|
||||
(check_file): Likewise.
|
||||
Based on patches from Jochen Hein and Florin Iucha.
|
||||
(main): Diagnose `too many arguments'.
|
||||
|
||||
* tests/head/Test.pm (null-1): Add test from Jochen Hein.
|
||||
|
||||
* src/tail.c (parse_obsolescent_option): Interpret `number' as decimal.
|
||||
(parse_options): Likewise.
|
||||
Reported by Kamal Paul Nigam.
|
||||
|
||||
* src/tail.c: New option: --max-unchanged-stats=N.
|
||||
New option: --max-n-consecutive-size-changes=N.
|
||||
|
||||
1999-01-03 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* src/md5sum.c (usage): Remove third program_name argument -- there
|
||||
@@ -5,8 +27,6 @@
|
||||
|
||||
1999-01-02 Jim Meyering <meyering@ascend.com>
|
||||
|
||||
* Version 1.22g.
|
||||
|
||||
* src/tsort.c (tsort): Use a single call to error instead of two
|
||||
to fprintf.
|
||||
(main): Remove `%s: ' prefix on format string.
|
||||
|
||||
20
src/copy.c
20
src/copy.c
@@ -1,5 +1,5 @@
|
||||
/* copy.c -- core functions for copying files and directories
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998 Free Software Foundation.
|
||||
Copyright (C) 89, 90, 91, 95, 96, 97, 1998, 1999 Free Software Foundation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -625,14 +625,28 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
|
||||
/* This happens when attempting to rename a directory to a
|
||||
subdirectory of itself. */
|
||||
if (errno == EINVAL)
|
||||
if (errno == EINVAL
|
||||
|
||||
/* When src_path is on an NFS file system, some types of
|
||||
clients, e.g., SunOS4.1.4 and IRIX-5.3, set errno to EIO
|
||||
instead. Testing for this here risks misinterpreting a real
|
||||
I/O error as an attempt to move a directory into itself, so
|
||||
FIXME: consider not doing this. */
|
||||
|| errno == EIO
|
||||
|
||||
/* And with SunOS-4.1.4 client and OpenBSD-2.3 server,
|
||||
we get ENOTEMPTY. */
|
||||
|| errno == ENOTEMPTY)
|
||||
{
|
||||
/* FIXME: this is a little fragile in that it relies on rename(2)
|
||||
returning a specific errno (EINVAL). Expect problems on
|
||||
failing with a specific errno value. Expect problems on
|
||||
non-POSIX systems. */
|
||||
*copy_into_self = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Ignore other types of failure (e.g. EXDEV), since the following
|
||||
code will try to perform a copy, then remove. */
|
||||
}
|
||||
|
||||
if (S_ISDIR (src_type))
|
||||
|
||||
2
src/ls.c
2
src/ls.c
@@ -1164,6 +1164,8 @@ decode_switches (int argc, char **argv)
|
||||
}
|
||||
|
||||
filename_quoting_options = clone_quoting_options (NULL);
|
||||
if (get_quoting_style (filename_quoting_options) == escape_quoting_style)
|
||||
set_char_quoting (filename_quoting_options, ' ', 1);
|
||||
if (indicator_style != none)
|
||||
for (p = "*=@|" + (int) indicator_style - 1; *p; p++)
|
||||
set_char_quoting (filename_quoting_options, *p, 1);
|
||||
|
||||
58
src/tail.c
58
src/tail.c
@@ -132,11 +132,24 @@ enum header_mode
|
||||
multiple_files, always, never
|
||||
};
|
||||
|
||||
/* FIXME: describe -- add option */
|
||||
static unsigned long max_n_unchanged_stats_between_opens = 5;
|
||||
/* When tailing a file by name, if there have been this many consecutive
|
||||
stat calls for which the size has remained the same, then open/fstat
|
||||
the file to determine if that file name is still associated with the
|
||||
same device/inode-number pair as before. This option is meaningful only
|
||||
when following by name. --max-unchanged-stats=N */
|
||||
#define DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS 5
|
||||
static unsigned long max_n_unchanged_stats_between_opens =
|
||||
DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS;
|
||||
|
||||
/* FIXME: describe -- add option */
|
||||
static unsigned long max_n_consecutive_size_changes = 200;
|
||||
/* This variable is used to ensure that a file that is unlinked or moved
|
||||
aside, yet always growing will be recognized as having been renamed.
|
||||
After detecting this many consecutive size changes for a file, open/fstat
|
||||
the file to determine if that file name is still associated with the
|
||||
same device/inode-number pair as before. This option is meaningful only
|
||||
when following by name. --max-n-consecutive-size-changes=N */
|
||||
#define DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES 200
|
||||
static unsigned long max_n_consecutive_size_changes_between_opens =
|
||||
DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES;
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
@@ -159,6 +172,8 @@ static struct option const long_options[] =
|
||||
{"bytes", required_argument, NULL, 'c'},
|
||||
{"follow", optional_argument, NULL, 'f'},
|
||||
{"lines", required_argument, NULL, 'n'},
|
||||
{"max-unchanged-stats", required_argument, NULL, CHAR_MAX + 2},
|
||||
{"max-consecutive-size-changes", required_argument, NULL, CHAR_MAX + 3},
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"silent", no_argument, NULL, 'q'},
|
||||
{"sleep-interval", required_argument, NULL, 's'},
|
||||
@@ -189,6 +204,8 @@ With no FILE, or when FILE is -, read standard input.\n\
|
||||
-c, --bytes=N output the last N bytes\n\
|
||||
-f, --follow[={name|descriptor}] output appended data as the file grows\n\
|
||||
-n, --lines=N output the last N lines, instead of last 10\n\
|
||||
--max-unchanged-stats=N FIXME describe and mention default\n\
|
||||
--max-consecutive-size-changes=N FIXME describe and mention default\n\
|
||||
-q, --quiet, --silent never output headers giving file names\n\
|
||||
-s, --sleep-interval=S with -f, sleep S seconds between iterations\n\
|
||||
-v, --verbose always output headers giving file names\n\
|
||||
@@ -782,10 +799,10 @@ tail_forever (struct File_spec *f, int nfiles)
|
||||
++f[i].n_consecutive_size_changes;
|
||||
|
||||
/* Ensure that a file that's unlinked or moved aside, yet always
|
||||
growing will be recognized has having been renamed. */
|
||||
growing will be recognized as having been renamed. */
|
||||
if (follow_mode == Follow_name
|
||||
&& (f[i].n_consecutive_size_changes
|
||||
> max_n_consecutive_size_changes))
|
||||
> max_n_consecutive_size_changes_between_opens))
|
||||
{
|
||||
f[i].n_consecutive_size_changes = 0;
|
||||
recheck (&f[i]);
|
||||
@@ -1142,7 +1159,7 @@ parse_obsolescent_option (int argc, const char *const *argv,
|
||||
strtol_error s_err;
|
||||
unsigned long int tmp_ulong;
|
||||
char *end;
|
||||
s_err = xstrtoul (n_string, &end, 0, &tmp_ulong, NULL);
|
||||
s_err = xstrtoul (n_string, &end, 10, &tmp_ulong, NULL);
|
||||
if (s_err == LONGINT_OK && tmp_ulong <= OFF_T_MAX)
|
||||
*n_units = (off_t) tmp_ulong;
|
||||
else
|
||||
@@ -1227,7 +1244,7 @@ parse_options (int argc, char **argv,
|
||||
{
|
||||
strtol_error s_err;
|
||||
unsigned long int tmp_ulong;
|
||||
s_err = xstrtoul (optarg, NULL, 0, &tmp_ulong, "bkm");
|
||||
s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, "bkm");
|
||||
if (s_err == LONGINT_INVALID)
|
||||
{
|
||||
error (EXIT_FAILURE, 0, "%s: %s", optarg,
|
||||
@@ -1259,6 +1276,29 @@ parse_options (int argc, char **argv,
|
||||
allow_missing = 1;
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 2:
|
||||
/* --max-unchanged-stats=N */
|
||||
if (xstrtoul (optarg, NULL, 10,
|
||||
&max_n_unchanged_stats_between_opens, "") != LONGINT_OK)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: invalid maximum number of unchanged stats between opens"),
|
||||
optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAR_MAX + 3:
|
||||
/* --max-consecutive-size-changes=N */
|
||||
if (xstrtoul (optarg, NULL, 10,
|
||||
&max_n_consecutive_size_changes_between_opens, "")
|
||||
!= LONGINT_OK)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: invalid maximum number of consecutive size changes"),
|
||||
optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
*header_mode = never;
|
||||
break;
|
||||
@@ -1267,7 +1307,7 @@ parse_options (int argc, char **argv,
|
||||
{
|
||||
strtol_error s_err;
|
||||
unsigned long int tmp_ulong;
|
||||
s_err = xstrtoul (optarg, NULL, 0, &tmp_ulong, "");
|
||||
s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, "");
|
||||
if (s_err != LONGINT_OK || tmp_ulong > UINT_MAX)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
|
||||
40
src/uniq.c
40
src/uniq.c
@@ -1,5 +1,5 @@
|
||||
/* uniq -- remove duplicate lines from a sorted file
|
||||
Copyright (C) 86, 91, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 86, 91, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -58,6 +58,7 @@ static enum countmode countmode;
|
||||
enum output_mode
|
||||
{
|
||||
output_repeated, /* -d Only lines that are repeated. */
|
||||
output_all_repeated, /* -D All lines that are repeated. */
|
||||
output_unique, /* -u Only lines that are not repeated. */
|
||||
output_all /* Default. Print first copy of each line. */
|
||||
};
|
||||
@@ -78,6 +79,7 @@ static struct option const longopts[] =
|
||||
{
|
||||
{"count", no_argument, NULL, 'c'},
|
||||
{"repeated", no_argument, NULL, 'd'},
|
||||
{"all-repeated", no_argument, NULL, 'D'},
|
||||
{"ignore-case", no_argument, NULL, 'i'},
|
||||
{"unique", no_argument, NULL, 'u'},
|
||||
{"skip-fields", required_argument, NULL, 'f'},
|
||||
@@ -106,6 +108,7 @@ standard input), writing to OUTPUT (or standard output).\n\
|
||||
\n\
|
||||
-c, --count prefix lines by the number of occurrences\n\
|
||||
-d, --repeated only print duplicate lines\n\
|
||||
-D, --all-repeated print all duplicate lines\n\
|
||||
-f, --skip-fields=N avoid comparing the first N fields\n\
|
||||
-i, --ignore-case ignore differences in case when comparing\n\
|
||||
-s, --skip-chars=N avoid comparing the first N characters\n\
|
||||
@@ -189,7 +192,8 @@ static void
|
||||
writeline (const struct linebuffer *line, FILE *stream, int linecount)
|
||||
{
|
||||
if ((mode == output_unique && linecount != 0)
|
||||
|| (mode == output_repeated && linecount == 0))
|
||||
|| (mode == output_repeated && linecount == 0)
|
||||
|| (mode == output_all_repeated && linecount == 0))
|
||||
return;
|
||||
|
||||
if (countmode == count_occurrences)
|
||||
@@ -240,22 +244,26 @@ check_file (const char *infile, const char *outfile)
|
||||
|
||||
while (!feof (istream))
|
||||
{
|
||||
int match;
|
||||
if (readline (thisline, istream) == 0)
|
||||
break;
|
||||
thisfield = find_field (thisline);
|
||||
thislen = thisline->length - (thisfield - thisline->buffer);
|
||||
if (!different (thisfield, prevfield, thislen, prevlen))
|
||||
match_count++;
|
||||
else
|
||||
match = !different (thisfield, prevfield, thislen, prevlen);
|
||||
|
||||
if (match)
|
||||
++match_count;
|
||||
|
||||
if (!match || mode == output_all_repeated)
|
||||
{
|
||||
writeline (prevline, ostream, match_count);
|
||||
match_count = 0;
|
||||
|
||||
exch = prevline;
|
||||
prevline = thisline;
|
||||
thisline = exch;
|
||||
prevfield = thisfield;
|
||||
prevlen = thislen;
|
||||
if (!match)
|
||||
match_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +297,7 @@ main (int argc, char **argv)
|
||||
mode = output_all;
|
||||
countmode = count_none;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "0123456789cdf:is:uw:", longopts,
|
||||
while ((optc = getopt_long (argc, argv, "0123456789cdDf:is:uw:", longopts,
|
||||
NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -318,6 +326,10 @@ main (int argc, char **argv)
|
||||
mode = output_repeated;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
mode = output_all_repeated;
|
||||
break;
|
||||
|
||||
case 'f': /* Like '-#'. */
|
||||
{
|
||||
long int tmp_long;
|
||||
@@ -400,7 +412,17 @@ main (int argc, char **argv)
|
||||
outfile = argv[optind++];
|
||||
|
||||
if (optind < argc)
|
||||
usage (1); /* Extra arguments. */
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (countmode == count_occurrences && mode == output_all_repeated)
|
||||
{
|
||||
error (0, 0,
|
||||
_("printing all duplicated lines and repeat counts is meaningless"));
|
||||
usage (1);
|
||||
}
|
||||
|
||||
check_file (infile, outfile);
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ CC = @CC@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
GENCAT = @GENCAT@
|
||||
GETHOSTBYNAME_LIB = @GETHOSTBYNAME_LIB@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
|
||||
@@ -63,7 +63,6 @@ CC = @CC@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
GENCAT = @GENCAT@
|
||||
GETHOSTBYNAME_LIB = @GETHOSTBYNAME_LIB@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
|
||||
@@ -6,14 +6,14 @@ explicit = in in-1024
|
||||
maint_gen = idem-0.I idem-0.X idem-1.I idem-1.X idem-2.I idem-2.X idem-3.I \
|
||||
idem-3.X basic-0-10.I basic-0-10.X basic-0-09.I basic-0-09.X basic-0-11.I \
|
||||
basic-0-11.X obs-0.I obs-0.X obs-1.I obs-1.X obs-2.I obs-2.X obs-3.I obs-3.X \
|
||||
fail-1.I fail-1.X posix-0.I posix-0.X posix-1.I posix-1.X posix-2.I posix-2.X \
|
||||
posix-3.I posix-3.X
|
||||
fail-1.I fail-1.X null-1.I null-1.X posix-0.I posix-0.X posix-1.I posix-1.X \
|
||||
posix-2.I posix-2.X posix-3.I posix-3.X
|
||||
run_gen = idem-0.O idem-0.E idem-1.O idem-1.E idem-2.O idem-2.E idem-3.O \
|
||||
idem-3.E basic-0-10.O basic-0-10.E basic-0-09.O basic-0-09.E basic-0-11.O \
|
||||
basic-0-11.E obs-0.O obs-0.E obs-1.O obs-1.E obs-2.O obs-2.E obs-3.O obs-3.E \
|
||||
obs-4.O obs-4.E obs-5.O obs-5.E fail-1.O fail-1.E posix-0.O posix-0.E \
|
||||
posix-1.O posix-1.E posix-2.O posix-2.E posix-3.O posix-3.E posix-4.O \
|
||||
posix-4.E posix-5.O posix-5.E
|
||||
obs-4.O obs-4.E obs-5.O obs-5.E fail-1.O fail-1.E null-1.O null-1.E posix-0.O \
|
||||
posix-0.E posix-1.O posix-1.E posix-2.O posix-2.E posix-3.O posix-3.E \
|
||||
posix-4.O posix-4.E posix-5.O posix-5.E
|
||||
##test-files-end
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
|
||||
@@ -92,14 +92,14 @@ explicit = in in-1024
|
||||
maint_gen = idem-0.I idem-0.X idem-1.I idem-1.X idem-2.I idem-2.X idem-3.I \
|
||||
idem-3.X basic-0-10.I basic-0-10.X basic-0-09.I basic-0-09.X basic-0-11.I \
|
||||
basic-0-11.X obs-0.I obs-0.X obs-1.I obs-1.X obs-2.I obs-2.X obs-3.I obs-3.X \
|
||||
fail-1.I fail-1.X posix-0.I posix-0.X posix-1.I posix-1.X posix-2.I posix-2.X \
|
||||
posix-3.I posix-3.X
|
||||
fail-1.I fail-1.X null-1.I null-1.X posix-0.I posix-0.X posix-1.I posix-1.X \
|
||||
posix-2.I posix-2.X posix-3.I posix-3.X
|
||||
run_gen = idem-0.O idem-0.E idem-1.O idem-1.E idem-2.O idem-2.E idem-3.O \
|
||||
idem-3.E basic-0-10.O basic-0-10.E basic-0-09.O basic-0-09.E basic-0-11.O \
|
||||
basic-0-11.E obs-0.O obs-0.E obs-1.O obs-1.E obs-2.O obs-2.E obs-3.O obs-3.E \
|
||||
obs-4.O obs-4.E obs-5.O obs-5.E fail-1.O fail-1.E posix-0.O posix-0.E \
|
||||
posix-1.O posix-1.E posix-2.O posix-2.E posix-3.O posix-3.E posix-4.O \
|
||||
posix-4.E posix-5.O posix-5.E
|
||||
obs-4.O obs-4.E obs-5.O obs-5.E fail-1.O fail-1.E null-1.O null-1.E posix-0.O \
|
||||
posix-0.E posix-1.O posix-1.E posix-2.O posix-2.E posix-3.O posix-3.E \
|
||||
posix-4.O posix-4.E posix-5.O posix-5.E
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
noinst_SCRIPTS = $x-tests
|
||||
|
||||
@@ -38,6 +38,8 @@ my @tv = (
|
||||
# In spite of its name, this test passes -- just to contrast with the above.
|
||||
['fail-1', '-n 2048m', "a\n", "a\n", 0],
|
||||
|
||||
# Make sure we don't break like AIX 4.3.1 on files with \0 in them.
|
||||
['null-1', '', "a\0a\n", "a\0a\n", 0],
|
||||
);
|
||||
|
||||
sub test_vector
|
||||
|
||||
@@ -63,7 +63,6 @@ CC = @CC@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
GENCAT = @GENCAT@
|
||||
GETHOSTBYNAME_LIB = @GETHOSTBYNAME_LIB@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
|
||||
@@ -63,7 +63,6 @@ CC = @CC@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
GENCAT = @GENCAT@
|
||||
GETHOSTBYNAME_LIB = @GETHOSTBYNAME_LIB@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
|
||||
@@ -5,16 +5,16 @@ x = uniq
|
||||
explicit =
|
||||
maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
|
||||
9.I 9.X 10.I 10.X 11.I 11.X 12.I 12.X 13.I 13.X 20.I 20.X 21.I 21.X 22.I 22.X \
|
||||
23.I 23.X 30.I 30.X 31.I 31.X 32.I 32.X 33.I 33.X 34.I 34.X 35.I 35.X 40.I \
|
||||
40.X 41.I 41.X 42.I 42.X 43.I 43.X 44.I 44.X 45.I 45.X 50.I 50.X 51.I 51.X \
|
||||
52.I 52.X 53.I 53.X 60.I 60.X 61.I 61.X 62.I 62.X 63.I 63.X 64.I 64.X 65.I \
|
||||
65.X 101.I 101.X 102.I 102.X
|
||||
23.I 23.X 30.I 30.X 31.I 31.X 32.I 32.X 33.I 33.X 34.I 34.X 35.I 35.X 42.I \
|
||||
42.X 43.I 43.X 50.I 50.X 51.I 51.X 52.I 52.X 53.I 53.X 60.I 60.X 61.I 61.X \
|
||||
62.I 62.X 63.I 63.X 64.I 64.X 65.I 65.X 90.I 90.X 91.I 91.X 92.I 92.X 93.I \
|
||||
93.X 94.I 94.X 101.I 101.X 102.I 102.X 110.I 110.X 111.I 111.X 112.I 112.X
|
||||
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
|
||||
9.E 10.O 10.E 11.O 11.E 12.O 12.E 13.O 13.E 20.O 20.E 21.O 21.E 22.O 22.E \
|
||||
23.O 23.E 30.O 30.E 31.O 31.E 32.O 32.E 33.O 33.E 34.O 34.E 35.O 35.E 40.O \
|
||||
40.E 41.O 41.E 42.O 42.E 43.O 43.E 44.O 44.E 45.O 45.E 50.O 50.E 51.O 51.E \
|
||||
52.O 52.E 53.O 53.E 60.O 60.E 61.O 61.E 62.O 62.E 63.O 63.E 64.O 64.E 65.O \
|
||||
65.E 101.O 101.E 102.O 102.E
|
||||
23.O 23.E 30.O 30.E 31.O 31.E 32.O 32.E 33.O 33.E 34.O 34.E 35.O 35.E 42.O \
|
||||
42.E 43.O 43.E 50.O 50.E 51.O 51.E 52.O 52.E 53.O 53.E 60.O 60.E 61.O 61.E \
|
||||
62.O 62.E 63.O 63.E 64.O 64.E 65.O 65.E 90.O 90.E 91.O 91.E 92.O 92.E 93.O \
|
||||
93.E 94.O 94.E 101.O 101.E 102.O 102.E 110.O 110.E 111.O 111.E 112.O 112.E
|
||||
##test-files-end
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
|
||||
@@ -93,12 +93,14 @@ maint_gen = 1.I 1.X 2.I 2.X 3.I 3.X 4.I 4.X 5.I 5.X 6.I 6.X 7.I 7.X 8.I 8.X \
|
||||
9.I 9.X 10.I 10.X 11.I 11.X 12.I 12.X 13.I 13.X 20.I 20.X 21.I 21.X 22.I 22.X \
|
||||
23.I 23.X 30.I 30.X 31.I 31.X 32.I 32.X 33.I 33.X 34.I 34.X 35.I 35.X 42.I \
|
||||
42.X 43.I 43.X 50.I 50.X 51.I 51.X 52.I 52.X 53.I 53.X 60.I 60.X 61.I 61.X \
|
||||
62.I 62.X 63.I 63.X 64.I 64.X 65.I 65.X 101.I 101.X 102.I 102.X
|
||||
62.I 62.X 63.I 63.X 64.I 64.X 65.I 65.X 90.I 90.X 91.I 91.X 92.I 92.X 93.I \
|
||||
93.X 94.I 94.X 101.I 101.X 102.I 102.X 110.I 110.X 111.I 111.X 112.I 112.X
|
||||
run_gen = 1.O 1.E 2.O 2.E 3.O 3.E 4.O 4.E 5.O 5.E 6.O 6.E 7.O 7.E 8.O 8.E 9.O \
|
||||
9.E 10.O 10.E 11.O 11.E 12.O 12.E 13.O 13.E 20.O 20.E 21.O 21.E 22.O 22.E \
|
||||
23.O 23.E 30.O 30.E 31.O 31.E 32.O 32.E 33.O 33.E 34.O 34.E 35.O 35.E 42.O \
|
||||
42.E 43.O 43.E 50.O 50.E 51.O 51.E 52.O 52.E 53.O 53.E 60.O 60.E 61.O 61.E \
|
||||
62.O 62.E 63.O 63.E 64.O 64.E 65.O 65.E 101.O 101.E 102.O 102.E
|
||||
62.O 62.E 63.O 63.E 64.O 64.E 65.O 65.E 90.O 90.E 91.O 91.E 92.O 92.E 93.O \
|
||||
93.E 94.O 94.E 101.O 101.E 102.O 102.E 110.O 110.E 111.O 111.E 112.O 112.E
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
noinst_SCRIPTS = $x-tests
|
||||
|
||||
@@ -36,17 +36,17 @@ my @tv = (
|
||||
['33', '-f 1',"a a a\nb a c\n", "a a a\nb a c\n", 0],
|
||||
['34', '-f 1',"b a\na a\n", "b a\n", 0],
|
||||
['35', '-f 2',"a a c\nb a c\n", "a a c\n", 0],
|
||||
# Skip over characters
|
||||
['40', '+1', "aaa\naaa\n", "aaa\n", 0],
|
||||
['41', '+1', "baa\naaa\n", "aaa\n", 0],
|
||||
# Skip over characters; FIXME: the parsing of +number is broken
|
||||
#['40', '+1', "aaa\naaa\n", "aaa\n", 0],
|
||||
#['41', '+1', "baa\naaa\n", "aaa\n", 0],
|
||||
['42', '-s 1',"aaa\naaa\n", "aaa\n", 0],
|
||||
['43', '-s 2',"baa\naaa\n", "baa\n", 0],
|
||||
['44', '+1 --', "aaa\naaa\n", "aaa\n", 0],
|
||||
['45', '+1 --', "baa\naaa\n", "aaa\n", 0],
|
||||
#['44', '+1 --', "aaa\naaa\n", "aaa\n", 0],
|
||||
#['45', '+1 --', "baa\naaa\n", "aaa\n", 0],
|
||||
# Skip over fields and characters
|
||||
['50', '-f 1 -s 1',"a aaa\nb ab\n", "a aaa\nb ab\n", 0],
|
||||
['50', '-f 1 -s 1',"a aaa\nb ab\n", "a aaa\nb ab\n", 0],
|
||||
['51', '-f 1 -s 1',"a aaa\nb aaa\n", "a aaa\n", 0],
|
||||
['52', '-s 1 -f 1',"a aaa\nb ab\n", "a aaa\nb ab\n", 0],
|
||||
['52', '-s 1 -f 1',"a aaa\nb ab\n", "a aaa\nb ab\n", 0],
|
||||
['53', '-s 1 -f 1',"a aaa\nb aaa\n", "a aaa\n", 0],
|
||||
# Only account for a number of characters
|
||||
['60', '-w 1',"a a\nb a\n", "a a\nb a\n", 0],
|
||||
@@ -56,9 +56,20 @@ my @tv = (
|
||||
# The blank after field one is checked too
|
||||
['64', '-f 1 -w 4',"a a a\nb a c\n", "a a a\nb a c\n", 0],
|
||||
['65', '-f 1 -w 3',"a a a\nb a c\n", "a a a\n", 0],
|
||||
# Check the count option
|
||||
# Make sure we don't break if the file contains \0
|
||||
['90', '', "a\0a\na\n", "a\0a\na\n", 0],
|
||||
# Check fields seperated by tabs and by spaces
|
||||
['91', '', "a\ta\na a\n", "a\ta\na a\n", 0],
|
||||
['92', '-f 1', "a\ta\na a\n", "a\ta\na a\n", 0],
|
||||
['93', '-f 2', "a\ta a\na a a\n", "a\ta a\n", 0],
|
||||
['94', '-f 1', "a\ta\na\ta\n", "a\ta\n", 0],
|
||||
# Check the count option; add tests for other options too
|
||||
['101', '-c', "a\nb\n", " 1\ta\n 1\tb\n", 0],
|
||||
['102', '-c', "a\na\n", " 2\ta\n", 0],
|
||||
# Check the local -D (--all-repeated) option
|
||||
['110', '-D', "a\na\n", "a\na\n", 0],
|
||||
['111', '-D -w1',"a a\na b\n", "a a\na b\n", 0],
|
||||
['112', '-D -c', "a a\na b\n", "", 1],
|
||||
);
|
||||
|
||||
sub test_vector
|
||||
|
||||
Reference in New Issue
Block a user