mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
233 Commits
FILEUTILS-
...
CPPI-1_8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0654f3206d | ||
|
|
67cf94a857 | ||
|
|
69ed54e544 | ||
|
|
3dabe6b533 | ||
|
|
2845214164 | ||
|
|
6b8102a180 | ||
|
|
570074d6d1 | ||
|
|
72a6d74ab2 | ||
|
|
cd6f0af0ea | ||
|
|
2746cd50c3 | ||
|
|
8a4261c7a5 | ||
|
|
90799b6c68 | ||
|
|
1c6320fe7c | ||
|
|
fecdd2bd2b | ||
|
|
15691fb64f | ||
|
|
cb366955f3 | ||
|
|
82a6fbda1c | ||
|
|
177b2553e2 | ||
|
|
814e63e371 | ||
|
|
2eed25f2ed | ||
|
|
1be9e19c7d | ||
|
|
b7895d0d10 | ||
|
|
8461820956 | ||
|
|
86960ce221 | ||
|
|
6670163eee | ||
|
|
437f8becaa | ||
|
|
5233121102 | ||
|
|
25c2989d30 | ||
|
|
4f96dfa43e | ||
|
|
f559a4afa3 | ||
|
|
b5d4b2c555 | ||
|
|
d8a157a00e | ||
|
|
85a75d3a16 | ||
|
|
d183ecddcd | ||
|
|
e30c09b4cb | ||
|
|
9d5d7f0d50 | ||
|
|
caae4ed5a7 | ||
|
|
a1ca60f4e5 | ||
|
|
ce861b2cb3 | ||
|
|
67ec78d188 | ||
|
|
d661be38ed | ||
|
|
69e30c7f2a | ||
|
|
8973e2b38c | ||
|
|
df52f23ebf | ||
|
|
5edc91fc05 | ||
|
|
8b4ac20908 | ||
|
|
1a0d9ea086 | ||
|
|
e49511faef | ||
|
|
e05c32a868 | ||
|
|
c2f898236f | ||
|
|
501ebc1cba | ||
|
|
77182607c0 | ||
|
|
6769657fa3 | ||
|
|
dab453378b | ||
|
|
aa266c29eb | ||
|
|
6b94589fa4 | ||
|
|
0d849addb3 | ||
|
|
1698b85090 | ||
|
|
a538ba0149 | ||
|
|
41f20fd38f | ||
|
|
1c8189de61 | ||
|
|
525e76fce0 | ||
|
|
d91624bd99 | ||
|
|
1c71127370 | ||
|
|
4f1553c89f | ||
|
|
1b9cb7ea23 | ||
|
|
479aba180c | ||
|
|
8eeae63a74 | ||
|
|
07584e33ec | ||
|
|
33ba435db5 | ||
|
|
73fe66c783 | ||
|
|
cc27b86c60 | ||
|
|
9db47bb808 | ||
|
|
8bf3961df0 | ||
|
|
df7d583cc2 | ||
|
|
271e41850b | ||
|
|
97b58344c5 | ||
|
|
627dac6c07 | ||
|
|
0742bc284e | ||
|
|
acca4638b8 | ||
|
|
05aabec021 | ||
|
|
e996c1bd77 | ||
|
|
b529a77be8 | ||
|
|
4faf0a9a17 | ||
|
|
3e50cea2f5 | ||
|
|
339738f351 | ||
|
|
a48a4d5c63 | ||
|
|
57a0382b5f | ||
|
|
835a8fa634 | ||
|
|
4ff7ab63ab | ||
|
|
d92f4ac85e | ||
|
|
21b8c52ae9 | ||
|
|
7303ca25db | ||
|
|
060fb58f86 | ||
|
|
d185a442b9 | ||
|
|
86046cb32f | ||
|
|
1500316caf | ||
|
|
72454050bb | ||
|
|
b0b9c6fee7 | ||
|
|
4a9feba665 | ||
|
|
afed66de3b | ||
|
|
d33f54f74f | ||
|
|
6d43eca61a | ||
|
|
59a56f4172 | ||
|
|
8cd774b0a3 | ||
|
|
7484a08597 | ||
|
|
3083c30362 | ||
|
|
81ae3684cc | ||
|
|
f8674300d4 | ||
|
|
b65d5875b7 | ||
|
|
7c85357876 | ||
|
|
913052e751 | ||
|
|
5536541dbb | ||
|
|
6fbae8149f | ||
|
|
be56f8286f | ||
|
|
b04a174558 | ||
|
|
1040389220 | ||
|
|
459b44b03d | ||
|
|
297c469d6f | ||
|
|
022f9b7d19 | ||
|
|
de2cfc1a5f | ||
|
|
005c4244f9 | ||
|
|
9b45312c35 | ||
|
|
bd3afcc718 | ||
|
|
d47e7953ba | ||
|
|
9860ca9f9b | ||
|
|
8f9f95b5ec | ||
|
|
2d354c5a2e | ||
|
|
7f5ed2b586 | ||
|
|
8ee842a15b | ||
|
|
7a16e5e6ff | ||
|
|
6cfcd41e1a | ||
|
|
89499f2124 | ||
|
|
e3db837339 | ||
|
|
b499483abd | ||
|
|
944f878a72 | ||
|
|
a1e9a949b4 | ||
|
|
d1680f86e1 | ||
|
|
019bdadfc9 | ||
|
|
7d57b34196 | ||
|
|
c8a0eec3f6 | ||
|
|
3d6852f7fa | ||
|
|
dd82647d0c | ||
|
|
b95b1e3c9a | ||
|
|
1d250b6098 | ||
|
|
b35b7e0553 | ||
|
|
d1703ad194 | ||
|
|
17800b0300 | ||
|
|
c9dcdd0fc5 | ||
|
|
b21c6f8e1e | ||
|
|
846b539b4e | ||
|
|
9a4e9f426c | ||
|
|
4e07d471cc | ||
|
|
5afa8c022e | ||
|
|
6202e79712 | ||
|
|
bd320fe27b | ||
|
|
bf319d9d88 | ||
|
|
1e9f7512fe | ||
|
|
75e63ae6cd | ||
|
|
d6dabd6cbb | ||
|
|
d5b2ff2b99 | ||
|
|
a3e608b76a | ||
|
|
d97f90581b | ||
|
|
5f90e3be67 | ||
|
|
f2f5e30bc2 | ||
|
|
6c1ee8402c | ||
|
|
ff9d584dcc | ||
|
|
aba2a0fd6d | ||
|
|
5baa94d136 | ||
|
|
6447e5b997 | ||
|
|
49d5578b0b | ||
|
|
ed757a3e9d | ||
|
|
e5aacbc6ea | ||
|
|
909f49e651 | ||
|
|
54f2cba1b5 | ||
|
|
880e67d643 | ||
|
|
166bbecf0b | ||
|
|
f94fab125e | ||
|
|
8bbc00b147 | ||
|
|
9ca70467e9 | ||
|
|
16f1ca4c35 | ||
|
|
c7087747a4 | ||
|
|
cdc8ee798f | ||
|
|
caf54306a3 | ||
|
|
cde06a54ea | ||
|
|
40af3c54b6 | ||
|
|
bb56dec673 | ||
|
|
1234569e43 | ||
|
|
82db55924e | ||
|
|
9a99175c0e | ||
|
|
88754c060d | ||
|
|
d3a2ca48d4 | ||
|
|
6adb4780b5 | ||
|
|
6e3bd39c14 | ||
|
|
cf59735d7b | ||
|
|
ff0e0181c9 | ||
|
|
138e17c26e | ||
|
|
2c7002e529 | ||
|
|
88b47ac69f | ||
|
|
f15c4ee154 | ||
|
|
9a25583ef1 | ||
|
|
d32d63e211 | ||
|
|
7daa83a149 | ||
|
|
b73eb2433d | ||
|
|
73ee461623 | ||
|
|
00fba41266 | ||
|
|
7822d5fe7f | ||
|
|
395dc1f7ff | ||
|
|
1f789a22a2 | ||
|
|
0354ab509e | ||
|
|
5b85894325 | ||
|
|
b77cb25935 | ||
|
|
ea9a4e4755 | ||
|
|
69c750af36 | ||
|
|
f2e553b126 | ||
|
|
8a93bbce06 | ||
|
|
965cb80669 | ||
|
|
0e397f0460 | ||
|
|
0ebd6b45a8 | ||
|
|
a8fab3b2eb | ||
|
|
2e9fdf49c5 | ||
|
|
0743fbb426 | ||
|
|
2c6fbbea7a | ||
|
|
3f6da994c0 | ||
|
|
adcacc9417 | ||
|
|
7e2f836a49 | ||
|
|
1bac92811e | ||
|
|
8fc17df678 | ||
|
|
1ff67f6c5c | ||
|
|
eabc99b8a4 | ||
|
|
b3f23e14d2 | ||
|
|
abe849cb76 | ||
|
|
4f9389cf1e |
@@ -25,3 +25,8 @@ all:
|
||||
@exit 1
|
||||
|
||||
endif
|
||||
|
||||
# Tell version 3.79 and up of GNU make to not build goals in this
|
||||
# directory in parallel. This is necessary in case someone tries to
|
||||
# build multiple targets on one command line.
|
||||
.NOTPARALLEL:
|
||||
|
||||
@@ -91,6 +91,7 @@ b_real_dir = fetish-ftp
|
||||
url_dir_list = $(foreach x,a b,ftp://$($(x)_host)/$($(x)_url_dir))
|
||||
|
||||
md5 = $(shell md5sum < $(distdir).tar.gz|sed 's/ -//')
|
||||
sha1 = $(shell sha1sum < $(distdir).tar.gz|sed 's/ -//')
|
||||
|
||||
rel-check:
|
||||
tarz=/tmp/rel-check-tarz-$$$$; \
|
||||
@@ -121,7 +122,10 @@ announcement: NEWS ChangeLog $(distdir).tar.gz
|
||||
echo " $$url/$(xd-delta)"; \
|
||||
done; \
|
||||
echo; \
|
||||
echo "Here are the MD5 and SHA1 signatures for the .tar.gz file"; \
|
||||
echo; \
|
||||
echo "$(md5) $(distdir).tar.gz"; \
|
||||
echo "$(sha1) $(distdir).tar.gz"; \
|
||||
echo; \
|
||||
echo NEWS:; \
|
||||
sed -n "/$(THIS_VERSION_REGEXP)/,/^\[$(PREV_VERSION_REGEXP)/p" NEWS \
|
||||
@@ -168,7 +172,7 @@ alpha: writable-files po-check
|
||||
cvs ci -m. $(prev_version_file)
|
||||
@echo =====================================
|
||||
@echo =====================================
|
||||
@echo 'scp $(xd-delta) $(distdir).tar.gz \'
|
||||
@echo 'rsync -e ssh --pro -av $(xd-delta) $(distdir).tar.gz \'
|
||||
@echo ' $(b_host):$(b_real_dir)'
|
||||
@echo '# send the /tmp/announcement e-mail'
|
||||
@echo =====================================
|
||||
|
||||
8
THANKS
8
THANKS
@@ -28,6 +28,7 @@ Andrew Dalke dalke@bioreason.com
|
||||
Andrew Tridgell tridge@samba.org
|
||||
Andries Brouwer Andries.Brouwer@cwi.nl
|
||||
Andy Longton alongton@metamark.com
|
||||
Antonio Rendas ajrendas@yahoo.com
|
||||
Ariel Faigon ariel@cthulhu.engr.sgi.com
|
||||
Arne H. Juul arnej@solan.unit.no
|
||||
Arne Henrik Juul arnej@imf.unit.no
|
||||
@@ -52,6 +53,7 @@ Carlos Canau Carlos.Canau@relay.puug.pt
|
||||
Charles Karney karney@pppl.gov
|
||||
Charles Randall crandall@matchlogic.com
|
||||
Chip Salzenberg chip@valinux.com
|
||||
Chris Sylvain csylvain@umm.edu
|
||||
Chris Yeo cyeo@biking.org
|
||||
Christi Alice Scarborough christi@chiark.greenend.org.uk
|
||||
Christian Krackowizer ckrackowiz@std.schuler-ag.com
|
||||
@@ -77,7 +79,7 @@ Doug McLaren dougmc@comco.com
|
||||
Dragos Harabor dharabor@us.oracle.com
|
||||
Ed Avis epa98@doc.ic.ac.uk
|
||||
Edzer Pebesma Edzer.Pebesma@rivm.nl
|
||||
Eirik Fuller eirik@netcom.com
|
||||
Eirik Fuller eirik@hackrat.com
|
||||
Eivind eivindt@multinet.no
|
||||
Eli Zaretskii eliz@is.elta.co.il
|
||||
Emile LeBlanc leblanc@math.toronto.edu
|
||||
@@ -154,6 +156,7 @@ Jungshik Shin jshin@pantheon.yale.edu
|
||||
Jürgen Fluk louis@dachau.marco.de
|
||||
jvogel jvogel@linkny.com
|
||||
Kai-Uwe Rommel rommel@informatik.tu-muenchen.de
|
||||
Kai Henningsen kai@debian.org
|
||||
Kalle Olavi Niemitalo tosi@stekt.oulu.fi
|
||||
Kamal Paul Nigam Kamal_Paul_Nigam@gs35.sp.cs.cmu.edu
|
||||
Karl Eichwalder keichwa@gmx.net
|
||||
@@ -183,6 +186,7 @@ Mark D. Roth roth@uiuc.edu
|
||||
Mark Harris mark@monitor.designacc.com
|
||||
Mark Hewitt mhewitt@armature.com
|
||||
Mark Kettenis kettenis@phys.uva.nl
|
||||
Mark Nudelman marknu@flash.net
|
||||
Mark W. Eichin eichin@cygnus.com
|
||||
Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
|
||||
Martin martin@dresden.nacamar.de
|
||||
@@ -198,6 +202,7 @@ Matthew Braun matthew@ans.net
|
||||
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
|
||||
Matthew S. Levine mslevine@theory.lcs.mit.edu
|
||||
Matthew Swift swift@alum.mit.edu
|
||||
Mattias Wadenstein maswan@acc.umu.se
|
||||
Matthias Urlichs smurf@noris.de
|
||||
Meelis Roos mroos@tartu.cyber.ee
|
||||
Michael ??? michael@roka.net
|
||||
@@ -281,6 +286,7 @@ Vin Shelton acs@alumni.princeton.edu
|
||||
Volker Borchert bt@teknon.de
|
||||
Wayne Stewart wstewa@atl.com
|
||||
Wenjun Zheng zwj@yahoo.com
|
||||
Werner Almesberger Werner.Almesberger@epfl.ch
|
||||
Wichert Akkerman wichert@cistron.nl
|
||||
Will Edgington wedgingt@acm.org
|
||||
William Bader william@nscs.fast.net
|
||||
|
||||
@@ -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{2000-10-27.17}
|
||||
\def\texinfoversion{2000-11-09.08}
|
||||
%
|
||||
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
|
||||
% Free Software Foundation, Inc.
|
||||
@@ -688,13 +688,14 @@ where each line of input produces a line of output.}
|
||||
\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
|
||||
\leftline{\hskip\leftskip{\rm#1}}}}
|
||||
|
||||
% @inmargin{TEXT} puts TEXT in the left margin next to the current
|
||||
% paragraph. For more general purposes, use the \margin insertion class.
|
||||
% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
|
||||
% paragraph. For more general purposes, use the \margin insertion
|
||||
% class. WHICH is `l' or `r'.
|
||||
%
|
||||
\newskip\inmarginspacing \inmarginspacing=1cm
|
||||
\def\strutdepth{\dp\strutbox}
|
||||
%
|
||||
\def\inmargin#1{\strut\vadjust{%
|
||||
\def\doinmargin#1#2{\strut\vadjust{%
|
||||
\nobreak
|
||||
\kern-\strutdepth
|
||||
\vtop to \strutdepth{%
|
||||
@@ -702,11 +703,24 @@ where each line of input produces a line of output.}
|
||||
\vss
|
||||
% if you have multiple lines of stuff to put here, you'll need to
|
||||
% make the vbox yourself of the appropriate size.
|
||||
\llap{#1\hskip\inmarginspacing}%
|
||||
\ifx#1l%
|
||||
\llap{#2\hskip\inmarginspacing}%
|
||||
\else
|
||||
\rlap{\hskip\hsize\hskip\inmarginspacing#2}%
|
||||
\fi
|
||||
\null
|
||||
}%
|
||||
}}
|
||||
|
||||
\def\inleftmargin{\doinmargin l}
|
||||
\def\inrightmargin{\doinmargin r}
|
||||
\def\inmargin{% not perfect, but better than nothing.
|
||||
\ifodd\pageno
|
||||
\let\temp=\inleftmargin
|
||||
\else
|
||||
\let\temp=\inrightmargin
|
||||
\fi
|
||||
\temp
|
||||
}
|
||||
|
||||
% @include file insert text of that file as input.
|
||||
% Allow normal characters that we make active in the argument (a file name).
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
\input texinfo
|
||||
@c %**start of header
|
||||
@setfilename textutils.info
|
||||
@settitle GNU text utilities
|
||||
@settitle @sc{gnu} text utilities
|
||||
@c %**end of header
|
||||
|
||||
@include version.texi
|
||||
@@ -20,7 +20,7 @@
|
||||
@ifinfo
|
||||
@format
|
||||
START-INFO-DIR-ENTRY
|
||||
* Text utilities: (textutils). GNU text utilities.
|
||||
* Text utilities: (textutils). GNU text utilities.
|
||||
* cat: (textutils)cat invocation. Concatenate and write files.
|
||||
* cksum: (textutils)cksum invocation. Print @sc{posix} CRC checksum.
|
||||
* comm: (textutils)comm invocation. Compare sorted files by line.
|
||||
@@ -56,30 +56,18 @@ This file documents the GNU text utilities.
|
||||
|
||||
Copyright (C) 1994, 95, 96 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no
|
||||
Front-Cover Texts, and with no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled ``GNU
|
||||
Free Documentation License''.
|
||||
|
||||
@ignore
|
||||
Permission is granted to process this file through TeX and print the
|
||||
results, provided the printed document carries copying permission
|
||||
notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual).
|
||||
|
||||
@end ignore
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Foundation.
|
||||
@end ifinfo
|
||||
|
||||
@titlepage
|
||||
@title GNU @code{textutils}
|
||||
@title @sc{gnu} @code{textutils}
|
||||
@subtitle A set of text utilities
|
||||
@subtitle for version @value{VERSION}, @value{UPDATED}
|
||||
@author David MacKenzie et al.
|
||||
@@ -88,19 +76,13 @@ by the Foundation.
|
||||
@vskip 0pt plus 1filll
|
||||
Copyright @copyright{} 1994, 95, 96 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Foundation.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no
|
||||
Front-Cover Texts, and with no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled ``GNU
|
||||
Free Documentation License''.
|
||||
@end titlepage
|
||||
|
||||
|
||||
@@ -114,7 +96,7 @@ by the Foundation.
|
||||
@cindex text utilities
|
||||
@cindex utilities for text handling
|
||||
|
||||
This manual documents version @value{VERSION} of the GNU text utilities.
|
||||
This manual documents version @value{VERSION} of the @sc{gnu} text utilities.
|
||||
|
||||
@menu
|
||||
* Introduction:: Caveats, overview, and authors.
|
||||
@@ -217,11 +199,12 @@ Opening the software toolbox
|
||||
|
||||
This manual is incomplete: No attempt is made to explain basic concepts
|
||||
in a way suitable for novices. Thus, if you are interested, please get
|
||||
involved in improving this manual. The entire GNU community will
|
||||
involved in improving this manual. The entire @sc{gnu} community will
|
||||
benefit.
|
||||
|
||||
@cindex POSIX.2
|
||||
The GNU text utilities are mostly compatible with the @sc{posix.2} standard.
|
||||
The @sc{gnu} text utilities are mostly compatible with the @sc{posix.2}
|
||||
standard.
|
||||
|
||||
@c This paragraph appears in all of fileutils.texi, textutils.texi, and
|
||||
@c sh-utils.texi too -- so be sure to keep them consistent.
|
||||
@@ -251,7 +234,7 @@ overall process.
|
||||
|
||||
Certain options are available in all of these programs. Rather than
|
||||
writing identical descriptions for each of the programs, they are
|
||||
described here. (In fact, every GNU program accepts (or should accept)
|
||||
described here. (In fact, every @sc{gnu} program accepts (or should accept)
|
||||
these options.)
|
||||
|
||||
Some of these programs recognize the @samp{--help} and @samp{--version}
|
||||
@@ -692,19 +675,19 @@ to the output line generated by the type specification.
|
||||
|
||||
@table @samp
|
||||
@item a
|
||||
named character,
|
||||
named character
|
||||
@item c
|
||||
@sc{ascii} character or backslash escape,
|
||||
@item d
|
||||
signed decimal,
|
||||
signed decimal
|
||||
@item f
|
||||
floating point,
|
||||
floating point
|
||||
@item o
|
||||
octal,
|
||||
octal
|
||||
@item u
|
||||
unsigned decimal,
|
||||
unsigned decimal
|
||||
@item x
|
||||
hexadecimal.
|
||||
hexadecimal
|
||||
@end table
|
||||
|
||||
The type @code{a} outputs things like @samp{sp} for space, @samp{nl} for
|
||||
@@ -722,24 +705,24 @@ one of the following characters. For integers (@samp{d}, @samp{o},
|
||||
|
||||
@table @samp
|
||||
@item C
|
||||
char,
|
||||
char
|
||||
@item S
|
||||
short,
|
||||
short
|
||||
@item I
|
||||
int,
|
||||
int
|
||||
@item L
|
||||
long.
|
||||
long
|
||||
@end table
|
||||
|
||||
For floating point (@code{f}):
|
||||
|
||||
@table @asis
|
||||
@item F
|
||||
float,
|
||||
float
|
||||
@item D
|
||||
double,
|
||||
double
|
||||
@item L
|
||||
long double.
|
||||
long double
|
||||
@end table
|
||||
|
||||
@item -v
|
||||
@@ -763,7 +746,8 @@ is not given at all, the default is 16.
|
||||
@end table
|
||||
|
||||
The next several options map the old, pre-@sc{posix} format specification
|
||||
options to the corresponding @sc{posix} format specs. GNU @code{od} accepts
|
||||
options to the corresponding @sc{posix} format specs.
|
||||
@sc{gnu} @code{od} accepts
|
||||
any combination of old- and new-style options. Format specification
|
||||
options accumulate.
|
||||
|
||||
@@ -983,27 +967,35 @@ is @samp{space}). For multicolumn output, lines will always be truncated to
|
||||
column output no line truncation occurs by default. Use @samp{-W} option to
|
||||
truncate lines in that case.
|
||||
|
||||
@c FIXME:??? Should this be something like "Starting with version 1.22i,..."
|
||||
Including version 1.22i:
|
||||
|
||||
The following changes were made in version 1.22i and apply to later
|
||||
versions of @command{pr}:
|
||||
@c FIXME: this whole section here sounds very awkward to me. I
|
||||
@c made a few small changes, but really it all needs to be redone. - Brian
|
||||
Some small @var{letter options} (@samp{-s}, @samp{-w}) have been redefined
|
||||
with the object of a better @sc{posix} compliance. The output of some
|
||||
further cases has been adapted to other Unix systems. These changes are
|
||||
not compatible with earlier versions of the program.
|
||||
@c OK, I fixed another sentence or two, but some of it I just don't understand.
|
||||
@ - Brian
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
Some small @var{letter options} (@samp{-s}, @samp{-w}) have been
|
||||
redefined for better @sc{posix} compliance. The output of some further
|
||||
cases has been adapted to other Unix systems. These changes are not
|
||||
compatible with earlier versions of the program.
|
||||
|
||||
@item
|
||||
Some @var{new capital letter} options (@samp{-J}, @samp{-S}, @samp{-W})
|
||||
have been introduced to turn off unexpected interferences of small letter
|
||||
options. The @samp{-N} option and the second argument @var{last_page}
|
||||
of @samp{+FIRST_PAGE} offer more flexibility. The detailed handling of
|
||||
form feeds set in the input files requires the @samp{-T} option.
|
||||
|
||||
@item
|
||||
Capital letter options override small letter ones.
|
||||
|
||||
@item
|
||||
Some of the option-arguments (compare @samp{-s}, @samp{-S}, @samp{-e},
|
||||
@samp{-i}, @samp{-n}) cannot be specified as separate arguments from the
|
||||
preceding option letter (already stated in the @sc{posix} specification).
|
||||
@end itemize
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@@ -1194,12 +1186,12 @@ opened. (The exit status will still be nonzero, however.)
|
||||
@itemx --separator[=@var{char}]
|
||||
@opindex -s
|
||||
@opindex --separator
|
||||
Separate columns by a single character @var{char}. Default for @var{char}
|
||||
is the TAB character without @samp{-w} and @samp{no character} with
|
||||
@samp{-w}. Without @samp{-s} default separator @samp{space} is set.
|
||||
@samp{-s[char]} turns off line truncation of all three column options
|
||||
(@samp{-COLUMN}|@samp{-a -COLUMN}|@samp{-m}) except @samp{-w} is set.
|
||||
That is a @sc{posix}-compliant formulation.
|
||||
Separate columns by a single character @var{char}. The default for
|
||||
@var{char} is the TAB character without @samp{-w} and @samp{no
|
||||
character} with @samp{-w}. Without @samp{-s} the default separator
|
||||
@samp{space} is set. @samp{-s[char]} turns off line truncation of all
|
||||
three column options (@samp{-COLUMN}|@samp{-a -COLUMN}|@samp{-m}) unless
|
||||
@samp{-w} is set. This is a @sc{posix}-compliant formulation.
|
||||
|
||||
|
||||
@item -S[@var{string}]
|
||||
@@ -1437,13 +1429,13 @@ one-line header consisting of
|
||||
before the output for each @var{file}.
|
||||
|
||||
@cindex BSD @code{tail}
|
||||
GNU @code{tail} can output any amount of data (some other versions of
|
||||
@sc{gnu} @code{tail} can output any amount of data (some other versions of
|
||||
@code{tail} cannot). It also has no @samp{-r} option (print in
|
||||
reverse), since reversing a file is really a different job from printing
|
||||
the end of a file; BSD @code{tail} (which is the one with @code{-r}) can
|
||||
only reverse files that are at most as large as its buffer, which is
|
||||
typically 32k. A more reliable and versatile way to reverse files is
|
||||
the GNU @code{tac} command.
|
||||
the @sc{gnu} @code{tac} command.
|
||||
|
||||
@code{tail} accepts two option formats: the new one, in which numbers
|
||||
are arguments to the options (@samp{-n 1}), and the old one, in which
|
||||
@@ -1702,9 +1694,9 @@ exhausted.
|
||||
|
||||
The output files' names consist of a prefix (@samp{xx} by default)
|
||||
followed by a suffix. By default, the suffix is an ascending sequence
|
||||
of two-digit decimal numbers from @samp{00} and up to @samp{99}. In any
|
||||
case, concatenating the output files in sorted order by filename
|
||||
produces the original input file.
|
||||
of two-digit decimal numbers from @samp{00} to @samp{99}. In any case,
|
||||
concatenating the output files in sorted order by filename produces the
|
||||
original input file.
|
||||
|
||||
By default, if @code{csplit} encounters an error or receives a hangup,
|
||||
interrupt, quit, or terminate signal, it removes any output files
|
||||
@@ -1821,9 +1813,9 @@ in columns. However, @sc{posix} requires that there be exactly one space
|
||||
separating columns. You can make @code{wc} use the @sc{posix}-mandated
|
||||
output format by setting the @env{POSIXLY_CORRECT} environment variable.
|
||||
|
||||
By default, @code{wc} prints three counts: the newline, words, byte counts.
|
||||
Options can specify that only certain counts be printed. Options do not
|
||||
undo others previously given, so
|
||||
By default, @code{wc} prints three counts: the newline, words, and byte
|
||||
counts. Options can specify that only certain counts be printed.
|
||||
Options do not undo others previously given, so
|
||||
|
||||
@example
|
||||
wc --bytes --words
|
||||
@@ -1890,10 +1882,10 @@ sum [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@code{sum} prints the checksum for each @var{file} followed by the
|
||||
number of blocks in the file (rounded up). If more than one @var{file}
|
||||
is given, file names are also printed (by default). (With the
|
||||
@samp{--sysv} option, corresponding file name are printed when there is
|
||||
@samp{--sysv} option, corresponding file names are printed when there is
|
||||
at least one file argument.)
|
||||
|
||||
By default, GNU @code{sum} computes checksums using an algorithm
|
||||
By default, @sc{gnu} @code{sum} computes checksums using an algorithm
|
||||
compatible with BSD @code{sum} and prints file sizes in units of
|
||||
1024-byte blocks.
|
||||
|
||||
@@ -2125,9 +2117,9 @@ 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.
|
||||
|
||||
GNU @code{sort} (as specified for all GNU utilities) has no limits on
|
||||
@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
|
||||
addition, if the final byte of an input file is not a newline, GNU
|
||||
addition, if the final byte of an input file is not a newline, @sc{gnu}
|
||||
@code{sort} silently supplies one. A line's trailing newline is not
|
||||
part of the line for comparison purposes.@footnote{@sc{posix}.2-1992
|
||||
requires that the trailing newline be part of the comparison, and some
|
||||
@@ -2277,7 +2269,9 @@ string between a non-whitespace character and a whitespace character.
|
||||
That is, given the input line @w{@samp{ foo bar}}, @code{sort} breaks it
|
||||
into fields @w{@samp{ foo}} and @w{@samp{ bar}}. The field separator is
|
||||
not considered to be part of either the field preceding or the field
|
||||
following.
|
||||
following. But note that sort fields that extend to the end of the line,
|
||||
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}
|
||||
@opindex -T
|
||||
@@ -2325,13 +2319,13 @@ and character positions are numbered starting with 0. See below.
|
||||
|
||||
@end table
|
||||
|
||||
In addition, when GNU @code{sort} is invoked with exactly one argument,
|
||||
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}. GNU sort follows the @sc{posix}
|
||||
@samp{-b}, @samp{-f}, and @samp{-n}. @sc{gnu} sort follows the @sc{posix}
|
||||
behavior, which is usually (but not always!) like the System V behavior.
|
||||
According to @sc{posix}, @samp{-n} no longer implies @samp{-b}. For
|
||||
consistency, @samp{-M} has been changed in the same way. This may
|
||||
@@ -2389,7 +2383,7 @@ sort -t : -k 2,2n -k 5.3,5.4
|
||||
@end example
|
||||
|
||||
Note that if you had written @samp{-k 2} instead of @samp{-k 2,2}
|
||||
@samp{sort} would have used all characters beginning in the second field
|
||||
@command{sort} would have used all characters beginning in the second field
|
||||
and extending to the end of the line as the primary @emph{numeric}
|
||||
key. For the large majority of applications, treating keys spanning
|
||||
more than one field as numeric will not do what you expect.
|
||||
@@ -2530,7 +2524,7 @@ Print only duplicate lines.
|
||||
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.
|
||||
This is a @sc{gnu} extension.
|
||||
@c FIXME: give an example showing *how* it's useful
|
||||
|
||||
@item -u
|
||||
@@ -2659,15 +2653,15 @@ ptx -G [@var{option} @dots{}] [@var{input} [@var{output}]]
|
||||
@end example
|
||||
|
||||
The @samp{-G} (or its equivalent: @samp{--traditional}) option disables
|
||||
all GNU extensions and reverts to traditional mode, thus introducing some
|
||||
all @sc{gnu} extensions and reverts to traditional mode, thus introducing some
|
||||
limitations and changing several of the program's default option values.
|
||||
When @samp{-G} is not specified, GNU extensions are always enabled. GNU
|
||||
extensions to @code{ptx} are documented wherever appropriate in this
|
||||
When @samp{-G} is not specified, @sc{gnu} extensions are always enabled.
|
||||
@sc{gnu} extensions to @code{ptx} are documented wherever appropriate in this
|
||||
document. For the full list, see @xref{Compatibility in ptx}.
|
||||
|
||||
Individual options are explained in the following sections.
|
||||
|
||||
When GNU extensions are enabled, there may be zero, one or several
|
||||
When @sc{gnu} extensions are enabled, there may be zero, one or several
|
||||
@var{file}s after the options. If there is no @var{file}, the program
|
||||
reads the standard input. If there is one or several @var{file}s, they
|
||||
give the name of input files which are all read in turn, as if all the
|
||||
@@ -2677,7 +2671,7 @@ file names and line numbers refer to individual text input files. In
|
||||
all cases, the program outputs the permuted index to the standard
|
||||
output.
|
||||
|
||||
When GNU extensions are @emph{not} enabled, that is, when the program
|
||||
When @sc{gnu} extensions are @emph{not} enabled, that is, when the program
|
||||
operates in traditional mode, there may be zero, one or two parameters
|
||||
besides the options. If there are no parameters, the program reads the
|
||||
standard input and outputs the permuted index to the standard output.
|
||||
@@ -2687,7 +2681,7 @@ respectively the name of the @var{input} file to read and the name of
|
||||
the @var{output} file to produce. @emph{Be very careful} to note that,
|
||||
in this case, the contents of file given by the second parameter is
|
||||
destroyed. This behavior is dictated by System V @code{ptx}
|
||||
compatibility; GNU Standards normally discourage output parameters not
|
||||
compatibility; @sc{gnu} Standards normally discourage output parameters not
|
||||
introduced by an option.
|
||||
|
||||
Note that for @emph{any} file named as the value of an option or as an
|
||||
@@ -2716,7 +2710,7 @@ exit without further processing.
|
||||
|
||||
@item -G
|
||||
@itemx --traditional
|
||||
As already explained, this option disables all GNU extensions to
|
||||
As already explained, this option disables all @sc{gnu} extensions to
|
||||
@code{ptx} and switches to traditional mode.
|
||||
|
||||
@item --help
|
||||
@@ -2737,7 +2731,7 @@ processing.
|
||||
As it is set up now, the program assumes that the input file is coded
|
||||
using 8-bit ISO 8859-1 code, also known as Latin-1 character set,
|
||||
@emph{unless} it is compiled for MS-DOS, in which case it uses the
|
||||
character set of the IBM-PC. (GNU @code{ptx} is not known to work on
|
||||
character set of the IBM-PC. (@sc{gnu} @code{ptx} is not known to work on
|
||||
smaller MS-DOS machines anymore.) Compared to 7-bit @sc{ascii}, the set
|
||||
of characters which are letters is different; this alters the behavior
|
||||
of regular expression matching. Thus, the default regular expression
|
||||
@@ -2770,9 +2764,9 @@ is not part of the Break file is a word constituent. If both options
|
||||
@samp{-b} and @samp{-W} are specified, then @samp{-W} has precedence and
|
||||
@samp{-b} is ignored.
|
||||
|
||||
When GNU extensions are enabled, the only way to avoid newline as a
|
||||
When @sc{gnu} extensions are enabled, the only way to avoid newline as a
|
||||
break character is to write all the break characters in the file with no
|
||||
newline at all, not even at the end of the file. When GNU extensions
|
||||
newline at all, not even at the end of the file. When @sc{gnu} extensions
|
||||
are disabled, spaces, tabs and newlines are always considered as break
|
||||
characters even if not included in the Break file.
|
||||
|
||||
@@ -2799,9 +2793,9 @@ is ignored. The file is called the @dfn{Only file}. The file contains
|
||||
exactly one word in each line; the end of line separation of words is
|
||||
not subject to the value of the @samp{-S} option.
|
||||
|
||||
There is no default for the Only file. In the case there are both an
|
||||
Only file and an Ignore file, a word can be a keyword only if it is
|
||||
given in the Only file and not given in the Ignore file.
|
||||
There is no default for the Only file. When both an Only file and an
|
||||
Ignore file are specified, a word is considered a keyword only
|
||||
if it is listed in the Only file and not in the Ignore file.
|
||||
|
||||
@item -r
|
||||
@itemx --references
|
||||
@@ -2815,7 +2809,7 @@ Using this option changes the default value for option @samp{-S}.
|
||||
Using this option, the program does not try very hard to remove
|
||||
references from contexts in output, but it succeeds in doing so
|
||||
@emph{when} the context ends exactly at the newline. If option
|
||||
@samp{-r} is used with @samp{-S} default value, or when GNU extensions
|
||||
@samp{-r} is used with @samp{-S} default value, or when @sc{gnu} extensions
|
||||
are disabled, this condition is always met and references are completely
|
||||
excluded from the output contexts.
|
||||
|
||||
@@ -2826,15 +2820,15 @@ This option selects which regular expression will describe the end of a
|
||||
line or the end of a sentence. In fact, this regular expression is not
|
||||
the only distinction between end of lines or end of sentences, and input
|
||||
line boundaries have no special significance outside this option. By
|
||||
default, when GNU extensions are enabled and if @samp{-r} option is not
|
||||
default, when @sc{gnu} extensions are enabled and if @samp{-r} option is not
|
||||
used, end of sentences are used. In this case, this @var{regex} is
|
||||
imported from GNU Emacs:
|
||||
imported from @sc{gnu} Emacs:
|
||||
|
||||
@example
|
||||
[.?!][]\"')@}]*\\($\\|\t\\| \\)[ \t\n]*
|
||||
@end example
|
||||
|
||||
Whenever GNU extensions are disabled or if @samp{-r} option is used, end
|
||||
Whenever @sc{gnu} extensions are disabled or if @samp{-r} option is used, end
|
||||
of lines are used; in this case, the default @var{regexp} is just:
|
||||
|
||||
@example
|
||||
@@ -2866,8 +2860,8 @@ corresponding characters by @code{ptx} itself.
|
||||
@itemx --word-regexp=@var{regexp}
|
||||
|
||||
This option selects which regular expression will describe each keyword.
|
||||
By default, if GNU extensions are enabled, a word is a sequence of
|
||||
letters; the @var{regexp} used is @samp{\w+}. When GNU extensions are
|
||||
By default, if @sc{gnu} extensions are enabled, a word is a sequence of
|
||||
letters; the @var{regexp} used is @samp{\w+}. When @sc{gnu} extensions are
|
||||
disabled, a word is by default anything which ends with a space, a tab
|
||||
or a newline; the @var{regexp} used is @samp{[^ \t\n]+}.
|
||||
|
||||
@@ -2887,14 +2881,14 @@ the corresponding characters by @code{ptx} itself.
|
||||
|
||||
Output format is mainly controlled by the @samp{-O} and @samp{-T} options
|
||||
described in the table below. When neither @samp{-O} nor @samp{-T} are
|
||||
selected, and if GNU extensions are enabled, the program chooses an
|
||||
selected, and if @sc{gnu} extensions are enabled, the program chooses an
|
||||
output format suitable for a dumb terminal. Each keyword occurrence is
|
||||
output to the center of one line, surrounded by its left and right
|
||||
contexts. Each field is properly justified, so the concordance output
|
||||
can be readily observed. As a special feature, if automatic
|
||||
references are selected by option @samp{-A} and are output before the
|
||||
left context, that is, if option @samp{-R} is @emph{not} selected, then
|
||||
a colon is added after the reference; this nicely interfaces with GNU
|
||||
a colon is added after the reference; this nicely interfaces with @sc{gnu}
|
||||
Emacs @code{next-error} processing. In this default output format, each
|
||||
white space character, like newline and tab, is merely changed to
|
||||
exactly one space, with no special attempt to compress consecutive
|
||||
@@ -2915,13 +2909,13 @@ output line.
|
||||
@item -w @var{number}
|
||||
@itemx --width=@var{number}
|
||||
|
||||
Select the output maximum width of each final line. If references are
|
||||
used, they are included or excluded from the output maximum width
|
||||
Select the maximum output width of each final line. If references are
|
||||
used, they are included or excluded from the maximum output width
|
||||
depending on the value of option @samp{-R}. If this option is not
|
||||
selected, that is, when references are output before the left context,
|
||||
the output maximum width takes into account the maximum length of all
|
||||
the maximum output width takes into account the maximum length of all
|
||||
references. If this option is selected, that is, when references are
|
||||
output after the right context, the output maximum width does not take
|
||||
output after the right context, the maximum output width does not take
|
||||
into account the space taken by references, nor the gap that precedes
|
||||
them.
|
||||
|
||||
@@ -2938,17 +2932,16 @@ reference is used at output time, overriding the input reference.
|
||||
@item -R
|
||||
@itemx --right-side-refs
|
||||
|
||||
In default output format, when option @samp{-R} is not used, any
|
||||
reference produced by the effect of options @samp{-r} or @samp{-A} are
|
||||
given to the far right of output lines, after the right context. In
|
||||
default output format, when option @samp{-R} is specified, references
|
||||
are rather given to the beginning of each output line, before the left
|
||||
context. For any other output format, option @samp{-R} is almost
|
||||
ignored, except for the fact that the width of references is @emph{not}
|
||||
taken into account in total output width given by @samp{-w} whenever
|
||||
@samp{-R} is selected.
|
||||
In the default output format, when option @samp{-R} is not used, any
|
||||
references produced by the effect of options @samp{-r} or @samp{-A} are
|
||||
placed to the far right of output lines, after the right context. With
|
||||
default output format, when the @samp{-R} option is specified, references
|
||||
are rather placed at the beginning of each output line, before the left
|
||||
context. For any other output format, option @samp{-R} is
|
||||
ignored, with one exception: with @samp{-R} the width of references
|
||||
is @emph{not} taken into account in total output width given by @samp{-w}.
|
||||
|
||||
This option is automatically selected whenever GNU extensions are
|
||||
This option is automatically selected whenever @sc{gnu} extensions are
|
||||
disabled.
|
||||
|
||||
@item -F @var{string}
|
||||
@@ -2990,8 +2983,8 @@ processing. Each output line will look like:
|
||||
@end smallexample
|
||||
|
||||
so it will be possible to write a @samp{.xx} roff macro to take care of
|
||||
the output typesetting. This is the default output format when GNU
|
||||
extensions are disabled. Option @samp{-M} might be used to change
|
||||
the output typesetting. This is the default output format when @sc{gnu}
|
||||
extensions are disabled. Option @samp{-M} can be used to change
|
||||
@samp{xx} to another macro name.
|
||||
|
||||
In this output format, each non-graphical character, like newline and
|
||||
@@ -3014,48 +3007,48 @@ so it will be possible to write a @code{\xx} definition to take care of
|
||||
the output typesetting. Note that when references are not being
|
||||
produced, that is, neither option @samp{-A} nor option @samp{-r} is
|
||||
selected, the last parameter of each @code{\xx} call is inhibited.
|
||||
Option @samp{-M} might be used to change @samp{xx} to another macro
|
||||
Option @samp{-M} can be used to change @samp{xx} to another macro
|
||||
name.
|
||||
|
||||
In this output format, some special characters, like @kbd{$}, @kbd{%},
|
||||
@kbd{&}, @kbd{#} and @kbd{_} are automatically protected with a
|
||||
backslash. Curly brackets @kbd{@{}, @kbd{@}} are also protected with a
|
||||
backslash, but also enclosed in a pair of dollar signs to force
|
||||
mathematical mode. The backslash itself produces the sequence
|
||||
@code{\backslash@{@}}. Circumflex and tilde diacritics produce the
|
||||
sequence @code{^\@{ @}} and @code{~\@{ @}} respectively. Other
|
||||
diacriticized characters of the underlying character set produce an
|
||||
appropriate @TeX{} sequence as far as possible. The other non-graphical
|
||||
characters, like newline and tab, and all others characters which are
|
||||
not part of @sc{ascii}, are merely changed to exactly one space, with no
|
||||
special attempt to compress consecutive spaces. Let me know how to
|
||||
improve this special character processing for @TeX{}.
|
||||
backslash. Curly brackets @kbd{@{}, @kbd{@}} are protected with a
|
||||
backslash and a pair of dollar signs (to force mathematical mode). The
|
||||
backslash itself produces the sequence @code{\backslash@{@}}.
|
||||
Circumflex and tilde diacritics produce the sequence @code{^\@{ @}} and
|
||||
@code{~\@{ @}} respectively. Other diacriticized characters of the
|
||||
underlying character set produce an appropriate @TeX{} sequence as far
|
||||
as possible. The other non-graphical characters, like newline and tab,
|
||||
and all other characters which are not part of @sc{ascii}, are merely
|
||||
changed to exactly one space, with no special attempt to compress
|
||||
consecutive spaces. Let me know how to improve this special character
|
||||
processing for @TeX{}.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Compatibility in ptx
|
||||
@subsection The GNU extensions to @code{ptx}
|
||||
@subsection The @sc{gnu} extensions to @code{ptx}
|
||||
|
||||
This version of @code{ptx} contains a few features which do not exist in
|
||||
System V @code{ptx}. These extra features are suppressed by using the
|
||||
@samp{-G} command line option, unless overridden by other command line
|
||||
options. Some GNU extensions cannot be recovered by overriding, so the
|
||||
simple rule is to avoid @samp{-G} if you care about GNU extensions.
|
||||
options. Some @sc{gnu} extensions cannot be recovered by overriding, so the
|
||||
simple rule is to avoid @samp{-G} if you care about @sc{gnu} extensions.
|
||||
Here are the differences between this program and System V @code{ptx}.
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
This program can read many input files at once, it always writes the
|
||||
resulting concordance on standard output. On the other end, System V
|
||||
@code{ptx} reads only one file and produce the result on standard output
|
||||
resulting concordance on standard output. On the other hand, System V
|
||||
@code{ptx} reads only one file and sends the result to standard output
|
||||
or, if a second @var{file} parameter is given on the command, to that
|
||||
@var{file}.
|
||||
|
||||
Having output parameters not introduced by options is a quite dangerous
|
||||
practice which GNU avoids as far as possible. So, for using @code{ptx}
|
||||
portably between GNU and System V, you should always use it with a
|
||||
Having output parameters not introduced by options is a dangerous
|
||||
practice which @sc{gnu} avoids as far as possible. So, for using @code{ptx}
|
||||
portably between @sc{gnu} and System V, you should always use it with a
|
||||
single input file, and always expect the result on standard output. You
|
||||
might also want to automatically configure in a @samp{-G} option to
|
||||
@code{ptx} calls in products using @code{ptx}, if the configurator finds
|
||||
@@ -3064,9 +3057,9 @@ that the installed @code{ptx} accepts @samp{-G}.
|
||||
@item
|
||||
The only options available in System V @code{ptx} are options @samp{-b},
|
||||
@samp{-f}, @samp{-g}, @samp{-i}, @samp{-o}, @samp{-r}, @samp{-t} and
|
||||
@samp{-w}. All other options are GNU extensions and are not repeated in
|
||||
@samp{-w}. All other options are @sc{gnu} extensions and are not repeated in
|
||||
this enumeration. Moreover, some options have a slightly different
|
||||
meaning when GNU extensions are enabled, as explained below.
|
||||
meaning when @sc{gnu} extensions are enabled, as explained below.
|
||||
|
||||
@item
|
||||
By default, concordance output is not formatted for @code{troff} or
|
||||
@@ -3075,29 +3068,29 @@ or @code{nroff} output may still be selected through option @samp{-O}.
|
||||
|
||||
@item
|
||||
Unless @samp{-R} option is used, the maximum reference width is
|
||||
subtracted from the total output line width. With GNU extensions
|
||||
subtracted from the total output line width. With @sc{gnu} extensions
|
||||
disabled, width of references is not taken into account in the output
|
||||
line width computations.
|
||||
|
||||
@item
|
||||
All 256 characters, even @kbd{NUL}s, are always read and processed from
|
||||
input file with no adverse effect, even if GNU extensions are disabled.
|
||||
input file with no adverse effect, even if @sc{gnu} extensions are disabled.
|
||||
However, System V @code{ptx} does not accept 8-bit characters, a few
|
||||
control characters are rejected, and the tilde @kbd{~} is also rejected.
|
||||
|
||||
@item
|
||||
Input line length is only limited by available memory, even if GNU
|
||||
Input line length is only limited by available memory, even if @sc{gnu}
|
||||
extensions are disabled. However, System V @code{ptx} processes only
|
||||
the first 200 characters in each line.
|
||||
|
||||
@item
|
||||
The break (non-word) characters default to be every character except all
|
||||
letters of the underlying character set, diacriticized or not. When GNU
|
||||
letters of the underlying character set, diacriticized or not. When @sc{gnu}
|
||||
extensions are disabled, the break characters default to space, tab and
|
||||
newline only.
|
||||
|
||||
@item
|
||||
The program makes better use of output line width. If GNU extensions
|
||||
The program makes better use of output line width. If @sc{gnu} extensions
|
||||
are disabled, the program rather tries to imitate System V @code{ptx},
|
||||
but still, there are some slight disposition glitches this program does
|
||||
not completely reproduce.
|
||||
@@ -3134,7 +3127,7 @@ cut [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
In the table which follows, the @var{byte-list}, @var{character-list},
|
||||
and @var{field-list} are one or more numbers or ranges (two numbers
|
||||
separated by a dash) separated by commas. Bytes, characters, and
|
||||
fields are numbered from starting at 1. Incomplete ranges may be
|
||||
fields are numbered starting at 1. Incomplete ranges may be
|
||||
given: @samp{-@var{m}} means @samp{1-@var{m}}; @samp{@var{n}-} means
|
||||
@samp{@var{n}} through end of line or last field.
|
||||
|
||||
@@ -3332,7 +3325,7 @@ Print a line for each unpairable line in file @var{file-number}
|
||||
|
||||
@end table
|
||||
|
||||
In addition, when GNU @code{join} is invoked with exactly one argument,
|
||||
In addition, when @sc{gnu} @code{join} is invoked with exactly one argument,
|
||||
options @samp{--help} and @samp{--version} are recognized. @xref{Common
|
||||
options}.
|
||||
|
||||
@@ -3440,7 +3433,7 @@ from @var{m} through @var{n}, in ascending order. @var{m} should
|
||||
collate before @var{n}; if it doesn't, an error results. As an example,
|
||||
@samp{0-9} is the same as @samp{0123456789}.
|
||||
|
||||
GNU @code{tr} does not support the System V syntax that uses square
|
||||
@sc{gnu} @code{tr} does not support the System V syntax that uses square
|
||||
brackets to enclose ranges. Translations specified in that format
|
||||
sometimes work as expected, since the brackets are often transliterated
|
||||
to themselves. However, they should be avoided because they sometimes
|
||||
@@ -3528,7 +3521,7 @@ The syntax @samp{[=@var{c}=]} expands to all of the characters that are
|
||||
equivalent to @var{c}, in no particular order. Equivalence classes are
|
||||
a relatively recent invention intended to support non-English alphabets.
|
||||
But there seems to be no standard way to define them or determine their
|
||||
contents. Therefore, they are not fully implemented in GNU @code{tr};
|
||||
contents. Therefore, they are not fully implemented in @sc{gnu} @code{tr};
|
||||
each character's equivalence class consists only of that character,
|
||||
which is of no particular use.
|
||||
|
||||
@@ -3576,8 +3569,8 @@ BSD @code{tr} pads @var{set2} to the length of @var{set1} by repeating
|
||||
the last character of @var{set2} as many times as necessary. System V
|
||||
@code{tr} truncates @var{set1} to the length of @var{set2}.
|
||||
|
||||
By default, GNU @code{tr} handles this case like BSD @code{tr}. When
|
||||
the @samp{--truncate-set1} (@samp{-t}) option is given, GNU @code{tr}
|
||||
By default, @sc{gnu} @code{tr} handles this case like BSD @code{tr}. When
|
||||
the @samp{--truncate-set1} (@samp{-t}) option is given, @sc{gnu} @code{tr}
|
||||
handles this case like the System V @code{tr} instead. This option is
|
||||
ignored for operations other than translation.
|
||||
|
||||
@@ -3716,7 +3709,7 @@ following warning and error messages, for strict compliance with
|
||||
|
||||
@item
|
||||
When the @samp{--delete} option is given but @samp{--squeeze-repeats}
|
||||
is not, and @var{set2} is given, GNU @code{tr} by default prints
|
||||
is not, and @var{set2} is given, @sc{gnu} @code{tr} by default prints
|
||||
a usage message and exits, because @var{set2} would not be used.
|
||||
The @sc{posix} specification says that @var{set2} must be ignored in
|
||||
this case. Silently ignoring arguments is a bad idea.
|
||||
@@ -3728,9 +3721,9 @@ value 400 octal does not fit into a single byte.
|
||||
|
||||
@end enumerate
|
||||
|
||||
GNU @code{tr} does not provide complete BSD or System V compatibility.
|
||||
@sc{gnu} @code{tr} does not provide complete BSD or System V compatibility.
|
||||
For example, it is impossible to disable interpretation of the @sc{posix}
|
||||
constructs @samp{[:alpha:]}, @samp{[=c=]}, and @samp{[c*10]}. Also, GNU
|
||||
constructs @samp{[:alpha:]}, @samp{[=c=]}, and @samp{[c*10]}. Also, @sc{gnu}
|
||||
@code{tr} does not delete zero bytes automatically, unlike traditional
|
||||
Unix versions, which provide no way to preserve zero bytes.
|
||||
|
||||
@@ -3855,13 +3848,13 @@ Robbins.
|
||||
@node Toolbox introduction
|
||||
@unnumberedsec Toolbox introduction
|
||||
|
||||
This month's column is only peripherally related to the GNU Project, in
|
||||
that it describes a number of the GNU tools on your Linux system and how they
|
||||
might be used. What it's really about is the ``Software Tools'' philosophy
|
||||
This month's column is only peripherally related to the @sc{gnu} Project, in
|
||||
that it describes a number of the @sc{gnu} tools on your Linux system and how
|
||||
they might be used. What it's really about is the ``Software Tools'' philosophy
|
||||
of program development and usage.
|
||||
|
||||
The software tools philosophy was an important and integral concept
|
||||
in the initial design and development of Unix (of which Linux and GNU are
|
||||
in the initial design and development of Unix (of which Linux and @sc{gnu} are
|
||||
essentially clones). Unfortunately, in the modern day press of
|
||||
Internetworking and flashy GUIs, it seems to have fallen by the
|
||||
wayside. This is a shame, since it provides a powerful mental model
|
||||
@@ -4354,8 +4347,8 @@ appropriate tool, build one.
|
||||
As of this writing, all the programs we've discussed are available via
|
||||
anonymous @code{ftp} from @code{prep.ai.mit.edu} as
|
||||
@file{/pub/gnu/textutils-1.9.tar.gz}.@footnote{Version 1.9 was current
|
||||
when this column was written. Check the nearest GNU archive for the
|
||||
current version. The main GNU FTP site is now @code{ftp.gnu.org}.}
|
||||
when this column was written. Check the nearest @sc{gnu} archive for the
|
||||
current version. The main @sc{gnu} FTP site is now @code{ftp.gnu.org}.}
|
||||
|
||||
None of what I have presented in this column is new. The Software Tools
|
||||
philosophy was first introduced in the book @cite{Software Tools},
|
||||
@@ -4381,8 +4374,8 @@ whose members had ported the original @code{ratfor} programs to essentially
|
||||
every computer system with a FORTRAN compiler. The popularity of the
|
||||
group waned in the middle '80s as Unix began to spread beyond universities.
|
||||
|
||||
With the current proliferation of GNU code and other clones of Unix programs,
|
||||
these programs now receive little attention; modern C versions are
|
||||
With the current proliferation of @sc{gnu} code and other clones of Unix
|
||||
programs, these programs now receive little attention; modern C versions are
|
||||
much more efficient and do more than these programs do. Nevertheless, as
|
||||
exposition of good programming style, and evangelism for a still-valuable
|
||||
philosophy, these books are unparalleled, and I recommend them highly.
|
||||
|
||||
@@ -1,15 +1,61 @@
|
||||
2000-12-05 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* dirname.c (dir_name_r): Add `const' in a few local declarations.
|
||||
|
||||
2000-12-04 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* path-concat.c: [!HAVE_DECL_MALLOC]: Declare malloc.
|
||||
Also include memory.h, stdlib.h, unistd.h if appropriate.
|
||||
Reported by Andreas Jaeger (conflicting declaration of malloc).
|
||||
|
||||
2000-12-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* closeout.h: Make idempotent, to avoid some obscure warnings.
|
||||
|
||||
2000-12-01 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/memrchr.c: Include <config.h> before any system include file.
|
||||
|
||||
2000-11-29 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/dirname.c (dir_name_r): Fix typo: int -> size_t.
|
||||
|
||||
2000-11-26 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* memcoll.c: Include sys/types.h. From Werner Almesberger.
|
||||
|
||||
2000-11-22 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* lib/strftime.c (my_strftime): Do not invoke mbrlen with a
|
||||
size of (size_t) -1; it's not portable.
|
||||
|
||||
2000-11-17 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* lib/obstack.h: Formatting changes.
|
||||
(obstack_grow, obstack_grow0): Don't cast WHERE at all: that would
|
||||
prevent type checking.
|
||||
(obstack_ptr_grow, obstack_ptr_grow_fast): When assigning, don't
|
||||
cast the value to (void *): assigning a `foo *' to a `void *'
|
||||
variable is valid.
|
||||
(obstack_int_grow, obstack_int_grow_fast): Don't cast AINT to int.
|
||||
|
||||
2000-11-17 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* strstr.c: Update from GNU libc.
|
||||
|
||||
2000-11-16 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* strverscmp.c: Incorporate weak-alias-related changes from glibc.
|
||||
|
||||
2000-11-11 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* error.c: Add a couple #includes, merging from GNU libc version.
|
||||
|
||||
2000-11-10 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* obstack.h: Update from GNU libc.
|
||||
* obstack.c: Likewise.
|
||||
|
||||
2000-11-03 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* unicodeio.c: Include wchar.h.
|
||||
(wcrtomb): Provide fallback definition for broken platforms.
|
||||
(print_unicode_char): New alternative definition for platforms where
|
||||
wchar_t is Unicode.
|
||||
|
||||
2000-11-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* getusershell.c (setusershell): Use rewind rather than
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
#ifndef CLOSEOUT_H
|
||||
# define CLOSEOUT_H 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void close_stdout_set_status PARAMS ((int status));
|
||||
void close_stdout_set_file_name PARAMS ((const char *file));
|
||||
void close_stdout PARAMS ((void));
|
||||
void close_stdout_status PARAMS ((int status));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,15 +54,15 @@ void *memrchr ();
|
||||
Works properly even if there are trailing slashes
|
||||
(by effectively ignoring them). */
|
||||
size_t
|
||||
dir_name_r (const char *path, const char **result)
|
||||
dir_name_r (char const *path, char const **result)
|
||||
{
|
||||
char *slash;
|
||||
int length; /* Length of result, not including NUL. */
|
||||
char const *slash;
|
||||
size_t length; /* Length of result, not including NUL. */
|
||||
|
||||
slash = strrchr (path, '/');
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char *b = strrchr (path, '\\');
|
||||
char const *b = strrchr (path, '\\');
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ dir_name_r (const char *path, const char **result)
|
||||
slash = memrchr (path, '/', slash - path);
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char *b = memrchr (path, '\\', slash - path);
|
||||
char const *b = memrchr (path, '\\', slash - path);
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ dir_name_r (const char *path, const char **result)
|
||||
/* Remove any trailing slashes from the result. */
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
const char *lim = ((path[0] >= 'A' && path[0] <= 'z'
|
||||
char const *lim = ((path[0] >= 'A' && path[0] <= 'z'
|
||||
&& path[1] == ':')
|
||||
? path + 2 : path);
|
||||
|
||||
@@ -126,9 +126,9 @@ dir_name_r (const char *path, const char **result)
|
||||
(by effectively ignoring them). */
|
||||
|
||||
char *
|
||||
dir_name (const char *path)
|
||||
dir_name (char const *path)
|
||||
{
|
||||
const char *result;
|
||||
char const *result;
|
||||
size_t length = dir_name_r (path, &result);
|
||||
char *newpath = (char *) malloc (length + 1);
|
||||
if (newpath == 0)
|
||||
@@ -170,7 +170,7 @@ main ()
|
||||
{
|
||||
char path[MAX_BUFF_LEN];
|
||||
char expected_result[MAX_BUFF_LEN];
|
||||
char *result;
|
||||
char const *result;
|
||||
sscanf (buff, "%s %s", path, expected_result);
|
||||
result = dir_name (path);
|
||||
if (strcmp (result, expected_result))
|
||||
|
||||
10
lib/error.c
10
lib/error.c
@@ -1,5 +1,5 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1998, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
@@ -26,6 +26,9 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||
# if __STDC__
|
||||
@@ -83,6 +86,11 @@ unsigned int error_message_count;
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
||||
# ifdef USE_IN_LIBIO
|
||||
# include <libio/iolibio.h>
|
||||
# define fflush(s) _IO_fflush (s)
|
||||
# endif
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
|
||||
@@ -145,7 +145,7 @@ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
|
||||
|
||||
/* The following is from gnupg-1.0.2's cipher/bithelp.h. */
|
||||
/* Rotate a 32 bit integer by n bytes */
|
||||
#if defined(__GNUC__) && defined(__i386__)
|
||||
#if defined __GNUC__ && defined __i386__
|
||||
static inline md5_uint32
|
||||
rol(md5_uint32 x, int n)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#undef __ptr_t
|
||||
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
|
||||
# define __ptr_t void *
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
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 the
|
||||
@@ -290,21 +291,24 @@ extern int obstack_exit_failure;
|
||||
standard C version. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, \
|
||||
(void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, \
|
||||
(void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) (long)) (chunkfun), \
|
||||
(void (*) (void *)) (freefun))
|
||||
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) (void *, long)) (chunkfun), \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) (void *, long)) (chunkfun), \
|
||||
(void (*) (void *, void *)) (freefun), (arg))
|
||||
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
@@ -315,21 +319,25 @@ extern int obstack_exit_failure;
|
||||
|
||||
#else
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, \
|
||||
(void (*) ()) obstack_chunk_free)
|
||||
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, \
|
||||
(void (*) ()) obstack_chunk_free)
|
||||
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), (void (*) ()) (freefun))
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), \
|
||||
(void (*) ()) (freefun))
|
||||
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), \
|
||||
(void (*) ()) (freefun), (arg))
|
||||
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
|
||||
@@ -387,7 +395,7 @@ __extension__ \
|
||||
int __len = (length); \
|
||||
if (__o->next_free + __len > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
_obstack_memcpy (__o->next_free, (const char *) (where), __len); \
|
||||
_obstack_memcpy (__o->next_free, (where), __len); \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
@@ -397,7 +405,7 @@ __extension__ \
|
||||
int __len = (length); \
|
||||
if (__o->next_free + __len + 1 > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, __len + 1); \
|
||||
_obstack_memcpy (__o->next_free, (const char *) (where), __len); \
|
||||
_obstack_memcpy (__o->next_free, (where), __len); \
|
||||
__o->next_free += __len; \
|
||||
*(__o->next_free)++ = 0; \
|
||||
(void) 0; })
|
||||
@@ -410,8 +418,8 @@ __extension__ \
|
||||
*(__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
/* These assume that the obstack alignment is good enough for pointers or ints,
|
||||
and that the data added so far to the current object
|
||||
/* These assume that the obstack alignment is good enough for pointers
|
||||
or ints, and that the data added so far to the current object
|
||||
shares that much alignment. */
|
||||
|
||||
# define obstack_ptr_grow(OBSTACK,datum) \
|
||||
@@ -419,7 +427,7 @@ __extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (void *)); \
|
||||
*((void **)__o->next_free)++ = ((const void *)datum); \
|
||||
*((void **)__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_int_grow(OBSTACK,datum) \
|
||||
@@ -427,11 +435,14 @@ __extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (int)); \
|
||||
*((int *)__o->next_free)++ = ((int)datum); \
|
||||
*((int *)__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
# define obstack_ptr_grow_fast(h,aptr) \
|
||||
(*((void **) (h)->next_free)++ = (aptr))
|
||||
|
||||
# define obstack_int_grow_fast(h,aint) \
|
||||
(*((int *) (h)->next_free)++ = (aint))
|
||||
|
||||
# define obstack_blank(OBSTACK,length) \
|
||||
__extension__ \
|
||||
@@ -512,14 +523,14 @@ __extension__ \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
|
||||
_obstack_memcpy ((h)->next_free, (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp)
|
||||
|
||||
# define obstack_grow0(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
|
||||
_obstack_memcpy ((h)->next_free, (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp, \
|
||||
*((h)->next_free)++ = 0)
|
||||
|
||||
@@ -531,15 +542,18 @@ __extension__ \
|
||||
# define obstack_ptr_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
|
||||
(*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
|
||||
(*((const char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = (datum)))
|
||||
|
||||
# define obstack_int_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
|
||||
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
|
||||
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = (datum)))
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
# define obstack_ptr_grow_fast(h,aptr) \
|
||||
(*((const char **) (h)->next_free)++ = (aptr))
|
||||
|
||||
# define obstack_int_grow_fast(h,aint) \
|
||||
(*((int *) (h)->next_free)++ = (aint))
|
||||
|
||||
# define obstack_blank(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
|
||||
@@ -26,12 +26,31 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# if !STDC_HEADERS && HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#else
|
||||
# if HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
# endif
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_MALLOC
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_MALLOC
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
#ifndef strdup
|
||||
char *strdup ();
|
||||
#endif
|
||||
|
||||
@@ -515,6 +515,9 @@ my_strftime (s, maxsize, format, tp ut_argument)
|
||||
size_t i = 0;
|
||||
CHAR_T *p = s;
|
||||
const CHAR_T *f;
|
||||
#if DO_MULTIBYTE && !defined COMPILE_WIDE
|
||||
const char *format_end = NULL;
|
||||
#endif
|
||||
|
||||
zone = NULL;
|
||||
#if HAVE_TM_ZONE
|
||||
@@ -607,10 +610,15 @@ my_strftime (s, maxsize, format, tp ut_argument)
|
||||
{
|
||||
mbstate_t mbstate = mbstate_zero;
|
||||
size_t len = 0;
|
||||
size_t fsize;
|
||||
|
||||
if (! format_end)
|
||||
format_end = f + strlen (f) + 1;
|
||||
fsize = format_end - f;
|
||||
|
||||
do
|
||||
{
|
||||
size_t bytes = mbrlen (f + len, (size_t) -1, &mbstate);
|
||||
size_t bytes = mbrlen (f + len, fsize - len, &mbstate);
|
||||
|
||||
if (bytes == 0)
|
||||
break;
|
||||
|
||||
@@ -28,11 +28,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#if defined _LIBC || defined HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef unsigned chartype;
|
||||
|
||||
#undef strstr
|
||||
|
||||
char *
|
||||
strstr (const char *phaystack, const char *pneedle)
|
||||
{
|
||||
@@ -105,7 +109,7 @@ jin: a = *++haystack;
|
||||
}
|
||||
while (*rhaystack == a);
|
||||
|
||||
needle = rneedle; /* took the register-poor aproach */
|
||||
needle = rneedle; /* took the register-poor approach */
|
||||
|
||||
if (a == '\0')
|
||||
break;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
/* states: S_N: normal, S_I: comparing integral part, S_F: comparing
|
||||
Fractional parts, S_Z: idem but with leading Zeroes only */
|
||||
fractional parts, S_Z: idem but with leading Zeroes only */
|
||||
#define S_N 0x0
|
||||
#define S_I 0x4
|
||||
#define S_F 0x8
|
||||
@@ -36,6 +36,7 @@
|
||||
#define CMP 2
|
||||
#define LEN 3
|
||||
|
||||
|
||||
/* ISDIGIT differs from isdigit, as follows:
|
||||
- Its arg may be any int or unsigned int; it need not be an unsigned char.
|
||||
- It's guaranteed to evaluate its argument exactly once.
|
||||
@@ -46,13 +47,20 @@
|
||||
host does not conform to Posix. */
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
|
||||
#undef __strverscmp
|
||||
#undef strverscmp
|
||||
|
||||
#ifndef weak_alias
|
||||
# define __strverscmp strverscmp
|
||||
#endif
|
||||
|
||||
/* Compare S1 and S2 as strings holding indices/version numbers,
|
||||
returning less than, equal to or greater than zero if S1 is less than,
|
||||
equal to or greater than S2 (for more info, see the texinfo doc).
|
||||
*/
|
||||
|
||||
int
|
||||
strverscmp (const char *s1, const char *s2)
|
||||
__strverscmp (const char *s1, const char *s2)
|
||||
{
|
||||
const unsigned char *p1 = (const unsigned char *) s1;
|
||||
const unsigned char *p2 = (const unsigned char *) s2;
|
||||
@@ -120,3 +128,6 @@ strverscmp (const char *s1, const char *s2)
|
||||
return state;
|
||||
}
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__strverscmp, strverscmp)
|
||||
#endif
|
||||
|
||||
19
m4/ChangeLog
19
m4/ChangeLog
@@ -1,3 +1,22 @@
|
||||
2000-12-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* xstrtoumax.m4 (jm_AC_PREREQ_XSTRTOUMAX): If we need the replacement
|
||||
strtoull, we may well need the replacement strtoul, too.
|
||||
Check for declarations of strtoul and strtoull.
|
||||
|
||||
2000-12-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* off_t-format.m4 (OFF_T_PRINTF_FORMAT_STRING): New file/macro.
|
||||
* jm-macros.m4 (jm_MACROS): require it.
|
||||
|
||||
2000-11-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* jm-macros.m4 (jm_MACROS): Check for stdint.h.
|
||||
|
||||
2000-11-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* getloadavg.m4: s/ifval/m4_ifval/ to accommodate new autoconf.
|
||||
|
||||
2000-11-03 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* jm-macros.m4 (jm_MACROS): Add test for wcrtomb.
|
||||
|
||||
@@ -44,6 +44,7 @@ mbstate_t.m4 \
|
||||
mbswidth.m4 \
|
||||
memcmp.m4 \
|
||||
nanosleep.m4 \
|
||||
off_t-format.m4 \
|
||||
perl.m4 \
|
||||
prereq.m4 \
|
||||
progtest.m4 \
|
||||
|
||||
@@ -159,6 +159,7 @@ mbstate_t.m4 \
|
||||
mbswidth.m4 \
|
||||
memcmp.m4 \
|
||||
nanosleep.m4 \
|
||||
off_t-format.m4 \
|
||||
perl.m4 \
|
||||
prereq.m4 \
|
||||
progtest.m4 \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 7
|
||||
#serial 8
|
||||
|
||||
# A replacement for autoconf's macro by the same name. This version
|
||||
# accepts an optional argument specifying the name of the $srcdir-relative
|
||||
@@ -15,7 +15,7 @@ AC_DEFUN([AC_FUNC_GETLOADAVG],
|
||||
# By default, expect to find getloadavg.c in $srcdir/.
|
||||
ac_lib_dir_getloadavg=$srcdir
|
||||
# But if there's an argument, DIR, expect to find getloadavg.c in $srcdir/DIR.
|
||||
ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
|
||||
m4_ifval([$1], [ac_lib_dir_getloadavg=$srcdir/$1])
|
||||
# Make sure getloadavg.c is where it belongs, at ./configure-time.
|
||||
test -f $ac_lib_dir_getloadavg/getloadavg.c \
|
||||
|| AC_MSG_ERROR([getloadavg.c is not in $ac_lib_dir_getloadavg])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 27
|
||||
#serial 28 -*- autoconf -*-
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
@@ -32,6 +32,7 @@ AC_DEFUN(jm_MACROS,
|
||||
paths.h \
|
||||
stdlib.h \
|
||||
stddef.h \
|
||||
stdint.h \
|
||||
string.h \
|
||||
sys/acl.h \
|
||||
sys/filsys.h \
|
||||
@@ -69,6 +70,7 @@ AC_DEFUN(jm_MACROS,
|
||||
|
||||
AC_REQUIRE([jm_PREREQ])
|
||||
|
||||
AC_REQUIRE([jm_SYS_OFF_T_PRINTF_FORMAT])
|
||||
AC_REQUIRE([jm_FUNC_LCHOWN])
|
||||
AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY])
|
||||
AC_REQUIRE([jm_FUNC_CHOWN])
|
||||
|
||||
55
m4/off_t-format.m4
Normal file
55
m4/off_t-format.m4
Normal file
@@ -0,0 +1,55 @@
|
||||
#serial 1 -*- autoconf -*-
|
||||
|
||||
dnl FIXME
|
||||
AC_DEFUN(jm_SYS_OFF_T_PRINTF_FORMAT,
|
||||
[dnl
|
||||
AC_REQUIRE([AC_TYPE_OFF_T])
|
||||
AC_CHECK_HEADERS(string.h stdlinb.h)
|
||||
AC_CACHE_CHECK([for printf format that works with type off_t],
|
||||
jm_cv_sys_off_t_printf_format,
|
||||
[
|
||||
jm_cv_sys_off_t_printf_format=undef
|
||||
for jm_fmt in '' L ll q; do
|
||||
jm_OFF_T_FORMAT="$jm_fmt"
|
||||
export jm_OFF_T_FORMAT
|
||||
AC_TRY_RUN([
|
||||
# include <sys/types.h>
|
||||
# include <stdio.h>
|
||||
# if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
# if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# endif
|
||||
int
|
||||
main()
|
||||
{
|
||||
static off_t x[] = {1, 255, 65535, 99999999};
|
||||
char buf[50], fmt[50];
|
||||
|
||||
/* this should be one of these values: "", "L", "ll", "q" */
|
||||
char *f = getenv ("jm_OFF_T_FORMAT");
|
||||
|
||||
sprintf (fmt, "%%%sd %%%sx %%%sx %%%sd", f, f, f, f);
|
||||
sprintf (buf, fmt, x[0], x[1], x[2], x[3]);
|
||||
exit (strcmp (buf, "1 ff ffff 99999999"));
|
||||
}
|
||||
], jm_cv_sys_off_t_printf_format=$jm_fmt; break
|
||||
, dnl didn't work
|
||||
dnl Cross compiling -- you lose. Specify it via the cache.
|
||||
)
|
||||
done
|
||||
|
||||
# Die if none of the above worked.
|
||||
# FIXME: If this failure become a problem that we can't work around,
|
||||
# an alternative would be to arrange not to build od.
|
||||
if test "$jm_cv_sys_off_t_printf_format" = undef; then
|
||||
AC_MSG_ERROR(dnl
|
||||
[couldn't find a printf format that works with the type, off_t])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFINE_UNQUOTED(OFF_T_PRINTF_FORMAT_STRING,
|
||||
"$jm_cv_sys_off_t_printf_format",
|
||||
[printf format string for type off_t, without the `%'])
|
||||
])
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 2
|
||||
#serial 3
|
||||
|
||||
# autoconf tests required for use of xstrtoumax.c
|
||||
|
||||
@@ -7,7 +7,8 @@ AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
|
||||
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
|
||||
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
|
||||
AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
|
||||
AC_CHECK_HEADERS(stdlib.h)
|
||||
AC_CHECK_DECLS([strtoul, strtoull])
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h)
|
||||
|
||||
AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
|
||||
jm_cv_func_strtoumax_macro,
|
||||
@@ -28,7 +29,13 @@ AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
|
||||
dnl so we need the replacement strtoull only if strtoumax does not exist.
|
||||
case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
|
||||
yes,no,no)
|
||||
AC_REPLACE_FUNCS(strtoull)
|
||||
AC_REPLACE_FUNCS(strtoull strtol)
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
|
||||
no,no)
|
||||
AC_REPLACE_FUNCS(strtoul strtol)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -1,3 +1,227 @@
|
||||
2000-12-03 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0.34.
|
||||
|
||||
* src/ls.c (gobble_file) [USE_ACL]: Set have_acl member unconditionally
|
||||
to avoid uninitialized memory reference via FILE_HAS_ACL.
|
||||
|
||||
* Makefile.maint (alpha): Use rsync rather than scp, so the destination
|
||||
file is created only after the successful completion of the copy.
|
||||
|
||||
2000-12-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/ls/Makefile.am (TESTS): Add follow-slink.
|
||||
* tests/ls/follow-slink: New file.
|
||||
|
||||
2000-12-01 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/ls.c (gobble_file): Do not fall back on lstat if stat
|
||||
fails; POSIX.2 does not allow this. Invoke acl only on
|
||||
non-symlinks, and only if lstat or stat succeeds.
|
||||
|
||||
2000-12-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* configure: Regenerate using the very latest version (in CVS) of
|
||||
autoconf.
|
||||
|
||||
* tests/dd/skip-seek: Remove test #2, now that support for the
|
||||
`B' suffix is gone.
|
||||
* tests/dd/Makefile.am (TESTS): Add skip-seek2
|
||||
* tests/dd/skip-seek2: New file.
|
||||
|
||||
2000-12-01 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/dd.c (skip, dd_copy): Use ssize_t to store result of
|
||||
safe_read, to avoid overflow e.g. on 64-bit Solaris sparc.
|
||||
(dd_copy): Remove unnecessary cast.
|
||||
|
||||
2000-12-01 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* doc/fileutils.texi: Remove B suffix. Document how to have
|
||||
the desired effect without it.
|
||||
|
||||
* src/dd.c: Undo most of the changes since 2000-11-24, since we've
|
||||
documented a standard way to do it.
|
||||
(skip_bytes, seek_bytes): Remove.
|
||||
(usage): Remove B suffix.
|
||||
(scanargs, skip, dd_copy, main): Remove support for B suffix.
|
||||
|
||||
2000-11-28 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/mkdir.c (main): Remove any trailing slash unconditionally.
|
||||
Reported by Volker Borchert.
|
||||
* tests/mkdir/t-slash: Add a test for this.
|
||||
|
||||
2000-11-27 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0.33.
|
||||
|
||||
* tests/touch/no-rights: Use touch with `-d tomorrow' to avoid a
|
||||
race condition.
|
||||
|
||||
* tests/Fetish.pm (_compare_files): New function.
|
||||
(_process_file_spec): Likewise.
|
||||
(_at_replace): Likewise.
|
||||
(run_tests): Support new keywords, AUX and CMP and associated
|
||||
syntax and semantics.
|
||||
|
||||
* config.sub: Likewise.
|
||||
* config.guess: Likewise.
|
||||
|
||||
2000-11-26 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/dd.c (skip): Perform the `records < blocksize' test
|
||||
at the top of the loop, not at the bottom.
|
||||
|
||||
2000-11-26 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/dd.c (skip): New arg COUNT_BYTES. Read with BLOCKSIZE
|
||||
bytes, but consider RECORDS to be a byte count if COUNT_BYTES
|
||||
is nonzero.
|
||||
|
||||
2000-11-25 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* doc/fileutils.texi: Document seek=nB and skip=nB.
|
||||
|
||||
* src/dd.c (skip_bytes, seek_bytes): Now booleans, not counts.
|
||||
(seek_records): Renamed from seek_record, for consistency with
|
||||
skip_records and max_records. All uses changed.
|
||||
|
||||
(usage, scanargs): Remove bseek=n and bskip=n; instead, use seek=nB
|
||||
and skip=nB.
|
||||
(enum Unit, Unit): Remove.
|
||||
(skip, dd_copy, main): Undo most recent change.
|
||||
(dd_copy, main): Pass blocksize of 1 as appropriate when
|
||||
skip_bytes or seek_bytes is nonzero.
|
||||
(main): Rework ftruncate failure diagnostic to always use byte count.
|
||||
|
||||
2000-11-25 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/dd.c: Add new options, bskip and bseek.
|
||||
Based on a patch from Chris Sylvain.
|
||||
* tests/dd/skip-seek: New tests.
|
||||
* tests/dd/Makefile.am (TESTS): Add skip-seek.
|
||||
|
||||
2000-11-24 Paul Eggert <eggert@green.twinsun.com>
|
||||
|
||||
* src/dd.c (S_TYPEISSHM): New macro.
|
||||
(main): Report failed fstat.
|
||||
Complain only when ftruncate fails on a regular file,
|
||||
a directory, or a shared memory object.
|
||||
|
||||
2000-11-24 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/dd.c: Declare a pointer parameters to be `const' as appropriate.
|
||||
|
||||
* src/dd.c (main): Use ftruncate only on regular files.
|
||||
Based on a patch from Michael Stone.
|
||||
Reported by andras@kolumbus.fi at http://bugs.debian.org/77174.
|
||||
|
||||
2000-11-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/df.c (show_point): Before accepting an entry as a match, make
|
||||
sure that the mount directory exists and has the required device number.
|
||||
Before, e.g., `df /floppy' would mistakenly report on the root
|
||||
partition if /floppy were not listed in /etc/mtab but / was.
|
||||
Patch from Eirik Fuller (http://bugs.debian.org/76923).
|
||||
|
||||
* src/chmod.c (mode_changed): New function.
|
||||
(change_file_mode): Use it to determine accurately when -c should
|
||||
make chmod announce there's been a change.
|
||||
Based on a patch from Michael Stone.
|
||||
Reported by Kai Henningsen as Debian bug #77349.
|
||||
|
||||
* tests/chmod/c-option: New test for the above fix.
|
||||
* tests/chmod/Makefile.am (TESTS): Add c-option
|
||||
|
||||
* tests/sticky-check: New file. Factored out of tests/mkdir/parents.
|
||||
* tests/Makefile.am (EXTRA_DIST): Add sticky-check.
|
||||
* tests/mkdir/parents: Source sticky-check instead of open-coding it.
|
||||
|
||||
2000-11-19 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/chmod/equal-x: Update to use its own directory, and better trap.
|
||||
|
||||
2000-11-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/ls.c (BLOCK_SIZE_OPTION, COLOR_OPTION, FORMAT_OPTION,
|
||||
INDICATOR_STYLE_OPTION, QUOTING_STYLE_OPTION,
|
||||
SHOW_CONTROL_CHARS_OPTION, SORT_OPTION, TIME_OPTION): New enum
|
||||
values, to ensure that option values can't collide with chars.
|
||||
(long_options, decode_switches): Use them.
|
||||
|
||||
2000-11-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sys2.h (GETOPT_HELP_CHAR, GETOPT_VERSION_CHAR): Now enum
|
||||
constants rather than macros. Use values that cannot conflict
|
||||
with C characters or with -1, CHAR_MAX + 1, etc.
|
||||
|
||||
2000-11-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/du.c (count_entry): Don't omit the size of a directory entry
|
||||
merely because we couldn't `chdir' into it. That would give subtly
|
||||
different results in some cases. Reported by Mattias Wadenstein
|
||||
via Michael Stone.
|
||||
|
||||
* src/ls.c: Revert change of 2000-11-11. It inadvertently change
|
||||
the output format of `ls -l --full-time'.
|
||||
|
||||
* src/mkdir.c (main): When failing to create a directory, give only
|
||||
one diagnostic, not two. Reported by Volker Borchert.
|
||||
|
||||
* src/mkdir.c (main): With --parents, remove any trailing slashes
|
||||
from the argument to the final mkdir call. Required for NetBSD.
|
||||
Reported by Volker Borchert.
|
||||
* tests/mkdir/t-slash: New test for this.
|
||||
* tests/mkdir/Makefile.am (TESTS): Add t-slash.
|
||||
|
||||
* tests/mv/mv-special-1: Create and `cd' into temporary directory
|
||||
before anything else. Reported by Volker Borchert.
|
||||
|
||||
* configure, config.h.in, Makefile.in, etc.: Regenerate using the
|
||||
very latest version (in CVS) of autoconf.
|
||||
|
||||
2000-11-17 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Makefile.am (.NOTPARALLEL): Remove target.
|
||||
* GNUmakefile (.NOTPARALLEL): ... put it here instead, since this
|
||||
file is common to these packages: fileutils, sh-utils, textutils.
|
||||
|
||||
* Makefile.am (.NOTPARALLEL): New target. Prevent unwanted parallelism.
|
||||
Suggestion from Ulrich Drepper.
|
||||
* po/Makefile.in.in (Makefile): Likewise.
|
||||
|
||||
* Makefile.maint (sha1): Define.
|
||||
(announcement): Include SHA1 digest of .tar.gz file.
|
||||
|
||||
2000-11-14 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/mkdir/perm: Add an `echo' so that the input to the sed command
|
||||
is NL-terminated. Otherwise, Solaris' /bin/sed generates no output.
|
||||
Reported by Vin Shelton.
|
||||
|
||||
2000-11-13 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sys2.h (ST_TIME_CMP_NS): Fix typo: ST_MTIM_NSEC should
|
||||
be tested with #ifdef, not with #if.
|
||||
|
||||
2000-11-12 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/ls.c (print_long_format): Remove obsolete comment.
|
||||
From Paul Eggert.
|
||||
|
||||
* doc/texinfo.tex: Update from master repository.
|
||||
|
||||
2000-11-11 Paul Eggert <eggert@sic.twinsun.com>
|
||||
|
||||
* src/ls.c (<langinfo.h>): Include if HAVE_LANGINFO_H.
|
||||
(DATE_FMT_LANGINFO): New macro, taken from sh-utils/src/date.c.
|
||||
(print_long_format): Use it to determine "date" format.
|
||||
Do not wrap "%b %e %Y" and "%b %e %H:%M" in _(), as it results in
|
||||
incorrect behavior when LC_ALL is unset, LC_TIME is "C", and
|
||||
LC_MESSAGES or LANG is set to something disagreeing with the POSIX
|
||||
locale.
|
||||
|
||||
2000-11-11 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0.32.
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
Changes in release 4.01:
|
||||
[4.0.34]
|
||||
* `ls -L dangling-symlink' now fails (per POSIX) rather than printing the
|
||||
link name
|
||||
* dd no longer honors the just-added `B' suffix on skip= and seek= arguments.
|
||||
* `mkdir no-such-dir/' no longer fails on NetBSD systems
|
||||
[4.0.33]
|
||||
* dd now accepts skip=nB and seek=nB, to advance past some number of bytes, n,
|
||||
that need not be a multiple of the block size.
|
||||
* dd (without conv=notrunc) now uses ftruncate only on regular files
|
||||
* chmod --changes (-c) once again issues diagnostics only for the files
|
||||
with changed permissions
|
||||
* mkdir now gives one diagnostic (rather than two) for certain failures
|
||||
* mkdir portability fix for NetBSD
|
||||
[4.0.32]
|
||||
* touch now interprets a lone numeric argument of 8 or 10 digits as a file name,
|
||||
rather than as a date/time in the obsolescent `MMDDhhmm[YY]' format.
|
||||
* mkdir no longer sets the permissions of the final directory component
|
||||
if it already exists (this bug, too, was introduced recently)
|
||||
* ls's --full-time format string is now local dependent
|
||||
* ls's --full-time format string is now locale dependent
|
||||
[4.0.31]
|
||||
* mkdir: fix a bug introduced in 4.0.30 whereby `mkdir existing-dir' would
|
||||
succeed. Now it fails, as it should (and used to).
|
||||
|
||||
@@ -1,3 +1,41 @@
|
||||
2000-12-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0.12.
|
||||
|
||||
* src/seq.c (valid_format): Move pre-increment to a separate statement
|
||||
to avoid a warning.
|
||||
|
||||
* src/id.c: Move dcls of globals used only in main...
|
||||
(main): ...to here.
|
||||
(usage): Clarify option descriptions.
|
||||
|
||||
2000-11-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* po/Makefile.in.in: Sync with the one from fileutils.
|
||||
|
||||
* configure, config.h.in, Makefile.in, etc.: Regenerate using the
|
||||
very latest version (in CVS) of autoconf.
|
||||
|
||||
2000-11-17 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* GNUmakefile (.NOTPARALLEL): New target. Prevent unwanted parallelism.
|
||||
Suggestion from Ulrich Drepper.
|
||||
|
||||
* src/pinky.c: Explicitly include sys/types.h before including system.h.
|
||||
* src/uptime.c: Likewise.
|
||||
* src/users.c: Likewise.
|
||||
* src/who.c: Likewise.
|
||||
|
||||
2000-11-13 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sys2.h (ST_TIME_CMP_NS): Fix typo: ST_MTIM_NSEC should
|
||||
be tested with #ifdef, not with #if.
|
||||
|
||||
2000-11-12 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/date.c (show_date): Add a comment explaining why the
|
||||
format string must not be translatable via _(). From Paul Eggert.
|
||||
|
||||
2000-10-31 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* doc/sh-utils.texi: Clean up indentation and punctuation.
|
||||
|
||||
@@ -1,3 +1,180 @@
|
||||
2000-12-03 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/tail.c (tail_file): Initialize ignore, dev, and ino members,
|
||||
when tailing forever and the open failed. Otherwise, we could get
|
||||
uninitialized memory references of those fields in recheck.
|
||||
* tests/tail-2/Makefile.am (TESTS): Add assert-2.
|
||||
* tests/tail-2/assert-2: New file.
|
||||
|
||||
* Version 2.0.9.
|
||||
|
||||
Make od print valid addresses for offsets of 2^32 and larger, and
|
||||
allow byte offset (-j) and byte count (-N) to be 2^32 and larger.
|
||||
|
||||
* src/od.c (MAX_ADDRESS_LENGTH): Don't hard-code as a literal.
|
||||
Rather, define in terms of the type, off_t.
|
||||
(string_min): Declare to be of type size_t.
|
||||
(flag_dump_strings): Declare to be of type int.
|
||||
(print_s_char): Declare the n_bytes parameter and the local, `i',
|
||||
to be of type off_t.
|
||||
(print_char): Likewise.
|
||||
(print_s_short): Likewise.
|
||||
(print_short): Likewise.
|
||||
(print_int): Likewise.
|
||||
(print_long): Likewise.
|
||||
(print_long_long): Likewise.
|
||||
(print_float): Likewise.
|
||||
(print_double): Likewise.
|
||||
(print_long_double): Likewise.
|
||||
(dump_hexl_mode_trailer): Likewise.
|
||||
(print_named_ascii): Likewise.
|
||||
(print_ascii): Likewise.
|
||||
(write_block): Likewise.
|
||||
(print_ascii): Declare local, `print_function' with a prototype.
|
||||
Change a few `>' comparisons to the equivalent `<' form.
|
||||
(parse_options): Declare `tmp' to be of type uintmax_t.
|
||||
Use xstrtoumax, not xstrtoul.
|
||||
Fail if the specified offset if larger than OFF_T_MAX.
|
||||
(dump_strings): Declare local `i' to be of type size_t.
|
||||
Remove the now-unnecessary cast-to-off_t.
|
||||
(main) [IF_LINT]: Initialize desired_width to avoid a warning.
|
||||
Declare `tmp' to be of type uintmax_t.
|
||||
Use xstrtoumax, not xstrtoul.
|
||||
Fail if minimum string length is larger than SIZE_MAX.
|
||||
Fail if specified width is larger than ULONG_MAX.
|
||||
|
||||
* src/od.c (format_address): Use off_t, not long unsigned_int as the
|
||||
parameter type.
|
||||
(format_address_none): Likewise. Mark parameter as unused.
|
||||
(format_address_std): Likewise.
|
||||
(format_address_label): Likewise.
|
||||
(print_ascii): Mark format string parameter as unused.
|
||||
(write_block): Use off_t, not long unsigned_int as offset type.
|
||||
(expand_address_fmt): New function.
|
||||
(main): Use it to expand each address format string template.
|
||||
Reported by Mark Nudelman, via Andreas Jaeger.
|
||||
|
||||
* src/sys2.h (OFF_T_MIN): Define here instead.
|
||||
(OFF_T_MAX): Likewise.
|
||||
(CHAR_BIT): Define.
|
||||
|
||||
* src/tail.c (parse_options): Use xstrtoumax to parse the byte and line
|
||||
offset. Give a better diagnostic when the requested offset is still
|
||||
representable but larger than OFF_T_MAX.
|
||||
(OFF_T_MIN): Remove definition.
|
||||
(OFF_T_MAX): Likewise.
|
||||
|
||||
2000-12-02 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sort.c (checkfp): Rename local `buf' to avoid shadowing previous
|
||||
declaration.
|
||||
|
||||
* src/sort.c (NONZERO): Define and use it to make the code a tiny
|
||||
bit more readable.
|
||||
|
||||
* doc/textutils.texi (sort invocation): Clarify how -t works
|
||||
when a sort key specifies a range of fields. From Karl O. Pinc.
|
||||
|
||||
2000-11-26 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/od.c (skip): Use lseek instead of worrying about fseeko or fseek.
|
||||
This should be portable, as we seek before doing any I/O.
|
||||
(fseeko): Remove; no longer used.
|
||||
|
||||
2000-11-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sort.c: s/SIZE_T_MAX/SIZE_MAX/.
|
||||
|
||||
2000-11-30 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sys2.h: Include <stdint.h> if HAVE_STDINT_H.
|
||||
(SIZE_MAX): Renamed from SIZE_T_MAX, as C99 uses SIZE_MAX.
|
||||
All uses changed.
|
||||
|
||||
2000-11-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sort.c: SIZE_MAX is not defined, so s/SIZE_MAX/SIZE_T_MAX/, and...
|
||||
* src/sys2.h (SIZE_T_MAX): ... define.
|
||||
|
||||
2000-11-29 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Port GNU "sort" to hosts where sizes don't fit in "int",
|
||||
e.g. 64-bit Solaris (sparc).
|
||||
|
||||
* src/sort.c ("human.h", "xstrtol.h"): Include.
|
||||
(struct line): length member is now size_t, not int.
|
||||
(struct lines): Likewise for used, alloc, limit members.
|
||||
(struct buffer): Likewise for used, alloc, left, newline_free members.
|
||||
(struct keyfield): Likewise for sword, schar, eword, echar members.
|
||||
(sortalloc, mergealloc, linelength): Now size_t, not int.
|
||||
|
||||
(initbuf, fillbuf, initlines, begfield, limfield, findlines,
|
||||
numcompare, getmonth, keycompare, compare, checkfp, mergefps,
|
||||
sortlines, sort): Accept, return, and use size_t for sizes, not int.
|
||||
|
||||
(fillbuf, initlines, findlines, checkfp, sort): Check for overflow
|
||||
when computing buffer sizes.
|
||||
|
||||
(begfield, limfield): Do not index past end of array.
|
||||
|
||||
(checkfp): Return a boolean, not a line number, as the line
|
||||
number may not fit in int. All callers changed. Use
|
||||
uintmax_t for line numbers, not int.
|
||||
|
||||
(sort): Don't allocate tmp until we need it (and know the right size).
|
||||
|
||||
(parse_field_count): New function.
|
||||
|
||||
(main): Use it to check for overflow in field counts.
|
||||
"outfile" is now a pointer to const.
|
||||
|
||||
2000-11-27 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/checksum.h: Don't include system.h here.
|
||||
* src/md5.c: Include config.h, stdio.h, sys/types.h. and system.h here
|
||||
instead.
|
||||
* src/sha1sum.c: Likewise.
|
||||
|
||||
2000-11-18 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/pr.c (main): Do not assume EOF == -1.
|
||||
Handle the case correctly when digits options immediately precede a
|
||||
non-option.
|
||||
|
||||
2000-11-18 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* doc/textutils.texi: Change GNU to @sc{gnu} in many places.
|
||||
Update to use the Free Documentation Licence.
|
||||
|
||||
* configure, config.h.in, Makefile.in, etc.: Regenerate using the
|
||||
very latest version (in CVS) of autoconf.
|
||||
|
||||
2000-11-17 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* GNUmakefile (.NOTPARALLEL): New target. Prevent unwanted parallelism.
|
||||
Suggestion from Ulrich Drepper.
|
||||
|
||||
2000-11-16 John David Anglin <dave@hiauly1.hia.nrc.ca>
|
||||
|
||||
* tsort.c: Include sys/types.h before system.h.
|
||||
|
||||
2000-11-16 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/join.c: Declare global `tab' to be of type *unsigned* char,
|
||||
so join works with 8-bit delimiter characters.
|
||||
Reported by Antonio Rendas.
|
||||
* tests/join/Test.pm (8-bit-t): New test for the above fix.
|
||||
|
||||
2000-11-13 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sys2.h (ST_TIME_CMP_NS): Fix typo: ST_MTIM_NSEC should
|
||||
be tested with #ifdef, not with #if.
|
||||
|
||||
2000-11-11 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* doc/textutils.texi: More minor rewording and grammar correction.
|
||||
From Brian Youmans.
|
||||
|
||||
2000-11-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/od.c (skip): st_size is not defined for directories.
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
Changes in release 2.1
|
||||
[2.0.9]
|
||||
* od now prints valid addresses for offsets of 2^32 and larger, and allows
|
||||
the byte offset (-j) and byte count (-N) arguments to be 2^32 and larger.
|
||||
* tail now works with line and byte counts of 2^32 and larger, on systems
|
||||
with large file support
|
||||
* join now works with an 8-bit delimiter
|
||||
* fix a compilation failure on some Solaris systems with wc.c
|
||||
[2.0.8]
|
||||
* od now supports 8-byte integers, assuming they're printable with e.g., %lld
|
||||
* new program: sha1sum
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Makefile for program source directory in GNU NLS utilities package.
|
||||
# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
|
||||
# -*- Makefile -*- for program source directory in GNU NLS utilities package.
|
||||
# Copyright (C) 1995, 1996, 1997, 2000 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
|
||||
#
|
||||
# This file file be copied and used freely without restrictions. It can
|
||||
# be used in projects which are not available under the GNU Public License
|
||||
@@ -176,7 +176,6 @@ uninstall:
|
||||
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
|
||||
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
done
|
||||
rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in.in
|
||||
|
||||
check: all
|
||||
|
||||
@@ -202,8 +201,7 @@ distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
dist distdir: update-po $(DISTFILES)
|
||||
dists="$(DISTFILES)"; \
|
||||
for file in $$dists; do \
|
||||
ln $(srcdir)/$$file $(distdir) 2> /dev/null \
|
||||
|| cp -p $(srcdir)/$$file $(distdir); \
|
||||
cp -p $(srcdir)/$$file $(distdir); \
|
||||
done
|
||||
|
||||
update-po: Makefile
|
||||
@@ -246,3 +244,7 @@ Makefile: Makefile.in.in ../config.status POTFILES
|
||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
||||
# Tell version 3.79 and up of GNU make to not build goals in this
|
||||
# directory in parallel.
|
||||
.NOTPARALLEL:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include "system.h"
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
|
||||
29
src/chmod.c
29
src/chmod.c
@@ -95,6 +95,31 @@ static struct option const long_options[] =
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static int
|
||||
mode_changed (const char *file, mode_t old_mode)
|
||||
{
|
||||
struct stat new_stats;
|
||||
|
||||
if (lstat (file, &new_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, _("getting new attributes of %s"), quote (file));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (S_ISLNK (new_stats.st_mode)
|
||||
&& stat (file, &new_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, _("getting new attributes of %s"), quote (file));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return old_mode != new_stats.st_mode;
|
||||
}
|
||||
|
||||
/* Tell the user how/if the MODE of FILE has been changed.
|
||||
CHANGED describes what (if anything) has happened. */
|
||||
|
||||
@@ -166,7 +191,9 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
fail = chmod (file, newmode);
|
||||
saved_errno = errno;
|
||||
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
if (verbosity == V_high
|
||||
|| (verbosity == V_changes_only
|
||||
&& !fail && mode_changed (file, file_stats.st_mode)))
|
||||
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
|
||||
|
||||
if (fail)
|
||||
|
||||
@@ -461,6 +461,13 @@ show_date (const char *format, time_t when)
|
||||
else
|
||||
{
|
||||
char *date_fmt = DATE_FMT_LANGINFO ();
|
||||
/* Do not wrap the following literal format string with _(...).
|
||||
For example, suppose LC_ALL is unset, LC_TIME="POSIX",
|
||||
and LANG="ko_KR". In that case, POSIX.2 says that LC_TIME
|
||||
determines the format and contents of date and time strings
|
||||
written by date, which means "date" must generate output
|
||||
using the POSIX locale; but adding _() would cause "date"
|
||||
to use a Korean translation of the format. */
|
||||
format = *date_fmt ? date_fmt : "%a %b %e %H:%M:%S %Z %Y";
|
||||
}
|
||||
}
|
||||
|
||||
77
src/dd.c
77
src/dd.c
@@ -48,6 +48,10 @@
|
||||
# define SIGINFO SIGUSR1
|
||||
#endif
|
||||
|
||||
#ifndef S_TYPEISSHM
|
||||
# define S_TYPEISSHM(Mode) 0
|
||||
#endif
|
||||
|
||||
#define ROUND_UP_OFFSET(X, M) ((M) - 1 - (((X) + (M) - 1) % (M)))
|
||||
#define PTR_ALIGN(Ptr, M) ((Ptr) \
|
||||
+ ROUND_UP_OFFSET ((char *)(Ptr) - (char *)0, (M)))
|
||||
@@ -100,7 +104,7 @@ static size_t conversion_blocksize = 0;
|
||||
static uintmax_t skip_records = 0;
|
||||
|
||||
/* Skip this many records of `output_blocksize' bytes before output. */
|
||||
static uintmax_t seek_record = 0;
|
||||
static uintmax_t seek_records = 0;
|
||||
|
||||
/* Copy only this many records. The default is effectively infinity. */
|
||||
static uintmax_t max_records = (uintmax_t) -1;
|
||||
@@ -298,7 +302,7 @@ Copy a file, converting and formatting according to the options.\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
BYTES may be followed by the following multiplicative suffixes:\n\
|
||||
BLOCKS and BYTES may be followed by the following multiplicative suffixes:\n\
|
||||
xM M, c 1, w 2, b 512, kD 1000, k 1024, MD 1,000,000, M 1,048,576,\n\
|
||||
GD 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.\n\
|
||||
Each KEYWORD may be:\n\
|
||||
@@ -583,7 +587,7 @@ scanargs (int argc, char **argv)
|
||||
else if (STREQ (name, "skip"))
|
||||
skip_records = n;
|
||||
else if (STREQ (name, "seek"))
|
||||
seek_record = n;
|
||||
seek_records = n;
|
||||
else if (STREQ (name, "count"))
|
||||
max_records = n;
|
||||
else
|
||||
@@ -758,22 +762,20 @@ static void
|
||||
skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
|
||||
unsigned char *buf)
|
||||
{
|
||||
off_t o;
|
||||
off_t offset = records * blocksize;
|
||||
|
||||
/* Try lseek and if an error indicates it was an inappropriate
|
||||
operation, fall back on using read. Some broken versions of
|
||||
lseek may return zero, so count that as an error too as a valid
|
||||
zero return is not possible here. */
|
||||
o = records * blocksize;
|
||||
if (o / blocksize != records
|
||||
|| buggy_lseek_support (fdesc)
|
||||
|| lseek (fdesc, o, SEEK_CUR) <= 0)
|
||||
{
|
||||
while (records-- > 0)
|
||||
{
|
||||
int nread;
|
||||
|
||||
nread = safe_read (fdesc, buf, blocksize);
|
||||
if (offset / blocksize != records
|
||||
|| buggy_lseek_support (fdesc)
|
||||
|| lseek (fdesc, offset, SEEK_CUR) <= 0)
|
||||
{
|
||||
while (records--)
|
||||
{
|
||||
ssize_t nread = safe_read (fdesc, buf, blocksize);
|
||||
if (nread < 0)
|
||||
{
|
||||
error (0, errno, _("reading %s"), quote (file));
|
||||
@@ -791,10 +793,10 @@ skip (int fdesc, char *file, uintmax_t records, size_t blocksize,
|
||||
/* Copy NREAD bytes of BUF, with no conversions. */
|
||||
|
||||
static void
|
||||
copy_simple (unsigned char *buf, int nread)
|
||||
copy_simple (unsigned char const *buf, int nread)
|
||||
{
|
||||
int nfree; /* Number of unused bytes in `obuf'. */
|
||||
unsigned char *start = buf; /* First uncopied char in BUF. */
|
||||
const unsigned char *start = buf; /* First uncopied char in BUF. */
|
||||
|
||||
do
|
||||
{
|
||||
@@ -818,7 +820,7 @@ copy_simple (unsigned char *buf, int nread)
|
||||
replacing the newline with trailing spaces). */
|
||||
|
||||
static void
|
||||
copy_with_block (unsigned char *buf, size_t nread)
|
||||
copy_with_block (unsigned char const *buf, size_t nread)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -850,7 +852,7 @@ copy_with_block (unsigned char *buf, size_t nread)
|
||||
with a newline). */
|
||||
|
||||
static void
|
||||
copy_with_unblock (unsigned char *buf, size_t nread)
|
||||
copy_with_unblock (unsigned char const *buf, size_t nread)
|
||||
{
|
||||
size_t i;
|
||||
unsigned char c;
|
||||
@@ -890,7 +892,7 @@ dd_copy (void)
|
||||
unsigned char *ibuf, *bufstart; /* Input buffer. */
|
||||
unsigned char *real_buf; /* real buffer address before alignment */
|
||||
unsigned char *real_obuf;
|
||||
int nread; /* Bytes read in the current block. */
|
||||
ssize_t nread; /* Bytes read in the current block. */
|
||||
int exit_status = 0;
|
||||
size_t page_size = getpagesize ();
|
||||
size_t n_bytes_read;
|
||||
@@ -935,7 +937,7 @@ dd_copy (void)
|
||||
if (skip_records != 0)
|
||||
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
|
||||
|
||||
if (seek_record != 0)
|
||||
if (seek_records != 0)
|
||||
{
|
||||
/* FIXME: this loses for
|
||||
% ./dd if=dd seek=1 |:
|
||||
@@ -944,8 +946,7 @@ dd_copy (void)
|
||||
0+0 records out
|
||||
*/
|
||||
|
||||
skip (STDOUT_FILENO, output_file, seek_record, output_blocksize,
|
||||
obuf);
|
||||
skip (STDOUT_FILENO, output_file, seek_records, output_blocksize, obuf);
|
||||
}
|
||||
|
||||
if (max_records == 0)
|
||||
@@ -990,7 +991,7 @@ dd_copy (void)
|
||||
}
|
||||
}
|
||||
|
||||
n_bytes_read = (size_t) nread;
|
||||
n_bytes_read = nread;
|
||||
|
||||
if (n_bytes_read < input_blocksize)
|
||||
{
|
||||
@@ -1138,27 +1139,41 @@ main (int argc, char **argv)
|
||||
mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||
int opts
|
||||
= (O_CREAT
|
||||
| (seek_record || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
|
||||
| (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
|
||||
|
||||
/* Open the output file with *read* access only if we might
|
||||
need to read to satisfy a `seek=' request. If we can't read
|
||||
the file, go ahead with write-only access; it might work. */
|
||||
if ((! seek_record
|
||||
if ((! seek_records
|
||||
|| open_fd (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0)
|
||||
&& open_fd (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0)
|
||||
error (1, errno, _("opening %s"), quote (output_file));
|
||||
|
||||
#if HAVE_FTRUNCATE
|
||||
if (seek_record != 0 && !(conversions_mask & C_NOTRUNC))
|
||||
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
|
||||
{
|
||||
off_t o = seek_record * output_blocksize;
|
||||
if (o / output_blocksize != seek_record)
|
||||
struct stat stdout_stat;
|
||||
off_t o = seek_records * output_blocksize;
|
||||
if (o / output_blocksize != seek_records)
|
||||
error (1, 0, _("file offset out of range"));
|
||||
if (ftruncate (STDOUT_FILENO, o) < 0)
|
||||
|
||||
if (fstat (STDOUT_FILENO, &stdout_stat) != 0)
|
||||
error (1, errno, _("cannot fstat %s"), quote (output_file));
|
||||
|
||||
/* Complain only when ftruncate fails on a regular file, a
|
||||
directory, or a shared memory object, as the 2000-08
|
||||
POSIX draft specifies ftruncate's behavior only for these
|
||||
file types. For example, do not complain when Linux 2.4
|
||||
ftruncate fails on /dev/fd0. */
|
||||
if (ftruncate (STDOUT_FILENO, o) != 0
|
||||
&& (S_ISREG (stdout_stat.st_mode)
|
||||
|| S_ISDIR (stdout_stat.st_mode)
|
||||
|| S_TYPEISSHM (stdout_stat.st_mode)))
|
||||
{
|
||||
char buf[LONGEST_HUMAN_READABLE + 1];
|
||||
error (1, errno, _("advancing past %s blocks in output file %s"),
|
||||
human_readable (seek_record, buf, 1, 1),
|
||||
quote (output_file));
|
||||
error (1, errno, _("advancing past %s bytes in output file %s"),
|
||||
human_readable (o, buf, 1, 1),
|
||||
quote (output_file));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
4
src/df.c
4
src/df.c
@@ -612,7 +612,9 @@ show_point (const char *point, const struct stat *statp)
|
||||
}
|
||||
}
|
||||
|
||||
if (best_match && !STREQ (best_match->me_type, "lofs"))
|
||||
if (best_match && !STREQ (best_match->me_type, "lofs")
|
||||
&& stat (best_match->me_mountdir, &disk_stats) == 0
|
||||
&& disk_stats.st_dev == statp->st_dev)
|
||||
{
|
||||
me = best_match;
|
||||
goto show_me;
|
||||
|
||||
9
src/du.c
9
src/du.c
@@ -520,6 +520,8 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
|
||||
|
||||
dir_dev = stat_buf.st_dev;
|
||||
|
||||
/* Return `0' here, not SIZE, since the SIZE bytes
|
||||
would reside in the new filesystem. */
|
||||
if (opt_one_file_system && !top && last_dev != dir_dev)
|
||||
return 0; /* Don't enter a new file system. */
|
||||
|
||||
@@ -553,7 +555,9 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
|
||||
if (cwd)
|
||||
free_cwd (cwd);
|
||||
exit_status = 1;
|
||||
return 0;
|
||||
/* Do return SIZE, here, since even though we can't chdir into ENT,
|
||||
we *can* count the blocks used by its directory entry. */
|
||||
return opt_separate_dirs ? 0 : size;
|
||||
}
|
||||
|
||||
name_space = savedir (".", stat_buf.st_size);
|
||||
@@ -562,7 +566,8 @@ count_entry (const char *ent, int top, dev_t last_dev, int depth)
|
||||
error (0, errno, "%s", quote (path->text));
|
||||
pop_dir (cwd, path->text);
|
||||
exit_status = 1;
|
||||
return 0;
|
||||
/* Do count the SIZE bytes. */
|
||||
return opt_separate_dirs ? 0 : size;
|
||||
}
|
||||
|
||||
/* Remember the current path. */
|
||||
|
||||
29
src/id.c
29
src/id.c
@@ -54,21 +54,9 @@ static void print_full_info PARAMS ((const char *username));
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
/* If nonzero, output only the group ID(s). -g */
|
||||
static int just_group = 0;
|
||||
|
||||
/* If nonzero, output user/group name instead of ID number. -n */
|
||||
static int use_name = 0;
|
||||
|
||||
/* If nonzero, output real UID/GID instead of default effective UID/GID. -r */
|
||||
static int use_real = 0;
|
||||
|
||||
/* If nonzero, output only the user ID(s). -u */
|
||||
static int just_user = 0;
|
||||
|
||||
/* If nonzero, output only the supplementary groups. -G */
|
||||
static int just_group_list = 0;
|
||||
|
||||
/* The real and effective IDs of the user to print. */
|
||||
static uid_t ruid, euid;
|
||||
static gid_t rgid, egid;
|
||||
@@ -101,11 +89,11 @@ usage (int status)
|
||||
Print information for USERNAME, or the current user.\n\
|
||||
\n\
|
||||
-a ignore, for compatibility with other versions\n\
|
||||
-g, --group print only the group ID\n\
|
||||
-G, --groups print only the supplementary groups\n\
|
||||
-g, --group print only the effective group ID\n\
|
||||
-G, --groups print all group IDs\n\
|
||||
-n, --name print a name instead of a number, for -ugG\n\
|
||||
-r, --real print the real ID instead of effective ID, for -ugG\n\
|
||||
-u, --user print only the user ID\n\
|
||||
-r, --real print the real ID instead of the effective ID, with -ugG\n\
|
||||
-u, --user print only the effective user ID\n\
|
||||
--help display this help and exit\n\
|
||||
--version output version information and exit\n\
|
||||
\n\
|
||||
@@ -121,6 +109,15 @@ main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
|
||||
/* If nonzero, output the list of all group IDs. -G */
|
||||
int just_group_list = 0;
|
||||
/* If nonzero, output only the group ID(s). -g */
|
||||
int just_group = 0;
|
||||
/* If nonzero, output real UID/GID instead of default effective UID/GID. -r */
|
||||
int use_real = 0;
|
||||
/* If nonzero, output only the user ID(s). -u */
|
||||
int just_user = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
|
||||
@@ -114,7 +114,7 @@ static struct outlist *outlist_end = &outlist_head;
|
||||
/* Tab character separating fields; if this is NUL fields are separated
|
||||
by any nonempty string of white space, otherwise by exactly one
|
||||
tab character. */
|
||||
static char tab;
|
||||
static unsigned char tab;
|
||||
|
||||
/* When using getopt_long_only, no long option can start with
|
||||
a character that is a short option. */
|
||||
|
||||
75
src/ls.c
75
src/ls.c
@@ -652,6 +652,20 @@ static int format_needs_type;
|
||||
|
||||
static int exit_status;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
BLOCK_SIZE_OPTION = CHAR_MAX + 1,
|
||||
COLOR_OPTION,
|
||||
FORMAT_OPTION,
|
||||
INDICATOR_STYLE_OPTION,
|
||||
QUOTING_STYLE_OPTION,
|
||||
SHOW_CONTROL_CHARS_OPTION,
|
||||
SORT_OPTION,
|
||||
TIME_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, 0, 'a'},
|
||||
@@ -674,19 +688,19 @@ static struct option const long_options[] =
|
||||
{"file-type", no_argument, 0, 'p'},
|
||||
{"si", no_argument, 0, 'H'},
|
||||
{"ignore", required_argument, 0, 'I'},
|
||||
{"indicator-style", required_argument, 0, 14},
|
||||
{"indicator-style", required_argument, 0, INDICATOR_STYLE_OPTION},
|
||||
{"dereference", no_argument, 0, 'L'},
|
||||
{"literal", no_argument, 0, 'N'},
|
||||
{"quote-name", no_argument, 0, 'Q'},
|
||||
{"quoting-style", required_argument, 0, 15},
|
||||
{"quoting-style", required_argument, 0, QUOTING_STYLE_OPTION},
|
||||
{"recursive", no_argument, 0, 'R'},
|
||||
{"format", required_argument, 0, 12},
|
||||
{"show-control-chars", no_argument, 0, 16},
|
||||
{"sort", required_argument, 0, 10},
|
||||
{"format", required_argument, 0, FORMAT_OPTION},
|
||||
{"show-control-chars", no_argument, 0, SHOW_CONTROL_CHARS_OPTION},
|
||||
{"sort", required_argument, 0, SORT_OPTION},
|
||||
{"tabsize", required_argument, 0, 'T'},
|
||||
{"time", required_argument, 0, 11},
|
||||
{"color", optional_argument, 0, 13},
|
||||
{"block-size", required_argument, 0, 17},
|
||||
{"time", required_argument, 0, TIME_OPTION},
|
||||
{"color", optional_argument, 0, COLOR_OPTION},
|
||||
{"block-size", required_argument, 0, BLOCK_SIZE_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -1250,20 +1264,20 @@ decode_switches (int argc, char **argv)
|
||||
format = one_per_line;
|
||||
break;
|
||||
|
||||
case 10: /* --sort */
|
||||
case SORT_OPTION:
|
||||
sort_type = XARGMATCH ("--sort", optarg, sort_args, sort_types);
|
||||
sort_type_specified = 1;
|
||||
break;
|
||||
|
||||
case 11: /* --time */
|
||||
case TIME_OPTION:
|
||||
time_type = XARGMATCH ("--time", optarg, time_args, time_types);
|
||||
break;
|
||||
|
||||
case 12: /* --format */
|
||||
case FORMAT_OPTION:
|
||||
format = XARGMATCH ("--format", optarg, format_args, format_types);
|
||||
break;
|
||||
|
||||
case 13: /* --color */
|
||||
case COLOR_OPTION:
|
||||
if (optarg)
|
||||
i = XARGMATCH ("--color", optarg, color_args, color_types);
|
||||
else
|
||||
@@ -1284,24 +1298,24 @@ decode_switches (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case 14: /* --indicator-style */
|
||||
case INDICATOR_STYLE_OPTION:
|
||||
indicator_style = XARGMATCH ("--indicator-style", optarg,
|
||||
indicator_style_args,
|
||||
indicator_style_types);
|
||||
break;
|
||||
|
||||
case 15: /* --quoting-style */
|
||||
case QUOTING_STYLE_OPTION:
|
||||
set_quoting_style (NULL,
|
||||
XARGMATCH ("--quoting-style", optarg,
|
||||
quoting_style_args,
|
||||
quoting_style_vals));
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case SHOW_CONTROL_CHARS_OPTION:
|
||||
qmark_funny_chars = 0;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
case BLOCK_SIZE_OPTION:
|
||||
human_block_size (optarg, 1, &output_block_size);
|
||||
break;
|
||||
|
||||
@@ -1873,23 +1887,9 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
|
||||
attach (path, dirname, name);
|
||||
}
|
||||
|
||||
if (trace_links)
|
||||
{
|
||||
val = stat (path, &files[files_index].stat);
|
||||
if (val < 0)
|
||||
{
|
||||
/* Perhaps a symbolically-linked to file doesn't exist; stat
|
||||
the link instead. */
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
#if USE_ACL
|
||||
files[files_index].have_acl = (acl (path, GETACLCNT, 0, NULL) > 4);
|
||||
#endif
|
||||
}
|
||||
val = (trace_links
|
||||
? stat (path, &files[files_index].stat)
|
||||
: lstat (path, &files[files_index].stat));
|
||||
|
||||
if (val < 0)
|
||||
{
|
||||
@@ -1898,6 +1898,12 @@ gobble_file (const char *name, enum filetype type, int explicit_arg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if USE_ACL
|
||||
files[files_index].have_acl =
|
||||
(! S_ISLNK (files[files_index].stat.st_mode)
|
||||
&& 4 < acl (path, GETACLCNT, 0, NULL));
|
||||
#endif
|
||||
|
||||
if (S_ISLNK (files[files_index].stat.st_mode)
|
||||
&& (explicit_arg || format == long_format || check_symlink_color))
|
||||
{
|
||||
@@ -2446,9 +2452,6 @@ print_long_format (const struct fileinfo *f)
|
||||
|
||||
p += strlen (p);
|
||||
|
||||
/* Use strftime rather than ctime, because the former can produce
|
||||
locale-dependent names for the weekday (%a) and month (%b). */
|
||||
|
||||
if ((when_local = localtime (&when)))
|
||||
{
|
||||
while (! (s = strftime (p, buf + bufsize - p - 1, fmt, when_local)))
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "checksum.h"
|
||||
|
||||
int algorithm = ALG_MD5;
|
||||
|
||||
21
src/mkdir.c
21
src/mkdir.c
@@ -34,6 +34,8 @@
|
||||
|
||||
#define AUTHORS "David MacKenzie"
|
||||
|
||||
void strip_trailing_slashes ();
|
||||
|
||||
/* The name this program was run with. */
|
||||
char *program_name;
|
||||
|
||||
@@ -141,6 +143,13 @@ main (int argc, char **argv)
|
||||
for (; optind < argc; ++optind)
|
||||
{
|
||||
int fail = 0;
|
||||
|
||||
/* Remove any trailing slashes. Not removing them would lead to calling
|
||||
`mkdir ("dir/", mode)' for e.g., the commands `mkdir dir/' and
|
||||
`mkdir -p dir/', and such a call fails on NetBSD systems when `dir'
|
||||
doesn't already exist. */
|
||||
strip_trailing_slashes (argv[optind]);
|
||||
|
||||
if (create_parents)
|
||||
{
|
||||
char *parents = dir_name (argv[optind]);
|
||||
@@ -156,11 +165,15 @@ main (int argc, char **argv)
|
||||
int t_errno;
|
||||
fail = make_dir (dir, dir, newmode, &dir_created);
|
||||
t_errno = errno;
|
||||
/* If make_dir `succeeds' because the directory already exists,
|
||||
then fail unless --parents (-p) was specified. */
|
||||
if (fail ||
|
||||
(!create_parents && !dir_created && (t_errno = EEXIST)))
|
||||
if (fail)
|
||||
{
|
||||
/* make_dir already gave a diagnostic. */
|
||||
}
|
||||
else if (!create_parents && !dir_created && (t_errno = EEXIST))
|
||||
{
|
||||
/* make_dir `succeeds' when DIR already exists.
|
||||
In that case, mkdir must fail, unless --parents (-p)
|
||||
was specified. */
|
||||
error (0, t_errno, _("cannot create directory %s"),
|
||||
quote (dir));
|
||||
fail = 1;
|
||||
|
||||
190
src/od.c
190
src/od.c
@@ -65,11 +65,6 @@ typedef double LONG_DOUBLE;
|
||||
# define LDBL_DIG DBL_DIG
|
||||
#endif
|
||||
|
||||
#if !HAVE_FSEEKO
|
||||
# undef fseeko
|
||||
# define fseeko(Stream, Offset, Whence) (-1)
|
||||
#endif
|
||||
|
||||
enum size_spec
|
||||
{
|
||||
NO_SIZE,
|
||||
@@ -158,16 +153,17 @@ static const char *const charname[33] =
|
||||
/* A printf control string for printing a file offset. */
|
||||
static const char *output_address_fmt_string;
|
||||
|
||||
/* FIXME: make this the number of octal digits in an unsigned long. */
|
||||
#define MAX_ADDRESS_LENGTH 13
|
||||
/* The number of octal digits required to represent the largest off_t value. */
|
||||
#define MAX_ADDRESS_LENGTH \
|
||||
((sizeof (off_t) * CHAR_BIT + CHAR_BIT - 1) / 3)
|
||||
|
||||
/* Space for a normal address, a space, a pseudo address, parentheses
|
||||
around the pseudo address, and a trailing zero byte. */
|
||||
static char address_fmt_buffer[2 * MAX_ADDRESS_LENGTH + 4];
|
||||
static char address_pad[MAX_ADDRESS_LENGTH + 1];
|
||||
|
||||
static unsigned long int string_min;
|
||||
static unsigned long int flag_dump_strings;
|
||||
static size_t string_min;
|
||||
static int flag_dump_strings;
|
||||
|
||||
/* Non-zero if we should recognize the pre-POSIX non-option arguments
|
||||
that specified at most one file and optional arguments specifying
|
||||
@@ -183,7 +179,7 @@ static long int pseudo_offset;
|
||||
|
||||
/* Function to format an address and optionally an additional parenthesized
|
||||
pseudo-address; it returns the formatted string. */
|
||||
static const char *(*format_address) PARAMS ((long unsigned int));
|
||||
static const char *(*format_address) PARAMS ((off_t));
|
||||
|
||||
/* The number of input bytes to skip before formatting and writing. */
|
||||
static off_t n_bytes_to_skip = 0;
|
||||
@@ -364,10 +360,9 @@ lcm (unsigned int u, unsigned int v)
|
||||
}
|
||||
|
||||
static void
|
||||
print_s_char (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_s_char (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes; i > 0; i--)
|
||||
{
|
||||
int tmp = (unsigned) *(const unsigned char *) block;
|
||||
@@ -380,10 +375,9 @@ print_s_char (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_char (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_char (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes; i > 0; i--)
|
||||
{
|
||||
unsigned int tmp = *(const unsigned char *) block;
|
||||
@@ -393,10 +387,9 @@ print_char (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_s_short (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_s_short (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (unsigned short); i > 0; i--)
|
||||
{
|
||||
int tmp = (unsigned) *(const unsigned short *) block;
|
||||
@@ -409,10 +402,9 @@ print_s_short (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_short (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_short (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (unsigned short); i > 0; i--)
|
||||
{
|
||||
unsigned int tmp = *(const unsigned short *) block;
|
||||
@@ -422,10 +414,9 @@ print_short (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_int (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_int (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (unsigned int); i > 0; i--)
|
||||
{
|
||||
unsigned int tmp = *(const unsigned int *) block;
|
||||
@@ -435,10 +426,9 @@ print_int (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_long (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_long (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (unsigned long); i > 0; i--)
|
||||
{
|
||||
unsigned long tmp = *(const unsigned long *) block;
|
||||
@@ -449,10 +439,9 @@ print_long (long unsigned int n_bytes, const char *block,
|
||||
|
||||
#ifdef HAVE_UNSIGNED_LONG_LONG
|
||||
static void
|
||||
print_long_long (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_long_long (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (unsigned long long); i > 0; i--)
|
||||
{
|
||||
unsigned long long tmp = *(const unsigned long long *) block;
|
||||
@@ -463,10 +452,9 @@ print_long_long (long unsigned int n_bytes, const char *block,
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_float (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_float (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (float); i > 0; i--)
|
||||
{
|
||||
float tmp = *(const float *) block;
|
||||
@@ -476,10 +464,9 @@ print_float (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_double (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_double (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (double); i > 0; i--)
|
||||
{
|
||||
double tmp = *(const double *) block;
|
||||
@@ -490,10 +477,9 @@ print_double (long unsigned int n_bytes, const char *block,
|
||||
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
static void
|
||||
print_long_double (long unsigned int n_bytes, const char *block,
|
||||
const char *fmt_string)
|
||||
print_long_double (off_t n_bytes, const char *block, const char *fmt_string)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes / sizeof (LONG_DOUBLE); i > 0; i--)
|
||||
{
|
||||
LONG_DOUBLE tmp = *(const LONG_DOUBLE *) block;
|
||||
@@ -505,9 +491,9 @@ print_long_double (long unsigned int n_bytes, const char *block,
|
||||
#endif
|
||||
|
||||
static void
|
||||
dump_hexl_mode_trailer (long unsigned int n_bytes, const char *block)
|
||||
dump_hexl_mode_trailer (off_t n_bytes, const char *block)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
fputs (" >", stdout);
|
||||
for (i = n_bytes; i > 0; i--)
|
||||
{
|
||||
@@ -520,10 +506,10 @@ dump_hexl_mode_trailer (long unsigned int n_bytes, const char *block)
|
||||
}
|
||||
|
||||
static void
|
||||
print_named_ascii (long unsigned int n_bytes, const char *block,
|
||||
const char *unused_fmt_string)
|
||||
print_named_ascii (off_t n_bytes, const char *block,
|
||||
const char *unused_fmt_string ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes; i > 0; i--)
|
||||
{
|
||||
unsigned int c = *(const unsigned char *) block;
|
||||
@@ -547,10 +533,10 @@ print_named_ascii (long unsigned int n_bytes, const char *block,
|
||||
}
|
||||
|
||||
static void
|
||||
print_ascii (long unsigned int n_bytes, const char *block,
|
||||
const char *unused_fmt_string)
|
||||
print_ascii (off_t n_bytes, const char *block,
|
||||
const char *unused_fmt_string ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int i;
|
||||
off_t i;
|
||||
for (i = n_bytes; i > 0; i--)
|
||||
{
|
||||
unsigned int c = *(const unsigned char *) block;
|
||||
@@ -652,7 +638,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
|
||||
enum output_format fmt;
|
||||
const char *pre_fmt_string;
|
||||
char *fmt_string;
|
||||
void (*print_function) ();
|
||||
void (*print_function) PARAMS ((off_t, const char *, const char *));
|
||||
const char *p;
|
||||
unsigned int c;
|
||||
unsigned int field_width = 0;
|
||||
@@ -702,7 +688,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
|
||||
size = sizeof (int);
|
||||
else
|
||||
{
|
||||
if (size > MAX_INTEGRAL_TYPE_SIZE
|
||||
if (MAX_INTEGRAL_TYPE_SIZE < size
|
||||
|| integral_type_size[size] == NO_SIZE)
|
||||
{
|
||||
error (0, 0, _("invalid type string `%s';\n\
|
||||
@@ -986,15 +972,15 @@ skip (off_t n_skip)
|
||||
if (n_skip == 0)
|
||||
break;
|
||||
|
||||
/* First try using fseek. For large offsets, this extra work is
|
||||
/* First try seeking. For large offsets, this extra work is
|
||||
worthwhile. If the offset is below some threshold it may be
|
||||
more efficient to move the pointer by reading. There are two
|
||||
issues when trying to use fseek:
|
||||
issues when trying to seek:
|
||||
- the file must be seekable.
|
||||
- before seeking to the specified position, make sure
|
||||
that the new position is in the current file.
|
||||
Try to do that by getting file's size using fstat().
|
||||
But that will work only for regular files and dirs. */
|
||||
Try to do that by getting file's size using fstat.
|
||||
But that will work only for regular files. */
|
||||
|
||||
if (fstat (fileno (in_stream), &file_stats))
|
||||
{
|
||||
@@ -1010,7 +996,7 @@ skip (off_t n_skip)
|
||||
n_skip and go on to the next file. */
|
||||
if (S_ISREG (file_stats.st_mode))
|
||||
{
|
||||
if (n_skip >= file_stats.st_size)
|
||||
if (file_stats.st_size <= n_skip)
|
||||
{
|
||||
n_skip -= file_stats.st_size;
|
||||
if (in_stream != stdin && fclose (in_stream) == EOF)
|
||||
@@ -1022,10 +1008,7 @@ skip (off_t n_skip)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Try fseeko if available, fseek otherwise. */
|
||||
if (fseeko (in_stream, n_skip, SEEK_SET) == 0
|
||||
|| (n_skip <= LONG_MAX
|
||||
&& fseek (in_stream, (long) n_skip, SEEK_SET) == 0))
|
||||
if (0 <= lseek (fileno (in_stream), n_skip, SEEK_CUR))
|
||||
{
|
||||
n_skip = 0;
|
||||
break;
|
||||
@@ -1036,10 +1019,10 @@ skip (off_t n_skip)
|
||||
/* Seek didn't work or wasn't attempted; position the file pointer
|
||||
by reading. */
|
||||
|
||||
for (j = n_skip / BUFSIZ; j >= 0; j--)
|
||||
for (j = n_skip / BUFSIZ; 0 <= j; j--)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
size_t n_bytes_to_read = (j > 0
|
||||
size_t n_bytes_to_read = (0 < j
|
||||
? BUFSIZ
|
||||
: n_skip % BUFSIZ);
|
||||
size_t n_bytes_read;
|
||||
@@ -1060,13 +1043,13 @@ skip (off_t n_skip)
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_address_none (long unsigned int address)
|
||||
format_address_none (off_t address ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_address_std (long unsigned int address)
|
||||
format_address_std (off_t address)
|
||||
{
|
||||
const char *address_string;
|
||||
|
||||
@@ -1076,7 +1059,7 @@ format_address_std (long unsigned int address)
|
||||
}
|
||||
|
||||
static const char *
|
||||
format_address_label (long unsigned int address)
|
||||
format_address_label (off_t address)
|
||||
{
|
||||
const char *address_string;
|
||||
assert (output_address_fmt_string != NULL);
|
||||
@@ -1099,7 +1082,7 @@ format_address_label (long unsigned int address)
|
||||
only when it has not been padded to length BYTES_PER_BLOCK. */
|
||||
|
||||
static void
|
||||
write_block (long unsigned int current_offset, long unsigned int n_bytes,
|
||||
write_block (off_t current_offset, off_t n_bytes,
|
||||
const char *prev_block, const char *curr_block)
|
||||
{
|
||||
static int first = 1;
|
||||
@@ -1264,7 +1247,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
|
||||
{
|
||||
int err;
|
||||
|
||||
assert (n > 0 && n <= bytes_per_block);
|
||||
assert (0 < n && n <= bytes_per_block);
|
||||
|
||||
*n_bytes_in_buffer = 0;
|
||||
|
||||
@@ -1341,7 +1324,7 @@ parse_old_offset (const char *s)
|
||||
int radix;
|
||||
off_t offset;
|
||||
enum strtol_error s_err;
|
||||
long unsigned int tmp;
|
||||
uintmax_t tmp;
|
||||
|
||||
if (*s == '\0')
|
||||
return -1;
|
||||
@@ -1363,12 +1346,15 @@ parse_old_offset (const char *s)
|
||||
radix = 8;
|
||||
}
|
||||
|
||||
s_err = xstrtoul (s, NULL, radix, &tmp, "Bb");
|
||||
s_err = xstrtoumax (s, NULL, radix, &tmp, "Bb");
|
||||
if (s_err != LONGINT_OK)
|
||||
{
|
||||
STRTOL_FAIL_WARN (s, _("old-style offset"), s_err);
|
||||
return -1;
|
||||
}
|
||||
if (OFF_T_MAX < tmp)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s is larger than the maximum file size on this system"), s);
|
||||
offset = tmp;
|
||||
return offset;
|
||||
}
|
||||
@@ -1485,15 +1471,14 @@ dump_strings (void)
|
||||
err = 0;
|
||||
while (1)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
int c;
|
||||
|
||||
/* See if the next `string_min' chars are all printing chars. */
|
||||
tryline:
|
||||
|
||||
if (limit_bytes_to_format
|
||||
&& address >= (n_bytes_to_skip + max_bytes_to_format -
|
||||
(off_t) string_min))
|
||||
&& address >= (n_bytes_to_skip + max_bytes_to_format - string_min))
|
||||
break;
|
||||
|
||||
for (i = 0; i < string_min; i++)
|
||||
@@ -1590,6 +1575,26 @@ dump_strings (void)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* There must be exactly one %s format specifier in FORMAT_TEMPLATE.
|
||||
Return the just-malloc'd result of using sprintf to insert
|
||||
OFF_T_PRINTF_FORMAT_STRING into FORMAT_TEMPLATE.
|
||||
Technically, the caller should free this memory, but IMHO it's not
|
||||
worth it in this case. */
|
||||
static char *
|
||||
expand_address_fmt (char const *format_template)
|
||||
{
|
||||
size_t len = strlen (format_template);
|
||||
char *fmt = xmalloc (len + 1);
|
||||
/* Ensure that the literal we're inserting is no longer than the two-byte
|
||||
string `%s' it's replacing. There's also the %%, so technically we don't
|
||||
even need the `+ 1' above. */
|
||||
assert (OFF_T_PRINTF_FORMAT_STRING[0] == 0
|
||||
|| OFF_T_PRINTF_FORMAT_STRING[1] == 0
|
||||
|| OFF_T_PRINTF_FORMAT_STRING[2] == 0);
|
||||
sprintf (fmt, format_template, OFF_T_PRINTF_FORMAT_STRING);
|
||||
return fmt;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -1598,7 +1603,7 @@ main (int argc, char **argv)
|
||||
unsigned int i;
|
||||
unsigned int l_c_m;
|
||||
unsigned int address_pad_len;
|
||||
unsigned long int desired_width;
|
||||
unsigned long int desired_width IF_LINT (= 0);
|
||||
int width_specified = 0;
|
||||
int n_failed_decodes = 0;
|
||||
int err;
|
||||
@@ -1641,7 +1646,7 @@ main (int argc, char **argv)
|
||||
n_specs_allocated = 5;
|
||||
spec = (struct tspec *) xmalloc (n_specs_allocated * sizeof (struct tspec));
|
||||
|
||||
output_address_fmt_string = "%07o";
|
||||
output_address_fmt_string = expand_address_fmt ("%%07%so");
|
||||
format_address = format_address_std;
|
||||
address_pad_len = 7;
|
||||
flag_dump_strings = 0;
|
||||
@@ -1649,7 +1654,7 @@ main (int argc, char **argv)
|
||||
while ((c = getopt_long (argc, argv, "abcdfhilos::xw::A:j:N:t:v",
|
||||
long_options, NULL)) != -1)
|
||||
{
|
||||
unsigned long int tmp;
|
||||
uintmax_t tmp;
|
||||
enum strtol_error s_err;
|
||||
|
||||
switch (c)
|
||||
@@ -1661,17 +1666,17 @@ main (int argc, char **argv)
|
||||
switch (optarg[0])
|
||||
{
|
||||
case 'd':
|
||||
output_address_fmt_string = "%07d";
|
||||
output_address_fmt_string = expand_address_fmt ("%%07%sd");
|
||||
format_address = format_address_std;
|
||||
address_pad_len = 7;
|
||||
break;
|
||||
case 'o':
|
||||
output_address_fmt_string = "%07o";
|
||||
output_address_fmt_string = expand_address_fmt ("%%07%so");
|
||||
format_address = format_address_std;
|
||||
address_pad_len = 7;
|
||||
break;
|
||||
case 'x':
|
||||
output_address_fmt_string = "%06x";
|
||||
output_address_fmt_string = expand_address_fmt ("%%06%sx");
|
||||
format_address = format_address_std;
|
||||
address_pad_len = 6;
|
||||
break;
|
||||
@@ -1690,7 +1695,7 @@ it must be one character from [doxn]"),
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
s_err = xstrtoul (optarg, NULL, 0, &tmp, "bkm");
|
||||
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
|
||||
n_bytes_to_skip = tmp;
|
||||
if (s_err != LONGINT_OK)
|
||||
STRTOL_FATAL_ERROR (optarg, _("skip argument"), s_err);
|
||||
@@ -1699,17 +1704,15 @@ it must be one character from [doxn]"),
|
||||
case 'N':
|
||||
limit_bytes_to_format = 1;
|
||||
|
||||
/* FIXME: if off_t is long long and that's an 8-byte type,
|
||||
use xstrtouq here. */
|
||||
s_err = xstrtoul (optarg, NULL, 0, &tmp, "bkm");
|
||||
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
|
||||
max_bytes_to_format = tmp;
|
||||
if (s_err != LONGINT_OK)
|
||||
STRTOL_FATAL_ERROR (optarg, _("limit argument"), s_err);
|
||||
|
||||
if (tmp > LONG_MAX)
|
||||
if (OFF_T_MAX < tmp)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("specified number of bytes `%s' is larger than \
|
||||
the maximum\nrepresentable value of type `long'"), optarg);
|
||||
_("%s is larger than the maximum file size on this system"),
|
||||
optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -1717,11 +1720,18 @@ the maximum\nrepresentable value of type `long'"), optarg);
|
||||
string_min = 3;
|
||||
else
|
||||
{
|
||||
s_err = xstrtoul (optarg, NULL, 0, &string_min, "bkm");
|
||||
s_err = xstrtoumax (optarg, NULL, 0, &tmp, "bkm");
|
||||
if (s_err != LONGINT_OK)
|
||||
STRTOL_FATAL_ERROR (optarg, _("minimum string length"), s_err);
|
||||
|
||||
/* The minimum string length may be no larger than SIZE_MAX,
|
||||
since we may allocate a buffer of this size. */
|
||||
if (SIZE_MAX < tmp)
|
||||
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
|
||||
|
||||
string_min = tmp;
|
||||
}
|
||||
++flag_dump_strings;
|
||||
flag_dump_strings = 1;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
@@ -1771,9 +1781,13 @@ the maximum\nrepresentable value of type `long'"), optarg);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_err = xstrtoul (optarg, NULL, 10, &desired_width, "");
|
||||
uintmax_t w_tmp;
|
||||
s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, "");
|
||||
if (s_err != LONGINT_OK)
|
||||
STRTOL_FATAL_ERROR (optarg, _("width specification"), s_err);
|
||||
if (ULONG_MAX < w_tmp)
|
||||
error (EXIT_FAILURE, 0, _("%s is too large"), optarg);
|
||||
desired_width = w_tmp;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1875,7 +1889,7 @@ the maximum\nrepresentable value of type `long'"), optarg);
|
||||
|
||||
if (output_address_fmt_string == NULL)
|
||||
{
|
||||
output_address_fmt_string = "(%07o)";
|
||||
output_address_fmt_string = expand_address_fmt ("(%%07%so)");
|
||||
format_address = format_address_std;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
#include "closeout.h"
|
||||
|
||||
65
src/pr.c
65
src/pr.c
@@ -861,57 +861,40 @@ main (int argc, char **argv)
|
||||
? (char **) xmalloc ((argc - 1) * sizeof (char *))
|
||||
: NULL);
|
||||
|
||||
while (1)
|
||||
while ((c = getopt_long (argc, argv,
|
||||
"-0123456789abcde::fFh:i::Jl:mn::N:o:rs::S::tTvw:W:",
|
||||
long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
c = getopt_long (argc, argv,
|
||||
"-0123456789abcde::fFh:i::Jl:mn::N:o:rs::S::tTvw:W:",
|
||||
long_options, NULL);
|
||||
if (c == 1) /* Non-option argument. */
|
||||
if (ISDIGIT (c))
|
||||
{
|
||||
char *s;
|
||||
s = optarg;
|
||||
if (*s == '+')
|
||||
{
|
||||
/* long option --page dominates old `+FIRST_PAGE ...' */
|
||||
if (first_page_number > 0 || last_page_number > 0)
|
||||
continue;
|
||||
++s;
|
||||
first_last_page (s);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_names[n_files++] = optarg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ISDIGIT (c))
|
||||
{
|
||||
accum = accum * 10 + c - '0';
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accum > 0)
|
||||
{
|
||||
columns = accum;
|
||||
explicit_columns = TRUE;
|
||||
accum = 0;
|
||||
}
|
||||
}
|
||||
accum = accum * 10 + c - '0';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == 1)
|
||||
continue;
|
||||
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (accum > 0)
|
||||
{
|
||||
columns = accum;
|
||||
explicit_columns = TRUE;
|
||||
accum = 0;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0: /* getopt long option */
|
||||
break;
|
||||
|
||||
case 1: /* Non-option argument. */
|
||||
if (*optarg == '+')
|
||||
{
|
||||
/* long option --page dominates old `+FIRST_PAGE ...' */
|
||||
if (first_page_number <= 0 && last_page_number <= 0)
|
||||
first_last_page (optarg);
|
||||
}
|
||||
else
|
||||
file_names[n_files++] = optarg;
|
||||
break;
|
||||
|
||||
case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */
|
||||
{ /* dominates old opt +... */
|
||||
if (optarg)
|
||||
|
||||
@@ -147,7 +147,10 @@ valid_format (const char *fmt)
|
||||
fmt += strspn (fmt, "0123456789");
|
||||
|
||||
if (*fmt == '.')
|
||||
fmt += strspn (++fmt, "0123456789");
|
||||
{
|
||||
++fmt;
|
||||
fmt += strspn (fmt, "0123456789");
|
||||
}
|
||||
}
|
||||
|
||||
if (!(*fmt == 'e' || *fmt == 'f' || *fmt == 'g'))
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "checksum.h"
|
||||
|
||||
int algorithm = ALG_SHA1;
|
||||
|
||||
280
src/sort.c
280
src/sort.c
@@ -32,8 +32,10 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "human.h"
|
||||
#include "memcoll.h"
|
||||
#include "xalloc.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "sort"
|
||||
@@ -99,6 +101,8 @@ static int hard_LC_TIME;
|
||||
|
||||
#endif
|
||||
|
||||
#define NONZERO(x) (x != 0)
|
||||
|
||||
/* The kind of blanks for '-b' to skip in various options. */
|
||||
enum blanktype { bl_start, bl_end, bl_both };
|
||||
|
||||
@@ -109,7 +113,7 @@ int eolchar = '\n';
|
||||
struct line
|
||||
{
|
||||
char *text; /* Text of the line. */
|
||||
int length; /* Length including final newline. */
|
||||
size_t length; /* Length including final newline. */
|
||||
char *keybeg; /* Start of first key. */
|
||||
char *keylim; /* Limit of first key. */
|
||||
};
|
||||
@@ -118,29 +122,29 @@ struct line
|
||||
struct lines
|
||||
{
|
||||
struct line *lines; /* Dynamically allocated array of lines. */
|
||||
int used; /* Number of slots used. */
|
||||
int alloc; /* Number of slots allocated. */
|
||||
int limit; /* Max number of slots to allocate. */
|
||||
size_t used; /* Number of slots used. */
|
||||
size_t alloc; /* Number of slots allocated. */
|
||||
size_t limit; /* Max number of slots to allocate. */
|
||||
};
|
||||
|
||||
/* Input buffers. */
|
||||
struct buffer
|
||||
{
|
||||
char *buf; /* Dynamically allocated buffer. */
|
||||
int used; /* Number of bytes used. */
|
||||
int alloc; /* Number of bytes allocated. */
|
||||
int left; /* Number of bytes left from previous reads. */
|
||||
int newline_free; /* Number of left bytes that are known
|
||||
size_t used; /* Number of bytes used. */
|
||||
size_t alloc; /* Number of bytes allocated. */
|
||||
size_t left; /* Number of bytes left from previous reads. */
|
||||
size_t newline_free; /* Number of left bytes that are known
|
||||
to be newline-free. */
|
||||
};
|
||||
|
||||
struct keyfield
|
||||
{
|
||||
int sword; /* Zero-origin 'word' to start at. */
|
||||
int schar; /* Additional characters to skip. */
|
||||
size_t sword; /* Zero-origin 'word' to start at. */
|
||||
size_t schar; /* Additional characters to skip. */
|
||||
int skipsblanks; /* Skip leading white space at start. */
|
||||
int eword; /* Zero-origin first word after field. */
|
||||
int echar; /* Additional characters in field. */
|
||||
size_t eword; /* Zero-origin first word after field. */
|
||||
size_t echar; /* Additional characters in field. */
|
||||
int skipeblanks; /* Skip trailing white space at finish. */
|
||||
int *ignore; /* Boolean array of characters to ignore. */
|
||||
char *translate; /* Translation applied to characters. */
|
||||
@@ -214,14 +218,14 @@ static MONTHTAB_CONST struct month monthtab[] =
|
||||
/* Initial buffer size for in-core sorting. The buffer will grow only
|
||||
if a line longer than this is seen. */
|
||||
#define SORTALLOC (8 * 1024 * 1024)
|
||||
static int const sortalloc = SORTALLOC;
|
||||
static size_t const sortalloc = SORTALLOC;
|
||||
|
||||
/* Initial buffer size for in core merge buffers. Bear in mind that
|
||||
up to NMERGE * mergealloc bytes may be allocated for merge buffers. */
|
||||
static int const mergealloc = SORTALLOC / NMERGE / 2;
|
||||
static size_t const mergealloc = SORTALLOC / NMERGE / 2;
|
||||
|
||||
/* Guess of average line length. */
|
||||
static int const linelength = 30;
|
||||
static size_t const linelength = 30;
|
||||
|
||||
/* Maximum number of elements for the array(s) of struct line's, in bytes. */
|
||||
#define LINEALLOC (SORTALLOC / 2)
|
||||
@@ -557,7 +561,7 @@ inittables (void)
|
||||
/* Initialize BUF, allocating ALLOC bytes initially. */
|
||||
|
||||
static void
|
||||
initbuf (struct buffer *buf, int alloc)
|
||||
initbuf (struct buffer *buf, size_t alloc)
|
||||
{
|
||||
buf->alloc = alloc;
|
||||
buf->buf = xmalloc (buf->alloc);
|
||||
@@ -569,7 +573,7 @@ initbuf (struct buffer *buf, int alloc)
|
||||
file wasn't terminated by a newline, supply one. Return a count
|
||||
of bytes buffered. */
|
||||
|
||||
static int
|
||||
static size_t
|
||||
fillbuf (struct buffer *buf, FILE *fp)
|
||||
{
|
||||
if (buf->used != buf->left)
|
||||
@@ -580,10 +584,12 @@ fillbuf (struct buffer *buf, FILE *fp)
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
int cc;
|
||||
size_t cc;
|
||||
if (buf->used == buf->alloc)
|
||||
{
|
||||
buf->alloc *= 2;
|
||||
if (buf->alloc < buf->used)
|
||||
xalloc_die ();
|
||||
buf->buf = xrealloc (buf->buf, buf->alloc);
|
||||
}
|
||||
cc = fread (buf->buf + buf->used, 1, buf->alloc - buf->used, fp);
|
||||
@@ -608,6 +614,8 @@ fillbuf (struct buffer *buf, FILE *fp)
|
||||
if (buf->newline_free != buf->used)
|
||||
return buf->used;
|
||||
buf->alloc *= 2;
|
||||
if (buf->alloc < buf->used)
|
||||
xalloc_die ();
|
||||
buf->buf = xrealloc (buf->buf, buf->alloc);
|
||||
}
|
||||
buf->buf[buf->used++] = eolchar;
|
||||
@@ -621,9 +629,11 @@ fillbuf (struct buffer *buf, FILE *fp)
|
||||
for, ever. */
|
||||
|
||||
static void
|
||||
initlines (struct lines *lines, int alloc, int limit)
|
||||
initlines (struct lines *lines, size_t alloc, size_t limit)
|
||||
{
|
||||
lines->alloc = alloc;
|
||||
if (SIZE_MAX / sizeof (struct line) < alloc)
|
||||
xalloc_die ();
|
||||
lines->lines = (struct line *) xmalloc (lines->alloc * sizeof (struct line));
|
||||
lines->used = 0;
|
||||
lines->limit = limit;
|
||||
@@ -636,7 +646,8 @@ static char *
|
||||
begfield (const struct line *line, const struct keyfield *key)
|
||||
{
|
||||
register char *ptr = line->text, *lim = ptr + line->length - 1;
|
||||
register int sword = key->sword, schar = key->schar;
|
||||
register size_t sword = key->sword;
|
||||
register size_t schar = key->schar;
|
||||
|
||||
if (tab)
|
||||
while (ptr < lim && sword--)
|
||||
@@ -659,7 +670,7 @@ begfield (const struct line *line, const struct keyfield *key)
|
||||
while (ptr < lim && blanks[UCHAR (*ptr)])
|
||||
++ptr;
|
||||
|
||||
if (ptr + schar <= lim)
|
||||
if (schar < lim - ptr)
|
||||
ptr += schar;
|
||||
else
|
||||
ptr = lim;
|
||||
@@ -674,7 +685,7 @@ static char *
|
||||
limfield (const struct line *line, const struct keyfield *key)
|
||||
{
|
||||
register char *ptr = line->text, *lim = ptr + line->length - 1;
|
||||
register int eword = key->eword, echar = key->echar;
|
||||
register size_t eword = key->eword, echar = key->echar;
|
||||
|
||||
/* Note: from the POSIX spec:
|
||||
The leading field separator itself is included in
|
||||
@@ -692,7 +703,7 @@ limfield (const struct line *line, const struct keyfield *key)
|
||||
{
|
||||
while (ptr < lim && *ptr != tab)
|
||||
++ptr;
|
||||
if (ptr < lim && (eword || echar > 0))
|
||||
if (ptr < lim && (eword | echar))
|
||||
++ptr;
|
||||
}
|
||||
else
|
||||
@@ -761,7 +772,7 @@ limfield (const struct line *line, const struct keyfield *key)
|
||||
++ptr;
|
||||
|
||||
/* Advance PTR by ECHAR (if possible), but no further than LIM. */
|
||||
if (ptr + echar <= lim)
|
||||
if (echar < lim - ptr)
|
||||
ptr += echar;
|
||||
else
|
||||
ptr = lim;
|
||||
@@ -796,6 +807,8 @@ findlines (struct buffer *buf, struct lines *lines)
|
||||
if (lines->used == lines->alloc)
|
||||
{
|
||||
lines->alloc *= 2;
|
||||
if (SIZE_MAX / sizeof (struct line) < lines->alloc)
|
||||
xalloc_die ();
|
||||
lines->lines = (struct line *)
|
||||
xrealloc ((char *) lines->lines,
|
||||
lines->alloc * sizeof (struct line));
|
||||
@@ -808,9 +821,9 @@ findlines (struct buffer *buf, struct lines *lines)
|
||||
if (key)
|
||||
{
|
||||
/* Precompute the position of the first key for efficiency. */
|
||||
line->keylim = 0 <= key->eword ? limfield (line, key) : ptr;
|
||||
line->keylim = (key->eword == -1 ? ptr : limfield (line, key));
|
||||
|
||||
if (key->sword >= 0)
|
||||
if (key->sword != -1)
|
||||
line->keybeg = begfield (line, key);
|
||||
else
|
||||
{
|
||||
@@ -902,7 +915,8 @@ fraccompare (register const char *a, register const char *b)
|
||||
static int
|
||||
numcompare (register const char *a, register const char *b)
|
||||
{
|
||||
register int tmpa, tmpb, loga, logb, tmp;
|
||||
register int tmpa, tmpb, tmp;
|
||||
register size_t loga, logb;
|
||||
|
||||
tmpa = *a;
|
||||
tmpb = *b;
|
||||
@@ -965,8 +979,8 @@ numcompare (register const char *a, register const char *b)
|
||||
tmpb = *++b;
|
||||
while (IS_THOUSANDS_SEP (tmpb));
|
||||
|
||||
if (logb - loga != 0)
|
||||
return logb - loga;
|
||||
if (loga != logb)
|
||||
return loga < logb ? 1 : -1;
|
||||
|
||||
if (!loga)
|
||||
return 0;
|
||||
@@ -1027,8 +1041,8 @@ numcompare (register const char *a, register const char *b)
|
||||
tmpb = *++b;
|
||||
while (IS_THOUSANDS_SEP (tmpb));
|
||||
|
||||
if (loga - logb != 0)
|
||||
return loga - logb;
|
||||
if (loga != logb)
|
||||
return loga < logb ? -1 : 1;
|
||||
|
||||
if (!loga)
|
||||
return 0;
|
||||
@@ -1070,10 +1084,11 @@ general_numcompare (const char *sa, const char *sb)
|
||||
Return 0 if the name in S is not recognized. */
|
||||
|
||||
static int
|
||||
getmonth (const char *s, int len)
|
||||
getmonth (const char *s, size_t len)
|
||||
{
|
||||
char *month;
|
||||
register int i, lo = 0, hi = MONTHS_PER_YEAR, result;
|
||||
register size_t i;
|
||||
register int lo = 0, hi = MONTHS_PER_YEAR, result;
|
||||
|
||||
while (len > 0 && blanks[UCHAR (*s)])
|
||||
{
|
||||
@@ -1123,7 +1138,8 @@ keycompare (const struct line *a, const struct line *b)
|
||||
register char *lima = a->keylim;
|
||||
register char *limb = b->keylim;
|
||||
|
||||
int diff, lena, lenb;
|
||||
int diff;
|
||||
size_t lena, lenb;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -1131,11 +1147,8 @@ keycompare (const struct line *a, const struct line *b)
|
||||
register int *ignore = key->ignore;
|
||||
|
||||
/* Find the lengths. */
|
||||
lena = lima - texta, lenb = limb - textb;
|
||||
if (lena < 0)
|
||||
lena = 0;
|
||||
if (lenb < 0)
|
||||
lenb = 0;
|
||||
lena = lima <= texta ? 0 : lima - texta;
|
||||
lenb = limb <= textb ? 0 : limb - textb;
|
||||
|
||||
if (key->skipeblanks)
|
||||
{
|
||||
@@ -1168,7 +1181,7 @@ keycompare (const struct line *a, const struct line *b)
|
||||
{
|
||||
char *copy_a = (char *) alloca (lena + 1 + lenb + 1);
|
||||
char *copy_b = copy_a + lena + 1;
|
||||
int new_len_a, new_len_b, i;
|
||||
size_t new_len_a, new_len_b, i;
|
||||
|
||||
/* Ignore and/or translate chars before comparing. */
|
||||
for (new_len_a = new_len_b = i = 0; i < max (lena, lenb); i++)
|
||||
@@ -1194,7 +1207,7 @@ keycompare (const struct line *a, const struct line *b)
|
||||
diff = memcoll (copy_a, new_len_a, copy_b, new_len_b);
|
||||
}
|
||||
else if (lena == 0)
|
||||
diff = -lenb;
|
||||
diff = - NONZERO (lenb);
|
||||
else if (lenb == 0)
|
||||
goto greater;
|
||||
else
|
||||
@@ -1232,7 +1245,7 @@ keycompare (const struct line *a, const struct line *b)
|
||||
CMP_WITH_IGNORE (UCHAR (*texta), UCHAR (*textb));
|
||||
}
|
||||
else if (lena == 0)
|
||||
diff = -lenb;
|
||||
diff = - NONZERO (lenb);
|
||||
else if (lenb == 0)
|
||||
goto greater;
|
||||
else
|
||||
@@ -1253,7 +1266,7 @@ keycompare (const struct line *a, const struct line *b)
|
||||
if (diff)
|
||||
goto not_equal;
|
||||
}
|
||||
diff = lena - lenb;
|
||||
diff = lena < lenb ? -1 : lena != lenb;
|
||||
}
|
||||
|
||||
if (diff)
|
||||
@@ -1264,12 +1277,12 @@ keycompare (const struct line *a, const struct line *b)
|
||||
break;
|
||||
|
||||
/* Find the beginning and limit of the next field. */
|
||||
if (key->eword >= 0)
|
||||
if (key->eword != -1)
|
||||
lima = limfield (a, key), limb = limfield (b, key);
|
||||
else
|
||||
lima = a->text + a->length - 1, limb = b->text + b->length - 1;
|
||||
|
||||
if (key->sword >= 0)
|
||||
if (key->sword != -1)
|
||||
texta = begfield (a, key), textb = begfield (b, key);
|
||||
else
|
||||
{
|
||||
@@ -1298,7 +1311,8 @@ keycompare (const struct line *a, const struct line *b)
|
||||
static int
|
||||
compare (register const struct line *a, register const struct line *b)
|
||||
{
|
||||
int diff, alen, blen;
|
||||
int diff;
|
||||
size_t alen, blen;
|
||||
|
||||
/* First try to compare on the specified keys (if any).
|
||||
The only two cases with no key at all are unadorned sort,
|
||||
@@ -1316,23 +1330,23 @@ compare (register const struct line *a, register const struct line *b)
|
||||
alen = a->length - 1, blen = b->length - 1;
|
||||
|
||||
if (alen == 0)
|
||||
diff = - blen;
|
||||
diff = - NONZERO (blen);
|
||||
else if (blen == 0)
|
||||
diff = alen;
|
||||
diff = NONZERO (alen);
|
||||
#ifdef ENABLE_NLS
|
||||
else if (hard_LC_COLLATE)
|
||||
diff = memcoll (a->text, alen, b->text, blen);
|
||||
#endif
|
||||
else if (! (diff = memcmp (a->text, b->text, min (alen, blen))))
|
||||
diff = alen - blen;
|
||||
diff = alen < blen ? -1 : alen != blen;
|
||||
|
||||
return reverse ? -diff : diff;
|
||||
}
|
||||
|
||||
/* Check that the lines read from the given FP come in order. Print a
|
||||
diagnostic (FILE_NAME, line number, contents of line) to stderr and return
|
||||
the line number of the first out-of-order line (counting from 1) if they
|
||||
are not in order. Otherwise, print no diagnostic and return zero. */
|
||||
one if they are not in order. Otherwise, print no diagnostic
|
||||
and return zero. */
|
||||
|
||||
static int
|
||||
checkfp (FILE *fp, const char *file_name)
|
||||
@@ -1340,11 +1354,11 @@ checkfp (FILE *fp, const char *file_name)
|
||||
struct buffer buf; /* Input buffer. */
|
||||
struct lines lines; /* Lines scanned from the buffer. */
|
||||
struct line temp; /* Copy of previous line. */
|
||||
int cc; /* Character count. */
|
||||
int alloc;
|
||||
int line_number = 1;
|
||||
size_t cc; /* Character count. */
|
||||
size_t alloc;
|
||||
uintmax_t line_number = 1;
|
||||
struct line *disorder_line IF_LINT (= NULL);
|
||||
int disorder_line_number = 0;
|
||||
uintmax_t disorder_line_number = 0;
|
||||
struct keyfield *key = keylist;
|
||||
|
||||
initbuf (&buf, mergealloc);
|
||||
@@ -1363,16 +1377,16 @@ checkfp (FILE *fp, const char *file_name)
|
||||
{
|
||||
struct line *prev_line; /* Pointer to previous line. */
|
||||
int cmp; /* Result of calling compare. */
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
/* Compare each line in the buffer with its successor. */
|
||||
for (i = 0; i < lines.used - 1; ++i)
|
||||
for (i = 1; i < lines.used; ++i)
|
||||
{
|
||||
cmp = compare (&lines.lines[i], &lines.lines[i + 1]);
|
||||
cmp = compare (&lines.lines[i - 1], &lines.lines[i]);
|
||||
if ((unique && cmp >= 0) || (cmp > 0))
|
||||
{
|
||||
disorder_line = &lines.lines[i + 1];
|
||||
disorder_line_number = line_number + i + 1;
|
||||
disorder_line = &lines.lines[i];
|
||||
disorder_line_number = line_number + i;
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
@@ -1383,8 +1397,14 @@ checkfp (FILE *fp, const char *file_name)
|
||||
prev_line = lines.lines + (lines.used - 1);
|
||||
if (alloc < prev_line->length)
|
||||
{
|
||||
while ((alloc *= 2) < prev_line->length)
|
||||
continue;
|
||||
do
|
||||
{
|
||||
if (alloc * 2 < alloc)
|
||||
xalloc_die ();
|
||||
alloc *= 2;
|
||||
}
|
||||
while (alloc < prev_line->length);
|
||||
|
||||
temp.text = xrealloc (temp.text, alloc);
|
||||
}
|
||||
memcpy (temp.text, prev_line->text, prev_line->length);
|
||||
@@ -1416,8 +1436,9 @@ finish:
|
||||
|
||||
if (disorder_line_number)
|
||||
{
|
||||
fprintf (stderr, _("%s: %s:%d: disorder: "), program_name, file_name,
|
||||
disorder_line_number);
|
||||
char hr_buf[LONGEST_HUMAN_READABLE + 1];
|
||||
fprintf (stderr, _("%s: %s:%s: disorder: "), program_name, file_name,
|
||||
human_readable (disorder_line_number, hr_buf, 1, 1));
|
||||
write_bytes (disorder_line->text, disorder_line->length, stderr,
|
||||
_("standard error"));
|
||||
}
|
||||
@@ -1425,7 +1446,7 @@ finish:
|
||||
free (buf.buf);
|
||||
free ((char *) lines.lines);
|
||||
free (temp.text);
|
||||
return disorder_line_number;
|
||||
return NONZERO (disorder_line_number);
|
||||
}
|
||||
|
||||
/* Merge lines from FPS onto OFP. NFPS cannot be greater than NMERGE.
|
||||
@@ -1439,8 +1460,8 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
|
||||
struct line saved; /* Saved line storage for unique check. */
|
||||
struct line const *savedline IF_LINT (= NULL);
|
||||
/* &saved if there is a saved line. */
|
||||
int savealloc IF_LINT (= 0); /* Size allocated for the saved line. */
|
||||
int cur[NMERGE]; /* Current line in each line table. */
|
||||
size_t savealloc IF_LINT (= 0); /* Size allocated for the saved line. */
|
||||
size_t cur[NMERGE]; /* Current line in each line table. */
|
||||
int ord[NMERGE]; /* Table representing a permutation of fps,
|
||||
such that lines[ord[0]].lines[cur[ord[0]]]
|
||||
is the smallest line and will be next
|
||||
@@ -1585,10 +1606,10 @@ mergefps (FILE **fps, register int nfps, FILE *ofp, const char *output_file)
|
||||
/* Sort the array LINES with NLINES members, using TEMP for temporary space. */
|
||||
|
||||
static void
|
||||
sortlines (struct line *lines, int nlines, struct line *temp)
|
||||
sortlines (struct line *lines, size_t nlines, struct line *temp)
|
||||
{
|
||||
register struct line *lo, *hi, *t;
|
||||
register int nlo, nhi;
|
||||
register size_t nlo, nhi;
|
||||
|
||||
if (nlines == 2)
|
||||
{
|
||||
@@ -1638,10 +1659,7 @@ check (char **files, int nfiles)
|
||||
for (i = 0; i < nfiles; ++i)
|
||||
{
|
||||
fp = xfopen (files[i], "r");
|
||||
if (checkfp (fp, files[i]))
|
||||
{
|
||||
++disorders;
|
||||
}
|
||||
disorders += checkfp (fp, files[i]);
|
||||
}
|
||||
return disorders;
|
||||
}
|
||||
@@ -1694,8 +1712,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
|
||||
{
|
||||
struct buffer buf;
|
||||
struct lines lines;
|
||||
struct line *tmp;
|
||||
int i, ntmp;
|
||||
struct line *tmp = NULL;
|
||||
size_t ntmp = 0;
|
||||
FILE *fp, *tfp;
|
||||
struct tempnode *node;
|
||||
int n_temp_files = 0;
|
||||
@@ -1704,8 +1722,6 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
|
||||
initbuf (&buf, sortalloc);
|
||||
initlines (&lines, sortalloc / linelength + 1,
|
||||
LINEALLOC / sizeof (struct line));
|
||||
ntmp = lines.alloc;
|
||||
tmp = (struct line *) xmalloc (ntmp * sizeof (struct line));
|
||||
|
||||
while (nfiles--)
|
||||
{
|
||||
@@ -1714,6 +1730,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
|
||||
fp = xfopen (*files++, "r");
|
||||
while (fillbuf (&buf, fp))
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (nfiles && buf.used != buf.alloc && feof (fp))
|
||||
{
|
||||
/* End of file, but there is more input and buffer room.
|
||||
@@ -1726,8 +1744,13 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
|
||||
findlines (&buf, &lines);
|
||||
if (ntmp < lines.used)
|
||||
{
|
||||
while ((ntmp *= 2) < lines.used)
|
||||
continue;
|
||||
if (ntmp == 0)
|
||||
ntmp = lines.used;
|
||||
else
|
||||
while ((ntmp *= 2) < lines.used)
|
||||
continue;
|
||||
if (SIZE_MAX / sizeof (struct line) < ntmp)
|
||||
xalloc_die ();
|
||||
tmp = (struct line *)
|
||||
xrealloc ((char *) tmp, ntmp * sizeof (struct line));
|
||||
}
|
||||
@@ -1759,8 +1782,8 @@ sort (char **files, int nfiles, FILE *ofp, const char *output_file)
|
||||
|
||||
if (n_temp_files)
|
||||
{
|
||||
int i = n_temp_files;
|
||||
tempfiles = (char **) xmalloc (n_temp_files * sizeof (char *));
|
||||
i = n_temp_files;
|
||||
for (node = temphead.next; i > 0; node = node->next)
|
||||
tempfiles[--i] = node->name;
|
||||
merge (tempfiles, n_temp_files, ofp, output_file);
|
||||
@@ -1787,6 +1810,39 @@ badfieldspec (const char *s)
|
||||
error (SORT_FAILURE, 0, _("invalid field specification `%s'"), s);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
static char const *
|
||||
parse_field_count (char const *string, size_t *val)
|
||||
{
|
||||
/* '@' can't possibly be a valid suffix; return &bad_suffix so that
|
||||
the caller will eventually invoke badfieldspec. */
|
||||
static char const invalid_suffix = '@';
|
||||
char *suffix;
|
||||
uintmax_t n;
|
||||
|
||||
switch (xstrtoumax (string, &suffix, 10, &n, ""))
|
||||
{
|
||||
case LONGINT_OK:
|
||||
case LONGINT_INVALID_SUFFIX_CHAR:
|
||||
*val = n;
|
||||
if (*val == n)
|
||||
break;
|
||||
/* Fall through. */
|
||||
case LONGINT_OVERFLOW:
|
||||
error (0, 0, _("count `%.*s' too large"),
|
||||
(int) (suffix - string), string);
|
||||
return &invalid_suffix;
|
||||
|
||||
case LONGINT_INVALID:
|
||||
error (0, 0, _("invalid count at start of `%s'"), string);
|
||||
return &invalid_suffix;
|
||||
}
|
||||
|
||||
return suffix;
|
||||
}
|
||||
|
||||
/* Handle interrupts and hangups. */
|
||||
|
||||
static void
|
||||
@@ -1865,10 +1921,11 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct keyfield *key = NULL, gkey;
|
||||
char *s;
|
||||
int i, t, t2;
|
||||
char const *s;
|
||||
int i;
|
||||
int checkonly = 0, mergeonly = 0, nfiles = 0;
|
||||
char *minus = "-", *outfile = minus, **files, *tmp;
|
||||
char *minus = "-", **files, *tmp;
|
||||
char const *outfile = minus;
|
||||
FILE *ofp;
|
||||
#ifdef SA_NOCLDSTOP
|
||||
struct sigaction oldact, newact;
|
||||
@@ -1966,18 +2023,10 @@ main (int argc, char **argv)
|
||||
s = argv[i] + 1;
|
||||
if (! (ISDIGIT (*s) || (*s == '.' && ISDIGIT (s[1]))))
|
||||
badfieldspec (argv[i]);
|
||||
for (t = 0; ISDIGIT (*s); ++s)
|
||||
t = 10 * t + *s - '0';
|
||||
t2 = 0;
|
||||
s = parse_field_count (s, &key->sword);
|
||||
if (*s == '.')
|
||||
for (++s; ISDIGIT (*s); ++s)
|
||||
t2 = 10 * t2 + *s - '0';
|
||||
if (t2 || t)
|
||||
{
|
||||
key->sword = t;
|
||||
key->schar = t2;
|
||||
}
|
||||
else
|
||||
s = parse_field_count (s + 1, &key->schar);
|
||||
if (! (key->sword | key->schar))
|
||||
key->sword = -1;
|
||||
s = set_ordering (s, key, bl_start);
|
||||
if (*s)
|
||||
@@ -1995,14 +2044,9 @@ main (int argc, char **argv)
|
||||
key specifiers,\nthe +POS specifier must come first"));
|
||||
usage (SORT_FAILURE);
|
||||
}
|
||||
for (t = 0; ISDIGIT (*s); ++s)
|
||||
t = t * 10 + *s - '0';
|
||||
t2 = 0;
|
||||
s = parse_field_count (s, &key->eword);
|
||||
if (*s == '.')
|
||||
for (++s; ISDIGIT (*s); ++s)
|
||||
t2 = t2 * 10 + *s - '0';
|
||||
key->eword = t;
|
||||
key->echar = t2;
|
||||
s = parse_field_count (s + 1, &key->echar);
|
||||
s = set_ordering (s, key, bl_end);
|
||||
if (*s)
|
||||
badfieldspec (argv[i]);
|
||||
@@ -2039,17 +2083,14 @@ key specifiers,\nthe +POS specifier must come first"));
|
||||
/* Get POS1. */
|
||||
if (!ISDIGIT (*s))
|
||||
badfieldspec (argv[i]);
|
||||
for (t = 0; ISDIGIT (*s); ++s)
|
||||
t = 10 * t + *s - '0';
|
||||
if (t == 0)
|
||||
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]);
|
||||
}
|
||||
--t;
|
||||
t2 = 0;
|
||||
if (*s == '.')
|
||||
{
|
||||
if (!ISDIGIT (s[1]))
|
||||
@@ -2059,23 +2100,16 @@ to the `-k' option must be positive"));
|
||||
lacks following character offset"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
for (++s; ISDIGIT (*s); ++s)
|
||||
t2 = 10 * t2 + *s - '0';
|
||||
if (t2 == 0)
|
||||
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\nmust be positive"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
--t2;
|
||||
}
|
||||
if (t2 || t)
|
||||
{
|
||||
key->sword = t;
|
||||
key->schar = t2;
|
||||
}
|
||||
else
|
||||
if (! (key->sword | key->schar))
|
||||
key->sword = -1;
|
||||
s = set_ordering (s, key, bl_start);
|
||||
if (*s == 0)
|
||||
@@ -2097,17 +2131,14 @@ lacks following field spec"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
/* Get POS2. */
|
||||
for (t = 0; ISDIGIT (*s); ++s)
|
||||
t = t * 10 + *s - '0';
|
||||
if (t == 0)
|
||||
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]);
|
||||
}
|
||||
--t;
|
||||
t2 = 0;
|
||||
if (*s == '.')
|
||||
{
|
||||
if (!ISDIGIT (s[1]))
|
||||
@@ -2117,16 +2148,13 @@ to the `-k' option must be positive"));
|
||||
but lacks following character offset"));
|
||||
badfieldspec (argv[i]);
|
||||
}
|
||||
for (++s; ISDIGIT (*s); ++s)
|
||||
t2 = t2 * 10 + *s - '0';
|
||||
s = parse_field_count (s + 1, &key->echar);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* `-k 2,3' is equivalent to `+1 -3'. */
|
||||
++t;
|
||||
key->eword++;
|
||||
}
|
||||
key->eword = t;
|
||||
key->echar = t2;
|
||||
s = set_ordering (s, key, bl_end);
|
||||
if (*s)
|
||||
badfieldspec (argv[i]);
|
||||
|
||||
32
src/sys2.h
32
src/sys2.h
@@ -126,7 +126,7 @@
|
||||
#define CHMOD_MODE_BITS \
|
||||
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
|
||||
#if ST_MTIM_NSEC
|
||||
#ifdef ST_MTIM_NSEC
|
||||
# define ST_TIME_CMP_NS(a, b, ns) ((a).ns < (b).ns ? -1 : (a).ns > (b).ns)
|
||||
#else
|
||||
# define ST_TIME_CMP_NS(a, b, ns) 0
|
||||
@@ -167,6 +167,10 @@ char *alloca ();
|
||||
# include <sys/exceptn.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
/* Jim Meyering writes:
|
||||
@@ -427,8 +431,14 @@ char *base_name PARAMS ((char const *));
|
||||
|
||||
/* Factor out some of the common --help and --version processing code. */
|
||||
|
||||
#define GETOPT_HELP_CHAR 250
|
||||
#define GETOPT_VERSION_CHAR 251
|
||||
/* These enum values cannot possibly conflict with the option values
|
||||
ordinarily used by commands, including CHAR_MAX + 1, etc. Avoid
|
||||
CHAR_MIN - 1, as it may equal -1, the getopt end-of-options value. */
|
||||
enum
|
||||
{
|
||||
GETOPT_HELP_CHAR = (CHAR_MIN - 2),
|
||||
GETOPT_VERSION_CHAR = (CHAR_MIN - 3)
|
||||
};
|
||||
|
||||
#define GETOPT_HELP_OPTION_DECL \
|
||||
"help", no_argument, 0, GETOPT_HELP_CHAR
|
||||
@@ -513,6 +523,18 @@ char *base_name PARAMS ((char const *));
|
||||
# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX TYPE_MAXIMUM (size_t)
|
||||
#endif
|
||||
|
||||
#ifndef OFF_T_MIN
|
||||
# define OFF_T_MIN TYPE_MINIMUM (off_t)
|
||||
#endif
|
||||
|
||||
#ifndef OFF_T_MAX
|
||||
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
|
||||
#endif
|
||||
|
||||
#ifndef UID_T_MAX
|
||||
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
|
||||
#endif
|
||||
@@ -525,6 +547,10 @@ char *base_name PARAMS ((char const *));
|
||||
# define PID_T_MAX TYPE_MAXIMUM (pid_t)
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
|
||||
#ifdef lint
|
||||
# define IF_LINT(Code) Code
|
||||
|
||||
33
src/tail.c
33
src/tail.c
@@ -44,14 +44,6 @@
|
||||
#define AUTHORS \
|
||||
"Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering"
|
||||
|
||||
#ifndef OFF_T_MIN
|
||||
# define OFF_T_MIN TYPE_MINIMUM (off_t)
|
||||
#endif
|
||||
|
||||
#ifndef OFF_T_MAX
|
||||
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
|
||||
#endif
|
||||
|
||||
#ifndef ENOSYS
|
||||
/* Some systems don't have ENOSYS -- this should be a big enough
|
||||
value that no valid errno value will match it. */
|
||||
@@ -1145,6 +1137,9 @@ tail_file (struct File_spec *f, off_t n_units)
|
||||
{
|
||||
f->fd = -1;
|
||||
f->errnum = errno;
|
||||
f->ignore = 0;
|
||||
f->ino = 0;
|
||||
f->dev = 0;
|
||||
}
|
||||
error (0, errno, "%s", pretty_name (f));
|
||||
errors = 1;
|
||||
@@ -1382,8 +1377,8 @@ parse_options (int argc, char **argv,
|
||||
|
||||
{
|
||||
strtol_error s_err;
|
||||
unsigned long int tmp_ulong;
|
||||
s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, "bkm");
|
||||
uintmax_t n;
|
||||
s_err = xstrtoumax (optarg, NULL, 10, &n, "bkm");
|
||||
if (s_err == LONGINT_INVALID)
|
||||
{
|
||||
error (EXIT_FAILURE, 0, "%s: %s", optarg,
|
||||
@@ -1391,14 +1386,16 @@ parse_options (int argc, char **argv,
|
||||
? _("invalid number of lines")
|
||||
: _("invalid number of bytes")));
|
||||
}
|
||||
if (s_err != LONGINT_OK || tmp_ulong > OFF_T_MAX)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: %s is so large that it is not representable"),
|
||||
optarg,
|
||||
c == 'n' ? _("number of lines") : _("number of bytes"));
|
||||
}
|
||||
*n_units = (off_t) tmp_ulong;
|
||||
|
||||
if (s_err != LONGINT_OK)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: is so large that it is not representable"), optarg);
|
||||
|
||||
if (OFF_T_MAX < n)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s is larger than the maximum file size on this system"),
|
||||
optarg);
|
||||
*n_units = (off_t) n;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
|
||||
@@ -21,10 +21,12 @@
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
|
||||
@@ -21,10 +21,12 @@
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "readutmp.h"
|
||||
#include "system.h"
|
||||
#include "closeout.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
|
||||
194
tests/Fetish.pm
194
tests/Fetish.pm
@@ -12,12 +12,12 @@ use FileHandle;
|
||||
use File::Compare qw(compare);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
($VERSION = '$Revision: 1.8 $ ') =~ tr/[0-9].//cd;
|
||||
($VERSION = '$Revision: 1.9 $ ') =~ tr/[0-9].//cd;
|
||||
@EXPORT = qw (run_tests);
|
||||
|
||||
my $debug = $ENV{DEBUG};
|
||||
|
||||
my @Types = qw (IN OUT ERR EXIT PRE POST);
|
||||
my @Types = qw (IN OUT ERR AUX CMP EXIT PRE POST);
|
||||
my %Types = map {$_ => 1} @Types;
|
||||
my %Zero_one_type = map {$_ => 1} qw (OUT ERR EXIT PRE POST);
|
||||
my $srcdir = $ENV{srcdir};
|
||||
@@ -35,7 +35,7 @@ my $Global_count = 1;
|
||||
# I/O spec: a hash ref with the following properties
|
||||
# ================
|
||||
# - one key/value pair
|
||||
# - the key must be one of these strings: IN, OUT, ERR, EXIT
|
||||
# - the key must be one of these strings: IN, OUT, ERR, AUX, CMP, EXIT
|
||||
# - the value must be a file spec
|
||||
# {OUT => 'data'} put data in a temp file and compare it to stdout from cmd
|
||||
# {OUT => {'filename'=>undef}} compare contents of existing filename to
|
||||
@@ -91,6 +91,82 @@ sub _create_file ($$$$)
|
||||
return $file;
|
||||
}
|
||||
|
||||
sub _compare_files ($$$$$)
|
||||
{
|
||||
my ($program_name, $test_name, $in_or_out, $actual, $expected) = @_;
|
||||
|
||||
my $differ = compare ($expected, $actual);
|
||||
if ($differ)
|
||||
{
|
||||
my $info = (defined $in_or_out ? "std$in_or_out " : '');
|
||||
warn "$program_name: test $test_name: ${info}mismatch, comparing "
|
||||
. "$actual (actual) and $expected (expected)\n";
|
||||
# Ignore any failure, discard stderr.
|
||||
system "diff -c $actual $expected 2>/dev/null";
|
||||
}
|
||||
|
||||
return $differ;
|
||||
}
|
||||
|
||||
sub _process_file_spec ($$$$$)
|
||||
{
|
||||
my ($program_name, $test_name, $file_spec, $type, $junk_files) = @_;
|
||||
|
||||
my ($file_name, $contents);
|
||||
if (!ref $file_spec)
|
||||
{
|
||||
($file_name, $contents) = (undef, $file_spec);
|
||||
}
|
||||
elsif (ref $file_spec eq 'HASH')
|
||||
{
|
||||
my $n = keys %$file_spec;
|
||||
die "$program_name: $test_name: $type spec has $n elements --"
|
||||
. " expected 1\n"
|
||||
if $n != 1;
|
||||
($file_name, $contents) = each %$file_spec;
|
||||
|
||||
# This happens for the AUX hash in an io_spec like this:
|
||||
# {CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
|
||||
defined $contents
|
||||
or return $file_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "$program_name: $test_name: invalid RHS in $type-spec\n"
|
||||
}
|
||||
|
||||
my $is_junk_file = (! defined $file_name
|
||||
|| (($type eq 'IN' || $type eq 'AUX' || $type eq 'CMP')
|
||||
&& defined $contents));
|
||||
my $file = _create_file ($program_name, $test_name,
|
||||
$file_name, $contents);
|
||||
|
||||
if ($is_junk_file)
|
||||
{
|
||||
push @$junk_files, $file
|
||||
}
|
||||
else
|
||||
{
|
||||
# FIXME: put $srcdir in here somewhere
|
||||
warn "$program_name: $test_name: specified file `$file' does"
|
||||
. " not exist\n"
|
||||
if ! -f "$srcdir/$file";
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
sub _at_replace ($$)
|
||||
{
|
||||
my ($map, $s) = @_;
|
||||
foreach my $eo (qw (AUX OUT ERR))
|
||||
{
|
||||
my $f = $map->{$eo};
|
||||
$f and $s =~ s/\@$eo\@/$f/g;
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
# FIXME: cleanup on interrupt
|
||||
# FIXME: extract `do_1_test' function
|
||||
|
||||
@@ -129,6 +205,7 @@ sub run_tests ($$$$$)
|
||||
my $fail = 0;
|
||||
foreach $t (@$t_spec)
|
||||
{
|
||||
my @post_compare;
|
||||
my $test_name = shift @$t;
|
||||
my $expect = {};
|
||||
my ($pre, $post);
|
||||
@@ -167,6 +244,48 @@ sub run_tests ($$$$$)
|
||||
next;
|
||||
}
|
||||
|
||||
if ($type eq 'CMP')
|
||||
{
|
||||
my $t = ref $val;
|
||||
$t && $t eq 'ARRAY'
|
||||
or die "$program_name: $test_name: invalid CMP spec\n";
|
||||
@$val == 2
|
||||
or die "$program_name: $test_name: invalid CMP list; must have"
|
||||
. " exactly 2 elements\n";
|
||||
my @cmp_files;
|
||||
foreach my $e (@$val)
|
||||
{
|
||||
my $r = ref $e;
|
||||
$r && $r ne 'HASH'
|
||||
and die "$program_name: $test_name: invalid element ($r)"
|
||||
. " in CMP list; only scalars and hash references "
|
||||
. "are allowed\n";
|
||||
if ($r && $r eq 'HASH')
|
||||
{
|
||||
my $n = keys %$e;
|
||||
$n == 1
|
||||
or die "$program_name: $test_name: CMP spec has $n "
|
||||
. "elements -- expected 1\n";
|
||||
|
||||
# Replace any `@AUX@' in the key of %$e.
|
||||
my ($ff, $val) = each %$e;
|
||||
my $new_ff = _at_replace $expect, $ff;
|
||||
if ($new_ff ne $ff)
|
||||
{
|
||||
$e->{$new_ff} = $val;
|
||||
delete $e->{$ff};
|
||||
}
|
||||
}
|
||||
my $cmp_file = _process_file_spec ($program_name, $test_name,
|
||||
$e, $type, \@junk_files);
|
||||
push @cmp_files, $cmp_file;
|
||||
}
|
||||
push @post_compare, [@cmp_files];
|
||||
|
||||
$expect->{$type} = $val;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($type eq 'EXIT')
|
||||
{
|
||||
die "$program_name: $test_name: invalid EXIT code\n"
|
||||
@@ -176,48 +295,20 @@ sub run_tests ($$$$$)
|
||||
next;
|
||||
}
|
||||
|
||||
my $file_spec = $val;
|
||||
my ($file_name, $contents);
|
||||
if (!ref $file_spec)
|
||||
{
|
||||
($file_name, $contents) = (undef, $file_spec);
|
||||
}
|
||||
elsif (ref $file_spec eq 'HASH')
|
||||
{
|
||||
my $n = keys %$file_spec;
|
||||
die "$program_name: $test_name: $type spec has $n elements --"
|
||||
. " expected 1\n"
|
||||
if $n != 1;
|
||||
($file_name, $contents) = each %$file_spec;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "$program_name: $test_name: invalid RHS in $type-spec\n"
|
||||
}
|
||||
my $file = _process_file_spec ($program_name, $test_name, $val,
|
||||
$type, \@junk_files);
|
||||
|
||||
my $is_junk_file = (! defined $file_name
|
||||
|| ($type eq 'IN' && defined $contents));
|
||||
my $file = _create_file ($program_name, $test_name,
|
||||
$file_name, $contents);
|
||||
if ($type eq 'IN')
|
||||
{
|
||||
push @args, _shell_quote $file;
|
||||
}
|
||||
else
|
||||
elsif ($type eq 'AUX' || $type eq 'OUT' || $type eq 'ERR')
|
||||
{
|
||||
$expect->{$type} = $file;
|
||||
}
|
||||
|
||||
if ($is_junk_file)
|
||||
{
|
||||
push @junk_files, $file
|
||||
}
|
||||
else
|
||||
{
|
||||
# FIXME: put $srcdir in here somewhere
|
||||
warn "$program_name: $test_name: specified file `$file' does"
|
||||
. " not exist\n"
|
||||
if ! -f "$srcdir/$file";
|
||||
die "$program_name: $test_name: invalid type: $type\n"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +316,7 @@ sub run_tests ($$$$$)
|
||||
$expect->{EXIT} ||= 0;
|
||||
|
||||
# Allow ERR to be omitted -- in that case, expect no error output.
|
||||
my $eo;
|
||||
foreach $eo (qw (OUT ERR))
|
||||
foreach my $eo (qw (OUT ERR))
|
||||
{
|
||||
if (!exists $expect->{$eo})
|
||||
{
|
||||
@@ -239,6 +329,15 @@ sub run_tests ($$$$$)
|
||||
# FIXME: Does it ever make sense to specify a filename *and* contents
|
||||
# in OUT or ERR spec?
|
||||
|
||||
# FIXME: this is really suboptimal...
|
||||
my @new_args;
|
||||
foreach my $a (@args)
|
||||
{
|
||||
$a = _at_replace $expect, $a;
|
||||
push @new_args, $a;
|
||||
}
|
||||
@args = @new_args;
|
||||
|
||||
warn "$test_name...\n" if $verbose;
|
||||
&{$expect->{PRE}} if $expect->{PRE};
|
||||
my %tmp;
|
||||
@@ -265,20 +364,21 @@ sub run_tests ($$$$$)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
foreach $eo (qw (OUT ERR))
|
||||
foreach my $eo (qw (OUT ERR))
|
||||
{
|
||||
my $eo_lower = lc $eo;
|
||||
if (compare ($expect->{$eo}, $tmp{$eo}))
|
||||
{
|
||||
warn "$program_name: test $test_name: std$eo_lower mismatch,"
|
||||
. " comparing $tmp{$eo} (actual)"
|
||||
. " and $expect->{$eo} (expected)\n";
|
||||
# Ignore any failure, discard stderr.
|
||||
system "diff -c $tmp{$eo} $expect->{$eo} 2>/dev/null";
|
||||
$fail = 1;
|
||||
}
|
||||
_compare_files ($program_name, $test_name, $eo_lower,
|
||||
$expect->{$eo}, $tmp{$eo})
|
||||
and $fail = 1;
|
||||
}
|
||||
|
||||
foreach my $pair (@post_compare)
|
||||
{
|
||||
my ($a, $b) = @$pair;
|
||||
_compare_files $program_name, $test_name, undef, $a, $b
|
||||
and $fail = 1;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
&{$expect->{POST}} if $expect->{POST};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
|
||||
AUTOMAKE_OPTIONS = 1.4 gnits
|
||||
|
||||
TESTS = equal-x
|
||||
TESTS = equal-x c-option
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
@@ -118,7 +118,7 @@ l = @l@
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.4 gnits
|
||||
|
||||
TESTS = equal-x
|
||||
TESTS = equal-x c-option
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
50
tests/chmod/c-option
Executable file
50
tests/chmod/c-option
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# Verify that chmod's --changes (-c) option works.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/../lang-default
|
||||
|
||||
pwd=`pwd`
|
||||
tmp=eq-x-$$
|
||||
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
framework_failure=0
|
||||
|
||||
# Record absolute path of srcdir.
|
||||
cd $srcdir || framework_failure=1
|
||||
abs_srcdir=`pwd`
|
||||
|
||||
cd $pwd || framework_failure=1
|
||||
mkdir $tmp || framework_failure=1
|
||||
cd $tmp || framework_failure=1
|
||||
|
||||
umask 0
|
||||
file=f
|
||||
touch $file || framework_failure=1
|
||||
chmod 444 $file || framework_failure=1
|
||||
|
||||
if test $framework_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
(exit 1); exit
|
||||
fi
|
||||
|
||||
. $abs_srcdir/../sticky-check
|
||||
|
||||
fail=0
|
||||
|
||||
chmod u=rwx $file || fail=1
|
||||
chmod -c g=rwx $file > out || fail=1
|
||||
chmod -c g=rwx $file > empty || fail=1
|
||||
|
||||
test -s empty && fail=1
|
||||
case "`cat out`" in
|
||||
"mode of \`f' changed to 0774 "?rwxrwxr--?) ;;
|
||||
*) fail=1 ;;
|
||||
esac
|
||||
|
||||
(exit $fail); exit
|
||||
@@ -5,26 +5,29 @@ if test "$VERBOSE" = yes; then
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
pwd=`pwd`
|
||||
tmp=eq-x-$$
|
||||
trap "rm -rf $tmp" 0 1 2 3 15
|
||||
trap 'status=$?; cd $pwd; chmod -R a+rwx $tmp; 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
|
||||
|
||||
rm -f $tmp
|
||||
> $tmp
|
||||
chmod 444 $tmp || framework_failure=1
|
||||
file=f
|
||||
touch $file || framework_failure=1
|
||||
chmod 444 $file || framework_failure=1
|
||||
|
||||
if test $framework_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
exit 1
|
||||
(exit 1); exit
|
||||
fi
|
||||
|
||||
umask 005
|
||||
chmod =x $tmp
|
||||
case "`ls -l $tmp`" in
|
||||
chmod =x $file
|
||||
case "`ls -l $file`" in
|
||||
---x--x---*) fail=0 ;;
|
||||
*) fail=1; ls -l $tmp ;;
|
||||
*) fail=1; ls -l $file ;;
|
||||
esac
|
||||
|
||||
rm -f $tmp
|
||||
exit $fail
|
||||
(exit $fail); exit
|
||||
|
||||
@@ -9,4 +9,4 @@ TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=dd
|
||||
|
||||
TESTS = misc not-rewound
|
||||
TESTS = misc not-rewound skip-seek skip-seek2
|
||||
|
||||
@@ -126,7 +126,7 @@ TESTS_ENVIRONMENT = \
|
||||
PROG=dd
|
||||
|
||||
|
||||
TESTS = misc not-rewound
|
||||
TESTS = misc not-rewound skip-seek skip-seek2
|
||||
subdir = tests/dd
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
|
||||
61
tests/dd/skip-seek
Executable file
61
tests/dd/skip-seek
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
: ${PERL=perl}
|
||||
: ${srcdir=.}
|
||||
|
||||
case "$PERL" in
|
||||
*'missing perl')
|
||||
echo 1>&2 "$0: configure didn't find a usable version of Perl, so can't run this test"
|
||||
exit 77
|
||||
;;
|
||||
esac
|
||||
|
||||
SCRIPT_NAME=$0
|
||||
export SCRIPT_NAME
|
||||
|
||||
exec $PERL -w -I$srcdir/.. -MFetish -- - <<\EOF
|
||||
require 5.003;
|
||||
use strict;
|
||||
|
||||
(my $program_name = $0) =~ s|.*/||;
|
||||
|
||||
# Turn off localisation of executable's ouput.
|
||||
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
|
||||
my $out = 'out';
|
||||
my $script_name = $ENV{SCRIPT_NAME};
|
||||
|
||||
my @Tests =
|
||||
(
|
||||
[
|
||||
'1', qw (bs=1 skip=1 seek=2 conv=notrunc count=3 of=@AUX@ < ),
|
||||
{IN=> '0123456789abcdef'},
|
||||
{AUX=> 'zyxwvutsrqponmlkji'},
|
||||
{OUT=> ''},
|
||||
{ERR=> "3+0 records in\n3+0 records out\n"},
|
||||
{CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
|
||||
],
|
||||
[
|
||||
'3', qw (bs=5 skip=1 seek=1 conv=notrunc count=1 of=@AUX@ < ),
|
||||
{IN=> '0123456789abcdef'},
|
||||
{AUX=> 'zyxwvutsrqponmlkji'},
|
||||
{OUT=> ''},
|
||||
{ERR=> "1+0 records in\n1+0 records out\n"},
|
||||
{CMP=> ['zyxwv56789ponmlkji', {'@AUX@'=> undef}]},
|
||||
],
|
||||
[
|
||||
'4', 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}]},
|
||||
],
|
||||
);
|
||||
|
||||
my $save_temps = $ENV{DEBUG};
|
||||
my $verbose = $ENV{VERBOSE};
|
||||
|
||||
my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
|
||||
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
|
||||
exit $fail;
|
||||
EOF
|
||||
40
tests/dd/skip-seek2
Executable file
40
tests/dd/skip-seek2
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# show how to skip an amount that is smaller than the nominal block size.
|
||||
# There's a more realistic example in the documentation.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
dd --version
|
||||
fi
|
||||
|
||||
pwd=`pwd`
|
||||
tmp=skip-seek.$$
|
||||
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
|
||||
|
||||
if test $framework_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
(exit 1); exit
|
||||
fi
|
||||
|
||||
fail=0
|
||||
|
||||
echo LA:3456789abcdef > in || fail=1
|
||||
(dd bs=1 skip=3 count=0 && dd bs=5) < in > out 2> /dev/null || fail=1
|
||||
case `cat out` in
|
||||
3456789abcdef) ;;
|
||||
*) fail=1 ;;
|
||||
esac
|
||||
|
||||
echo LA:3456789abcdef > in || fail=1
|
||||
(dd bs=1 skip=3 count=0 && dd bs=5 count=2) < in > out 2> /dev/null || fail=1
|
||||
case `cat out` in
|
||||
3456789abc) ;;
|
||||
*) fail=1 ;;
|
||||
esac
|
||||
|
||||
(exit $fail); exit
|
||||
41
tests/general/Makefile.am
Normal file
41
tests/general/Makefile.am
Normal file
@@ -0,0 +1,41 @@
|
||||
## Process this file with automake to create Makefile.in.
|
||||
|
||||
## Makefile for Autoconf testsuite.
|
||||
## Copyright 2000 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
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
## 02111-1307, USA.
|
||||
|
||||
AUTOMAKE_OPTIONS = gnits
|
||||
|
||||
SUITE = suite.at dd.at m4sh.at
|
||||
|
||||
EXTRA_DIST = $(SUITE) testsuite
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
TESTS = testsuite
|
||||
|
||||
check-local: atconfig
|
||||
|
||||
testsuite: $(SUITE) atgeneral.m4
|
||||
$(M4) -I $(srcdir) atgeneral.m4 suite.at > $@-t1
|
||||
sed 's/[ ]*$$//;/^$$/N;/\n$$/D' $@-t1 > $@-tmp
|
||||
rm -f $@-t1
|
||||
chmod +x $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
DISTCLEANFILES = atconfig
|
||||
304
tests/general/Makefile.in
Normal file
304
tests/general/Makefile.in
Normal file
@@ -0,0 +1,304 @@
|
||||
# Makefile.in generated automatically by automake 1.4a from Makefile.am
|
||||
|
||||
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
|
||||
# Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
|
||||
@SET_MAKE@
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AMDEP = @AMDEP@
|
||||
AMTAR = @AMTAR@
|
||||
AUTOTEST_PATH = @AUTOTEST_PATH@
|
||||
AWK = @AWK@
|
||||
CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
DEPDIR = @DEPDIR@
|
||||
DF_PROG = @DF_PROG@
|
||||
FESETROUND_LIBM = @FESETROUND_LIBM@
|
||||
GENCAT = @GENCAT@
|
||||
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
|
||||
GLIBC21 = @GLIBC21@
|
||||
GMOFILES = @GMOFILES@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
GNU_PACKAGE = @GNU_PACKAGE@
|
||||
GT_NO = @GT_NO@
|
||||
GT_YES = @GT_YES@
|
||||
INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@
|
||||
INSTOBJEXT = @INSTOBJEXT@
|
||||
INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
KMEM_GROUP = @KMEM_GROUP@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
|
||||
LIB_CRYPT = @LIB_CRYPT@
|
||||
LIB_NANOSLEEP = @LIB_NANOSLEEP@
|
||||
M4 = @M4@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MAN = @MAN@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
NEED_SETGID = @NEED_SETGID@
|
||||
OPTIONAL_BIN_PROGS = @OPTIONAL_BIN_PROGS@
|
||||
OPTIONAL_BIN_ZCRIPTS = @OPTIONAL_BIN_ZCRIPTS@
|
||||
PACKAGE = @PACKAGE@
|
||||
PERL = @PERL@
|
||||
POFILES = @POFILES@
|
||||
POSUB = @POSUB@
|
||||
POW_LIBM = @POW_LIBM@
|
||||
RANLIB = @RANLIB@
|
||||
SEQ_LIBM = @SEQ_LIBM@
|
||||
SQRT_LIBM = @SQRT_LIBM@
|
||||
U = @U@
|
||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
|
||||
USE_NLS = @USE_NLS@
|
||||
VERSION = @VERSION@
|
||||
YACC = @YACC@
|
||||
install_sh = @install_sh@
|
||||
l = @l@
|
||||
|
||||
|
||||
AUTOMAKE_OPTIONS = gnits
|
||||
|
||||
SUITE = suite.at dd.at m4sh.at
|
||||
|
||||
EXTRA_DIST = $(SUITE) testsuite
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH
|
||||
|
||||
|
||||
TESTS = testsuite
|
||||
|
||||
DISTCLEANFILES = atconfig
|
||||
subdir = tests/general
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
CONFIG_CLEAN_FILES = atconfig
|
||||
DIST_SOURCES =
|
||||
DIST_COMMON = Makefile.am Makefile.in atconfig.in configure \
|
||||
configure.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnits tests/general/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
atconfig: $(top_builddir)/config.status atconfig.in
|
||||
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
check-TESTS: $(TESTS)
|
||||
@failed=0; all=0; xfail=0; xpass=0; \
|
||||
srcdir=$(srcdir); export srcdir; \
|
||||
list='$(TESTS)'; \
|
||||
if test -n "$$list"; then \
|
||||
for tst in $$list; do \
|
||||
if test -f ./$$tst; then dir=./; \
|
||||
elif test -f $$tst; then dir=; \
|
||||
else dir="$(srcdir)/"; fi; \
|
||||
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*" $$tst "*) \
|
||||
xpass=`expr $$xpass + 1`; \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "XPASS: $$tst"; \
|
||||
;; \
|
||||
*) \
|
||||
echo "PASS: $$tst"; \
|
||||
;; \
|
||||
esac; \
|
||||
elif test $$? -ne 77; then \
|
||||
all=`expr $$all + 1`; \
|
||||
case " $(XFAIL_TESTS) " in \
|
||||
*" $$tst "*) \
|
||||
xfail=`expr $$xfail + 1`; \
|
||||
echo "XFAIL: $$tst"; \
|
||||
;; \
|
||||
*) \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "FAIL: $$tst"; \
|
||||
;; \
|
||||
esac; \
|
||||
fi; \
|
||||
done; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
if test "$$xfail" -eq 0; then \
|
||||
banner="All $$all tests passed"; \
|
||||
else \
|
||||
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
|
||||
fi; \
|
||||
else \
|
||||
if test "$$xpass" -eq 0; then \
|
||||
banner="$$failed of $$all tests failed"; \
|
||||
else \
|
||||
banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dashes=`echo "$$banner" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
echo "$$dashes"; \
|
||||
test "$$failed" -eq 0; \
|
||||
fi
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pR $$d/$$file $(distdir) \
|
||||
|| exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
-rm -f Makefile.in
|
||||
mostlyclean-am: mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-generic clean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: tags check-TESTS distdir info-am info dvi-am dvi check-local \
|
||||
check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all install-strip \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
check-local: atconfig
|
||||
|
||||
testsuite: $(SUITE) atgeneral.m4
|
||||
$(M4) -I $(srcdir) atgeneral.m4 suite.at > $@-t1
|
||||
sed 's/[ ]*$$//;/^$$/N;/\n$$/D' $@-t1 > $@-tmp
|
||||
rm -f $@-t1
|
||||
chmod +x $@-tmp
|
||||
mv $@-tmp $@
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
447
tests/general/atgeneral.m4
Normal file
447
tests/general/atgeneral.m4
Normal file
@@ -0,0 +1,447 @@
|
||||
include(m4sh.m4) -*- Autoconf -*-
|
||||
# M4 macros used in building test suites.
|
||||
# Copyright 2000 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
# This script is part of Autotest. Unlimited permission to copy,
|
||||
# distribute and modify the testing scripts that are the output of
|
||||
# that Autotest script is given. You need not follow the terms of the
|
||||
# GNU General Public License when using or distributing such scripts,
|
||||
# even though portions of the text of Autotest appear in them. The
|
||||
# GNU General Public License (GPL) does govern all other use of the
|
||||
# material that constitutes the Autotest.
|
||||
#
|
||||
# Certain portions of the Autotest source text are designed to be
|
||||
# copied (in certain cases, depending on the input) into the output of
|
||||
# Autotest. We call these the "data" portions. The rest of the
|
||||
# Autotest source text consists of comments plus executable code that
|
||||
# decides which of the data portions to output in any given case. We
|
||||
# call these comments and executable code the "non-data" portions.
|
||||
# Autotest never copies any of the non-data portions into its output.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of Autotest
|
||||
# released by the Free Software Foundation. When you make and
|
||||
# distribute a modified version of Autotest, you may extend this
|
||||
# special exception to the GPL to apply to your modified version as
|
||||
# well, *unless* your modified version has the potential to copy into
|
||||
# its output some of the text that was the non-data portion of the
|
||||
# version that you started with. (In other words, unless your change
|
||||
# moves or copies text from the non-data portions to the data
|
||||
# portions.) If your modification has such potential, you must delete
|
||||
# any notice of this special exception to the GPL from your modified
|
||||
# version.
|
||||
|
||||
|
||||
m4_define([AT_DEFINE], m4_defn([m4_define]))
|
||||
m4_define([AT_INCLUDE], m4_defn([m4_include]))
|
||||
m4_define([AT_SHIFT], m4_defn([m4_shift]))
|
||||
m4_define([AT_UNDEFINE], m4_defn([m4_undefine]))
|
||||
|
||||
|
||||
|
||||
# Use of diversions:
|
||||
#
|
||||
# - DEFAULT
|
||||
# Overall initialization, value of $at_tests_all.
|
||||
# - OPTIONS
|
||||
# Option processing
|
||||
# - HELP
|
||||
# Help message. Of course it is useless, you could just push into
|
||||
# OPTIONS, but that's much clearer this way.
|
||||
# - SETUP
|
||||
# Be ready to run the tests.
|
||||
# - TESTS
|
||||
# The core of the test suite, the ``normal'' diversion.
|
||||
# - TAIL
|
||||
# tail of the core for;case, overall wrap up, generation of debugging
|
||||
# scripts and statistics.
|
||||
#
|
||||
# - TEST
|
||||
# for each test group: proper code, to reinsert between cleanups;
|
||||
# undiverted into TESTS once at_data_files diverted.
|
||||
|
||||
m4_define([_m4_divert(DEFAULT)], 0)
|
||||
m4_define([_m4_divert(OPTIONS)], 10)
|
||||
m4_define([_m4_divert(HELP)], 20)
|
||||
m4_define([_m4_divert(SETUP)], 30)
|
||||
m4_define([_m4_divert(TESTS)], 50)
|
||||
m4_define([_m4_divert(TAIL)], 60)
|
||||
|
||||
m4_define([_m4_divert(TEST)], 100)
|
||||
|
||||
m4_divert_push([TESTS])
|
||||
m4_divert_push([KILL])
|
||||
|
||||
|
||||
# AT_LINE
|
||||
# -------
|
||||
# Return the current file sans directory, a colon, and the current line.
|
||||
AT_DEFINE([AT_LINE],
|
||||
[m4_patsubst(__file__, ^.*/\(.*\), \1):__line__])
|
||||
|
||||
|
||||
# AT_INIT(PROGRAM)
|
||||
# ----------------
|
||||
# Begin testing suite, using PROGRAM to check version. The search path
|
||||
# should be already preset so the proper executable will be selected.
|
||||
AT_DEFINE([AT_INIT],
|
||||
[AT_DEFINE([AT_ordinal], 0)
|
||||
m4_divert_push([DEFAULT])dnl
|
||||
#! /bin/sh
|
||||
|
||||
AS_SHELL_SANITIZE
|
||||
|
||||
. ./atconfig
|
||||
# Use absolute file notations, as the test might change directories.
|
||||
at_srcdir=`cd "$srcdir" && pwd`
|
||||
at_top_srcdir=`cd "$top_srcdir" && pwd`
|
||||
|
||||
if test -n "$AUTOTEST_PATH"; then
|
||||
export PATH; PATH=`pwd`:`cd "$AUTOTEST_PATH" && pwd`:$PATH
|
||||
else
|
||||
export PATH; PATH=`pwd`:$PATH
|
||||
fi
|
||||
|
||||
test -f atlocal && . ./atlocal
|
||||
|
||||
# -e sets to true
|
||||
at_stop_on_error=false;
|
||||
# Shall we save and check stdout and stderr?
|
||||
# -n sets to false
|
||||
at_check_stds=:;
|
||||
# Shall we be verbose?
|
||||
at_verbose=:
|
||||
# Shall we keep the debug scripts? Must be `:' when testsuite is
|
||||
# run by a debug script, so that the script doesn't remove itself.
|
||||
at_debug=false
|
||||
# Display help message?
|
||||
at_help=false
|
||||
# Tests to run
|
||||
at_tests=
|
||||
m4_divert([OPTIONS])dnl Other vars inserted here.
|
||||
|
||||
while test $[#] -gt 0; do
|
||||
case $[1] in
|
||||
--help | -h) at_help=:; break ;;
|
||||
--version) echo "$[0] ($at_package) $at_version"; exit 0 ;;
|
||||
|
||||
-d) at_debug=:;;
|
||||
-e) at_stop_on_error=:;;
|
||||
-n) at_check_stds=false;;
|
||||
-v) at_verbose=echo;;
|
||||
-x) at_traceon='set -vx'; at_traceoff='set +vx'; at_check_stds=false;;
|
||||
|
||||
[[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
|
||||
at_tests="$at_tests$[1] ";;
|
||||
|
||||
*) echo 1>&2 "Try \`$[0] --help' for more information."; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
test -z "$at_tests" && at_tests=$at_tests_all
|
||||
|
||||
# Help message.
|
||||
# Display only the title of selected tests.
|
||||
if $at_help; then
|
||||
cat <<EOF
|
||||
Usage: $[0] [[OPTION]]... [[TESTS]]
|
||||
|
||||
Run all the tests, or the selected TESTS.
|
||||
|
||||
Options:
|
||||
-h Display this help message and the list of tests
|
||||
-e Abort the full suite and inhibit normal clean up if a test fails
|
||||
-n Do not redirect stdout and stderr and do not test their contents
|
||||
-v Force more detailed output, default for debugging scripts
|
||||
-x Have the shell to trace command execution; also implies option -n
|
||||
|
||||
Tests:
|
||||
EOF
|
||||
# "1 42 45 " => " (1|42|45|dummy): "
|
||||
at_tests_pattern=`echo "$at_tests" | tr ' ' '|'`
|
||||
egrep -e " (${at_tests_pattern}dummy): " <<EOF
|
||||
m4_divert([HELP])dnl Help message inserted here.
|
||||
m4_divert([SETUP])dnl
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# To check whether a test succeeded or not, we compare an expected
|
||||
# output with a reference. In the testing suite, we just need `cmp'
|
||||
# but in debugging scripts, we want more information, so we prefer
|
||||
# `diff -u'. Nonetheless we will use `diff' only, because in DOS
|
||||
# environments, `diff' considers that two files are equal included
|
||||
# when there are only differences on the coding of new lines. `cmp'
|
||||
# does not.
|
||||
#
|
||||
# Finally, not all the `diff' support `-u', and some, like Tru64, even
|
||||
# refuse to `diff' /dev/null.
|
||||
: >empty
|
||||
|
||||
if diff -u empty empty >/dev/null 2>&1; then
|
||||
at_diff='diff -u'
|
||||
else
|
||||
at_diff='diff'
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Each generated debugging script, containing a single test group, cleans
|
||||
# up files at the beginning only, not at the end. This is so we can repeat
|
||||
# the script many times and browse left over files. To cope with such left
|
||||
# over files, the full test suite cleans up both before and after test groups.
|
||||
|
||||
if $1 --version | grep "$at_package.*$at_version" >/dev/null; then
|
||||
at_banner="Test suite for $at_package, version $at_version"
|
||||
at_dashes=`echo $at_banner | sed s/./=/g`
|
||||
echo "$at_dashes"
|
||||
echo "$at_banner"
|
||||
echo "$at_dashes"
|
||||
else
|
||||
echo '======================================================='
|
||||
echo 'ERROR: Not using the proper version, no tests performed'
|
||||
echo '======================================================='
|
||||
exit 1
|
||||
fi
|
||||
|
||||
at_failed_list=
|
||||
at_ignore_count=0
|
||||
at_test_count=0
|
||||
m4_divert([TESTS])dnl
|
||||
|
||||
for at_test in $at_tests
|
||||
do
|
||||
at_status=0;
|
||||
case $at_test in
|
||||
m4_divert([TAIL])[]dnl
|
||||
esac
|
||||
at_test_count=`expr 1 + $at_test_count`
|
||||
$at_verbose $at_n " $at_test. $srcdir/`cat at-setup-line`: $at_c"
|
||||
case $at_status in
|
||||
0) echo ok
|
||||
;;
|
||||
77) echo "ignored near \``cat at-check-line`'"
|
||||
at_ignore_count=`expr $at_ignore_count + 1`
|
||||
;;
|
||||
*) echo "FAILED near \``cat at-check-line`'"
|
||||
at_failed_list="$at_failed_list $at_test"
|
||||
$at_stop_on_error && break
|
||||
;;
|
||||
esac
|
||||
$at_debug || rm -rf $at_data_files
|
||||
done
|
||||
|
||||
# Wrap up the testing suite with summary statistics.
|
||||
|
||||
rm -f at-check-line at-setup-line
|
||||
at_fail_count=0
|
||||
if test -z "$at_failed_list"; then
|
||||
if test "$at_ignore_count" = 0; then
|
||||
at_banner="All $at_test_count tests were successful"
|
||||
else
|
||||
at_banner="All $at_test_count tests were successful ($at_ignore_count ignored)"
|
||||
fi
|
||||
elif test $at_debug = false; then
|
||||
# Remove any debugging script resulting from a previous run.
|
||||
rm -f debug-*.sh
|
||||
echo
|
||||
echo $at_n "Writing \`debug-NN.sh' scripts, NN =$at_c"
|
||||
for at_group in $at_failed_list; do
|
||||
echo $at_n " $at_group$at_c"
|
||||
( echo "#! /bin/sh"
|
||||
echo 'exec '"$[0]"' -v -d '"$at_group"' ${1+"$[@]"}'
|
||||
echo 'exit 1'
|
||||
) >debug-$at_group.sh
|
||||
chmod +x debug-$at_group.sh
|
||||
at_fail_count=`expr $at_fail_count + 1`
|
||||
done
|
||||
echo ', done'
|
||||
if $at_stop_on_error; then
|
||||
at_banner='ERROR: One of the tests failed, inhibiting subsequent tests'
|
||||
else
|
||||
at_banner="ERROR: Suite unsuccessful, $at_fail_count of $at_test_count tests failed"
|
||||
fi
|
||||
fi
|
||||
at_dashes=`echo $at_banner | sed s/./=/g`
|
||||
echo
|
||||
echo "$at_dashes"
|
||||
echo "$at_banner"
|
||||
echo "$at_dashes"
|
||||
|
||||
if test $at_debug = false && test -n "$at_failed_list"; then
|
||||
echo
|
||||
echo 'When reporting failed tests to maintainers, do not merely list test'
|
||||
echo 'numbers, as the numbering changes between releases and pretests.'
|
||||
echo 'Be careful to give at least all the information you got about them.'
|
||||
echo 'You may investigate any problem if you feel able to do so, in which'
|
||||
echo 'case the testsuite provide a good starting point.'
|
||||
echo 'information. Now, failed tests will be executed again, verbosely.'
|
||||
for at_group in $at_failed_list; do
|
||||
./debug-$at_group.sh
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
m4_divert_pop()dnl
|
||||
m4_wrap([m4_divert_text([DEFAULT],
|
||||
[# List of the tests.
|
||||
at_tests_all="m4_for([i], 1, AT_ordinal, 1, [i ])"])])dnl
|
||||
])# AT_INIT
|
||||
|
||||
|
||||
|
||||
# AT_SETUP(DESCRIPTION)
|
||||
# ---------------------
|
||||
# Start a group of related tests, all to be executed in the same subshell.
|
||||
# The group is testing what DESCRIPTION says.
|
||||
AT_DEFINE([AT_SETUP],
|
||||
[m4_define([AT_ordinal], m4_eval(AT_ordinal + 1))
|
||||
m4_divert_text([HELP],
|
||||
[m4_format([ %3d: %-15s %s], AT_ordinal, AT_LINE, [$1])])
|
||||
m4_pushdef([AT_data_files], [stdout stderr ])
|
||||
m4_divert_push([TESTS])dnl
|
||||
AT_ordinal )
|
||||
dnl Here will be inserted the definition of at_data_files.
|
||||
m4_divert([TEST])[]dnl
|
||||
rm -rf $at_data_files
|
||||
echo AT_LINE >at-setup-line
|
||||
$at_verbose 'testing $1'
|
||||
$at_verbose $at_n " $at_c"
|
||||
if test $at_verbose = echo; then
|
||||
echo "AT_ordinal. $srcdir/AT_LINE..."
|
||||
else
|
||||
echo $at_n "m4_substr(AT_ordinal. $srcdir/AT_LINE , 0, 30)[]$at_c"
|
||||
fi
|
||||
(
|
||||
$at_traceon
|
||||
])
|
||||
|
||||
|
||||
# AT_CLEANUP_FILE_IFELSE(FILE, IF-REGISTERED, IF-NOT-REGISTERED)
|
||||
# --------------------------------------------------------------
|
||||
AT_DEFINE([AT_CLEANUP_FILE_IFELSE],
|
||||
[ifelse(m4_regexp(AT_data_files, m4_patsubst([ $1 ], [\([\[\]*.]\)], [\\\1])),
|
||||
-1,
|
||||
[$3], [$2])])
|
||||
|
||||
|
||||
# AT_CLEANUP_FILE(FILE)
|
||||
# ---------------------
|
||||
# Register FILE for AT_CLEANUP.
|
||||
AT_DEFINE([AT_CLEANUP_FILE],
|
||||
[AT_CLEANUP_FILE_IFELSE([$1], [],
|
||||
[m4_append([AT_data_files], [$1 ])])])
|
||||
|
||||
|
||||
# AT_CLEANUP_FILES(FILES)
|
||||
# -----------------------
|
||||
# Declare a list of FILES to clean.
|
||||
AT_DEFINE([AT_CLEANUP_FILES],
|
||||
[m4_foreach([AT_File], m4_quote(m4_patsubst([$1], [ *], [,])),
|
||||
[AT_CLEANUP_FILE(AT_File)])])
|
||||
|
||||
|
||||
# AT_CLEANUP(FILES)
|
||||
# -----------------
|
||||
# Complete a group of related tests, recursively remove those FILES
|
||||
# created within the test. There is no need to list stdout, stderr,
|
||||
# nor files created with AT_DATA.
|
||||
AT_DEFINE([AT_CLEANUP],
|
||||
[AT_CLEANUP_FILES([$1])dnl
|
||||
$at_traceoff
|
||||
)
|
||||
at_status=$?
|
||||
;;
|
||||
m4_divert([TESTS])[]dnl
|
||||
at_data_files="AT_data_files"
|
||||
m4_undivert([TEST])[]dnl
|
||||
m4_popdef([AT_data_files])dnl
|
||||
m4_divert_pop()dnl
|
||||
])# AT_CLEANUP
|
||||
|
||||
|
||||
# AT_DATA(FILE, CONTENTS)
|
||||
# -----------------------
|
||||
# Initialize an input data FILE with given CONTENTS, which should end with
|
||||
# an end of line.
|
||||
# This macro is not robust to active symbols in CONTENTS *on purpose*.
|
||||
# If you don't want CONTENT to be evaluated, quote it twice.
|
||||
AT_DEFINE([AT_DATA],
|
||||
[AT_CLEANUP_FILES([$1])dnl
|
||||
cat >$1 <<'_ATEOF'
|
||||
$2[]_ATEOF
|
||||
])
|
||||
|
||||
|
||||
# AT_CHECK(COMMANDS, [STATUS], STDOUT, STDERR)
|
||||
# --------------------------------------------
|
||||
# Execute a test by performing given shell COMMANDS. These commands
|
||||
# should normally exit with STATUS, while producing expected STDOUT and
|
||||
# STDERR contents. The special word `expout' for STDOUT means that file
|
||||
# `expout' contents has been set to the expected stdout. The special word
|
||||
# `experr' for STDERR means that file `experr' contents has been set to
|
||||
# the expected stderr.
|
||||
# STATUS is not checked if it is empty.
|
||||
# STDOUT and STDERR can be the special value `ignore', in which case
|
||||
# their content is not checked.
|
||||
AT_DEFINE([AT_CHECK],
|
||||
[$at_traceoff
|
||||
$at_verbose "$srcdir/AT_LINE: m4_patsubst([$1], [\([\"`$]\)], \\\1)"
|
||||
echo AT_LINE >at-check-line
|
||||
$at_check_stds && exec 5>&1 6>&2 1>stdout 2>stderr
|
||||
$at_traceon
|
||||
$1
|
||||
ifelse([$2], [], [],
|
||||
[at_status=$?
|
||||
if test $at_status != $2; then
|
||||
$at_verbose "Exit code was $at_status, expected $2" >&6
|
||||
dnl Maybe there was an important message to read before it died.
|
||||
$at_verbose = echo && $at_check_stds && cat stderr >&6
|
||||
dnl Preserve exit code 77.
|
||||
test $at_status = 77 && exit 77
|
||||
exit 1
|
||||
fi
|
||||
])dnl
|
||||
$at_traceoff
|
||||
if $at_check_stds; then
|
||||
dnl Restore stdout to fd1 and stderr to fd2.
|
||||
exec 1>&5 2>&6
|
||||
dnl If not verbose, neutralize the output of diff.
|
||||
test $at_verbose = : && exec 1>/dev/null 2>/dev/null
|
||||
at_failed=false;
|
||||
m4_case([$4],
|
||||
ignore, [$at_verbose = echo && cat stderr;:],
|
||||
experr, [AT_CLEANUP_FILE([experr])dnl
|
||||
$at_diff experr stderr || at_failed=:],
|
||||
[], [$at_diff empty stderr || at_failed=:],
|
||||
[echo $at_n "m4_patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr || at_failed=:])
|
||||
m4_case([$3],
|
||||
ignore, [test $at_verbose = echo && cat stdout;:],
|
||||
expout, [AT_CLEANUP_FILES([expout])dnl
|
||||
$at_diff expout stdout || at_failed=:],
|
||||
[], [$at_diff empty stdout || at_failed=:],
|
||||
[echo $at_n "m4_patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout || at_failed=:])
|
||||
if $at_failed; then
|
||||
exit 1
|
||||
else
|
||||
:
|
||||
fi
|
||||
fi
|
||||
$at_traceon
|
||||
])# AT_CHECK
|
||||
50
tests/general/dd.at
Normal file
50
tests/general/dd.at
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- autoconf -*-
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Executables (autoheader, autoupdate...)
|
||||
|
||||
EOF
|
||||
|
||||
AT_SETUP([dd's skip, seek, and conv=notrunc options])
|
||||
|
||||
AT_DATA(in, [[12345*7
|
||||
]])
|
||||
AT_DATA(out, [[abcdefghijklmnop
|
||||
]])
|
||||
|
||||
AT_CHECK([dd bs=1 skip=1 seek=2 conv=notrunc count=3 if=in of=out], 0, [],
|
||||
[3+0 records in
|
||||
3+0 records out
|
||||
])
|
||||
AT_CHECK([cat out], 0, [ab234fghijklmnop
|
||||
])
|
||||
|
||||
AT_CHECK([dd bskip=5 bseek=9 conv=notrunc count=1 if=in of=out], 0, [],
|
||||
[0+1 records in
|
||||
0+1 records out
|
||||
])
|
||||
AT_CHECK([cat out], 0, [ab234fghi*7
|
||||
mnop
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
# ======================================================
|
||||
AT_SETUP([dd])
|
||||
AT_SETUP([dd's new bskip and bseek options])
|
||||
|
||||
AT_DATA(in, [[1*3
|
||||
]])
|
||||
AT_DATA(out, [[abcde
|
||||
]])
|
||||
|
||||
AT_CHECK([dd bskip=1 bseek=2 count=1 if=in of=out], 0, [],
|
||||
[0+1 records in
|
||||
0+1 records out
|
||||
])
|
||||
AT_CHECK([cat out], 0, [ab*3
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -12,13 +12,13 @@ maint_gen = 1a.I1 1a.I2 1a.X 1b.I1 1b.I2 1b.X 1c.I1 1c.I2 1c.X 1d.I1 1d.I2 \
|
||||
5k.I2 5k.X 5l.I1 5l.I2 5l.X 5m.I1 5m.I2 5m.X 6a.I1 6a.I2 6a.X 6b.I1 6b.I2 \
|
||||
6b.X 6c.I1 6c.I2 6c.X 7a.I1 7a.I2 7a.X 8a.I1 8a.I2 8a.X 8b.I1 8b.I2 8b.X \
|
||||
9a.I1 9a.I2 9a.X trailing-sp.I1 trailing-sp.I2 trailing-sp.X sp-vs-blank.I1 \
|
||||
sp-vs-blank.I2 sp-vs-blank.X
|
||||
sp-vs-blank.I2 sp-vs-blank.X 8-bit-t.I1 8-bit-t.I2 8-bit-t.X
|
||||
run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 2a.O \
|
||||
2a.E 2b.O 2b.E 2c.O 2c.E 3a.O 3a.E 4a.O 4a.E 4b.O 4b.E 4c.O 4c.E 4d.O 4d.E \
|
||||
4e.O 4e.E 5a.O 5a.E 5b.O 5b.E 5c.O 5c.E 5d.O 5d.E 5e.O 5e.E 5f.O 5f.E 5g.O \
|
||||
5g.E 5h.O 5h.E 5i.O 5i.E 5j.O 5j.E 5k.O 5k.E 5l.O 5l.E 5m.O 5m.E 6a.O 6a.E \
|
||||
6b.O 6b.E 6c.O 6c.E 7a.O 7a.E 8a.O 8a.E 8b.O 8b.E 9a.O 9a.E trailing-sp.O \
|
||||
trailing-sp.E sp-vs-blank.O sp-vs-blank.E
|
||||
trailing-sp.E sp-vs-blank.O sp-vs-blank.E 8-bit-t.O 8-bit-t.E
|
||||
##test-files-end
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
|
||||
@@ -127,14 +127,14 @@ maint_gen = 1a.I1 1a.I2 1a.X 1b.I1 1b.I2 1b.X 1c.I1 1c.I2 1c.X 1d.I1 1d.I2 \
|
||||
5k.I2 5k.X 5l.I1 5l.I2 5l.X 5m.I1 5m.I2 5m.X 6a.I1 6a.I2 6a.X 6b.I1 6b.I2 \
|
||||
6b.X 6c.I1 6c.I2 6c.X 7a.I1 7a.I2 7a.X 8a.I1 8a.I2 8a.X 8b.I1 8b.I2 8b.X \
|
||||
9a.I1 9a.I2 9a.X trailing-sp.I1 trailing-sp.I2 trailing-sp.X sp-vs-blank.I1 \
|
||||
sp-vs-blank.I2 sp-vs-blank.X
|
||||
sp-vs-blank.I2 sp-vs-blank.X 8-bit-t.I1 8-bit-t.I2 8-bit-t.X
|
||||
|
||||
run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 2a.O \
|
||||
2a.E 2b.O 2b.E 2c.O 2c.E 3a.O 3a.E 4a.O 4a.E 4b.O 4b.E 4c.O 4c.E 4d.O 4d.E \
|
||||
4e.O 4e.E 5a.O 5a.E 5b.O 5b.E 5c.O 5c.E 5d.O 5d.E 5e.O 5e.E 5f.O 5f.E 5g.O \
|
||||
5g.E 5h.O 5h.E 5i.O 5i.E 5j.O 5j.E 5k.O 5k.E 5l.O 5l.E 5m.O 5m.E 6a.O 6a.E \
|
||||
6b.O 6b.E 6c.O 6c.E 7a.O 7a.E 8a.O 8a.E 8b.O 8b.E 9a.O 9a.E trailing-sp.O \
|
||||
trailing-sp.E sp-vs-blank.O sp-vs-blank.E
|
||||
trailing-sp.E sp-vs-blank.O sp-vs-blank.E 8-bit-t.O 8-bit-t.E
|
||||
|
||||
|
||||
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
|
||||
|
||||
@@ -2,6 +2,13 @@ package Test;
|
||||
require 5.002;
|
||||
use strict;
|
||||
|
||||
my $delim = chr 0247;
|
||||
sub t_subst ($)
|
||||
{
|
||||
(my $s = $_[0]) =~ s/:/$delim/g;
|
||||
return $s;
|
||||
}
|
||||
|
||||
my @tv = (
|
||||
# test name
|
||||
# flags file-1 file-2 expected output expected return code
|
||||
@@ -105,6 +112,11 @@ my @tv = (
|
||||
# fail on e.g. Linux systems, because the input to join isn't sorted.
|
||||
# ['lc-collate', '', ["a 1a\nB 1B\n", "B 2B\n"], "B 1B 2B\n", 0],
|
||||
|
||||
# Based on a report from Antonio Rendas. Fixed in 2.0.9.
|
||||
['8-bit-t', t_subst "-t:",
|
||||
[t_subst "a:1\nb:1\n", t_subst "a:2:\nb:2:\n"],
|
||||
t_subst "a:1:2:\nb:1:2:\n", 0],
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -684,8 +684,26 @@ else
|
||||
esac
|
||||
fi
|
||||
test -s sp-vs-blank.E || rm -f sp-vs-blank.E
|
||||
$xx -t§ $srcdir/8-bit-t.I1 $srcdir/8-bit-t.I2 > 8-bit-t.O 2> 8-bit-t.E
|
||||
code=$?
|
||||
if test $code != 0; then
|
||||
$echo "Test 8-bit-t failed: ../../src/join return code $code differs from expected value 0" 1>&2
|
||||
errors=`expr $errors + 1`
|
||||
else
|
||||
cmp 8-bit-t.O $srcdir/8-bit-t.X > /dev/null 2>&1
|
||||
case $? in
|
||||
0) if test "$VERBOSE"; then $echo "passed 8-bit-t"; fi;;
|
||||
1) $echo "Test 8-bit-t failed: files 8-bit-t.O and $srcdir/8-bit-t.X differ" 1>&2
|
||||
(diff -c 8-bit-t.O $srcdir/8-bit-t.X) 2> /dev/null
|
||||
errors=`expr $errors + 1`;;
|
||||
2) $echo "Test 8-bit-t may have failed." 1>&2
|
||||
$echo The command "cmp 8-bit-t.O $srcdir/8-bit-t.X" failed. 1>&2
|
||||
errors=`expr $errors + 1`;;
|
||||
esac
|
||||
fi
|
||||
test -s 8-bit-t.E || rm -f 8-bit-t.E
|
||||
if test $errors = 0; then
|
||||
$echo Passed all 37 tests. 1>&2
|
||||
$echo Passed all 38 tests. 1>&2
|
||||
else
|
||||
$echo Failed $errors tests. 1>&2
|
||||
fi
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.2 gnits
|
||||
|
||||
TESTS = rt-1 time-1 symlink-slash
|
||||
TESTS = rt-1 time-1 symlink-slash follow-slink
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
|
||||
@@ -118,7 +118,7 @@ l = @l@
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.2 gnits
|
||||
|
||||
TESTS = rt-1 time-1 symlink-slash
|
||||
TESTS = rt-1 time-1 symlink-slash follow-slink
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
|
||||
28
tests/ls/follow-slink
Executable file
28
tests/ls/follow-slink
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# make sure ls -L always follows symlinks
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
ls --version
|
||||
fi
|
||||
|
||||
pwd=`pwd`
|
||||
tmp=follow-sl.$$
|
||||
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
|
||||
ln -s link link || framework_failure=1
|
||||
|
||||
if test $framework_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
(exit 1); exit
|
||||
fi
|
||||
|
||||
fail=0
|
||||
|
||||
ls -L link 2> /dev/null && fail=1
|
||||
|
||||
(exit $fail); exit
|
||||
@@ -1,7 +1,7 @@
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
|
||||
AUTOMAKE_OPTIONS = 1.1 gnits
|
||||
|
||||
TESTS = p-1 p-2 special-1 perm parents
|
||||
TESTS = p-1 p-2 special-1 perm parents t-slash
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
srcdir=$(srcdir) \
|
||||
|
||||
@@ -118,7 +118,7 @@ l = @l@
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.1 gnits
|
||||
|
||||
TESTS = p-1 p-2 special-1 perm parents
|
||||
TESTS = p-1 p-2 special-1 perm parents t-slash
|
||||
EXTRA_DIST = $(TESTS)
|
||||
TESTS_ENVIRONMENT = \
|
||||
srcdir=$(srcdir) \
|
||||
|
||||
@@ -27,17 +27,9 @@ if test $framework_failure = 1; then
|
||||
(exit 1); exit
|
||||
fi
|
||||
|
||||
fail=0
|
||||
. $abs_srcdir/../sticky-check
|
||||
|
||||
p=`ls -ld e-dir|sed 's/ .*//'`
|
||||
case $p in drwx------);; *) fail=1;; esac
|
||||
if test $fail = 1; then
|
||||
cat <<EOF >&2
|
||||
$0: Since it looks like you're running this test in a directory with
|
||||
the sticky bit set, we're skipping this test.
|
||||
EOF
|
||||
(exit 77); exit
|
||||
fi
|
||||
fail=0
|
||||
|
||||
# Make sure `mkdir -p existing-dir' succeeds
|
||||
# and that `mkdir existing-dir' fails.
|
||||
|
||||
@@ -40,7 +40,7 @@ for p in empty -p; do
|
||||
|
||||
old_IFS=$IFS
|
||||
IFS=':'
|
||||
set - `echo "$tests"|tr -d '\012'|sed 's/^ *//;s/ *:/:/g;s/: */:/g'`
|
||||
set - `(echo "$tests"|tr -d '\012'; echo)|sed 's/^ *//;s/ *:/:/g;s/: */:/g'`
|
||||
IFS=$old_IFS
|
||||
|
||||
while :; do
|
||||
|
||||
33
tests/mkdir/t-slash
Executable file
33
tests/mkdir/t-slash
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# Ensure that mkdir works with arguments specified with and without
|
||||
# a trailing slash.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
mkdir --version
|
||||
fi
|
||||
|
||||
pwd=`pwd`
|
||||
tmp=t-slash.$$
|
||||
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
|
||||
|
||||
if test $framework_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
(exit 1); exit
|
||||
fi
|
||||
|
||||
fail=0
|
||||
|
||||
mkdir -p dir/ || fail=1
|
||||
test -d dir || fail=1
|
||||
|
||||
# This failed on NetBSD for fileutils-4.0.33.
|
||||
mkdir d2/ || fail=1
|
||||
test -d d2 || fail=1
|
||||
|
||||
(exit $fail); exit
|
||||
@@ -23,7 +23,8 @@ null=.mv-null
|
||||
dir=.mv-dir
|
||||
|
||||
framework_failure=0
|
||||
|
||||
mkdir $tmp || framework_failure=1
|
||||
cd $tmp || framework_failure=1
|
||||
rm -f $null || framework_failure=1
|
||||
mknod $null p || framework_failure=1
|
||||
mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure=1
|
||||
|
||||
@@ -9,4 +9,4 @@ TESTS_ENVIRONMENT = \
|
||||
PATH=`pwd`/../../src:$$PATH \
|
||||
PROG=tail
|
||||
|
||||
TESTS = assert
|
||||
TESTS = assert assert-2
|
||||
|
||||
46
tests/tail-2/assert-2
Executable file
46
tests/tail-2/assert-2
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# This variant of `assert' would get a UMR reliably in 2.0.9.
|
||||
# Due to a race condition in the test, the `assert' script would get
|
||||
# the UMR on Solaris only some of the time, and not at all on Linux/GNU.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
tail --version
|
||||
fi
|
||||
|
||||
tmp=tail-as2.$$
|
||||
pwd=`pwd`
|
||||
trap "cd $pwd; rm -rf $tmp" 0 1 2 3 15
|
||||
|
||||
test_failure=0
|
||||
mkdir $tmp || test_failure=1
|
||||
cd $tmp || test_failure=1
|
||||
|
||||
if test $test_failure = 1; then
|
||||
echo 'failure in testing framework'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ok='ok ok ok'
|
||||
|
||||
touch a
|
||||
tail --follow=name a foo > err 2>&1 &
|
||||
tail_pid=$!
|
||||
# Arrange for the tail process to die after 12 seconds.
|
||||
(sleep 12; kill $tail_pid) &
|
||||
echo $ok > f
|
||||
echo sleeping for 7 seconds...
|
||||
sleep 7
|
||||
mv f foo
|
||||
|
||||
# echo waiting....
|
||||
wait
|
||||
|
||||
case "`cat err`" in
|
||||
*$ok) fail=0;;
|
||||
*) fail=1;;
|
||||
esac
|
||||
|
||||
test $fail = 1 && cat err
|
||||
|
||||
exit $fail
|
||||
@@ -25,7 +25,7 @@ set x `ls -t $t1 $t2`
|
||||
test "$*" = "x $t2 $t1" || fail=1
|
||||
|
||||
chmod 0 $t1
|
||||
touch -c $t1 || fail=1
|
||||
touch -d tomorrow -c $t1 || fail=1
|
||||
|
||||
set x `ls -t $t1 $t2`
|
||||
test "$*" = "x $t1 $t2" || fail=1
|
||||
|
||||
Reference in New Issue
Block a user