Compare commits

...

127 Commits

Author SHA1 Message Date
Jim Meyering
6b3f36f935 . 1997-01-27 02:18:56 +00:00
Jim Meyering
1010c1f580 . 1997-01-26 20:01:11 +00:00
Jim Meyering
7490632078 . 1997-01-26 19:04:03 +00:00
Jim Meyering
537381d409 . 1997-01-26 19:03:30 +00:00
Jim Meyering
3a01be66d4 . 1997-01-26 19:02:52 +00:00
Jim Meyering
8a87c1a169 . 1997-01-26 19:01:54 +00:00
Jim Meyering
07b07ca07c . 1997-01-26 18:57:36 +00:00
Jim Meyering
26a10a8026 (usage): Fix typo (--writeable -> --writable) in help output 1997-01-26 18:51:44 +00:00
Jim Meyering
072c1efe39 (parse_options): Add quotes to make messages identical. 1997-01-26 18:50:33 +00:00
Jim Meyering
c38939be8e . 1997-01-26 07:03:50 +00:00
Jim Meyering
e48314ac1b bracket prototype with PARAMS 1997-01-26 06:23:06 +00:00
Jim Meyering
7c94dda02d . 1997-01-26 05:57:12 +00:00
Jim Meyering
fe6c711f48 Restore dcl of free. with obstacks, you need it. 1997-01-26 05:57:04 +00:00
Jim Meyering
2c7c121c13 Revert last change. With obstack, dcl of free is *required*. 1997-01-26 05:55:02 +00:00
Jim Meyering
7a8b837062 . 1997-01-26 05:13:26 +00:00
Jim Meyering
25eb22e88f . 1997-01-26 05:08:56 +00:00
Jim Meyering
7f798f5f4f (count_entry): Fix blatant bug (typo?) that made
--megabytes report numbers in units of kilobytes.
Reported by Galen Hazelwood.
1997-01-26 05:05:06 +00:00
Jim Meyering
9d502e7240 . 1997-01-26 05:04:35 +00:00
Jim Meyering
c1ecd3afea . 1997-01-26 04:52:42 +00:00
Jim Meyering
a95088a5ea (print_factors): Reflect changes to xstrtoul interface. 1997-01-26 04:52:32 +00:00
Jim Meyering
fb43ebcbae . 1997-01-26 04:48:39 +00:00
Jim Meyering
73ed11f2b7 (parse_options): Remove unnecessary goto and label. 1997-01-26 04:48:29 +00:00
Jim Meyering
6390686aab . 1997-01-26 04:44:03 +00:00
Jim Meyering
3e0c759c3a (parse_obsolescent_option): Comment. 1997-01-26 04:43:42 +00:00
Jim Meyering
10f565971b . 1997-01-26 04:30:49 +00:00
Jim Meyering
e1ea22da05 (is_ancestor): Add it. 1997-01-26 04:30:39 +00:00
Jim Meyering
1e71247ea0 . 1997-01-26 04:14:26 +00:00
Jim Meyering
46f650f6b0 . 1997-01-26 04:13:46 +00:00
Jim Meyering
74bca24efe . 1997-01-26 04:12:46 +00:00
Jim Meyering
e385fd1e4c . 1997-01-26 04:12:20 +00:00
Jim Meyering
239899ae58 Interpret `input arg is a hash
reference' as meaning that the tested program will read no input.
Most of the tests for the date program use this feature.
Also for date, the generated script now reflects specification
(in Test.pm) of default and per-test environment settings.
1997-01-26 03:12:41 +00:00
Jim Meyering
2a3863e2b8 . 1997-01-26 03:01:01 +00:00
Jim Meyering
bd30083472 . 1997-01-26 02:59:50 +00:00
Jim Meyering
01839f9f82 remove trailing blanks 1997-01-25 13:50:24 +00:00
Jim Meyering
6f807a8598 remove now-spurious junk 1997-01-25 13:45:55 +00:00
Jim Meyering
94439345f5 . 1997-01-25 13:38:54 +00:00
Jim Meyering
e9dc554349 (noinst_HEADERS): Add getdate.h. 1997-01-25 13:38:49 +00:00
Jim Meyering
68ed0308cf . 1997-01-25 06:59:56 +00:00
Jim Meyering
fb04070061 . 1997-01-25 06:54:19 +00:00
Jim Meyering
9200311684 . 1997-01-25 06:52:50 +00:00
Jim Meyering
dd374cd779 . 1997-01-25 06:46:53 +00:00
Jim Meyering
71076df2d8 . 1997-01-25 06:46:33 +00:00
Jim Meyering
a1a27df129 . 1997-01-25 06:45:38 +00:00
Jim Meyering
fd685e41d6 Move the code from configure.in into
this macro that resorts to looking for getgroups in -lbsd.
Set new shell variable, GETGROUPS_LIB (that callers should check),
if it is found there.
1997-01-25 06:45:32 +00:00
Jim Meyering
c672fc6df6 . 1997-01-25 06:43:47 +00:00
Jim Meyering
0a735b7b9e . 1997-01-25 06:43:16 +00:00
Jim Meyering
5aaadded9d . 1997-01-25 06:37:40 +00:00
Jim Meyering
a8bcd782c4 update for changed xstrtou?l 1997-01-25 06:21:24 +00:00
Jim Meyering
2be7ff8311 . 1997-01-25 06:17:20 +00:00
Jim Meyering
0894db7b3f (XSTRTOL_H): Undefine it. 1997-01-25 06:17:13 +00:00
Jim Meyering
d58a074dea . 1997-01-25 06:15:49 +00:00
Jim Meyering
d73bc3ca57 [!_STRTOL_ERROR]: Define the type `enum strtol_error'
only if it hasn't already been defined.
1997-01-25 06:15:18 +00:00
Jim Meyering
186d893f27 (__xstrtol): Change interpretation of
VALID_SUFFIXES == NULL vs VALID_SUFFIXES == "".  Use the former
when any suffix is valid, the later when no suffix is allowed.
1997-01-25 06:13:46 +00:00
Jim Meyering
edeada009c fix copyright filling 1997-01-25 06:11:48 +00:00
Jim Meyering
18195dd699 fix copyright filling 1997-01-25 06:11:22 +00:00
Jim Meyering
338b31ba60 . 1997-01-25 05:58:58 +00:00
Jim Meyering
562eb3d16d . 1997-01-25 05:56:52 +00:00
Jim Meyering
175fb661e0 (parse_long_options): Reset optind to zero
before just returning so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later.
1997-01-25 05:37:15 +00:00
Jim Meyering
50c04a9d3e (parse_obsolescent_option): Recognize and fail for
more malformed obsolescent options.  Makes for better diagnostics.
1997-01-24 02:11:52 +00:00
Jim Meyering
8a66d0dd57 . 1997-01-24 01:16:39 +00:00
Jim Meyering
1f678023d5 . 1997-01-23 05:15:14 +00:00
Jim Meyering
b66a30133f . 1997-01-23 04:12:43 +00:00
Jim Meyering
598a7bda46 . 1997-01-23 04:03:50 +00:00
Jim Meyering
0800b55642 . 1997-01-23 04:01:58 +00:00
Jim Meyering
5ac433d292 . 1997-01-23 04:00:19 +00:00
Jim Meyering
b22469537b . 1997-01-23 03:55:50 +00:00
Jim Meyering
591844b387 . 1997-01-23 03:47:20 +00:00
Jim Meyering
2611844743 (parse_options): New function.
(parse_obsolescent_option): New function.
(main): Use the new functions instead of open-coding them.
This better fixes the bug in handling obsolescent `+Nc' options.
General cleanup.
1997-01-23 03:38:23 +00:00
Jim Meyering
c04fc60484 . 1997-01-23 03:22:16 +00:00
Jim Meyering
ffb626613a . 1997-01-23 03:02:56 +00:00
Jim Meyering
3452006a53 . 1997-01-23 03:02:17 +00:00
Jim Meyering
161422b9b2 . 1997-01-23 02:45:08 +00:00
Jim Meyering
2091adbbb1 Update from GNU via Uli 1997-01-23 02:45:02 +00:00
Jim Meyering
ccbf5f37f1 . 1997-01-23 02:25:26 +00:00
Jim Meyering
ef2b6836fd revert last change 1997-01-23 02:23:44 +00:00
Jim Meyering
44386ac6ff . 1997-01-23 02:21:03 +00:00
Jim Meyering
5c7e1b6bee . 1997-01-23 02:18:00 +00:00
Jim Meyering
3266134b2a . 1997-01-23 02:16:55 +00:00
Jim Meyering
63571532a2 (AM_FUNC_MKTIME): Run tests for each of a few values
for the TZ environment variable.  Andre Novaes Cunha provided the
hairy TZ setting that exercized the Solaris tzset bug.
1997-01-23 02:16:20 +00:00
Jim Meyering
82b01ee905 increment serial number 1997-01-23 00:39:19 +00:00
Jim Meyering
48569d6b98 [strftime]: Add parameters to macro definition. From Drepper. 1997-01-22 23:23:04 +00:00
Jim Meyering
211fe36692 (main): Use TZ=GMT0, not TZ=GMT, since only GMT0 is specified by Posix.1. 1997-01-22 22:45:47 +00:00
Jim Meyering
8dd8bb78b1 . 1997-01-22 22:43:41 +00:00
Jim Meyering
d64cc3c1ef (_strftime_copytm): New function, to work around Solaris 2.5 tzset bug.
From Paul Eggert.
1997-01-22 22:43:15 +00:00
Jim Meyering
db7201835d . 1997-01-22 22:39:41 +00:00
Jim Meyering
74cb2ee314 (AM_FUNC_MKTIME): Fix bug in mktime test -- don't
test now, test a couple of thousand times.
1997-01-22 22:38:37 +00:00
Jim Meyering
6d24eee926 . 1997-01-22 04:56:25 +00:00
Jim Meyering
aeb7c0bc47 . 1997-01-22 04:55:59 +00:00
Jim Meyering
940f23f4a4 . 1997-01-22 04:53:59 +00:00
Jim Meyering
f3f1cae097 (main): Properly handle what the POSIX spec calls
the `obsolescent' usage (e.g., tail +2c).  It didn't work.
Reported by Karl Heuer.
1997-01-22 04:53:52 +00:00
Jim Meyering
fbe50426e2 . 1997-01-22 04:48:32 +00:00
Jim Meyering
8011a147de . 1997-01-21 04:21:48 +00:00
Jim Meyering
3cca257a3b . 1997-01-19 15:24:40 +00:00
Jim Meyering
de96d28c57 . 1997-01-19 13:18:30 +00:00
Jim Meyering
783fb6b2a6 . 1997-01-19 13:11:40 +00:00
Jim Meyering
b969dad022 Indent with GNU indent. 1997-01-18 20:17:39 +00:00
Jim Meyering
c1db691c12 Indent 2 more cpp-directives to reflect nesting. 1997-01-18 20:12:10 +00:00
Jim Meyering
5f9c33edfe (get_date): Change prototype to reflect const'ness of parameters.
Indent cpp-directives to reflect nesting.
1997-01-18 20:11:05 +00:00
Jim Meyering
10d7644859 . 1997-01-18 20:08:05 +00:00
Jim Meyering
6cb5a99aa7 Include getdate.h.
(<time.h>, <sys/time.h>): Don't include -- now getdate.h does it.
1997-01-18 20:06:50 +00:00
Jim Meyering
f696bb6737 . 1997-01-18 16:58:30 +00:00
Jim Meyering
8a9acec293 . 1997-01-18 16:57:45 +00:00
Jim Meyering
7eeedf8385 . 1997-01-18 15:46:09 +00:00
Jim Meyering
4c066c3552 . 1997-01-18 15:32:52 +00:00
Jim Meyering
6e5149f0ab 1997-01-06 Paul Eggert <eggert@twinsun.com>
* getdate.y: Rewrite to use mktime.

<sys/timeb.h>: Don't include.
(mktime): Declare.

(struct timeb, timezone, DOOMSDAY, SECSPERDAY, DSTMODE, yyDSTmode,
ToSeconds, Convert, DSTcorrect, RelativeDate, RelativeMonth): Remove.
(ToHour): New function (part of the old ToSeconds fn).
(ToYear): New function (part of the old Convert fn).

(TABLE.value, yyDayOrdinal, yyDayNumber, yyTimezone, yyDay, yyHour,
yyMinutes, yyMonth, yySeconds, yyYear, yyRelMonth, yyRelSeconds,
Number): Now int instead of time_t.
(HOUR): Don't cast to time_t.

(tDAY_UNIT, tHOUR_UNIT, tYEAR_UNIT): New %tokens.
(UnitsTable): Use new units that are closer to the keywords.

(yyRelDay, yyRelHour, yyRelMinutes, yyRelYear): New variables.
(rel, relunit, get_date): Add support for them.

(time): Fix timezone calculations for negative half-hour offsets
when integer division truncates towards minus infinity.

(zone): Incorporiate DST calculation directly.

(get_date): 2nd arg is now time_t *, not struct timeb *.
Use mktime to do most of the work, instead of computing it ourselves.
Guard against falsely reporting errors near the time_t boundaries
when parsing times in other time zones.
1997-01-18 15:32:16 +00:00
Jim Meyering
af12dd6260 Add comment re HAVE_PSTAT_GETDYNAMIC. 1997-01-18 15:07:16 +00:00
Jim Meyering
f8e40348be reindent 1997-01-18 13:44:49 +00:00
Jim Meyering
be8f2b0de2 . 1997-01-17 03:01:15 +00:00
Jim Meyering
279f065a06 (AM_FUNC_GETLOADAVG): Check for pstat_getdynamic. 1997-01-17 03:00:45 +00:00
Jim Meyering
c7837e95d2 Fix up indentation a little. 1997-01-15 04:59:07 +00:00
Jim Meyering
9130f4b9d2 Indent cpp-directives to reflect nesting. 1997-01-15 04:55:39 +00:00
Jim Meyering
5aa14aeef0 [!STDC_HEADERS]: Remove unnecessary declaration of free. 1997-01-15 04:42:05 +00:00
Jim Meyering
61976fe88d [!STDC_HEADERS]: Remove unnecessary declaration of free. 1997-01-15 04:41:12 +00:00
Jim Meyering
0868a7d0bd Add struct dir_list and is_ancestor. 1997-01-15 04:35:01 +00:00
Jim Meyering
48be557ad6 . 1997-01-13 04:23:05 +00:00
Jim Meyering
371f45401c Regenerated to reflect renamed tests. 1997-01-13 04:21:30 +00:00
Jim Meyering
9b9213f122 Rename tests so that the associated files
have names that are distinct even on filesystems on which file
names are case insensitive.
1997-01-13 04:20:54 +00:00
Jim Meyering
4c3d7d6a8b . 1997-01-13 04:17:16 +00:00
Jim Meyering
720d1c1c5e Regenerated to reflect renamed tests. 1997-01-13 04:16:57 +00:00
Jim Meyering
0dac1e107c Rename tests so that the associated files
have names that are distinct even on filesystems on which file
names are case insensitive.
1997-01-13 04:16:16 +00:00
Jim Meyering
31a8ced738 . 1997-01-11 22:35:42 +00:00
Jim Meyering
eb07a88b9e . 1997-01-11 04:23:46 +00:00
Jim Meyering
0503b28076 . 1997-01-11 04:21:29 +00:00
Jim Meyering
f45eaa5782 . 1997-01-09 12:38:53 +00:00
Jim Meyering
2f00343264 Remove AC_ISC_POSIX. 1997-01-09 12:24:51 +00:00
Jim Meyering
323c9cfee7 . 1997-01-09 02:35:52 +00:00
Jim Meyering
676a608318 . 1997-01-09 02:35:30 +00:00
73 changed files with 5790 additions and 2939 deletions

4
THANKS
View File

@@ -1,9 +1,12 @@
This is just a start at listing e-mail addresses of contributors.
The rest of the addresses are still in the ChangeLog.
Arne Henrik Juul arnej@imf.unit.no
Bauke Jan Douma: bjdouma@xs4all.nl
Charles Karney: karney@pppl.gov
Eirik Fuller: eirik@netcom.com
Emile LeBlanc: leblanc@math.toronto.edu
Galen Hazelwood: galenh@micron.net
James Antill: jmanti%essex.ac.uk@seralph21.essex.ac.uk
Jesse Thilo: jgt2@eecs.lehigh.edu
Joakim Rosqvist: dvljrt@cs.umu.se
@@ -16,4 +19,3 @@ Santiago Vila Doncel: sanvila@ctv.es
Thomas Bushnell, n/BSG: thomas@gnu.ai.mit.edu
Tony Leneis: tony@plaza.ds.adp.com
Wayne Stewart: wstewa@atl.com

View File

@@ -18,8 +18,8 @@ libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h error.h fnmatch.h fsusage.h \
getline.h getopt.h group-member.h long-options.h makepath.h modechange.h \
mountlist.h path-concat.h pathmax.h \
getdate.h getline.h getopt.h group-member.h long-options.h \
makepath.h modechange.h mountlist.h path-concat.h pathmax.h \
save-cwd.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c

View File

@@ -64,8 +64,8 @@ libfu_a_LIBADD = @LIBOBJS@ @ALLOCA@
libfu_a_DEPENDENCIES = $(libfu_a_LIBADD)
noinst_HEADERS = argmatch.h backupfile.h error.h fnmatch.h fsusage.h \
getline.h getopt.h group-member.h long-options.h makepath.h modechange.h \
mountlist.h path-concat.h pathmax.h \
getdate.h getline.h getopt.h group-member.h long-options.h \
makepath.h modechange.h mountlist.h path-concat.h pathmax.h \
save-cwd.h xstrtol.h xstrtoul.h
BUILT_SOURCES = getdate.c posixtm.c
@@ -97,7 +97,8 @@ error.h euidaccess.c fileblocks.c fnmatch.c fsusage.c ftruncate.c \
getdate.c getgroups.c getline.c group-member.c interlock memcmp.c \
memcpy.c memset.c mkdir.c mktime.c mountlist.c obstack.c obstack.h \
posixtm.c regex.c regex.h rename.c rmdir.c rpmatch.c rx.c rx.h stpcpy.c \
strcasecmp.c strdup.c strndup.c strstr.c strtol.c strtoul.c ylwrap
strcasecmp.c strdup.c strftime.c strndup.c strstr.c strtol.c strtoul.c \
ylwrap
PACKAGE = @PACKAGE@
@@ -118,10 +119,10 @@ DEP_FILES = .deps/alloca.P .deps/argmatch.P .deps/backupfile.P \
.deps/obstack.P .deps/path-concat.P .deps/posixtm.P .deps/regex.P \
.deps/rename.P .deps/rmdir.P .deps/rpmatch.P .deps/rx.P \
.deps/safe-read.P .deps/save-cwd.P .deps/savedir.P .deps/stpcpy.P \
.deps/strcasecmp.P .deps/strdup.P .deps/stripslash.P .deps/strndup.P \
.deps/strstr.P .deps/strtol.P .deps/strtoul.P .deps/userspec.P \
.deps/xgetcwd.P .deps/xmalloc.P .deps/xstrdup.P .deps/xstrtol.P \
.deps/xstrtoul.P .deps/yesno.P
.deps/strcasecmp.P .deps/strdup.P .deps/strftime.P .deps/stripslash.P \
.deps/strndup.P .deps/strstr.P .deps/strtol.P .deps/strtoul.P \
.deps/userspec.P .deps/xgetcwd.P .deps/xmalloc.P .deps/xstrdup.P \
.deps/xstrtol.P .deps/xstrtoul.P .deps/yesno.P
SOURCES = $(libfu_a_SOURCES)
OBJECTS = $(libfu_a_OBJECTS)

46
lib/getdate.h Normal file
View File

@@ -0,0 +1,46 @@
/* Copyright (C) 1995 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
# ifndef PARAMS
# if defined (__GNUC__) || __STDC__
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif
# endif
#if defined (vms)
# include <types.h>
# include <time.h>
#else
# include <sys/types.h>
# ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
# else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
#endif /* defined (vms) */
time_t get_date PARAMS ((const char *p, const time_t *now));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
Free Software Foundation, Inc.
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.
@@ -52,7 +52,7 @@
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 1
#define GETOPT_INTERFACE_VERSION 2
#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
@@ -88,7 +88,7 @@
#ifndef _
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
#if defined (HAVE_LIBINTL_H) || defined (ENABLE_NLS)
#ifdef HAVE_LIBINTL_H
# include <libintl.h>
# define _(msgid) gettext (msgid)
#else
@@ -126,7 +126,7 @@ char *optarg = NULL;
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
@@ -188,7 +188,7 @@ int optopt = '?';
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
static enum
{
@@ -417,7 +417,7 @@ _getopt_initialize (argc, argv, optstring)
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns `EOF'.
If there are no more option characters, `getopt' returns -1.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
@@ -546,7 +546,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
return EOF;
return -1;
}
/* If we have come to a non-option and did not permute it,
@@ -555,7 +555,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (NONOPTION_P)
{
if (ordering == REQUIRE_ORDER)
return EOF;
return -1;
optarg = argv[optind++];
return 1;
}
@@ -763,8 +763,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (opterr)
{
/* 1003.2 specifies the format of this message. */
fprintf (stderr,
_ ("%s: option requires an argument -- %c\n"),
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
argv[0], c);
}
optopt = c;
@@ -811,7 +810,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, _ ("%s: option `-W %s' is ambiguous\n"),
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
@@ -829,8 +828,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
else
{
if (opterr)
fprintf (stderr,
_ ("%s: option `-W %s' doesn't allow an argument\n"),
fprintf (stderr, _("\
%s: option `-W %s' doesn't allow an argument\n"),
argv[0], pfound->name);
nextchar += strlen (nextchar);
@@ -845,7 +844,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
{
if (opterr)
fprintf (stderr,
_ ("%s: option `%s' requires an argument\n"),
_("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
@@ -946,7 +945,7 @@ main (argc, argv)
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
if (c == EOF)
if (c == -1)
break;
switch (c)

View File

@@ -1,19 +1,23 @@
/* Declarations for getopt.
Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
Copyright (C) 1989,90,91,92,93,94,96,97 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 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.
This program is distributed in the hope that it will be useful,
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library 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. */
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
@@ -36,7 +40,7 @@ extern char *optarg;
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next

View File

@@ -1,20 +1,23 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
Free Software Foundation, Inc.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97 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 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.
This program is distributed in the hope that it will be useful,
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -40,15 +43,21 @@
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
#define GETOPT_INTERFACE_VERSION 2
#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#else
char *getenv ();
#endif
#ifndef NULL
@@ -83,7 +92,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
#endif /* Not ELIDE_CODE. */
#ifdef TEST
@@ -114,7 +123,7 @@ main (argc, argv)
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == EOF)
if (c == -1)
break;
switch (c)

View File

@@ -46,10 +46,8 @@ parse_long_options (argc, argv, command_name, package, version, usage)
{
int c;
int saved_opterr;
int saved_optind;
saved_opterr = opterr;
saved_optind = optind;
/* Don't print an error message for unrecognized options. */
opterr = 0;
@@ -75,6 +73,7 @@ parse_long_options (argc, argv, command_name, package, version, usage)
/* Restore previous value. */
opterr = saved_opterr;
/* Restore optind in case it has advanced past a leading `--'. */
optind = saved_optind;
/* Reset this to zero so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later. */
optind = 0;
}

View File

@@ -264,7 +264,7 @@ read_filesystem_list (need_fs_type, all_fs)
struct tabmntent *mntlist, *p;
struct mntent *mnt;
struct mount_entry *me;
/* the third and fourth arguments could be used to filter mounts,
but Crays doesn't seem to have any mounts that we want to
remove. Specifically, automount create normal NFS mounts.

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
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.
@@ -329,6 +329,31 @@ static char const month_name[][10] =
};
#endif
#if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
/* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
Work around this bug by copying *tp before it might be munged. */
size_t _strftime_copytm __P ((char *, size_t, const char *,
const struct tm *));
size_t
strftime (s, maxsize, format, tp)
char *s;
size_t maxsize;
const char *format;
const struct tm *tp;
{
struct tm tmcopy;
tmcopy = *tp;
return _strftime_copytm (s, maxsize, format, &tmcopy);
}
# ifdef strftime
# undef strftime
# endif
# define strftime _strftime_copytm
#endif
/* Write information from TP into S according to the format
string FORMAT, writing no more that MAXSIZE characters
(including the terminating '\0') and returning number of

View File

@@ -91,15 +91,14 @@ __xstrtol (s, ptr, base, val, valid_suffixes)
return LONGINT_OVERFLOW;
if (*p == s)
return LONGINT_INVALID;
/* Let valid_suffixes == NULL mean `allow any suffix'. */
/* FIXME: update all callers except the one in tail.c changing
last parameter NULL to `""'. */
if (!valid_suffixes)
{
if (**p == '\0')
{
*val = tmp;
return LONGINT_OK;
}
else
return LONGINT_INVALID_SUFFIX_CHAR;
*val = tmp;
return LONGINT_OK;
}
if (**p != '\0')

View File

@@ -20,16 +20,19 @@
# define PARAMS(Args) ()
# endif
#ifndef _STRTOL_ERROR
enum strtol_error
{
LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW
};
typedef enum strtol_error strtol_error;
#endif
strtol_error
__xstrtol PARAMS ((const char *s, char **ptr, int base,
__unsigned long int *val, const char *valid_suffixes));
#undef _STRTOL_ERROR
# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
do \
{ \

View File

@@ -2,6 +2,12 @@
# define XSTRTOUL_H_ 1
# define STRING_TO_UNSIGNED 1
/* Undefine this symbol so we can include xstrtol.h a second time.
Otherwise, a program that wanted both xstrtol.h and xstrtoul.h
would never get the declaration corresponding to the header file
included after the first one. */
# undef XSTRTOL_H_
# include "xstrtol.h"
#endif /* not XSTRTOUL_H_ */

View File

@@ -41,11 +41,15 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
RANLIB = @RANLIB@
YACC = @YACC@
GENCAT = @GENCAT@
PERL = @PERL@
MV = @MV@
GMSGFMT = @GMSGFMT@
CC = @CC@
RANLIB = @RANLIB@
LN = @LN@
RM = @RM@
EXTRA_DIST = README \
ccstdc.m4 dmalloc.m4 error.m4 getgroups.m4 getline.m4 getloadavg.m4 \

View File

@@ -1,4 +1,4 @@
#serial 1
#serial 2
dnl From Jim Meyering.
dnl If you use this macro in a package, you should
@@ -6,11 +6,24 @@ dnl add the following two lines to acconfig.h:
dnl /* Define to rpl_getgroups if the replacement function should be used. */
dnl #undef getgroups
dnl
dnl Invoking code should check $GETGROUPS_LIB something like this:
dnl jm_FUNC_GETGROUPS
dnl test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS"
dnl
AC_DEFUN(jm_FUNC_GETGROUPS,
[AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
AC_CHECK_FUNCS(getgroups)
# If we don't yet have getgroups, see if it's in -lbsd.
# This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
if test $ac_cv_func_getgroups = no; then
jm_cv_sys_getgroups_saved_lib="$LIBS"
AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
LIBS="$jm_cv_sys_getgroups_saved_lib"
fi
# Run the program to test the functionality of the system-supplied
# getgroups function only if there is such a function.
if test $ac_cv_func_getgroups = yes; then

View File

@@ -1,10 +1,13 @@
#serial 2
#serial 3
AC_DEFUN(AM_FUNC_GETLOADAVG,
[ac_have_func=no # yes means we've found a way to get the load average.
am_cv_saved_LIBS="$LIBS"
# On HPUX9, an unprivileged user can get load averages through this function.
AC_CHECK_FUNCS(pstat_getdynamic)
# Solaris has libkstat which does not require root.
AC_CHECK_LIB(kstat, kstat_open)
if test $ac_cv_lib_kstat_kstat_open = yes ; then ac_have_func=yes ; fi

View File

@@ -184,7 +184,6 @@ AC_DEFUN(AM_WITH_NLS,
AC_DEFUN(AM_GNU_GETTEXT,
[AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_ISC_POSIX])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_HEADER_STDC])dnl
AC_REQUIRE([AC_C_CONST])dnl

View File

@@ -1,3 +1,5 @@
#serial 2
dnl From Jim Meyering.
dnl FIXME: this should migrate into libit.
@@ -5,7 +7,10 @@ AC_DEFUN(AM_FUNC_MKTIME,
[AC_REQUIRE([AC_HEADER_TIME])dnl
AC_CHECK_HEADERS(sys/time.h)
AC_CACHE_CHECK([for working mktime], am_cv_func_working_mktime,
[AC_TRY_RUN([/* Test program from Tony Leneis (tony@plaza.ds.adp.com). */
[AC_TRY_RUN(
changequote(<<, >>)dnl
<</* Test program from Paul Eggert (eggert@twinsun.com)
and Tony Leneis (tony@plaza.ds.adp.com). */
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
@@ -16,14 +21,50 @@ AC_DEFUN(AM_FUNC_MKTIME,
# include <time.h>
# endif
#endif
static time_t time_t_max;
/* Values we'll use to set the TZ environment variable. */
static const char *const tz_strings[] = {
NULL, "GMT0", "JST-9", "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
};
#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
static void
mktime_test (now)
time_t now;
{
if (mktime (localtime (&now)) != now)
exit (1);
now = time_t_max - now;
if (mktime (localtime (&now)) != now)
exit (1);
}
int
main ()
{
time_t today = time (0);
struct tm *local = localtime (&today);
exit (mktime (local) != today);
time_t t, delta;
int i;
for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
continue;
time_t_max--;
delta = time_t_max / 997; /* a suitable prime number */
for (i = 0; i < N_STRINGS; i++)
{
if (tz_strings[i])
putenv (tz_strings[i]);
for (t = 0; t <= time_t_max - delta; t += delta)
mktime_test (t);
mktime_test ((time_t) 60 * 60);
mktime_test ((time_t) 60 * 60 * 24);
}
exit (0);
}
],
>>,
changequote([, ])dnl
am_cv_func_working_mktime=yes, am_cv_func_working_mktime=no,
dnl When crosscompiling, assume mktime is missing or broken.
am_cv_func_working_mktime=no)

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
dnl From Jim Meyering.
dnl If you use this macro in a package, you should
@@ -56,7 +56,7 @@ main ()
/* This is necessary to make strftime give consistent zone strings and
e.g., seconds since the epoch (%s). */
putenv ("TZ=GMT");
putenv ("TZ=GMT0");
#undef CMP
#define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))

View File

@@ -1,3 +1,63 @@
Sun Jan 26 20:17:50 1997 Jim Meyering <meyering@na-net.ornl.gov>
* Version 3.16.
* acconfig.h (strftime): Add #undef. From Marcus Daniels.
Sat Jan 25 00:34:39 1997 Jim Meyering <meyering@na-net.ornl.gov>
* src/du.c (count_entry): Fix blatant bug (typo?) that made
--megabytes report numbers in units of kilobytes.
Reported by Galen Hazelwood.
* src/cp.h: Remove now-unnecessary prototype for is_ancestor.
* lib/Makefile.am (noinst_HEADERS): Add getdate.h.
* src/cp-aux.c (is_ancestor): Remove function.
* src/cp.c (is_ancestor): Add function.
* src/cp.h: Remove spurious extern dcl of htab.
* m4/getgroups.m4: Move the code from configure.in into
this macro that resorts to looking for getgroups in -lbsd.
Set new shell variable, GETGROUPS_LIB (that callers should check),
if it is found there.
* configure.in: Check $GETGROUPS_LIB just after jm_FUNC_GETGROUPS.
(AC_CHECK_FUNCS): Remove getgroups.
Remove code that resorts to looking for getgroups in -lbsd.
* configure.in (jm_FUNC_GNU_STRFTIME): Use it -- because ls
needs a version of strftime that supports the %e format and
pretty many systems lack that: NextStep 3.3, Mips Ultrix ?.?.
This is a little bit overkill (for now) in that if the strftime
in your C library doesn't have all features of GNU strftime (even
though it may support %e) ls will be linked with the version of
strftime provided with this package. But for an upcoming release,
GNU ls will provide an option to allow the user to specify the
date format string -- and for that I want to make GNU strftime
the default in any case. Think of this as an incentive to use
the GNU C library.
Fri Jan 24 23:36:00 1997 Jim Meyering <meyering@na-net.ornl.gov>
* lib/long-options.c (parse_long_options): Reset optind to zero
before just returning so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later.
From Ulrich Drepper.
Mon Jan 20 06:52:09 1997 Jim Meyering <meyering@na-net.ornl.gov>
* configure.in (fu_cv_sys_truncating_statfs): Add preprocessor
guard to make sure that this test for Sun brokenness doesn't
get a false positive on any other type of system. Eirik Fuller
reported that Linux 2.1.20 <sys/vfs.h> has a f_spare member in
the statfs struct. And that triggered a false positive.
Thu Jan 9 06:23:18 1997 Jim Meyering <meyering@na-net.ornl.gov>
* m4/gettext.m4: Remove AC_ISC_POSIX. From Karl Heuer.
Wed Jan 8 16:38:24 1997 Jim Meyering <meyering@na-net.ornl.gov>
* Version 3.15.

View File

@@ -1,3 +1,8 @@
Changes in release 3.16:
[3.15a]
* du --megabytes (-m) works
* ls -l works even on systems with non-POSIX strftime in their C library
Changes in release 3.15:
* touch --date=DATE bug (due to broken getdate.y) has been fixed
* ls -l no longer misformats the date when run in a locale for which the
@@ -13,6 +18,7 @@ Changes in release 3.15:
with EUID == 0
* dircolors no longer accepts --print-data-base (alternate spelling of
--print-database)
Changes in release 3.14:
* ls --color highlights based on suffix rules only for regular files
* touch --date=DATE accepts dates like those in an RCS log listing, e.g.,

View File

@@ -1,5 +1,131 @@
Sun Jan 26 12:51:05 1997 Jim Meyering <meyering@na-net.ornl.gov>
* Version 1.16.
* src/who-users.c (usage): Fix typo (--writeable -> --writable)
in help output. From Galen Hazelwood.
Sat Jan 25 21:01:13 1997 Jim Meyering <meyering@na-net.ornl.gov>
* src/factor.c (print_factors): Reflect changes to xstrtoul interface.
* tests/date/mk-script.pl: Generated script now reflects
specification (in Test.pm) of default and per-test environment
settings.
Fri Jan 24 23:36:00 1997 Jim Meyering <meyering@na-net.ornl.gov>
* lib/long-options.c (parse_long_options): Reset optind to zero
before just returning so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later.
This solves the problem (reintroduced with 1.15) where `stty -tabs'
would not work as advertised but instead act like `stty -a'.
Reported by Arne Juul.
Suggested fix from Ulrich Drepper.
Wed Jan 22 20:12:31 1997 Jim Meyering <meyering@na-net.ornl.gov>
* lib/getopt.c: Update from GNU C library.
* lib/getopt1.c: Update from GNU C library.
* lib/getopt.h: Update from GNU C library.
* tests/Makefile.am (EXTRA_DIST): Add README Makefile.am.in.
(SUBDIRS): Set to `date'.
* configure.in: Check for perl.
(AC_OUTPUT): Add tests/date/Makefile.
* tests/date: New directory.
* m4/getgroups.m4: Move the code from configure.in into
this macro that resorts to looking for getgroups in -lbsd.
Set new shell variable, GETGROUPS_LIB (that callers should check),
if it is found there.
* configure.in: Check $GETGROUPS_LIB just after jm_FUNC_GETGROUPS.
(AC_CHECK_FUNCS): Remove getgroups.
Remove code that resorts to looking for getgroups in -lbsd.
* m4/mktime.m4 (AM_FUNC_MKTIME): Run tests for each of a few values
for the TZ environment variable. Andre Novaes Cunha provided the
hairy TZ setting that exercized the Solaris tzset bug.
1997-01-22 Paul Eggert <eggert@twinsun.com>
* lib/strftime.c (_strftime_copytm):
New function, to work around Solaris 2.5 tzset bug.
* m4/mktime.m4: (AM_FUNC_MKTIME): Fix bug in mktime test -- don't
test now, test a couple of thousand times.
* m4/strftime.m4 (main): Use TZ=GMT0, not TZ=GMT, since only GMT0 is
specified by Posix.1.
Sat Jan 18 09:32:26 1997 Jim Meyering <meyering@na-net.ornl.gov>
* lib/getdate.y (get_date): Change prototype to reflect const'ness
of parameters.
Indent cpp-directives to reflect nesting.
Indent with GNU indent.
* lib/getdate.h: New file.
* src/date.c: Include getdate.h.
(<time.h>, <sys/time.h>): Don't include -- now getdate.h does it.
(get_date): Don't declare. getdate.h does it.
* lib/Makefile.am (noinst_HEADERS): Add getdate.h.
1997-01-06 Paul Eggert <eggert@twinsun.com>
* getdate.y: Rewrite to use mktime.
<sys/timeb.h>: Don't include.
(mktime): Declare.
(struct timeb, timezone, DOOMSDAY, SECSPERDAY, DSTMODE, yyDSTmode,
ToSeconds, Convert, DSTcorrect, RelativeDate, RelativeMonth): Remove.
(ToHour): New function (part of the old ToSeconds fn).
(ToYear): New function (part of the old Convert fn).
(TABLE.value, yyDayOrdinal, yyDayNumber, yyTimezone, yyDay, yyHour,
yyMinutes, yyMonth, yySeconds, yyYear, yyRelMonth, yyRelSeconds,
Number): Now int instead of time_t.
(HOUR): Don't cast to time_t.
(tDAY_UNIT, tHOUR_UNIT, tYEAR_UNIT): New %tokens.
(UnitsTable): Use new units that are closer to the keywords.
(yyRelDay, yyRelHour, yyRelMinutes, yyRelYear): New variables.
(rel, relunit, get_date): Add support for them.
(time): Fix timezone calculations for negative half-hour offsets
when integer division truncates towards minus infinity.
(zone): Incorporiate DST calculation directly.
(get_date): 2nd arg is now time_t *, not struct timeb *.
Use mktime to do most of the work, instead of computing it ourselves.
Guard against falsely reporting errors near the time_t boundaries
when parsing times in other time zones.
Thu Jan 16 20:58:40 1997 Jim Meyering <meyering@na-net.ornl.gov>
* m4/getloadavg.m4 (AM_FUNC_GETLOADAVG): Check for pstat_getdynamic.
* configure.in (AC_CHECK_FUNCS): Don't check for pstat_getdynamic here.
Tue Jan 14 22:45:36 1997 Jim Meyering <meyering@na-net.ornl.gov>
* configure.in (AC_CHECK_FUNCS): Add pstat_getdynamic.
Alphabetize functions.
* lib/getloadavg.c [hpux && HAVE_PSTAT_GETDYNAMIC]: Use HPUX's
pstat_getdynamic function so we don't need any special privileges
to determine load averages. Patch from Kaveh Ghazi, based on a
sample implementation from Richard J. Rauenzahn.
Indent cpp-directives to reflect nesting.
Wed Jan 8 16:38:24 1997 Jim Meyering <meyering@na-net.ornl.gov>
* Version 1.15.
* lib/getopt.c (_getopt_internal): Use `_', rather than the
(sometimes-)expansion `gettext'.

View File

@@ -1,3 +1,8 @@
Changes in release 1.16
1.15a
* stty -tabs works properly
* add tests for date
Changes in release 1.15
* nice works with very recently-changed GNU libc getopt
* fix several bugs in m4 macros used to create `configure' script

View File

@@ -1,5 +1,84 @@
Sun Jan 26 12:49:50 1997 Jim Meyering <meyering@na-net.ornl.gov>
* Version 1.22.
* src/tail.c (parse_options): Add quotes to make messages identical.
Sat Jan 25 00:12:29 1997 Jim Meyering <meyering@na-net.ornl.gov>
* src/tail.c (parse_obsolescent_option): Comment.
(parse_options): Remove unnecessary goto and label.
* tests/sort-test/mk-script.pl: Interpret `input arg is a hash
reference' as meaning that the tested program will read no input.
Most of the tests for the date program use this feature.
Also for date, the generated script now reflects specification
(in Test.pm) of default and per-test environment settings.
* src/csplit.c: Reflect changes to xstrtol and xstrtoul interfaces.
* src/fold.c: Likewise.
* src/head.c: Likewise.
* src/join.c: Likewise.
* src/nl.c: Likewise.
* src/od.c: Likewise.
* src/pr.c: Likewise.
* src/uniq.c: Likewise.
* lib/xstrtoul.h (XSTRTOL_H): Undefine it.
* lib/xstrtol.h [!_STRTOL_ERROR]: Define the type `enum strtol_error'
only if it hasn't already been defined.
(_STRTOL_ERROR): Undefine.
* lib/xstrtol.c (__xstrtol): Change interpretation of
VALID_SUFFIXES == NULL vs VALID_SUFFIXES == "". Use the former
when any suffix is valid, the later when no suffix is allowed.
Fri Jan 24 23:36:00 1997 Jim Meyering <meyering@na-net.ornl.gov>
* lib/long-options.c (parse_long_options): Reset optind to zero
before just returning so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later.
From Ulrich Drepper.
Thu Jan 23 19:17:03 1997 Jim Meyering <meyering@na-net.ornl.gov>
* src/tail.c (parse_obsolescent_option): Recognize and fail for
more malformed obsolescent options. Makes for better diagnostics.
Wed Jan 22 21:34:50 1997 Jim Meyering <meyering@na-net.ornl.gov>
* tests/Makefile.am (SUBDIRS): Add tail.
* tests/tail: New directory.
* configure.in (AC_OUTPUT): Add tests/tail/Makefile.
* src/tail.c (parse_options): New function.
(parse_obsolescent_option): New function.
(main): Use the new functions instead of open-coding them.
This better fixes the bug in handling obsolescent `+Nc' options.
General cleanup.
Tue Jan 21 22:49:00 1997 Jim Meyering <meyering@na-net.ornl.gov>
* src/tail.c (main): Properly handle what the POSIX spec calls
the `obsolescent' usage (e.g., tail +2c). It didn't work.
Reported by Karl Heuer.
Sun Jan 12 22:13:27 1997 Jim Meyering <meyering@na-net.ornl.gov>
* tests/tr-test/Test.pm: Rename tests so that the associated files
have names that are distinct even on filesystems on which file
names are case insensitive.
Reported by Fred Fish.
* tests/cut-test/Test.pm: Likewise.
* tests/tr-test/Makefile.am: Regenerated to reflect renamed tests.
* tests/cut-test/Makefile.am: Likewise.
Wed Jan 8 16:38:24 1997 Jim Meyering <meyering@na-net.ornl.gov>
* Version 1.21.
* lib/getopt.c (_getopt_internal): Use `_', rather than the
(sometimes-)expansion `gettext'.

View File

@@ -1,3 +1,8 @@
Changes in release 1.22
[1.21a]
* Fix a bug in tail when invoked with an argument like `+NUMBERc'
* Add test suite for tail
Changes in release 1.21
* Using --program-prefix no longer applies the prefix twice

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Richard Stallman and David MacKenzie. */

803
src/copy.c Normal file
View File

@@ -0,0 +1,803 @@
#ifdef _AIX
#pragma alloca
#endif
#include <config.h>
#include <stdio.h>
#include "cp.h"
#include "copy.h"
#include "backupfile.h"
/* On Linux (from slackware-1.2.13 to 2.0.2?) there is no lchown function.
To change ownership of symlinks, you must run chown with an effective
UID of 0. */
#ifdef __linux__
# define ROOT_CHOWN_AFFECTS_SYMLINKS
#endif
#define DO_CHOWN(Chown, File, New_uid, New_gid) \
(Chown ((File), (x->myeuid == 0 ? (New_uid) : x->myeuid), (New_gid)) \
/* If non-root uses -p, it's ok if we can't preserve ownership. \
But root probably wants to know, e.g. if NFS disallows it. */ \
&& (errno != EPERM || x->myeuid == 0))
/* Control creation of sparse files (files with holes). */
enum Sparse_type
{
/* Never create holes in DEST. */
SPARSE_NEVER,
/* This is the default. Use a crude (and sometimes inaccurate)
heuristic to determine if SOURCE has holes. If so, try to create
holes in DEST. */
SPARSE_AUTO,
/* For every sufficiently long sequence of bytes in SOURCE, try to
create a corresponding hole in DEST. There is a performance penalty
here because CP has to search for holes in SRC. But if the holes are
big enough, that penalty can be offset by the decrease in the amount
of data written to disk. */
SPARSE_ALWAYS
};
struct flag
{
/* If nonzero, copy all files except (directories and, if not dereferencing
them, symbolic links,) as if they were regular files. */
int copy_as_regular;
/* If nonzero, dereference symbolic links (copy the files they point to). */
int dereference;
/* If nonzero, remove existing destination nondirectories. */
int force;
/* If nonzero, create hard links instead of copying files.
Create destination directories as usual. */
int hard_link;
/* If nonzero, query before overwriting existing destinations
with regular files. */
int interactive;
/* If nonzero, when copying recursively, skip any subdirectories that are
on different filesystems from the one we started on. */
int one_file_system;
/* If nonzero, give the copies the original files' permissions,
ownership, and timestamps. */
int preserve;
/* If nonzero, copy directories recursively and copy special files
as themselves rather than copying their contents. */
int recursive;
/* Control creation of sparse files. */
enum Sparse_type sparse_mode;
/* If nonzero, create symbolic links instead of copying files.
Create destination directories as usual. */
int symbolic_link;
/* The bits to preserve in created files' modes. */
int umask_kill;
/* If nonzero, do not copy a nondirectory that has an existing destination
with the same or newer modification time. */
int update;
/* If nonzero, display the names of the files before copying them. */
int verbose;
/* This process's effective user ID. */
uid_t myeuid;
/* A pointer to either lstat or stat, depending on
whether dereferencing of symlinks is done. */
int (*xstat) ();
};
struct dir_list
{
struct dir_list *parent;
ino_t ino;
dev_t dev;
};
int full_write ();
int euidaccess ();
/* The invocation name of this program. */
extern char *program_name;
static int
is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
{
while (ancestors != 0)
{
if (ancestors->ino == sb->st_ino && ancestors->dev == sb->st_dev)
return 1;
ancestors = ancestors->parent;
}
return 0;
}
/* Read the contents of the directory SRC_PATH_IN, and recursively
copy the contents to DST_PATH_IN. NEW_DST is nonzero if
DST_PATH_IN is a directory that was created previously in the
recursion. SRC_SB and ANCESTORS describe SRC_PATH_IN.
Return 0 if successful, -1 if an error occurs. */
static int
copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
const struct stat *src_sb, struct dir_list *ancestors,
const struct flag *x)
{
char *name_space;
char *namep;
char *src_path;
char *dst_path;
int ret = 0;
errno = 0;
name_space = savedir (src_path_in, src_sb->st_size);
if (name_space == 0)
{
if (errno)
{
error (0, errno, "%s", src_path_in);
return -1;
}
else
error (1, 0, _("virtual memory exhausted"));
}
namep = name_space;
while (*namep != '\0')
{
int fn_length = strlen (namep) + 1;
dst_path = xmalloc (strlen (dst_path_in) + fn_length + 1);
src_path = xmalloc (strlen (src_path_in) + fn_length + 1);
stpcpy (stpcpy (stpcpy (src_path, src_path_in), "/"), namep);
stpcpy (stpcpy (stpcpy (dst_path, dst_path_in), "/"), namep);
ret |= copy (src_path, dst_path, new_dst, src_sb->st_dev, ancestors, x);
/* Free the memory for `src_path'. The memory for `dst_path'
cannot be deallocated, since it is used to create multiple
hard links. */
free (src_path);
namep += fn_length;
}
free (name_space);
return -ret;
}
/* Copy a regular file from SRC_PATH to DST_PATH.
If the source file contains holes, copies holes and blocks of zeros
in the source file as holes in the destination file.
(Holes are read as zeroes by the `read' system call.)
Return 0 if successful, -1 if an error occurred.
FIXME: describe sparse_mode. */
static int
copy_reg (const char *src_path, const char *dst_path,
enum Sparse_type sparse_mode)
{
char *buf;
int buf_size;
int dest_desc;
int source_desc;
int n_read;
struct stat sb;
char *cp;
int *ip;
int return_val = 0;
long n_read_total = 0;
int last_write_made_hole = 0;
int make_holes = (sparse_mode == SPARSE_ALWAYS);
source_desc = open (src_path, O_RDONLY);
if (source_desc < 0)
{
error (0, errno, "%s", src_path);
return -1;
}
/* Create the new regular file with small permissions initially,
to not create a security hole. */
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (dest_desc < 0)
{
error (0, errno, _("cannot create regular file `%s'"), dst_path);
return_val = -1;
goto ret2;
}
/* Find out the optimal buffer size. */
if (fstat (dest_desc, &sb))
{
error (0, errno, "%s", dst_path);
return_val = -1;
goto ret;
}
buf_size = ST_BLKSIZE (sb);
#ifdef HAVE_ST_BLOCKS
if (sparse_mode == SPARSE_AUTO && S_ISREG (sb.st_mode))
{
/* Use a heuristic to determine whether SRC_PATH contains any
sparse blocks. */
if (fstat (source_desc, &sb))
{
error (0, errno, "%s", src_path);
return_val = -1;
goto ret;
}
/* If the file has fewer blocks than would normally
be needed for a file of its size, then
at least one of the blocks in the file is a hole. */
if (S_ISREG (sb.st_mode)
&& (size_t) (sb.st_size / 512) > (size_t) ST_NBLOCKS (sb))
make_holes = 1;
}
#endif
/* Make a buffer with space for a sentinel at the end. */
buf = (char *) alloca (buf_size + sizeof (int));
for (;;)
{
n_read = read (source_desc, buf, buf_size);
if (n_read < 0)
{
#ifdef EINTR
if (errno == EINTR)
continue;
#endif
error (0, errno, "%s", src_path);
return_val = -1;
goto ret;
}
if (n_read == 0)
break;
n_read_total += n_read;
ip = 0;
if (make_holes)
{
buf[n_read] = 1; /* Sentinel to stop loop. */
/* Find first nonzero *word*, or the word with the sentinel. */
ip = (int *) buf;
while (*ip++ == 0)
;
/* Find the first nonzero *byte*, or the sentinel. */
cp = (char *) (ip - 1);
while (*cp++ == 0)
;
/* If we found the sentinel, the whole input block was zero,
and we can make a hole. */
if (cp > buf + n_read)
{
/* Make a hole. */
if (lseek (dest_desc, (off_t) n_read, SEEK_CUR) < 0L)
{
error (0, errno, "%s", dst_path);
return_val = -1;
goto ret;
}
last_write_made_hole = 1;
}
else
/* Clear to indicate that a normal write is needed. */
ip = 0;
}
if (ip == 0)
{
if (full_write (dest_desc, buf, n_read) < 0)
{
error (0, errno, "%s", dst_path);
return_val = -1;
goto ret;
}
last_write_made_hole = 0;
}
}
/* If the file ends with a `hole', something needs to be written at
the end. Otherwise the kernel would truncate the file at the end
of the last write operation. */
if (last_write_made_hole)
{
#ifdef HAVE_FTRUNCATE
/* Write a null character and truncate it again. */
if (full_write (dest_desc, "", 1) < 0
|| ftruncate (dest_desc, n_read_total) < 0)
#else
/* Seek backwards one character and write a null. */
if (lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L
|| full_write (dest_desc, "", 1) < 0)
#endif
{
error (0, errno, "%s", dst_path);
return_val = -1;
}
}
ret:
if (close (dest_desc) < 0)
{
error (0, errno, "%s", dst_path);
return_val = -1;
}
ret2:
if (close (source_desc) < 0)
{
error (0, errno, "%s", src_path);
return_val = -1;
}
return return_val;
}
/* Copy the file SRC_PATH to the file DST_PATH. The files may be of
any type. NEW_DST should be nonzero if the file DST_PATH cannot
exist because its parent directory was just created; NEW_DST should
be zero if DST_PATH might already exist. DEVICE is the device
number of the parent directory, or 0 if the parent of this file is
not known. ANCESTORS points to a linked, null terminated list of
devices and inodes of parent directories of SRC_PATH.
Return 0 if successful, 1 if an error occurs. */
static int
copy_internal (const char *src_path, const char *dst_path,
int new_dst, dev_t device, struct dir_list *ancestors,
const struct flag *x)
{
struct stat src_sb;
struct stat dst_sb;
int src_mode;
int src_type;
char *earlier_file;
char *dst_backup = NULL;
int fix_mode = 0;
if ((*(x->xstat)) (src_path, &src_sb))
{
error (0, errno, "%s", src_path);
return 1;
}
/* Are we crossing a file system boundary? */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
return 0;
/* We wouldn't insert a node unless nlink > 1, except that we need to
find created files so as to not copy infinitely if a directory is
copied into itself. */
earlier_file = remember_copied (dst_path, src_sb.st_ino, src_sb.st_dev);
/* Did we just create this file? */
if (earlier_file == &new_file)
return 0;
src_mode = src_sb.st_mode;
src_type = src_sb.st_mode;
if (S_ISDIR (src_type) && !x->recursive)
{
error (0, 0, _("%s: omitting directory"), src_path);
return 1;
}
if (!new_dst)
{
if ((*(x->xstat)) (dst_path, &dst_sb))
{
if (errno != ENOENT)
{
error (0, errno, "%s", dst_path);
return 1;
}
else
new_dst = 1;
}
else
{
/* The file exists already. */
if (src_sb.st_ino == dst_sb.st_ino && src_sb.st_dev == dst_sb.st_dev)
{
if (x->hard_link)
return 0;
error (0, 0, _("`%s' and `%s' are the same file"),
src_path, dst_path);
return 1;
}
if (!S_ISDIR (src_type))
{
if (S_ISDIR (dst_sb.st_mode))
{
error (0, 0,
_("%s: cannot overwrite directory with non-directory"),
dst_path);
return 1;
}
if (x->update && src_sb.st_mtime <= dst_sb.st_mtime)
return 0;
}
if (!S_ISDIR (src_type) && !x->force && x->interactive)
{
if (euidaccess (dst_path, W_OK) != 0)
{
fprintf (stderr,
_("%s: overwrite `%s', overriding mode %04o? "),
program_name, dst_path,
(unsigned int) (dst_sb.st_mode & 07777));
}
else
{
fprintf (stderr, _("%s: overwrite `%s'? "),
program_name, dst_path);
}
if (!yesno ())
return 0;
}
if (backup_type != none && !S_ISDIR (dst_sb.st_mode))
{
char *tmp_backup = find_backup_file_name (dst_path);
if (tmp_backup == NULL)
error (1, 0, _("virtual memory exhausted"));
/* Detect (and fail) when creating the backup file would
destroy the source file. Before, running the commands
cd /tmp; rm -f a a~; : > a; echo A > a~; cp -b -V simple a~ a
would leave two zero-length files: a and a~. */
if (STREQ (tmp_backup, src_path))
{
error (0, 0,
_("backing up `%s' would destroy source; `%s' not copied"),
dst_path, src_path);
return 1;
}
dst_backup = (char *) alloca (strlen (tmp_backup) + 1);
strcpy (dst_backup, tmp_backup);
free (tmp_backup);
if (rename (dst_path, dst_backup))
{
if (errno != ENOENT)
{
error (0, errno, _("cannot backup `%s'"), dst_path);
return 1;
}
else
dst_backup = NULL;
}
new_dst = 1;
}
else if (x->force)
{
if (S_ISDIR (dst_sb.st_mode))
{
/* Temporarily change mode to allow overwriting. */
if (euidaccess (dst_path, W_OK | X_OK) != 0)
{
if (chmod (dst_path, 0700))
{
error (0, errno, "%s", dst_path);
return 1;
}
else
fix_mode = 1;
}
}
else
{
if (unlink (dst_path) && errno != ENOENT)
{
error (0, errno, _("cannot remove old link to `%s'"),
dst_path);
return 1;
}
new_dst = 1;
}
}
}
}
/* If the source is a directory, we don't always create the destination
directory. So --verbose should not announce anything until we're
sure we'll create a directory. */
if (x->verbose && !S_ISDIR (src_type))
printf ("%s -> %s\n", src_path, dst_path);
/* Did we copy this inode somewhere else (in this command line argument)
and therefore this is a second hard link to the inode? */
if (!x->dereference && src_sb.st_nlink > 1 && earlier_file)
{
if (link (earlier_file, dst_path))
{
error (0, errno, "%s", dst_path);
goto un_backup;
}
return 0;
}
if (S_ISDIR (src_type))
{
struct dir_list *dir;
/* If this directory has been copied before during the
recursion, there is a symbolic link to an ancestor
directory of the symbolic link. It is impossible to
continue to copy this, unless we've got an infinite disk. */
if (is_ancestor (&src_sb, ancestors))
{
error (0, 0, _("%s: cannot copy cyclic symbolic link"), src_path);
goto un_backup;
}
/* Insert the current directory in the list of parents. */
dir = (struct dir_list *) alloca (sizeof (struct dir_list));
dir->parent = ancestors;
dir->ino = src_sb.st_ino;
dir->dev = src_sb.st_dev;
if (new_dst || !S_ISDIR (dst_sb.st_mode))
{
/* Create the new directory writable and searchable, so
we can create new entries in it. */
if (mkdir (dst_path, (src_mode & x->umask_kill) | 0700))
{
error (0, errno, _("cannot create directory `%s'"), dst_path);
goto un_backup;
}
/* Insert the created directory's inode and device
numbers into the search structure, so that we can
avoid copying it again. */
if (remember_created (dst_path))
goto un_backup;
if (x->verbose)
printf ("%s -> %s\n", src_path, dst_path);
}
/* Copy the contents of the directory. */
if (copy_dir (src_path, dst_path, new_dst, &src_sb, dir, x))
return 1;
}
#ifdef S_ISLNK
else if (x->symbolic_link)
{
if (*src_path == '/'
|| (!strncmp (dst_path, "./", 2) && strchr (dst_path + 2, '/') == 0)
|| strchr (dst_path, '/') == 0)
{
if (symlink (src_path, dst_path))
{
error (0, errno, "%s", dst_path);
goto un_backup;
}
return 0;
}
else
{
error (0, 0,
_("%s: can make relative symbolic links only in current directory"),
dst_path);
goto un_backup;
}
}
#endif
else if (x->hard_link)
{
if (link (src_path, dst_path))
{
error (0, errno, _("cannot create link `%s'"), dst_path);
goto un_backup;
}
return 0;
}
else if (S_ISREG (src_type)
|| (x->copy_as_regular && !S_ISDIR (src_type)
#ifdef S_ISLNK
&& !S_ISLNK (src_type)
#endif
))
{
if (copy_reg (src_path, dst_path, x->sparse_mode))
goto un_backup;
}
else
#ifdef S_ISFIFO
if (S_ISFIFO (src_type))
{
if (mkfifo (dst_path, src_mode & x->umask_kill))
{
error (0, errno, _("cannot create fifo `%s'"), dst_path);
goto un_backup;
}
}
else
#endif
if (S_ISBLK (src_type) || S_ISCHR (src_type)
#ifdef S_ISSOCK
|| S_ISSOCK (src_type)
#endif
)
{
if (mknod (dst_path, src_mode & x->umask_kill, src_sb.st_rdev))
{
error (0, errno, _("cannot create special file `%s'"), dst_path);
goto un_backup;
}
}
else
#ifdef S_ISLNK
if (S_ISLNK (src_type))
{
char *link_val;
int link_size;
link_val = (char *) alloca (PATH_MAX + 2);
link_size = readlink (src_path, link_val, PATH_MAX + 1);
if (link_size < 0)
{
error (0, errno, _("cannot read symbolic link `%s'"), src_path);
goto un_backup;
}
link_val[link_size] = '\0';
if (symlink (link_val, dst_path))
{
error (0, errno, _("cannot create symbolic link `%s'"), dst_path);
goto un_backup;
}
if (x->preserve)
{
/* Preserve the owner and group of the just-`copied'
symbolic link, if possible. */
#ifdef HAVE_LCHOWN
if (DO_CHOWN (lchown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, "%s", dst_path);
goto un_backup;
}
#else
# ifdef ROOT_CHOWN_AFFECTS_SYMLINKS
if (x->myeuid == 0)
{
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, "%s", dst_path);
goto un_backup;
}
}
else
{
/* FIXME: maybe give a diagnostic: you must be root
to preserve ownership and group of symlinks. */
}
# else
/* Can't preserve ownership of symlinks.
FIXME: maybe give a warning or even error for symlinks
in directories with the sticky bit set -- there, not
preserving owner/group is a potential security problem. */
# endif
#endif
}
return 0;
}
else
#endif
{
error (0, 0, _("%s: unknown file type"), src_path);
goto un_backup;
}
/* Adjust the times (and if possible, ownership) for the copy.
chown turns off set[ug]id bits for non-root,
so do the chmod last. */
if (x->preserve)
{
struct utimbuf utb;
utb.actime = src_sb.st_atime;
utb.modtime = src_sb.st_mtime;
if (utime (dst_path, &utb))
{
error (0, errno, "%s", dst_path);
return 1;
}
if (DO_CHOWN (chown, dst_path, src_sb.st_uid, src_sb.st_gid))
{
error (0, errno, "%s", dst_path);
return 1;
}
}
if ((x->preserve || new_dst)
&& (x->copy_as_regular || S_ISREG (src_type) || S_ISDIR (src_type)))
{
if (chmod (dst_path, src_mode & x->umask_kill))
{
error (0, errno, "%s", dst_path);
return 1;
}
}
else if (fix_mode)
{
/* Reset the temporarily changed mode. */
if (chmod (dst_path, dst_sb.st_mode))
{
error (0, errno, "%s", dst_path);
return 1;
}
}
return 0;
un_backup:
if (dst_backup)
{
if (rename (dst_backup, dst_path))
error (0, errno, _("cannot un-backup `%s'"), dst_path);
}
return 1;
}
/* Copy the file SRC_PATH to the file DST_PATH. The files may be of
any type. NONEXISTENT_DST should be nonzero if the file DST_PATH is
not to exist (e.g., because its parent directory was just created);
NONEXISTENT_DST should be zero if DST_PATH might already exist.
DEVICE is the device number of the parent directory, or 0 if the
parent of this file is not known. ANCESTORS points to a linked, null
terminated list of devices and inodes of parent directories of SRC_PATH.
Return 0 if successful, 1 if an error occurs. */
int
copy (const char *src_path, const char *dst_path, int nonexistent_dst,
const struct flag *x)
{
copy_internal (src_path, dst_path, ... , x);
}

View File

@@ -211,6 +211,18 @@ static struct option const long_opts[] =
{NULL, 0, NULL, 0}
};
static int
is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
{
while (ancestors != 0)
{
if (ancestors->ino == sb->st_ino && ancestors->dev == sb->st_dev)
return 1;
ancestors = ancestors->parent;
}
return 0;
}
int
main (int argc, char **argv)
{
@@ -570,7 +582,7 @@ is not a directory"),
usage (1);
}
}
/* Copy the file SRC_PATH to the file DST_PATH. The files may be of
any type. NEW_DST should be nonzero if the file DST_PATH cannot
exist because its parent directory was just created; NEW_DST should

View File

@@ -1129,7 +1129,7 @@ check_for_offset (struct control *p, const char *str, const char *num)
if (*num != '-' && *num != '+')
error (EXIT_FAILURE, 0, _("%s: `+' or `-' expected after delimeter"), str);
if (xstrtoul (num + 1, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtoul (num + 1, NULL, 10, &val, "") != LONGINT_OK
|| val > UINT_MAX)
error (EXIT_FAILURE, 0, _("%s: integer expected after `%c'"), str, *num);
p->offset = (unsigned int) val;
@@ -1158,7 +1158,7 @@ parse_repeat_count (int argnum, struct control *p, char *str)
p->repeat_forever = 1;
else
{
if (xstrtoul (str + 1, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtoul (str + 1, NULL, 10, &val, "") != LONGINT_OK
|| val > UINT_MAX)
{
error (EXIT_FAILURE, 0,
@@ -1240,7 +1240,7 @@ parse_patterns (int argc, int start, char **argv)
p = new_control_record ();
p->argnum = i;
if (xstrtoul (argv[i], NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtoul (argv[i], NULL, 10, &val, "") != LONGINT_OK
|| val > INT_MAX)
error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]);
if (val == 0)
@@ -1496,7 +1496,7 @@ main (int argc, char **argv)
break;
case 'n':
if (xstrtoul (optarg, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
|| val > INT_MAX)
error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
digits = (int) val;

View File

@@ -1,5 +1,6 @@
/* date - print or set the system date and time
Copyright (C) 89, 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
Copyright (C) 89, 90, 91, 92, 93, 94, 95, 96, 1997
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
@@ -25,12 +26,7 @@
#include "system.h"
#include "getline.h"
#include "error.h"
#ifdef TM_IN_SYS_TIME
#include <sys/time.h>
#else
#include <time.h>
#endif
#include "getdate.h"
#ifndef STDC_HEADERS
size_t strftime ();
@@ -41,7 +37,6 @@ int putenv ();
int stime ();
char *xrealloc ();
time_t get_date ();
time_t posixtime ();
static void show_date __P ((const char *format, time_t when));

View File

@@ -638,7 +638,7 @@ count_entry (char *ent, int top, dev_t last_dev)
else
{
printf ("%ld\t%s\n", output_size == size_bytes ? size
: convert_blocks (size, output_size == size_kilobytes),
: convert_blocks (size, output_size),
path->text);
}
fflush (stdout);

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* By default, convert all tabs to spaces.
Preserves backspace characters in the output; they decrement the

View File

@@ -136,7 +136,7 @@ print_factors (const char *s)
int n_factors;
int i;
if (xstrtoul (s, NULL, 10, &n, NULL) != LONGINT_OK)
if (xstrtoul (s, NULL, 10, &n, "") != LONGINT_OK)
{
error (0, 0, _("`%s' is not a valid positive integer"), s);
return 1;

View File

@@ -12,9 +12,8 @@
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.
*/
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Ross Paterson <rap@doc.ic.ac.uk>. */
@@ -382,7 +381,7 @@ main (register int argc, register char **argv)
case 'w':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid line number increment: `%s'"),
optarg);

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by David MacKenzie, djm@gnu.ai.mit.edu. */
@@ -295,7 +295,7 @@ main (int argc, char **argv)
case 'w': /* Line width. */
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid number of columns: `%s'"), optarg);

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Options: (see usage)
Reads from standard input if no files are given or when a filename of

View File

@@ -12,8 +12,8 @@
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.
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Written by Mike Haertel, mike@gnu.ai.mit.edu. */
@@ -678,7 +678,7 @@ decode_field_spec (const char *s, int *file_index, int *field_index)
strtol_error s_err;
long int tmp_long;
s_err = xstrtol (s + 2, NULL, 10, &tmp_long, NULL);
s_err = xstrtol (s + 2, NULL, 10, &tmp_long, "");
if (s_err != LONGINT_OK || tmp_long <= 0 || tmp_long > INT_MAX)
{
error (0, 0, _("invalid field number: `%s'"), s + 2);
@@ -787,7 +787,7 @@ main (int argc, char **argv)
/* Fall through. */
case 'a':
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &val, "") != LONGINT_OK
|| (val != 1 && val != 2))
error (EXIT_FAILURE, 0, _("invalid field number: `%s'"), optarg);
if (val == 1)
@@ -805,7 +805,7 @@ main (int argc, char **argv)
break;
case '1':
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &val, "") != LONGINT_OK
|| val <= 0 || val > INT_MAX)
{
error (EXIT_FAILURE, 0,
@@ -815,7 +815,7 @@ main (int argc, char **argv)
break;
case '2':
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &val, "") != LONGINT_OK
|| val <= 0 || val > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid field number for file 2: `%s'"), optarg);
@@ -823,7 +823,7 @@ main (int argc, char **argv)
break;
case 'j':
if (xstrtol (optarg, NULL, 10, &val, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &val, "") != LONGINT_OK
|| val <= 0 || val > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid field number: `%s'"), optarg);
join_field_1 = join_field_2 = (int) val - 1;

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Scott Bartram (nancy!scott@uunet.uu.net)
Revised by David MacKenzie (djm@gnu.ai.mit.edu) */
@@ -495,7 +495,7 @@ main (int argc, char **argv)
case 'v':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
/* Allow it to be negative. */
|| tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid starting line number: `%s'"),
@@ -506,7 +506,7 @@ main (int argc, char **argv)
case 'i':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid line number increment: `%s'"),
optarg);
@@ -519,7 +519,7 @@ main (int argc, char **argv)
case 'l':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid number of blank lines: `%s'"),
optarg);
@@ -532,7 +532,7 @@ main (int argc, char **argv)
case 'w':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid line number field width: `%s'"),

View File

@@ -1776,7 +1776,7 @@ the maximum\nrepresentable value of type `long'"), optarg);
}
else
{
s_err = xstrtoul (optarg, NULL, 10, &desired_width, NULL);
s_err = xstrtoul (optarg, NULL, 10, &desired_width, "");
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (optarg, _("width specification"), s_err);
}

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Author: Pete TerMaat. */
@@ -634,7 +634,7 @@ first_last_page (char *pages)
{
long int tmp_long;
if (xstrtol (pages, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (pages, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid starting page number: `%s'"),
pages);
@@ -646,7 +646,7 @@ first_last_page (char *pages)
{
long int tmp_long;
if (xstrtol (str1 + 1, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (str1 + 1, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0, _("invalid ending page number: `%s'"),
str1 + 1);
@@ -775,7 +775,7 @@ main (int argc, char **argv)
case 'l':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
{
error (EXIT_FAILURE, 0,
@@ -799,7 +799,7 @@ main (int argc, char **argv)
skip_count = FALSE;
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long > INT_MAX)
{
error (EXIT_FAILURE, 0,
@@ -812,7 +812,7 @@ main (int argc, char **argv)
case 'o':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("`-o MARGIN' invalid line offset: `%s'"), optarg);
@@ -842,7 +842,7 @@ main (int argc, char **argv)
truncate_lines = TRUE;
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("`-w PAGE_WIDTH' invalid column number: `%s'"), optarg);
@@ -919,7 +919,7 @@ getoptarg (char *arg, char switch_char, char *character, int *number)
if (*arg)
{
long int tmp_long;
if (xstrtol (arg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (arg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
{
error (0, 0,

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* By tege@sics.se, with rms.

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Can display any amount of data, unlike the Unix version, which uses
a fixed size buffer and therefore can only deliver a limited number
@@ -49,11 +49,27 @@
#include <assert.h>
#include <getopt.h>
#include <sys/types.h>
#if HAVE_LIMITS_H
# include <limits.h>
#endif
#include "system.h"
#include "xstrtol.h"
#include "xstrtoul.h"
#include "error.h"
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
#ifndef OFF_T_MIN
# define OFF_T_MIN (0 < (off_t) -1 ? (off_t) 0 \
: ~ (off_t) 0 << (sizeof (off_t) * CHAR_BIT - 1))
#endif
#ifndef OFF_T_MAX
# define OFF_T_MAX (~ (off_t) 0 - OFF_T_MIN)
#endif
/* Disable assertions. Some systems have broken assert macros. */
#define NDEBUG 1
@@ -837,17 +853,211 @@ tail_file (const char *filename, off_t n_units, int filenum)
return errors;
}
/* If the command line arguments are of the obsolescent form and the
option string is well-formed, set *FAIL to zero, set *N_UNITS, the
globals COUNT_LINES, FOREVER, and FROM_START, and return non-zero.
Otherwise, if the command line arguments appear to be of the
obsolescent form but the option string is malformed, set *FAIL to
non-zero, don't modify any other parameter or global variable, and
return non-zero. Otherwise, return zero and don't modify any parameter
or global variable. */
static int
parse_obsolescent_option (int argc, const char *const *argv,
off_t *n_units, int *fail)
{
const char *p = argv[1];
const char *n_string = NULL;
const char *n_string_end;
int t_from_start;
int t_count_lines;
int t_forever;
/* With the obsolescent form, there is one option string and at most
one file argument. */
if (argc < 2 || argc > 3)
return 0;
/* If I were implementing this in Perl, the rest of this function
would be essentially this single statement:
return $p ne '-' && $p ne '-c' && $p =~ /^[+-]\d*[cl]?f?$/; */
/* Test this:
if (STREQ (p, "-") || STREQ (p, "-c"))
but without using strcmp. */
if (p[0] == '-' && (p[1] == 0 || (p[1] == 'c' && p[2] == 0)))
return 0;
if (*p == '+')
t_from_start = 1;
else if (*p == '-')
t_from_start = 0;
else
return 0;
++p;
if (ISDIGIT (*p))
{
n_string = p;
do
{
++p;
}
while (ISDIGIT (*p));
}
n_string_end = p;
t_count_lines = 1;
if (*p == 'c')
{
t_count_lines = 0;
++p;
}
else if (*p == 'l')
{
++p;
}
t_forever = 0;
if (*p == 'f')
{
t_forever = 1;
++p;
}
if (*p != '\0')
{
/* If (argv[1] begins with a `+' or if it begins with `-' followed
by a digit), but has an invalid suffix character, give a diagnostic
and indicate to caller that this *is* of the obsolescent form,
but that it's an invalid option. */
if (t_from_start || n_string)
{
error (0, 0,
_("%c: invalid suffix character in obsolescent option" ), *p);
*fail = 1;
return 1;
}
/* Otherwise, it might be a valid non-obsolescent option like -n. */
return 0;
}
*fail = 0;
if (n_string == NULL)
*n_units = DEFAULT_N_LINES;
else
{
strtol_error s_err;
unsigned long int tmp_ulong;
char *end;
s_err = xstrtoul (n_string, &end, 0, &tmp_ulong, NULL);
if (s_err == LONGINT_OK && tmp_ulong <= OFF_T_MAX)
*n_units = (off_t) tmp_ulong;
else
{
/* Extract a NUL-terminated string for the error message. */
size_t len = n_string_end - n_string;
char *n_string_tmp = xmalloc (len + 1);
strncpy (n_string_tmp, n_string, len);
n_string_tmp[len] = '\0';
error (0, 0,
_("%s, `%s' is so large that it is not representable"),
count_lines ? _("number of lines") : _("number of bytes"),
n_string_tmp);
free (n_string_tmp);
*fail = 1;
}
}
if (!*fail)
{
/* Set globals. */
from_start = t_from_start;
count_lines = t_count_lines;
forever = t_forever;
}
return 1;
}
static void
parse_options (int argc, char **argv,
off_t *n_units, enum header_mode *header_mode)
{
int c;
count_lines = 1;
forever = forever_multiple = from_start = print_headers = 0;
while ((c = getopt_long (argc, argv, "c:n:fqv", long_options, (int *) 0))
!= EOF)
{
switch (c)
{
case 0:
break;
case 'c':
case 'n':
count_lines = (c == 'n');
if (*optarg == '+')
from_start = 1;
else if (*optarg == '-')
++optarg;
{
strtol_error s_err;
unsigned long int tmp_ulong;
s_err = xstrtoul (optarg, NULL, 0, &tmp_ulong, "bkm");
if (s_err == LONGINT_INVALID)
{
error (EXIT_FAILURE, 0, "%s: %s", optarg,
(c == 'n'
? _("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;
}
break;
case 'f':
forever = 1;
break;
case 'q':
*header_mode = never;
break;
case 'v':
*header_mode = always;
break;
default:
usage (1);
}
}
}
int
main (int argc, char **argv)
{
enum header_mode header_mode = multiple_files;
int exit_status = 0;
/* If from_start, the number of items to skip before printing; otherwise,
the number of items at the end of the file to print. Initially, -1
means the value has not been set. */
off_t n_units = -1;
long int tmp_long;
int c; /* Option character. */
the number of items at the end of the file to print. Although the type
is signed, the value is never negative. */
off_t n_units = DEFAULT_N_LINES;
int n_files;
char **file;
@@ -857,123 +1067,24 @@ main (int argc, char **argv)
textdomain (PACKAGE);
have_read_stdin = 0;
count_lines = 1;
forever = forever_multiple = from_start = print_headers = 0;
if (argc > 1
&& ((argv[1][0] == '-' && ISDIGIT (argv[1][1]))
|| (argv[1][0] == '+' && (ISDIGIT (argv[1][1])
|| argv[1][1] == 0))))
{
/* Old option syntax: a dash or plus, one or more digits (zero digits
are acceptable with a plus), and one or more option letters. */
if (argv[1][0] == '+')
from_start = 1;
if (argv[1][1] != '\0')
{
strtol_error s_err;
char *p;
s_err = xstrtol (++argv[1], &p, 0, &tmp_long, "bkm");
n_units = tmp_long;
if (s_err == LONGINT_OVERFLOW)
{
STRTOL_FATAL_ERROR (argv[1], _("argument"), s_err);
}
/* If a [bkm] suffix was given then count bytes, not lines. */
if (p[-1] == 'b' || p[-1] == 'k' || p[-1] == 'm')
count_lines = 0;
/* Parse any appended option letters. */
while (*p)
{
switch (*p)
{
case 'c':
/* Interpret N_UNITS as # of bytes. */
count_lines = 0;
break;
case 'f':
forever = 1;
break;
case 'l':
count_lines = 1;
break;
case 'q':
header_mode = never;
break;
case 'v':
header_mode = always;
break;
default:
error (0, 0, _("unrecognized option `-%c'"), *p);
usage (1);
}
++p;
}
}
/* Make the options we just parsed invisible to getopt. */
argv[1] = argv[0];
argv++;
argc--;
}
while ((c = getopt_long (argc, argv, "c:n:fqv", long_options, (int *) 0))
!= EOF)
{
strtol_error s_err;
switch (c)
{
case 0:
break;
case 'c':
count_lines = 0;
goto getnum;
case 'n':
count_lines = 1;
getnum:
if (*optarg == '+')
{
from_start = 1;
}
s_err = xstrtol (optarg, NULL, 0, &tmp_long, "bkm");
if (tmp_long < 0)
tmp_long = -tmp_long;
n_units = tmp_long;
if (s_err != LONGINT_OK)
{
STRTOL_FATAL_ERROR (optarg, (c == 'n'
? _("number of lines")
: _("number of bytes")), s_err);
}
break;
case 'f':
forever = 1;
break;
case 'q':
header_mode = never;
break;
case 'v':
header_mode = always;
break;
default:
usage (1);
}
}
{
int found_obsolescent;
int fail;
found_obsolescent = parse_obsolescent_option (argc,
(const char *const *) argv,
&n_units, &fail);
if (found_obsolescent)
{
if (fail)
exit (EXIT_FAILURE);
optind = 2;
}
else
{
parse_options (argc, argv, &n_units, &header_mode);
}
}
if (show_version)
{
@@ -984,9 +1095,6 @@ main (int argc, char **argv)
if (show_help)
usage (0);
if (n_units == -1)
n_units = DEFAULT_N_LINES;
/* To start printing with item N_UNITS from the start of the file, skip
N_UNITS - 1 items. `tail +0' is actually meaningless, but for Unix
compatibility it's treated the same as `tail +1'. */

View File

@@ -654,7 +654,7 @@ unary_operator (void)
value = -1 != eaccess (argv[pos - 1], R_OK);
return (TRUE == value);
case 'w': /* File is writeable? */
case 'w': /* File is writable? */
unary_advance ();
value = -1 != eaccess (argv[pos - 1], W_OK);
return (TRUE == value);

View File

@@ -12,8 +12,8 @@
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. */
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Written by Richard Stallman and David MacKenzie. */
@@ -336,7 +336,7 @@ main (int argc, char **argv)
case 'f': /* Like '-#'. */
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid number of fields to skip: `%s'"),
@@ -352,7 +352,7 @@ main (int argc, char **argv)
case 's': /* Like '+#'. */
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid number of bytes to skip: `%s'"),
@@ -368,7 +368,7 @@ main (int argc, char **argv)
case 'w':
{
long int tmp_long;
if (xstrtol (optarg, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid number of bytes to compare: `%s'"),
@@ -399,7 +399,7 @@ main (int argc, char **argv)
{
char *opt_str = argv[optind++];
long int tmp_long;
if (xstrtol (opt_str, NULL, 10, &tmp_long, NULL) != LONGINT_OK
if (xstrtol (opt_str, NULL, 10, &tmp_long, "") != LONGINT_OK
|| tmp_long <= 0 || tmp_long > INT_MAX)
error (EXIT_FAILURE, 0,
_("invalid number of bytes to compare: `%s'"),

View File

@@ -648,7 +648,7 @@ usage (int status)
-s (ignored)\n\
-T, -w, --mesg add user's message status as +, - or ?\n\
--message same as -T\n\
--writeable same as -T\n\
--writable same as -T\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\

View File

@@ -1,3 +1,3 @@
A note about Makefile.am.in.
It is used (usually only by the maintainer) to generate most of the
Makefile.am files in these subdirectories.
Makefile.am files in these subdirectories.

View File

@@ -9,15 +9,17 @@ tc.in tc.exp td.in td.exp te.in te.exp tf.in tf.exp tg.in tg.exp th.in th.exp \
ti.in ti.exp tj.in tj.exp tk.in tk.exp tl.in tl.exp tm.in tm.exp tn.in tn.exp \
to.in to.exp tp.in tp.exp tq.in tq.exp tr.in tr.exp ts.in ts.exp tt.in tt.exp \
tu.in tu.exp tv.in tv.exp tw.in tw.exp tx.in tx.exp ty.in ty.exp tz.in tz.exp \
tA.in tA.exp tB.in tB.exp tC.in tC.exp tD.in tD.exp
tempty-fl.in tempty-fl.exp tmissing-fl.in tmissing-fl.exp tempty-bl.in \
tempty-bl.exp tmissing-bl.in tmissing-bl.exp
run_gen = t1.out t1.err t2.out t2.err t3.out t3.err t4.out t4.err t5.out \
t5.err t6.out t6.err t7.out t7.err t8.out t8.err t9.out t9.err ta.out ta.err \
tb.out tb.err tc.out tc.err td.out td.err te.out te.err tf.out tf.err tg.out \
tg.err th.out th.err ti.out ti.err tj.out tj.err tk.out tk.err tl.out tl.err \
tm.out tm.err tn.out tn.err to.out to.err tp.out tp.err tq.out tq.err tr.out \
tr.err ts.out ts.err tt.out tt.err tu.out tu.err tv.out tv.err tw.out tw.err \
tx.out tx.err ty.out ty.err tz.out tz.err tA.out tA.err tB.out tB.err tC.out \
tC.err tD.out tD.err
tx.out tx.err ty.out ty.err tz.out tz.err tempty-fl.out tempty-fl.err \
tmissing-fl.out tmissing-fl.err tempty-bl.out tempty-bl.err tmissing-bl.out \
tmissing-bl.err
##test-files-end
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)

View File

@@ -50,15 +50,17 @@ tc.in tc.exp td.in td.exp te.in te.exp tf.in tf.exp tg.in tg.exp th.in th.exp \
ti.in ti.exp tj.in tj.exp tk.in tk.exp tl.in tl.exp tm.in tm.exp tn.in tn.exp \
to.in to.exp tp.in tp.exp tq.in tq.exp tr.in tr.exp ts.in ts.exp tt.in tt.exp \
tu.in tu.exp tv.in tv.exp tw.in tw.exp tx.in tx.exp ty.in ty.exp tz.in tz.exp \
tA.in tA.exp tB.in tB.exp tC.in tC.exp tD.in tD.exp
tempty-fl.in tempty-fl.exp tmissing-fl.in tmissing-fl.exp tempty-bl.in \
tempty-bl.exp tmissing-bl.in tmissing-bl.exp
run_gen = t1.out t1.err t2.out t2.err t3.out t3.err t4.out t4.err t5.out \
t5.err t6.out t6.err t7.out t7.err t8.out t8.err t9.out t9.err ta.out ta.err \
tb.out tb.err tc.out tc.err td.out td.err te.out te.err tf.out tf.err tg.out \
tg.err th.out th.err ti.out ti.err tj.out tj.err tk.out tk.err tl.out tl.err \
tm.out tm.err tn.out tn.err to.out to.err tp.out tp.err tq.out tq.err tr.out \
tr.err ts.out ts.err tt.out tt.err tu.out tu.err tv.out tv.err tw.out tw.err \
tx.out tx.err ty.out ty.err tz.out tz.err tA.out tA.err tB.out tB.err tC.out \
tC.err tD.out tD.err
tx.out tx.err ty.out ty.err tz.out tz.err tempty-fl.out tempty-fl.err \
tmissing-fl.out tmissing-fl.err tempty-bl.out tempty-bl.err tmissing-bl.out \
tmissing-bl.err
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests

View File

@@ -49,13 +49,13 @@ my @tv = (
# You must specify bytes or fields (or chars)
['z', '', ":\n", "", 1],
# Empty field list
['A', '-f \'\'', ":\n", "", 1],
['empty-fl', '-f \'\'', ":\n", "", 1],
# Missing field list
['B', '-f', ":\n", "", 1],
['missing-fl', '-f', ":\n", "", 1],
# Empty byte list
['C', '-b \'\'', ":\n", "", 1],
['empty-bl', '-b \'\'', ":\n", "", 1],
# Missing byte list
['D', '-b', ":\n", "", 1],
['missing-bl', '-b', ":\n", "", 1],
);
sub test_vector

View File

@@ -12,15 +12,15 @@ test "$VERBOSE" && $xx --version 2> /dev/null
$xx -d: -f1,3- $srcdir/t1.in > t1.out 2> t1.err
code=$?
if test $code != 0 ; then
$echo Test 1 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 1 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1.out $srcdir/t1.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1; fi ;; # equal files
1) $echo Test 1 failed: files t1.out and $srcdir/t1.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1"; fi ;;
1) $echo "Test 1 failed: files t1.out and $srcdir/t1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1 may have failed. 1>&2;
2) $echo "Test 1 may have failed." 1>&2;
$echo The command "cmp t1.out $srcdir/t1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -29,15 +29,15 @@ test -s t1.err || rm -f t1.err
$xx -d: -f1,3- $srcdir/t2.in > t2.out 2> t2.err
code=$?
if test $code != 0 ; then
$echo Test 2 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 2 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t2.out $srcdir/t2.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 2; fi ;; # equal files
1) $echo Test 2 failed: files t2.out and $srcdir/t2.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 2"; fi ;;
1) $echo "Test 2 failed: files t2.out and $srcdir/t2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 2 may have failed. 1>&2;
2) $echo "Test 2 may have failed." 1>&2;
$echo The command "cmp t2.out $srcdir/t2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -46,15 +46,15 @@ test -s t2.err || rm -f t2.err
$xx -d: -f2- $srcdir/t3.in > t3.out 2> t3.err
code=$?
if test $code != 0 ; then
$echo Test 3 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 3 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t3.out $srcdir/t3.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 3; fi ;; # equal files
1) $echo Test 3 failed: files t3.out and $srcdir/t3.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 3"; fi ;;
1) $echo "Test 3 failed: files t3.out and $srcdir/t3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 3 may have failed. 1>&2;
2) $echo "Test 3 may have failed." 1>&2;
$echo The command "cmp t3.out $srcdir/t3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -63,15 +63,15 @@ test -s t3.err || rm -f t3.err
$xx -d: -f4 $srcdir/t4.in > t4.out 2> t4.err
code=$?
if test $code != 0 ; then
$echo Test 4 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 4 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4.out $srcdir/t4.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4; fi ;; # equal files
1) $echo Test 4 failed: files t4.out and $srcdir/t4.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4"; fi ;;
1) $echo "Test 4 failed: files t4.out and $srcdir/t4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4 may have failed. 1>&2;
2) $echo "Test 4 may have failed." 1>&2;
$echo The command "cmp t4.out $srcdir/t4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -80,15 +80,15 @@ test -s t4.err || rm -f t4.err
$xx -d: -f4 $srcdir/t5.in > t5.out 2> t5.err
code=$?
if test $code != 0 ; then
$echo Test 5 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 5 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5.out $srcdir/t5.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5; fi ;; # equal files
1) $echo Test 5 failed: files t5.out and $srcdir/t5.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5"; fi ;;
1) $echo "Test 5 failed: files t5.out and $srcdir/t5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5 may have failed. 1>&2;
2) $echo "Test 5 may have failed." 1>&2;
$echo The command "cmp t5.out $srcdir/t5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -97,15 +97,15 @@ test -s t5.err || rm -f t5.err
$xx -c4 $srcdir/t6.in > t6.out 2> t6.err
code=$?
if test $code != 0 ; then
$echo Test 6 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 6 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t6.out $srcdir/t6.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 6; fi ;; # equal files
1) $echo Test 6 failed: files t6.out and $srcdir/t6.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 6"; fi ;;
1) $echo "Test 6 failed: files t6.out and $srcdir/t6.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 6 may have failed. 1>&2;
2) $echo "Test 6 may have failed." 1>&2;
$echo The command "cmp t6.out $srcdir/t6.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -114,15 +114,15 @@ test -s t6.err || rm -f t6.err
$xx -c4 $srcdir/t7.in > t7.out 2> t7.err
code=$?
if test $code != 0 ; then
$echo Test 7 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 7 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t7.out $srcdir/t7.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 7; fi ;; # equal files
1) $echo Test 7 failed: files t7.out and $srcdir/t7.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 7"; fi ;;
1) $echo "Test 7 failed: files t7.out and $srcdir/t7.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 7 may have failed. 1>&2;
2) $echo "Test 7 may have failed." 1>&2;
$echo The command "cmp t7.out $srcdir/t7.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -131,15 +131,15 @@ test -s t7.err || rm -f t7.err
$xx -c4 $srcdir/t8.in > t8.out 2> t8.err
code=$?
if test $code != 0 ; then
$echo Test 8 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 8 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t8.out $srcdir/t8.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 8; fi ;; # equal files
1) $echo Test 8 failed: files t8.out and $srcdir/t8.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 8"; fi ;;
1) $echo "Test 8 failed: files t8.out and $srcdir/t8.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 8 may have failed. 1>&2;
2) $echo "Test 8 may have failed." 1>&2;
$echo The command "cmp t8.out $srcdir/t8.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -148,15 +148,15 @@ test -s t8.err || rm -f t8.err
$xx -c4 $srcdir/t9.in > t9.out 2> t9.err
code=$?
if test $code != 0 ; then
$echo Test 9 failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test 9 failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t9.out $srcdir/t9.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 9; fi ;; # equal files
1) $echo Test 9 failed: files t9.out and $srcdir/t9.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 9"; fi ;;
1) $echo "Test 9 failed: files t9.out and $srcdir/t9.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 9 may have failed. 1>&2;
2) $echo "Test 9 may have failed." 1>&2;
$echo The command "cmp t9.out $srcdir/t9.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -165,15 +165,15 @@ test -s t9.err || rm -f t9.err
$xx -s -d: -f3- $srcdir/ta.in > ta.out 2> ta.err
code=$?
if test $code != 0 ; then
$echo Test a failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test a failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp ta.out $srcdir/ta.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed a; fi ;; # equal files
1) $echo Test a failed: files ta.out and $srcdir/ta.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed a"; fi ;;
1) $echo "Test a failed: files ta.out and $srcdir/ta.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test a may have failed. 1>&2;
2) $echo "Test a may have failed." 1>&2;
$echo The command "cmp ta.out $srcdir/ta.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -182,15 +182,15 @@ test -s ta.err || rm -f ta.err
$xx -s -d: -f2,3 $srcdir/tb.in > tb.out 2> tb.err
code=$?
if test $code != 0 ; then
$echo Test b failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test b failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tb.out $srcdir/tb.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed b; fi ;; # equal files
1) $echo Test b failed: files tb.out and $srcdir/tb.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed b"; fi ;;
1) $echo "Test b failed: files tb.out and $srcdir/tb.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test b may have failed. 1>&2;
2) $echo "Test b may have failed." 1>&2;
$echo The command "cmp tb.out $srcdir/tb.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -199,15 +199,15 @@ test -s tb.err || rm -f tb.err
$xx -s -d: -f1,3 $srcdir/tc.in > tc.out 2> tc.err
code=$?
if test $code != 0 ; then
$echo Test c failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test c failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tc.out $srcdir/tc.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed c; fi ;; # equal files
1) $echo Test c failed: files tc.out and $srcdir/tc.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed c"; fi ;;
1) $echo "Test c failed: files tc.out and $srcdir/tc.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test c may have failed. 1>&2;
2) $echo "Test c may have failed." 1>&2;
$echo The command "cmp tc.out $srcdir/tc.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -216,15 +216,15 @@ test -s tc.err || rm -f tc.err
$xx -s -d: -f1,3 $srcdir/td.in > td.out 2> td.err
code=$?
if test $code != 0 ; then
$echo Test d failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test d failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp td.out $srcdir/td.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed d; fi ;; # equal files
1) $echo Test d failed: files td.out and $srcdir/td.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed d"; fi ;;
1) $echo "Test d failed: files td.out and $srcdir/td.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test d may have failed. 1>&2;
2) $echo "Test d may have failed." 1>&2;
$echo The command "cmp td.out $srcdir/td.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -233,15 +233,15 @@ test -s td.err || rm -f td.err
$xx -s -d: -f3- $srcdir/te.in > te.out 2> te.err
code=$?
if test $code != 0 ; then
$echo Test e failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test e failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp te.out $srcdir/te.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed e; fi ;; # equal files
1) $echo Test e failed: files te.out and $srcdir/te.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed e"; fi ;;
1) $echo "Test e failed: files te.out and $srcdir/te.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test e may have failed. 1>&2;
2) $echo "Test e may have failed." 1>&2;
$echo The command "cmp te.out $srcdir/te.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -250,15 +250,15 @@ test -s te.err || rm -f te.err
$xx -s -d: -f3-4 $srcdir/tf.in > tf.out 2> tf.err
code=$?
if test $code != 0 ; then
$echo Test f failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test f failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tf.out $srcdir/tf.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed f; fi ;; # equal files
1) $echo Test f failed: files tf.out and $srcdir/tf.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed f"; fi ;;
1) $echo "Test f failed: files tf.out and $srcdir/tf.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test f may have failed. 1>&2;
2) $echo "Test f may have failed." 1>&2;
$echo The command "cmp tf.out $srcdir/tf.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -267,15 +267,15 @@ test -s tf.err || rm -f tf.err
$xx -s -d: -f3,4 $srcdir/tg.in > tg.out 2> tg.err
code=$?
if test $code != 0 ; then
$echo Test g failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test g failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tg.out $srcdir/tg.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed g; fi ;; # equal files
1) $echo Test g failed: files tg.out and $srcdir/tg.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed g"; fi ;;
1) $echo "Test g failed: files tg.out and $srcdir/tg.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test g may have failed. 1>&2;
2) $echo "Test g may have failed." 1>&2;
$echo The command "cmp tg.out $srcdir/tg.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -284,15 +284,15 @@ test -s tg.err || rm -f tg.err
$xx -s -d: -f2,3 $srcdir/th.in > th.out 2> th.err
code=$?
if test $code != 0 ; then
$echo Test h failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test h failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp th.out $srcdir/th.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed h; fi ;; # equal files
1) $echo Test h failed: files th.out and $srcdir/th.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed h"; fi ;;
1) $echo "Test h failed: files th.out and $srcdir/th.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test h may have failed. 1>&2;
2) $echo "Test h may have failed." 1>&2;
$echo The command "cmp th.out $srcdir/th.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -301,15 +301,15 @@ test -s th.err || rm -f th.err
$xx -d: -f1-3 $srcdir/ti.in > ti.out 2> ti.err
code=$?
if test $code != 0 ; then
$echo Test i failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test i failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp ti.out $srcdir/ti.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed i; fi ;; # equal files
1) $echo Test i failed: files ti.out and $srcdir/ti.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed i"; fi ;;
1) $echo "Test i failed: files ti.out and $srcdir/ti.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test i may have failed. 1>&2;
2) $echo "Test i may have failed." 1>&2;
$echo The command "cmp ti.out $srcdir/ti.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -318,15 +318,15 @@ test -s ti.err || rm -f ti.err
$xx -d: -f1-4 $srcdir/tj.in > tj.out 2> tj.err
code=$?
if test $code != 0 ; then
$echo Test j failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test j failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tj.out $srcdir/tj.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed j; fi ;; # equal files
1) $echo Test j failed: files tj.out and $srcdir/tj.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed j"; fi ;;
1) $echo "Test j failed: files tj.out and $srcdir/tj.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test j may have failed. 1>&2;
2) $echo "Test j may have failed." 1>&2;
$echo The command "cmp tj.out $srcdir/tj.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -335,15 +335,15 @@ test -s tj.err || rm -f tj.err
$xx -d: -f2-3 $srcdir/tk.in > tk.out 2> tk.err
code=$?
if test $code != 0 ; then
$echo Test k failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test k failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tk.out $srcdir/tk.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed k; fi ;; # equal files
1) $echo Test k failed: files tk.out and $srcdir/tk.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed k"; fi ;;
1) $echo "Test k failed: files tk.out and $srcdir/tk.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test k may have failed. 1>&2;
2) $echo "Test k may have failed." 1>&2;
$echo The command "cmp tk.out $srcdir/tk.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -352,15 +352,15 @@ test -s tk.err || rm -f tk.err
$xx -d: -f2-4 $srcdir/tl.in > tl.out 2> tl.err
code=$?
if test $code != 0 ; then
$echo Test l failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test l failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tl.out $srcdir/tl.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed l; fi ;; # equal files
1) $echo Test l failed: files tl.out and $srcdir/tl.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed l"; fi ;;
1) $echo "Test l failed: files tl.out and $srcdir/tl.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test l may have failed. 1>&2;
2) $echo "Test l may have failed." 1>&2;
$echo The command "cmp tl.out $srcdir/tl.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -369,15 +369,15 @@ test -s tl.err || rm -f tl.err
$xx -s -d: -f1-3 $srcdir/tm.in > tm.out 2> tm.err
code=$?
if test $code != 0 ; then
$echo Test m failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test m failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tm.out $srcdir/tm.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed m; fi ;; # equal files
1) $echo Test m failed: files tm.out and $srcdir/tm.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed m"; fi ;;
1) $echo "Test m failed: files tm.out and $srcdir/tm.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test m may have failed. 1>&2;
2) $echo "Test m may have failed." 1>&2;
$echo The command "cmp tm.out $srcdir/tm.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -386,15 +386,15 @@ test -s tm.err || rm -f tm.err
$xx -s -d: -f1-4 $srcdir/tn.in > tn.out 2> tn.err
code=$?
if test $code != 0 ; then
$echo Test n failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test n failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn.out $srcdir/tn.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed n; fi ;; # equal files
1) $echo Test n failed: files tn.out and $srcdir/tn.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed n"; fi ;;
1) $echo "Test n failed: files tn.out and $srcdir/tn.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test n may have failed. 1>&2;
2) $echo "Test n may have failed." 1>&2;
$echo The command "cmp tn.out $srcdir/tn.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -403,15 +403,15 @@ test -s tn.err || rm -f tn.err
$xx -s -d: -f2-3 $srcdir/to.in > to.out 2> to.err
code=$?
if test $code != 0 ; then
$echo Test o failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test o failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp to.out $srcdir/to.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed o; fi ;; # equal files
1) $echo Test o failed: files to.out and $srcdir/to.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed o"; fi ;;
1) $echo "Test o failed: files to.out and $srcdir/to.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test o may have failed. 1>&2;
2) $echo "Test o may have failed." 1>&2;
$echo The command "cmp to.out $srcdir/to.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -420,15 +420,15 @@ test -s to.err || rm -f to.err
$xx -s -d: -f2-4 $srcdir/tp.in > tp.out 2> tp.err
code=$?
if test $code != 0 ; then
$echo Test p failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test p failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tp.out $srcdir/tp.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed p; fi ;; # equal files
1) $echo Test p failed: files tp.out and $srcdir/tp.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed p"; fi ;;
1) $echo "Test p failed: files tp.out and $srcdir/tp.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test p may have failed. 1>&2;
2) $echo "Test p may have failed." 1>&2;
$echo The command "cmp tp.out $srcdir/tp.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -437,15 +437,15 @@ test -s tp.err || rm -f tp.err
$xx -s -d: -f2-4 $srcdir/tq.in > tq.out 2> tq.err
code=$?
if test $code != 0 ; then
$echo Test q failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test q failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tq.out $srcdir/tq.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed q; fi ;; # equal files
1) $echo Test q failed: files tq.out and $srcdir/tq.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed q"; fi ;;
1) $echo "Test q failed: files tq.out and $srcdir/tq.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test q may have failed. 1>&2;
2) $echo "Test q may have failed." 1>&2;
$echo The command "cmp tq.out $srcdir/tq.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -454,15 +454,15 @@ test -s tq.err || rm -f tq.err
$xx -s -d: -f2-4 $srcdir/tr.in > tr.out 2> tr.err
code=$?
if test $code != 0 ; then
$echo Test r failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test r failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tr.out $srcdir/tr.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed r; fi ;; # equal files
1) $echo Test r failed: files tr.out and $srcdir/tr.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed r"; fi ;;
1) $echo "Test r failed: files tr.out and $srcdir/tr.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test r may have failed. 1>&2;
2) $echo "Test r may have failed." 1>&2;
$echo The command "cmp tr.out $srcdir/tr.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -471,15 +471,15 @@ test -s tr.err || rm -f tr.err
$xx -s -d: -f1-4 $srcdir/ts.in > ts.out 2> ts.err
code=$?
if test $code != 0 ; then
$echo Test s failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test s failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp ts.out $srcdir/ts.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed s; fi ;; # equal files
1) $echo Test s failed: files ts.out and $srcdir/ts.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed s"; fi ;;
1) $echo "Test s failed: files ts.out and $srcdir/ts.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test s may have failed. 1>&2;
2) $echo "Test s may have failed." 1>&2;
$echo The command "cmp ts.out $srcdir/ts.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -488,15 +488,15 @@ test -s ts.err || rm -f ts.err
$xx -s -d: -f3- $srcdir/tt.in > tt.out 2> tt.err
code=$?
if test $code != 0 ; then
$echo Test t failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test t failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tt.out $srcdir/tt.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed t; fi ;; # equal files
1) $echo Test t failed: files tt.out and $srcdir/tt.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed t"; fi ;;
1) $echo "Test t failed: files tt.out and $srcdir/tt.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test t may have failed. 1>&2;
2) $echo "Test t may have failed." 1>&2;
$echo The command "cmp tt.out $srcdir/tt.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -505,15 +505,15 @@ test -s tt.err || rm -f tt.err
$xx -s -f3- $srcdir/tu.in > tu.out 2> tu.err
code=$?
if test $code != 0 ; then
$echo Test u failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test u failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tu.out $srcdir/tu.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed u; fi ;; # equal files
1) $echo Test u failed: files tu.out and $srcdir/tu.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed u"; fi ;;
1) $echo "Test u failed: files tu.out and $srcdir/tu.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test u may have failed. 1>&2;
2) $echo "Test u may have failed." 1>&2;
$echo The command "cmp tu.out $srcdir/tu.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -522,15 +522,15 @@ test -s tu.err || rm -f tu.err
$xx -f3- $srcdir/tv.in > tv.out 2> tv.err
code=$?
if test $code != 0 ; then
$echo Test v failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test v failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tv.out $srcdir/tv.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed v; fi ;; # equal files
1) $echo Test v failed: files tv.out and $srcdir/tv.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed v"; fi ;;
1) $echo "Test v failed: files tv.out and $srcdir/tv.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test v may have failed. 1>&2;
2) $echo "Test v may have failed." 1>&2;
$echo The command "cmp tv.out $srcdir/tv.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -539,15 +539,15 @@ test -s tv.err || rm -f tv.err
$xx -b 1 $srcdir/tw.in > tw.out 2> tw.err
code=$?
if test $code != 0 ; then
$echo Test w failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test w failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tw.out $srcdir/tw.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed w; fi ;; # equal files
1) $echo Test w failed: files tw.out and $srcdir/tw.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed w"; fi ;;
1) $echo "Test w failed: files tw.out and $srcdir/tw.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test w may have failed. 1>&2;
2) $echo "Test w may have failed." 1>&2;
$echo The command "cmp tw.out $srcdir/tw.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -556,15 +556,15 @@ test -s tw.err || rm -f tw.err
$xx -s -d: -f2-4 $srcdir/tx.in > tx.out 2> tx.err
code=$?
if test $code != 0 ; then
$echo Test x failed: ../../src/cut return code $code differs from expected value 0 1>&2
$echo "Test x failed: ../../src/cut return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tx.out $srcdir/tx.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed x; fi ;; # equal files
1) $echo Test x failed: files tx.out and $srcdir/tx.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed x"; fi ;;
1) $echo "Test x failed: files tx.out and $srcdir/tx.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test x may have failed. 1>&2;
2) $echo "Test x may have failed." 1>&2;
$echo The command "cmp tx.out $srcdir/tx.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -573,15 +573,15 @@ test -s tx.err || rm -f tx.err
$xx -s -b4 $srcdir/ty.in > ty.out 2> ty.err
code=$?
if test $code != 1 ; then
$echo Test y failed: ../../src/cut return code $code differs from expected value 1 1>&2
$echo "Test y failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp ty.out $srcdir/ty.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed y; fi ;; # equal files
1) $echo Test y failed: files ty.out and $srcdir/ty.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed y"; fi ;;
1) $echo "Test y failed: files ty.out and $srcdir/ty.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test y may have failed. 1>&2;
2) $echo "Test y may have failed." 1>&2;
$echo The command "cmp ty.out $srcdir/ty.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -590,88 +590,88 @@ test -s ty.err || rm -f ty.err
$xx $srcdir/tz.in > tz.out 2> tz.err
code=$?
if test $code != 1 ; then
$echo Test z failed: ../../src/cut return code $code differs from expected value 1 1>&2
$echo "Test z failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp tz.out $srcdir/tz.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed z; fi ;; # equal files
1) $echo Test z failed: files tz.out and $srcdir/tz.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed z"; fi ;;
1) $echo "Test z failed: files tz.out and $srcdir/tz.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test z may have failed. 1>&2;
2) $echo "Test z may have failed." 1>&2;
$echo The command "cmp tz.out $srcdir/tz.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tz.err || rm -f tz.err
$xx -f '' $srcdir/tA.in > tA.out 2> tA.err
$xx -f '' $srcdir/tempty-fl.in > tempty-fl.out 2> tempty-fl.err
code=$?
if test $code != 1 ; then
$echo Test A failed: ../../src/cut return code $code differs from expected value 1 1>&2
$echo "Test empty-fl failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp tA.out $srcdir/tA.exp
cmp tempty-fl.out $srcdir/tempty-fl.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed A; fi ;; # equal files
1) $echo Test A failed: files tA.out and $srcdir/tA.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed empty-fl"; fi ;;
1) $echo "Test empty-fl failed: files tempty-fl.out and $srcdir/tempty-fl.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test A may have failed. 1>&2;
$echo The command "cmp tA.out $srcdir/tA.exp" failed. 1>&2 ;
2) $echo "Test empty-fl may have failed." 1>&2;
$echo The command "cmp tempty-fl.out $srcdir/tempty-fl.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tA.err || rm -f tA.err
$xx -f $srcdir/tB.in > tB.out 2> tB.err
test -s tempty-fl.err || rm -f tempty-fl.err
$xx -f $srcdir/tmissing-fl.in > tmissing-fl.out 2> tmissing-fl.err
code=$?
if test $code != 1 ; then
$echo Test B failed: ../../src/cut return code $code differs from expected value 1 1>&2
$echo "Test missing-fl failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp tB.out $srcdir/tB.exp
cmp tmissing-fl.out $srcdir/tmissing-fl.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed B; fi ;; # equal files
1) $echo Test B failed: files tB.out and $srcdir/tB.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed missing-fl"; fi ;;
1) $echo "Test missing-fl failed: files tmissing-fl.out and $srcdir/tmissing-fl.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test B may have failed. 1>&2;
$echo The command "cmp tB.out $srcdir/tB.exp" failed. 1>&2 ;
2) $echo "Test missing-fl may have failed." 1>&2;
$echo The command "cmp tmissing-fl.out $srcdir/tmissing-fl.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tB.err || rm -f tB.err
$xx -b '' $srcdir/tC.in > tC.out 2> tC.err
test -s tmissing-fl.err || rm -f tmissing-fl.err
$xx -b '' $srcdir/tempty-bl.in > tempty-bl.out 2> tempty-bl.err
code=$?
if test $code != 1 ; then
$echo Test C failed: ../../src/cut return code $code differs from expected value 1 1>&2
$echo "Test empty-bl failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp tC.out $srcdir/tC.exp
cmp tempty-bl.out $srcdir/tempty-bl.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed C; fi ;; # equal files
1) $echo Test C failed: files tC.out and $srcdir/tC.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed empty-bl"; fi ;;
1) $echo "Test empty-bl failed: files tempty-bl.out and $srcdir/tempty-bl.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test C may have failed. 1>&2;
$echo The command "cmp tC.out $srcdir/tC.exp" failed. 1>&2 ;
2) $echo "Test empty-bl may have failed." 1>&2;
$echo The command "cmp tempty-bl.out $srcdir/tempty-bl.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tC.err || rm -f tC.err
$xx -b $srcdir/tD.in > tD.out 2> tD.err
test -s tempty-bl.err || rm -f tempty-bl.err
$xx -b $srcdir/tmissing-bl.in > tmissing-bl.out 2> tmissing-bl.err
code=$?
if test $code != 1 ; then
$echo Test D failed: ../../src/cut return code $code differs from expected value 1 1>&2
$echo "Test missing-bl failed: ../../src/cut return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp tD.out $srcdir/tD.exp
cmp tmissing-bl.out $srcdir/tmissing-bl.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed D; fi ;; # equal files
1) $echo Test D failed: files tD.out and $srcdir/tD.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed missing-bl"; fi ;;
1) $echo "Test missing-bl failed: files tmissing-bl.out and $srcdir/tmissing-bl.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test D may have failed. 1>&2;
$echo The command "cmp tD.out $srcdir/tD.exp" failed. 1>&2 ;
2) $echo "Test missing-bl may have failed." 1>&2;
$echo The command "cmp tmissing-bl.out $srcdir/tmissing-bl.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tD.err || rm -f tD.err
test -s tmissing-bl.err || rm -f tmissing-bl.err
if test $errors = 0 ; then
$echo Passed all 39 tests. 1>&2
else

View File

@@ -37,6 +37,7 @@ sub validate
# the top level variable to the actual string literal.
# If $SPEC is a literal Perl string (not a reference), then treat $SPEC
# as the contents of a file.
# If $SPEC is a hash reference, then there are no inputs.
# If $SPEC is an array reference, consider each element of the array.
# If the element is a string reference, treat the string as the name of
# an existing file. Otherwise, the element must be a string and is treated
@@ -58,9 +59,20 @@ sub spec_to_list ($$$)
my @explicit_file;
my @maint_gen_file;
my @content_string;
# If SPEC is a hash reference, return empty lists.
if (ref $spec eq 'HASH')
{
assert ($type eq 'in');
return {
EXPLICIT => \@explicit_file,
MAINT_GEN => \@maint_gen_file
};
}
if (ref $spec)
{
assert (ref $spec eq 'ARRAY');
assert (ref $spec eq 'ARRAY' || ref $spec eq 'HASH');
my $file_spec;
foreach $file_spec (@$spec)
{
@@ -225,27 +237,34 @@ foreach $test_vector (Test::test_vector ())
? '< ' : '');
my $z = $Test::common_option_prefix if defined $Test::common_option_prefix;
$z ||= '';
my $env = $Test::env{$test_name} || $Test::default_env || [''];
my $cmd = "\$xx $z$flags $redirect_stdin" . join (' ', @srcdir_rel_in_file)
. " > $out 2> $err_output";
print <<EOF;
$cmd
my $e;
foreach $e (@$env)
{
my $t_name = ($e ? "$test_name($e)" : $test_name);
my $e_cmd = ($e ? "$e " : '');
print <<EOF;
$e_cmd$cmd
code=\$?
if test \$code != $e_ret_code ; then
\$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2
\$echo "Test $t_name failed: $xx return code \$code differs from expected value $e_ret_code" 1>&2
errors=`expr \$errors + 1`
else
cmp $out $exp_name
case \$? in
0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files
1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2;
0) if test "\$VERBOSE" ; then \$echo "passed $t_name"; fi ;;
1) \$echo "Test $t_name failed: files $out and $exp_name differ" 1>&2;
errors=`expr \$errors + 1` ;;
2) \$echo Test $test_name may have failed. 1>&2;
2) \$echo "Test $t_name may have failed." 1>&2;
\$echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
errors=`expr \$errors + 1` ;;
esac
fi
test -s $err_output || rm -f $err_output
EOF
}
}
my $n_tests = Test::test_vector ();
print <<EOF2 ;

41
tests/date/Makefile.am Normal file
View File

@@ -0,0 +1,41 @@
## Process this file with automake to produce Makefile.in.
##test-files-begin
x = date
explicit =
maint_gen =
##test-files-end
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
PERL = @PERL@
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g'
TESTS = $x-tests
$x-tests: @MAINT@mk-script Test.pm
./mk-script ../../src/$x > $@.n
mv $@.n $@
chmod 755 $@
SUFFIXES = .pl
.pl:
rm -f $@ $@.tmp
$(editpl) $< > $@.tmp
chmod +x-w $@.tmp
mv $@.tmp $@
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
@MAINT@rebuild-check: Test.pm mk-script
@MAINT@ rb=rb-check; rm -f $rb; \
@MAINT@ m_template=../Makefile.am.in; \
@MAINT@ sed -n '1,/^##test-files-begin/p' $$m_template > $$rb; \
@MAINT@ tool=`echo $(subdir)|sed 's/^tests.//;s/-test//'`; \
@MAINT@ echo "x = $$tool" >> $$rb; \
@MAINT@ ./mk-script --list >> $$rb; \
@MAINT@ sed -n '/^##test-files-end/,$$p' $$m_template >> $$rb; \
@MAINT@ diff -u Makefile.am $$rb && echo ok || echo no

200
tests/date/Makefile.in Normal file
View File

@@ -0,0 +1,200 @@
# Makefile.in generated automatically by automake 1.1l from Makefile.am
# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
SHELL = /bin/sh
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 = ../..
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
YACC = @YACC@
RANLIB = @RANLIB@
GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
CC = @CC@
x = date
explicit =
maint_gen =
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
PERL = @PERL@
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g'
TESTS = $x-tests
SUFFIXES = .pl
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
SCRIPTS = $(noinst_SCRIPTS)
DIST_COMMON = Makefile.am Makefile.in
PACKAGE = @PACKAGE@
VERSION = @VERSION@
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) \
$(TEXINFOS) $(MANS) $(EXTRA_DIST)
TAR = tar
default: all
.SUFFIXES:
.SUFFIXES: .pl
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL)
cd $(top_srcdir) && automake --gnu tests/date/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tests/date
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; \
srcdir=$(srcdir); export srcdir; \
for tst in $(TESTS); do \
all=`expr $$all + 1`; \
if test -f $$tst; then dir=.; \
else dir="$(srcdir)"; fi; \
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
echo "PASS: $$tst"; \
else \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
echo "========================"; \
echo "All $$all tests passed"; \
echo "========================"; \
else \
echo "$$failed of $$all tests failed"; \
fi
info:
dvi:
check: all
$(MAKE) check-TESTS
installcheck:
install-exec:
$(NORMAL_INSTALL)
install-data:
$(NORMAL_INSTALL)
install: install-exec install-data all
@:
uninstall:
all: $(SCRIPTS) Makefile
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs:
mostlyclean-generic:
test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic:
test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
rm -f Makefile $(DISTCLEANFILES)
rm -f config.cache config.log stamp-h
test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-generic
clean: clean-generic mostlyclean
distclean: distclean-generic clean
rm -f config.status
maintainer-clean: maintainer-clean-generic distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
.PHONY: default tags distdir check-TESTS info dvi installcheck \
install-exec install-data install uninstall all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
$x-tests: @MAINT@mk-script Test.pm
./mk-script ../../src/$x > $@.n
mv $@.n $@
chmod 755 $@
.pl:
rm -f $@ $@.tmp
$(editpl) $< > $@.tmp
chmod +x-w $@.tmp
mv $@.tmp $@
@MAINT@rebuild-check: Test.pm mk-script
@MAINT@ rb=rb-check; rm -f $rb; \
@MAINT@ m_template=../Makefile.am.in; \
@MAINT@ sed -n '1,/^##test-files-begin/p' $$m_template > $$rb; \
@MAINT@ tool=`echo $(subdir)|sed 's/^tests.//;s/-test//'`; \
@MAINT@ echo "x = $$tool" >> $$rb; \
@MAINT@ ./mk-script --list >> $$rb; \
@MAINT@ sed -n '/^##test-files-end/,$$p' $$m_template >> $$rb; \
@MAINT@ diff -u Makefile.am $$rb && echo ok || echo no
# 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:

45
tests/date/Test.pm Normal file
View File

@@ -0,0 +1,45 @@
# -*-perl-*-
package Test;
require 5.002;
use strict;
# For each test...
# Export LANG=C so that the locale-dependent strings match.
# Export TZ=UTC so that zone-dependent strings match.
$Test::default_env = ['LANG=C TZ=UTC'];
sub test_vector
{
my $d1 = '1997-01-19 08:17:48 +0';
my @tvec =
(
# test-name options input expected-output expected-return-code
#
['1', "-d '$d1' +'%% %a %A %b %B'", {}, '% Sun Sunday Jan January', 0],
['2', "-d '$d1' +'%c'", {}, 'Sun Jan 19 08:17:48 1997', 0],
['3', "-d '$d1' +'%d_%D_%e_%h_%H'", {}, '19_01/19/97_19_Jan_08', 0],
['4', "-d '$d1' +'%I_%j_%k_%l_%m'", {}, '08_019_ 8_ 8_01', 0],
['5', "-d '$d1' +'%M_%n_%p_%r'", {}, "17_\n_AM_08:17:48 AM", 0],
['6', "-d '$d1' +'%s_%S_%t_%T'", {}, "853661868_48_\t_08:17:48", 0],
['7', "-d '$d1' +'%U_%V_%w_%W'", {}, '03_03_0_02', 0],
['8', "-d '$d1' +'%x_%X_%y_%Y'", {}, '01/19/97_08:17:48_97_1997', 0],
['9', "-d '$d1' +'%z_%Z'", {}, '+0000_GMT', 0],
);
my @tv;
my $t;
foreach $t (@tvec)
{
my ($test_name, $flags, $in, $exp, $ret) = @$t;
# Append a newline to end of each expected string.
push (@tv, [$test_name, $flags, $in, "$exp\n", $ret]);
}
# Verify that the test-script generation code properly handles
# per-test overrides.
$Test::env{2} = ['LANG=C TZ=GMT'];
return @tv;
}
1;

171
tests/date/date-tests Executable file
View File

@@ -0,0 +1,171 @@
#! /bin/sh
# This script was generated automatically by build-script.
case $# in
0) xx='../../src/date';;
*) xx="$1";;
esac
test "$VERBOSE" && echo=echo || echo=:
$echo testing program: $xx
errors=0
test "$srcdir" || srcdir=.
test "$VERBOSE" && $xx --version 2> /dev/null
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%% %a %A %b %B' > t1.out 2> t1.err
code=$?
if test $code != 0 ; then
$echo "Test 1(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1.out $srcdir/t1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 1(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 1(LANG=C TZ=UTC) failed: files t1.out and $srcdir/t1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 1(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t1.out $srcdir/t1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t1.err || rm -f t1.err
LANG=C TZ=GMT $xx -d '1997-01-19 08:17:48 +0' +'%c' > t2.out 2> t2.err
code=$?
if test $code != 0 ; then
$echo "Test 2(LANG=C TZ=GMT) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t2.out $srcdir/t2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 2(LANG=C TZ=GMT)"; fi ;;
1) $echo "Test 2(LANG=C TZ=GMT) failed: files t2.out and $srcdir/t2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 2(LANG=C TZ=GMT) may have failed." 1>&2;
$echo The command "cmp t2.out $srcdir/t2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t2.err || rm -f t2.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%d_%D_%e_%h_%H' > t3.out 2> t3.err
code=$?
if test $code != 0 ; then
$echo "Test 3(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t3.out $srcdir/t3.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 3(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 3(LANG=C TZ=UTC) failed: files t3.out and $srcdir/t3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 3(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t3.out $srcdir/t3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t3.err || rm -f t3.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%I_%j_%k_%l_%m' > t4.out 2> t4.err
code=$?
if test $code != 0 ; then
$echo "Test 4(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4.out $srcdir/t4.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 4(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 4(LANG=C TZ=UTC) failed: files t4.out and $srcdir/t4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 4(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t4.out $srcdir/t4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t4.err || rm -f t4.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%M_%n_%p_%r' > t5.out 2> t5.err
code=$?
if test $code != 0 ; then
$echo "Test 5(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5.out $srcdir/t5.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 5(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 5(LANG=C TZ=UTC) failed: files t5.out and $srcdir/t5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 5(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t5.out $srcdir/t5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t5.err || rm -f t5.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%s_%S_%t_%T' > t6.out 2> t6.err
code=$?
if test $code != 0 ; then
$echo "Test 6(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t6.out $srcdir/t6.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 6(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 6(LANG=C TZ=UTC) failed: files t6.out and $srcdir/t6.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 6(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t6.out $srcdir/t6.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t6.err || rm -f t6.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%U_%V_%w_%W' > t7.out 2> t7.err
code=$?
if test $code != 0 ; then
$echo "Test 7(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t7.out $srcdir/t7.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 7(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 7(LANG=C TZ=UTC) failed: files t7.out and $srcdir/t7.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 7(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t7.out $srcdir/t7.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t7.err || rm -f t7.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%x_%X_%y_%Y' > t8.out 2> t8.err
code=$?
if test $code != 0 ; then
$echo "Test 8(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t8.out $srcdir/t8.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 8(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 8(LANG=C TZ=UTC) failed: files t8.out and $srcdir/t8.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 8(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t8.out $srcdir/t8.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t8.err || rm -f t8.err
LANG=C TZ=UTC $xx -d '1997-01-19 08:17:48 +0' +'%z_%Z' > t9.out 2> t9.err
code=$?
if test $code != 0 ; then
$echo "Test 9(LANG=C TZ=UTC) failed: ../../src/date return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t9.out $srcdir/t9.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed 9(LANG=C TZ=UTC)"; fi ;;
1) $echo "Test 9(LANG=C TZ=UTC) failed: files t9.out and $srcdir/t9.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test 9(LANG=C TZ=UTC) may have failed." 1>&2;
$echo The command "cmp t9.out $srcdir/t9.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s t9.err || rm -f t9.err
if test $errors = 0 ; then
$echo Passed all 9 tests. 1>&2
else
$echo Failed $errors tests. 1>&2
fi
test $errors = 0 || errors=1
exit $errors

View File

@@ -37,6 +37,7 @@ sub validate
# the top level variable to the actual string literal.
# If $SPEC is a literal Perl string (not a reference), then treat $SPEC
# as the contents of a file.
# If $SPEC is a hash reference, then there are no inputs.
# If $SPEC is an array reference, consider each element of the array.
# If the element is a string reference, treat the string as the name of
# an existing file. Otherwise, the element must be a string and is treated
@@ -58,9 +59,20 @@ sub spec_to_list ($$$)
my @explicit_file;
my @maint_gen_file;
my @content_string;
# If SPEC is a hash reference, return empty lists.
if (ref $spec eq 'HASH')
{
assert ($type eq 'in');
return {
EXPLICIT => \@explicit_file,
MAINT_GEN => \@maint_gen_file
};
}
if (ref $spec)
{
assert (ref $spec eq 'ARRAY');
assert (ref $spec eq 'ARRAY' || ref $spec eq 'HASH');
my $file_spec;
foreach $file_spec (@$spec)
{
@@ -225,27 +237,34 @@ foreach $test_vector (Test::test_vector ())
? '< ' : '');
my $z = $Test::common_option_prefix if defined $Test::common_option_prefix;
$z ||= '';
my $env = $Test::env{$test_name} || $Test::default_env || [''];
my $cmd = "\$xx $z$flags $redirect_stdin" . join (' ', @srcdir_rel_in_file)
. " > $out 2> $err_output";
print <<EOF;
$cmd
my $e;
foreach $e (@$env)
{
my $t_name = ($e ? "$test_name($e)" : $test_name);
my $e_cmd = ($e ? "$e " : '');
print <<EOF;
$e_cmd$cmd
code=\$?
if test \$code != $e_ret_code ; then
\$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2
\$echo "Test $t_name failed: $xx return code \$code differs from expected value $e_ret_code" 1>&2
errors=`expr \$errors + 1`
else
cmp $out $exp_name
case \$? in
0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files
1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2;
0) if test "\$VERBOSE" ; then \$echo "passed $t_name"; fi ;;
1) \$echo "Test $t_name failed: files $out and $exp_name differ" 1>&2;
errors=`expr \$errors + 1` ;;
2) \$echo Test $test_name may have failed. 1>&2;
2) \$echo "Test $t_name may have failed." 1>&2;
\$echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
errors=`expr \$errors + 1` ;;
esac
fi
test -s $err_output || rm -f $err_output
EOF
}
}
my $n_tests = Test::test_vector ();
print <<EOF2 ;

View File

@@ -12,15 +12,15 @@ test "$VERBOSE" && $xx --version 2> /dev/null
$xx -a1 $srcdir/t1a.in1 $srcdir/t1a.in2 > t1a.out 2> t1a.err
code=$?
if test $code != 0 ; then
$echo Test 1a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 1a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1a.out $srcdir/t1a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1a; fi ;; # equal files
1) $echo Test 1a failed: files t1a.out and $srcdir/t1a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1a"; fi ;;
1) $echo "Test 1a failed: files t1a.out and $srcdir/t1a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1a may have failed. 1>&2;
2) $echo "Test 1a may have failed." 1>&2;
$echo The command "cmp t1a.out $srcdir/t1a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -29,15 +29,15 @@ test -s t1a.err || rm -f t1a.err
$xx -a2 $srcdir/t1b.in1 $srcdir/t1b.in2 > t1b.out 2> t1b.err
code=$?
if test $code != 0 ; then
$echo Test 1b failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 1b failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1b.out $srcdir/t1b.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1b; fi ;; # equal files
1) $echo Test 1b failed: files t1b.out and $srcdir/t1b.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1b"; fi ;;
1) $echo "Test 1b failed: files t1b.out and $srcdir/t1b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1b may have failed. 1>&2;
2) $echo "Test 1b may have failed." 1>&2;
$echo The command "cmp t1b.out $srcdir/t1b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -46,15 +46,15 @@ test -s t1b.err || rm -f t1b.err
$xx -a1 -a2 $srcdir/t1c.in1 $srcdir/t1c.in2 > t1c.out 2> t1c.err
code=$?
if test $code != 0 ; then
$echo Test 1c failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 1c failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1c.out $srcdir/t1c.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1c; fi ;; # equal files
1) $echo Test 1c failed: files t1c.out and $srcdir/t1c.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1c"; fi ;;
1) $echo "Test 1c failed: files t1c.out and $srcdir/t1c.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1c may have failed. 1>&2;
2) $echo "Test 1c may have failed." 1>&2;
$echo The command "cmp t1c.out $srcdir/t1c.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -63,15 +63,15 @@ test -s t1c.err || rm -f t1c.err
$xx -a1 $srcdir/t1d.in1 $srcdir/t1d.in2 > t1d.out 2> t1d.err
code=$?
if test $code != 0 ; then
$echo Test 1d failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 1d failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1d.out $srcdir/t1d.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1d; fi ;; # equal files
1) $echo Test 1d failed: files t1d.out and $srcdir/t1d.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1d"; fi ;;
1) $echo "Test 1d failed: files t1d.out and $srcdir/t1d.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1d may have failed. 1>&2;
2) $echo "Test 1d may have failed." 1>&2;
$echo The command "cmp t1d.out $srcdir/t1d.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -80,15 +80,15 @@ test -s t1d.err || rm -f t1d.err
$xx -a2 $srcdir/t1e.in1 $srcdir/t1e.in2 > t1e.out 2> t1e.err
code=$?
if test $code != 0 ; then
$echo Test 1e failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 1e failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1e.out $srcdir/t1e.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1e; fi ;; # equal files
1) $echo Test 1e failed: files t1e.out and $srcdir/t1e.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1e"; fi ;;
1) $echo "Test 1e failed: files t1e.out and $srcdir/t1e.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1e may have failed. 1>&2;
2) $echo "Test 1e may have failed." 1>&2;
$echo The command "cmp t1e.out $srcdir/t1e.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -97,15 +97,15 @@ test -s t1e.err || rm -f t1e.err
$xx -a2 $srcdir/t1f.in1 $srcdir/t1f.in2 > t1f.out 2> t1f.err
code=$?
if test $code != 0 ; then
$echo Test 1f failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 1f failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1f.out $srcdir/t1f.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1f; fi ;; # equal files
1) $echo Test 1f failed: files t1f.out and $srcdir/t1f.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1f"; fi ;;
1) $echo "Test 1f failed: files t1f.out and $srcdir/t1f.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1f may have failed. 1>&2;
2) $echo "Test 1f may have failed." 1>&2;
$echo The command "cmp t1f.out $srcdir/t1f.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -114,15 +114,15 @@ test -s t1f.err || rm -f t1f.err
$xx -a1 -e . $srcdir/t2a.in1 $srcdir/t2a.in2 > t2a.out 2> t2a.err
code=$?
if test $code != 0 ; then
$echo Test 2a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 2a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t2a.out $srcdir/t2a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 2a; fi ;; # equal files
1) $echo Test 2a failed: files t2a.out and $srcdir/t2a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 2a"; fi ;;
1) $echo "Test 2a failed: files t2a.out and $srcdir/t2a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 2a may have failed. 1>&2;
2) $echo "Test 2a may have failed." 1>&2;
$echo The command "cmp t2a.out $srcdir/t2a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -131,15 +131,15 @@ test -s t2a.err || rm -f t2a.err
$xx -a1 -e . -o 2.1,2.2,2.3 $srcdir/t2b.in1 $srcdir/t2b.in2 > t2b.out 2> t2b.err
code=$?
if test $code != 0 ; then
$echo Test 2b failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 2b failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t2b.out $srcdir/t2b.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 2b; fi ;; # equal files
1) $echo Test 2b failed: files t2b.out and $srcdir/t2b.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 2b"; fi ;;
1) $echo "Test 2b failed: files t2b.out and $srcdir/t2b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 2b may have failed. 1>&2;
2) $echo "Test 2b may have failed." 1>&2;
$echo The command "cmp t2b.out $srcdir/t2b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -148,15 +148,15 @@ test -s t2b.err || rm -f t2b.err
$xx -a1 -e . -o 2.1,2.2,2.3 $srcdir/t2c.in1 $srcdir/t2c.in2 > t2c.out 2> t2c.err
code=$?
if test $code != 0 ; then
$echo Test 2c failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 2c failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t2c.out $srcdir/t2c.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 2c; fi ;; # equal files
1) $echo Test 2c failed: files t2c.out and $srcdir/t2c.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 2c"; fi ;;
1) $echo "Test 2c failed: files t2c.out and $srcdir/t2c.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 2c may have failed. 1>&2;
2) $echo "Test 2c may have failed." 1>&2;
$echo The command "cmp t2c.out $srcdir/t2c.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -165,15 +165,15 @@ test -s t2c.err || rm -f t2c.err
$xx -t: $srcdir/t3a.in1 $srcdir/t3a.in2 > t3a.out 2> t3a.err
code=$?
if test $code != 0 ; then
$echo Test 3a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 3a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t3a.out $srcdir/t3a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 3a; fi ;; # equal files
1) $echo Test 3a failed: files t3a.out and $srcdir/t3a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 3a"; fi ;;
1) $echo "Test 3a failed: files t3a.out and $srcdir/t3a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 3a may have failed. 1>&2;
2) $echo "Test 3a may have failed." 1>&2;
$echo The command "cmp t3a.out $srcdir/t3a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -182,15 +182,15 @@ test -s t3a.err || rm -f t3a.err
$xx -v 1 $srcdir/t4a.in1 $srcdir/t4a.in2 > t4a.out 2> t4a.err
code=$?
if test $code != 0 ; then
$echo Test 4a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 4a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4a.out $srcdir/t4a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4a; fi ;; # equal files
1) $echo Test 4a failed: files t4a.out and $srcdir/t4a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4a"; fi ;;
1) $echo "Test 4a failed: files t4a.out and $srcdir/t4a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4a may have failed. 1>&2;
2) $echo "Test 4a may have failed." 1>&2;
$echo The command "cmp t4a.out $srcdir/t4a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -199,15 +199,15 @@ test -s t4a.err || rm -f t4a.err
$xx -v 2 $srcdir/t4b.in1 $srcdir/t4b.in2 > t4b.out 2> t4b.err
code=$?
if test $code != 0 ; then
$echo Test 4b failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 4b failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4b.out $srcdir/t4b.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4b; fi ;; # equal files
1) $echo Test 4b failed: files t4b.out and $srcdir/t4b.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4b"; fi ;;
1) $echo "Test 4b failed: files t4b.out and $srcdir/t4b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4b may have failed. 1>&2;
2) $echo "Test 4b may have failed." 1>&2;
$echo The command "cmp t4b.out $srcdir/t4b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -216,15 +216,15 @@ test -s t4b.err || rm -f t4b.err
$xx -v 1 $srcdir/t4c.in1 $srcdir/t4c.in2 > t4c.out 2> t4c.err
code=$?
if test $code != 0 ; then
$echo Test 4c failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 4c failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4c.out $srcdir/t4c.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4c; fi ;; # equal files
1) $echo Test 4c failed: files t4c.out and $srcdir/t4c.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4c"; fi ;;
1) $echo "Test 4c failed: files t4c.out and $srcdir/t4c.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4c may have failed. 1>&2;
2) $echo "Test 4c may have failed." 1>&2;
$echo The command "cmp t4c.out $srcdir/t4c.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -233,15 +233,15 @@ test -s t4c.err || rm -f t4c.err
$xx -v 2 $srcdir/t4d.in1 $srcdir/t4d.in2 > t4d.out 2> t4d.err
code=$?
if test $code != 0 ; then
$echo Test 4d failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 4d failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4d.out $srcdir/t4d.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4d; fi ;; # equal files
1) $echo Test 4d failed: files t4d.out and $srcdir/t4d.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4d"; fi ;;
1) $echo "Test 4d failed: files t4d.out and $srcdir/t4d.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4d may have failed. 1>&2;
2) $echo "Test 4d may have failed." 1>&2;
$echo The command "cmp t4d.out $srcdir/t4d.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -250,15 +250,15 @@ test -s t4d.err || rm -f t4d.err
$xx -v 2 $srcdir/t4e.in1 $srcdir/t4e.in2 > t4e.out 2> t4e.err
code=$?
if test $code != 0 ; then
$echo Test 4e failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 4e failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4e.out $srcdir/t4e.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4e; fi ;; # equal files
1) $echo Test 4e failed: files t4e.out and $srcdir/t4e.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4e"; fi ;;
1) $echo "Test 4e failed: files t4e.out and $srcdir/t4e.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4e may have failed. 1>&2;
2) $echo "Test 4e may have failed." 1>&2;
$echo The command "cmp t4e.out $srcdir/t4e.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -267,15 +267,15 @@ test -s t4e.err || rm -f t4e.err
$xx -a1 -e - -o 1.1 2.2 $srcdir/t5a.in1 $srcdir/t5a.in2 > t5a.out 2> t5a.err
code=$?
if test $code != 0 ; then
$echo Test 5a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5a.out $srcdir/t5a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5a; fi ;; # equal files
1) $echo Test 5a failed: files t5a.out and $srcdir/t5a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5a"; fi ;;
1) $echo "Test 5a failed: files t5a.out and $srcdir/t5a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5a may have failed. 1>&2;
2) $echo "Test 5a may have failed." 1>&2;
$echo The command "cmp t5a.out $srcdir/t5a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -284,15 +284,15 @@ test -s t5a.err || rm -f t5a.err
$xx -a1 -e - -o 1.1 2.2 $srcdir/t5b.in1 $srcdir/t5b.in2 > t5b.out 2> t5b.err
code=$?
if test $code != 0 ; then
$echo Test 5b failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5b failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5b.out $srcdir/t5b.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5b; fi ;; # equal files
1) $echo Test 5b failed: files t5b.out and $srcdir/t5b.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5b"; fi ;;
1) $echo "Test 5b failed: files t5b.out and $srcdir/t5b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5b may have failed. 1>&2;
2) $echo "Test 5b may have failed." 1>&2;
$echo The command "cmp t5b.out $srcdir/t5b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -301,15 +301,15 @@ test -s t5b.err || rm -f t5b.err
$xx -a1 -e - -o 1.1 2.2 $srcdir/t5c.in1 $srcdir/t5c.in2 > t5c.out 2> t5c.err
code=$?
if test $code != 0 ; then
$echo Test 5c failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5c failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5c.out $srcdir/t5c.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5c; fi ;; # equal files
1) $echo Test 5c failed: files t5c.out and $srcdir/t5c.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5c"; fi ;;
1) $echo "Test 5c failed: files t5c.out and $srcdir/t5c.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5c may have failed. 1>&2;
2) $echo "Test 5c may have failed." 1>&2;
$echo The command "cmp t5c.out $srcdir/t5c.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -318,15 +318,15 @@ test -s t5c.err || rm -f t5c.err
$xx -a1 -e - -o 1.1 2.2 $srcdir/t5d.in1 $srcdir/t5d.in2 > t5d.out 2> t5d.err
code=$?
if test $code != 0 ; then
$echo Test 5d failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5d failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5d.out $srcdir/t5d.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5d; fi ;; # equal files
1) $echo Test 5d failed: files t5d.out and $srcdir/t5d.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5d"; fi ;;
1) $echo "Test 5d failed: files t5d.out and $srcdir/t5d.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5d may have failed. 1>&2;
2) $echo "Test 5d may have failed." 1>&2;
$echo The command "cmp t5d.out $srcdir/t5d.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -335,15 +335,15 @@ test -s t5d.err || rm -f t5d.err
$xx -a2 -e - -o 1.1 2.2 $srcdir/t5e.in1 $srcdir/t5e.in2 > t5e.out 2> t5e.err
code=$?
if test $code != 0 ; then
$echo Test 5e failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5e failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5e.out $srcdir/t5e.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5e; fi ;; # equal files
1) $echo Test 5e failed: files t5e.out and $srcdir/t5e.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5e"; fi ;;
1) $echo "Test 5e failed: files t5e.out and $srcdir/t5e.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5e may have failed. 1>&2;
2) $echo "Test 5e may have failed." 1>&2;
$echo The command "cmp t5e.out $srcdir/t5e.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -352,15 +352,15 @@ test -s t5e.err || rm -f t5e.err
$xx -a2 -e - -o 2.2 1.1 $srcdir/t5f.in1 $srcdir/t5f.in2 > t5f.out 2> t5f.err
code=$?
if test $code != 0 ; then
$echo Test 5f failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5f failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5f.out $srcdir/t5f.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5f; fi ;; # equal files
1) $echo Test 5f failed: files t5f.out and $srcdir/t5f.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5f"; fi ;;
1) $echo "Test 5f failed: files t5f.out and $srcdir/t5f.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5f may have failed. 1>&2;
2) $echo "Test 5f may have failed." 1>&2;
$echo The command "cmp t5f.out $srcdir/t5f.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -369,15 +369,15 @@ test -s t5f.err || rm -f t5f.err
$xx -a1 -e - -o 2.2 1.1 $srcdir/t5g.in1 $srcdir/t5g.in2 > t5g.out 2> t5g.err
code=$?
if test $code != 0 ; then
$echo Test 5g failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5g failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5g.out $srcdir/t5g.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5g; fi ;; # equal files
1) $echo Test 5g failed: files t5g.out and $srcdir/t5g.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5g"; fi ;;
1) $echo "Test 5g failed: files t5g.out and $srcdir/t5g.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5g may have failed. 1>&2;
2) $echo "Test 5g may have failed." 1>&2;
$echo The command "cmp t5g.out $srcdir/t5g.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -386,15 +386,15 @@ test -s t5g.err || rm -f t5g.err
$xx -a1 -e - -o 2.2 1.1 $srcdir/t5h.in1 $srcdir/t5h.in2 > t5h.out 2> t5h.err
code=$?
if test $code != 0 ; then
$echo Test 5h failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5h failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5h.out $srcdir/t5h.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5h; fi ;; # equal files
1) $echo Test 5h failed: files t5h.out and $srcdir/t5h.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5h"; fi ;;
1) $echo "Test 5h failed: files t5h.out and $srcdir/t5h.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5h may have failed. 1>&2;
2) $echo "Test 5h may have failed." 1>&2;
$echo The command "cmp t5h.out $srcdir/t5h.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -403,15 +403,15 @@ test -s t5h.err || rm -f t5h.err
$xx -a1 -e - -o 1.1 2.2 $srcdir/t5i.in1 $srcdir/t5i.in2 > t5i.out 2> t5i.err
code=$?
if test $code != 0 ; then
$echo Test 5i failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5i failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5i.out $srcdir/t5i.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5i; fi ;; # equal files
1) $echo Test 5i failed: files t5i.out and $srcdir/t5i.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5i"; fi ;;
1) $echo "Test 5i failed: files t5i.out and $srcdir/t5i.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5i may have failed. 1>&2;
2) $echo "Test 5i may have failed." 1>&2;
$echo The command "cmp t5i.out $srcdir/t5i.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -420,15 +420,15 @@ test -s t5i.err || rm -f t5i.err
$xx -a2 -e - -o 2.2 1.1 $srcdir/t5j.in1 $srcdir/t5j.in2 > t5j.out 2> t5j.err
code=$?
if test $code != 0 ; then
$echo Test 5j failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5j failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5j.out $srcdir/t5j.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5j; fi ;; # equal files
1) $echo Test 5j failed: files t5j.out and $srcdir/t5j.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5j"; fi ;;
1) $echo "Test 5j failed: files t5j.out and $srcdir/t5j.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5j may have failed. 1>&2;
2) $echo "Test 5j may have failed." 1>&2;
$echo The command "cmp t5j.out $srcdir/t5j.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -437,15 +437,15 @@ test -s t5j.err || rm -f t5j.err
$xx -a2 -e - -o 2.2 1.1 $srcdir/t5k.in1 $srcdir/t5k.in2 > t5k.out 2> t5k.err
code=$?
if test $code != 0 ; then
$echo Test 5k failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5k failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5k.out $srcdir/t5k.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5k; fi ;; # equal files
1) $echo Test 5k failed: files t5k.out and $srcdir/t5k.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5k"; fi ;;
1) $echo "Test 5k failed: files t5k.out and $srcdir/t5k.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5k may have failed. 1>&2;
2) $echo "Test 5k may have failed." 1>&2;
$echo The command "cmp t5k.out $srcdir/t5k.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -454,15 +454,15 @@ test -s t5k.err || rm -f t5k.err
$xx -a1 -e - -o 2.2 1.1 $srcdir/t5l.in1 $srcdir/t5l.in2 > t5l.out 2> t5l.err
code=$?
if test $code != 0 ; then
$echo Test 5l failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5l failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5l.out $srcdir/t5l.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5l; fi ;; # equal files
1) $echo Test 5l failed: files t5l.out and $srcdir/t5l.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5l"; fi ;;
1) $echo "Test 5l failed: files t5l.out and $srcdir/t5l.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5l may have failed. 1>&2;
2) $echo "Test 5l may have failed." 1>&2;
$echo The command "cmp t5l.out $srcdir/t5l.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -471,15 +471,15 @@ test -s t5l.err || rm -f t5l.err
$xx -a2 -e - -o 2.2 1.1 $srcdir/t5m.in1 $srcdir/t5m.in2 > t5m.out 2> t5m.err
code=$?
if test $code != 0 ; then
$echo Test 5m failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 5m failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5m.out $srcdir/t5m.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5m; fi ;; # equal files
1) $echo Test 5m failed: files t5m.out and $srcdir/t5m.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5m"; fi ;;
1) $echo "Test 5m failed: files t5m.out and $srcdir/t5m.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5m may have failed. 1>&2;
2) $echo "Test 5m may have failed." 1>&2;
$echo The command "cmp t5m.out $srcdir/t5m.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -488,15 +488,15 @@ test -s t5m.err || rm -f t5m.err
$xx -e - $srcdir/t6a.in1 $srcdir/t6a.in2 > t6a.out 2> t6a.err
code=$?
if test $code != 0 ; then
$echo Test 6a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 6a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t6a.out $srcdir/t6a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 6a; fi ;; # equal files
1) $echo Test 6a failed: files t6a.out and $srcdir/t6a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 6a"; fi ;;
1) $echo "Test 6a failed: files t6a.out and $srcdir/t6a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 6a may have failed. 1>&2;
2) $echo "Test 6a may have failed." 1>&2;
$echo The command "cmp t6a.out $srcdir/t6a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -505,15 +505,15 @@ test -s t6a.err || rm -f t6a.err
$xx -a1 -e - $srcdir/t6b.in1 $srcdir/t6b.in2 > t6b.out 2> t6b.err
code=$?
if test $code != 0 ; then
$echo Test 6b failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 6b failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t6b.out $srcdir/t6b.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 6b; fi ;; # equal files
1) $echo Test 6b failed: files t6b.out and $srcdir/t6b.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 6b"; fi ;;
1) $echo "Test 6b failed: files t6b.out and $srcdir/t6b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 6b may have failed. 1>&2;
2) $echo "Test 6b may have failed." 1>&2;
$echo The command "cmp t6b.out $srcdir/t6b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -522,15 +522,15 @@ test -s t6b.err || rm -f t6b.err
$xx -a1 -e - $srcdir/t6c.in1 $srcdir/t6c.in2 > t6c.out 2> t6c.err
code=$?
if test $code != 0 ; then
$echo Test 6c failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 6c failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t6c.out $srcdir/t6c.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 6c; fi ;; # equal files
1) $echo Test 6c failed: files t6c.out and $srcdir/t6c.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 6c"; fi ;;
1) $echo "Test 6c failed: files t6c.out and $srcdir/t6c.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 6c may have failed. 1>&2;
2) $echo "Test 6c may have failed." 1>&2;
$echo The command "cmp t6c.out $srcdir/t6c.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -539,15 +539,15 @@ test -s t6c.err || rm -f t6c.err
$xx -a1 -e . -o 2.7 $srcdir/t7a.in1 $srcdir/t7a.in2 > t7a.out 2> t7a.err
code=$?
if test $code != 0 ; then
$echo Test 7a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 7a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t7a.out $srcdir/t7a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 7a; fi ;; # equal files
1) $echo Test 7a failed: files t7a.out and $srcdir/t7a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 7a"; fi ;;
1) $echo "Test 7a failed: files t7a.out and $srcdir/t7a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 7a may have failed. 1>&2;
2) $echo "Test 7a may have failed." 1>&2;
$echo The command "cmp t7a.out $srcdir/t7a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -556,15 +556,15 @@ test -s t7a.err || rm -f t7a.err
$xx -a1 -e . -o 0,1.2 $srcdir/t8a.in1 $srcdir/t8a.in2 > t8a.out 2> t8a.err
code=$?
if test $code != 0 ; then
$echo Test 8a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 8a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t8a.out $srcdir/t8a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 8a; fi ;; # equal files
1) $echo Test 8a failed: files t8a.out and $srcdir/t8a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 8a"; fi ;;
1) $echo "Test 8a failed: files t8a.out and $srcdir/t8a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 8a may have failed. 1>&2;
2) $echo "Test 8a may have failed." 1>&2;
$echo The command "cmp t8a.out $srcdir/t8a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -573,15 +573,15 @@ test -s t8a.err || rm -f t8a.err
$xx -a1 -a2 -e . -o 0,1.2 $srcdir/t8b.in1 $srcdir/t8b.in2 > t8b.out 2> t8b.err
code=$?
if test $code != 0 ; then
$echo Test 8b failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 8b failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t8b.out $srcdir/t8b.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 8b; fi ;; # equal files
1) $echo Test 8b failed: files t8b.out and $srcdir/t8b.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 8b"; fi ;;
1) $echo "Test 8b failed: files t8b.out and $srcdir/t8b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 8b may have failed. 1>&2;
2) $echo "Test 8b may have failed." 1>&2;
$echo The command "cmp t8b.out $srcdir/t8b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -590,15 +590,15 @@ test -s t8b.err || rm -f t8b.err
$xx $srcdir/t9a.in1 $srcdir/t9a.in2 > t9a.out 2> t9a.err
code=$?
if test $code != 0 ; then
$echo Test 9a failed: ../../src/join return code $code differs from expected value 0 1>&2
$echo "Test 9a failed: ../../src/join return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t9a.out $srcdir/t9a.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 9a; fi ;; # equal files
1) $echo Test 9a failed: files t9a.out and $srcdir/t9a.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 9a"; fi ;;
1) $echo "Test 9a failed: files t9a.out and $srcdir/t9a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 9a may have failed. 1>&2;
2) $echo "Test 9a may have failed." 1>&2;
$echo The command "cmp t9a.out $srcdir/t9a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac

View File

@@ -37,6 +37,7 @@ sub validate
# the top level variable to the actual string literal.
# If $SPEC is a literal Perl string (not a reference), then treat $SPEC
# as the contents of a file.
# If $SPEC is a hash reference, then there are no inputs.
# If $SPEC is an array reference, consider each element of the array.
# If the element is a string reference, treat the string as the name of
# an existing file. Otherwise, the element must be a string and is treated
@@ -58,9 +59,20 @@ sub spec_to_list ($$$)
my @explicit_file;
my @maint_gen_file;
my @content_string;
# If SPEC is a hash reference, return empty lists.
if (ref $spec eq 'HASH')
{
assert ($type eq 'in');
return {
EXPLICIT => \@explicit_file,
MAINT_GEN => \@maint_gen_file
};
}
if (ref $spec)
{
assert (ref $spec eq 'ARRAY');
assert (ref $spec eq 'ARRAY' || ref $spec eq 'HASH');
my $file_spec;
foreach $file_spec (@$spec)
{
@@ -225,27 +237,34 @@ foreach $test_vector (Test::test_vector ())
? '< ' : '');
my $z = $Test::common_option_prefix if defined $Test::common_option_prefix;
$z ||= '';
my $env = $Test::env{$test_name} || $Test::default_env || [''];
my $cmd = "\$xx $z$flags $redirect_stdin" . join (' ', @srcdir_rel_in_file)
. " > $out 2> $err_output";
print <<EOF;
$cmd
my $e;
foreach $e (@$env)
{
my $t_name = ($e ? "$test_name($e)" : $test_name);
my $e_cmd = ($e ? "$e " : '');
print <<EOF;
$e_cmd$cmd
code=\$?
if test \$code != $e_ret_code ; then
\$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2
\$echo "Test $t_name failed: $xx return code \$code differs from expected value $e_ret_code" 1>&2
errors=`expr \$errors + 1`
else
cmp $out $exp_name
case \$? in
0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files
1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2;
0) if test "\$VERBOSE" ; then \$echo "passed $t_name"; fi ;;
1) \$echo "Test $t_name failed: files $out and $exp_name differ" 1>&2;
errors=`expr \$errors + 1` ;;
2) \$echo Test $test_name may have failed. 1>&2;
2) \$echo "Test $t_name may have failed." 1>&2;
\$echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
errors=`expr \$errors + 1` ;;
esac
fi
test -s $err_output || rm -f $err_output
EOF
}
}
my $n_tests = Test::test_vector ();
print <<EOF2 ;

View File

@@ -37,6 +37,7 @@ sub validate
# the top level variable to the actual string literal.
# If $SPEC is a literal Perl string (not a reference), then treat $SPEC
# as the contents of a file.
# If $SPEC is a hash reference, then there are no inputs.
# If $SPEC is an array reference, consider each element of the array.
# If the element is a string reference, treat the string as the name of
# an existing file. Otherwise, the element must be a string and is treated
@@ -58,9 +59,20 @@ sub spec_to_list ($$$)
my @explicit_file;
my @maint_gen_file;
my @content_string;
# If SPEC is a hash reference, return empty lists.
if (ref $spec eq 'HASH')
{
assert ($type eq 'in');
return {
EXPLICIT => \@explicit_file,
MAINT_GEN => \@maint_gen_file
};
}
if (ref $spec)
{
assert (ref $spec eq 'ARRAY');
assert (ref $spec eq 'ARRAY' || ref $spec eq 'HASH');
my $file_spec;
foreach $file_spec (@$spec)
{
@@ -225,27 +237,34 @@ foreach $test_vector (Test::test_vector ())
? '< ' : '');
my $z = $Test::common_option_prefix if defined $Test::common_option_prefix;
$z ||= '';
my $env = $Test::env{$test_name} || $Test::default_env || [''];
my $cmd = "\$xx $z$flags $redirect_stdin" . join (' ', @srcdir_rel_in_file)
. " > $out 2> $err_output";
print <<EOF;
$cmd
my $e;
foreach $e (@$env)
{
my $t_name = ($e ? "$test_name($e)" : $test_name);
my $e_cmd = ($e ? "$e " : '');
print <<EOF;
$e_cmd$cmd
code=\$?
if test \$code != $e_ret_code ; then
\$echo Test $test_name failed: $xx return code \$code differs from expected value $e_ret_code 1>&2
\$echo "Test $t_name failed: $xx return code \$code differs from expected value $e_ret_code" 1>&2
errors=`expr \$errors + 1`
else
cmp $out $exp_name
case \$? in
0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files
1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2;
0) if test "\$VERBOSE" ; then \$echo "passed $t_name"; fi ;;
1) \$echo "Test $t_name failed: files $out and $exp_name differ" 1>&2;
errors=`expr \$errors + 1` ;;
2) \$echo Test $test_name may have failed. 1>&2;
2) \$echo "Test $t_name may have failed." 1>&2;
\$echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
errors=`expr \$errors + 1` ;;
esac
fi
test -s $err_output || rm -f $err_output
EOF
}
}
my $n_tests = Test::test_vector ();
print <<EOF2 ;

View File

@@ -12,15 +12,15 @@ test "$VERBOSE" && $xx --version 2> /dev/null
$xx < $srcdir/t1.in > t1.out 2> t1.err
code=$?
if test $code != 0 ; then
$echo Test 1 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 1 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t1.out $srcdir/t1.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 1; fi ;; # equal files
1) $echo Test 1 failed: files t1.out and $srcdir/t1.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 1"; fi ;;
1) $echo "Test 1 failed: files t1.out and $srcdir/t1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 1 may have failed. 1>&2;
2) $echo "Test 1 may have failed." 1>&2;
$echo The command "cmp t1.out $srcdir/t1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -29,15 +29,15 @@ test -s t1.err || rm -f t1.err
$xx < $srcdir/t2.in > t2.out 2> t2.err
code=$?
if test $code != 0 ; then
$echo Test 2 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 2 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t2.out $srcdir/t2.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 2; fi ;; # equal files
1) $echo Test 2 failed: files t2.out and $srcdir/t2.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 2"; fi ;;
1) $echo "Test 2 failed: files t2.out and $srcdir/t2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 2 may have failed. 1>&2;
2) $echo "Test 2 may have failed." 1>&2;
$echo The command "cmp t2.out $srcdir/t2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -46,15 +46,15 @@ test -s t2.err || rm -f t2.err
$xx < $srcdir/t3.in > t3.out 2> t3.err
code=$?
if test $code != 0 ; then
$echo Test 3 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 3 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t3.out $srcdir/t3.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 3; fi ;; # equal files
1) $echo Test 3 failed: files t3.out and $srcdir/t3.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 3"; fi ;;
1) $echo "Test 3 failed: files t3.out and $srcdir/t3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 3 may have failed. 1>&2;
2) $echo "Test 3 may have failed." 1>&2;
$echo The command "cmp t3.out $srcdir/t3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -63,15 +63,15 @@ test -s t3.err || rm -f t3.err
$xx < $srcdir/t4.in > t4.out 2> t4.err
code=$?
if test $code != 0 ; then
$echo Test 4 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 4 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t4.out $srcdir/t4.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 4; fi ;; # equal files
1) $echo Test 4 failed: files t4.out and $srcdir/t4.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 4"; fi ;;
1) $echo "Test 4 failed: files t4.out and $srcdir/t4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 4 may have failed. 1>&2;
2) $echo "Test 4 may have failed." 1>&2;
$echo The command "cmp t4.out $srcdir/t4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -80,15 +80,15 @@ test -s t4.err || rm -f t4.err
$xx < $srcdir/t5.in > t5.out 2> t5.err
code=$?
if test $code != 0 ; then
$echo Test 5 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 5 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t5.out $srcdir/t5.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 5; fi ;; # equal files
1) $echo Test 5 failed: files t5.out and $srcdir/t5.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 5"; fi ;;
1) $echo "Test 5 failed: files t5.out and $srcdir/t5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 5 may have failed. 1>&2;
2) $echo "Test 5 may have failed." 1>&2;
$echo The command "cmp t5.out $srcdir/t5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -97,15 +97,15 @@ test -s t5.err || rm -f t5.err
$xx < $srcdir/t6.in > t6.out 2> t6.err
code=$?
if test $code != 0 ; then
$echo Test 6 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 6 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t6.out $srcdir/t6.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 6; fi ;; # equal files
1) $echo Test 6 failed: files t6.out and $srcdir/t6.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 6"; fi ;;
1) $echo "Test 6 failed: files t6.out and $srcdir/t6.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 6 may have failed. 1>&2;
2) $echo "Test 6 may have failed." 1>&2;
$echo The command "cmp t6.out $srcdir/t6.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
@@ -114,15 +114,15 @@ test -s t6.err || rm -f t6.err
$xx < $srcdir/t7.in > t7.out 2> t7.err
code=$?
if test $code != 0 ; then
$echo Test 7 failed: ../../src/md5sum return code $code differs from expected value 0 1>&2
$echo "Test 7 failed: ../../src/md5sum return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp t7.out $srcdir/t7.exp
case $? in
0) if test "$VERBOSE" ; then $echo passed 7; fi ;; # equal files
1) $echo Test 7 failed: files t7.out and $srcdir/t7.exp differ 1>&2;
0) if test "$VERBOSE" ; then $echo "passed 7"; fi ;;
1) $echo "Test 7 failed: files t7.out and $srcdir/t7.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo Test 7 may have failed. 1>&2;
2) $echo "Test 7 may have failed." 1>&2;
$echo The command "cmp t7.out $srcdir/t7.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

5
tests/tail/.cvsignore Normal file
View File

@@ -0,0 +1,5 @@
t*.out
t*.in
t*.exp
Makefile
mk-script

62
tests/tail/Makefile.am Normal file
View File

@@ -0,0 +1,62 @@
## Process this file with automake to produce Makefile.in.
##test-files-begin
x = tail
explicit =
maint_gen = tobs-c1.in tobs-c1.exp tobs-c2.in tobs-c2.exp tobs-c3.in \
tobs-c3.exp tobs-c4.in tobs-c4.exp tobs-c5.in tobs-c5.exp tobs-l1.in \
tobs-l1.exp tobs-l2.in tobs-l2.exp tobs-l3.in tobs-l3.exp tobs-l4.in \
tobs-l4.exp tobs-l5.in tobs-l5.exp tobs-1.in tobs-1.exp tobs-2.in tobs-2.exp \
tobs-3.in tobs-3.exp tobs-4.in tobs-4.exp tobs-5.in tobs-5.exp tobsx-1.in \
tobsx-1.exp tobsx-2.in tobsx-2.exp tobs-l.in tobs-l.exp terr-1.in terr-1.exp \
terr-2.in terr-2.exp terr-3.in terr-3.exp terr-4.in terr-4.exp terr-5.in \
terr-5.exp terr-6.in terr-6.exp tminus-1.in tminus-1.exp tminus-2.in \
tminus-2.exp tn-1.in tn-1.exp tn-2.in tn-2.exp tn-3.in tn-3.exp tn-4.in \
tn-4.exp tn-4a.in tn-4a.exp tn-5.in tn-5.exp tn-5a.in tn-5a.exp tn-5b.in \
tn-5b.exp
run_gen = tobs-c1.out tobs-c1.err tobs-c2.out tobs-c2.err tobs-c3.out \
tobs-c3.err tobs-c4.out tobs-c4.err tobs-c5.out tobs-c5.err tobs-l1.out \
tobs-l1.err tobs-l2.out tobs-l2.err tobs-l3.out tobs-l3.err tobs-l4.out \
tobs-l4.err tobs-l5.out tobs-l5.err tobs-1.out tobs-1.err tobs-2.out \
tobs-2.err tobs-3.out tobs-3.err tobs-4.out tobs-4.err tobs-5.out tobs-5.err \
tobsx-1.out tobsx-1.err tobsx-2.out tobsx-2.err tobs-l.out tobs-l.err \
terr-1.out terr-1.err terr-2.out terr-2.err terr-3.out terr-3.err terr-4.out \
terr-4.err terr-5.out terr-5.err terr-6.out terr-6.err tminus-1.out \
tminus-1.err tminus-2.out tminus-2.err tn-1.out tn-1.err tn-2.out tn-2.err \
tn-3.out tn-3.err tn-4.out tn-4.err tn-4a.out tn-4a.err tn-5.out tn-5.err \
tn-5a.out tn-5a.err tn-5b.out tn-5b.err
##test-files-end
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
PERL = @PERL@
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g'
TESTS = $x-tests
$x-tests: @MAINT@mk-script Test.pm
./mk-script ../../src/$x > $@.n
mv $@.n $@
chmod 755 $@
SUFFIXES = .pl
.pl:
rm -f $@ $@.tmp
$(editpl) $< > $@.tmp
chmod +x-w $@.tmp
mv $@.tmp $@
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
@MAINT@rebuild-check: Test.pm mk-script
@MAINT@ rb=rb-check; rm -f $rb; \
@MAINT@ m_template=../Makefile.am.in; \
@MAINT@ sed -n '1,/^##test-files-begin/p' $$m_template > $$rb; \
@MAINT@ tool=`echo $(subdir)|sed 's/^tests.//;s/-test//'`; \
@MAINT@ echo "x = $$tool" >> $$rb; \
@MAINT@ ./mk-script --list >> $$rb; \
@MAINT@ sed -n '/^##test-files-end/,$$p' $$m_template >> $$rb; \
@MAINT@ diff -u Makefile.am $$rb && echo ok || echo no

220
tests/tail/Makefile.in Normal file
View File

@@ -0,0 +1,220 @@
# Makefile.in generated automatically by automake 1.1l from Makefile.am
# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
SHELL = /bin/sh
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 = ../..
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
RANLIB = @RANLIB@
GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
CC = @CC@
x = tail
explicit =
maint_gen = tobs-c1.in tobs-c1.exp tobs-c2.in tobs-c2.exp tobs-c3.in \
tobs-c3.exp tobs-c4.in tobs-c4.exp tobs-c5.in tobs-c5.exp tobs-l1.in \
tobs-l1.exp tobs-l2.in tobs-l2.exp tobs-l3.in tobs-l3.exp tobs-l4.in \
tobs-l4.exp tobs-l5.in tobs-l5.exp tobs-1.in tobs-1.exp tobs-2.in tobs-2.exp \
tobs-3.in tobs-3.exp tobs-4.in tobs-4.exp tobs-5.in tobs-5.exp tobsx-1.in \
tobsx-1.exp tobsx-2.in tobsx-2.exp tobs-l.in tobs-l.exp terr-1.in terr-1.exp \
terr-2.in terr-2.exp terr-3.in terr-3.exp terr-4.in terr-4.exp terr-5.in \
terr-5.exp terr-6.in terr-6.exp tminus-1.in tminus-1.exp tminus-2.in \
tminus-2.exp tn-1.in tn-1.exp tn-2.in tn-2.exp tn-3.in tn-3.exp tn-4.in \
tn-4.exp tn-4a.in tn-4a.exp tn-5.in tn-5.exp tn-5a.in tn-5a.exp tn-5b.in \
tn-5b.exp
run_gen = tobs-c1.out tobs-c1.err tobs-c2.out tobs-c2.err tobs-c3.out \
tobs-c3.err tobs-c4.out tobs-c4.err tobs-c5.out tobs-c5.err tobs-l1.out \
tobs-l1.err tobs-l2.out tobs-l2.err tobs-l3.out tobs-l3.err tobs-l4.out \
tobs-l4.err tobs-l5.out tobs-l5.err tobs-1.out tobs-1.err tobs-2.out \
tobs-2.err tobs-3.out tobs-3.err tobs-4.out tobs-4.err tobs-5.out tobs-5.err \
tobsx-1.out tobsx-1.err tobsx-2.out tobsx-2.err tobs-l.out tobs-l.err \
terr-1.out terr-1.err terr-2.out terr-2.err terr-3.out terr-3.err terr-4.out \
terr-4.err terr-5.out terr-5.err terr-6.out terr-6.err tminus-1.out \
tminus-1.err tminus-2.out tminus-2.err tn-1.out tn-1.err tn-2.out tn-2.err \
tn-3.out tn-3.err tn-4.out tn-4.err tn-4a.out tn-4a.err tn-5.out tn-5.err \
tn-5a.out tn-5a.err tn-5b.out tn-5b.err
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
PERL = @PERL@
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,@srcdir@,g'
TESTS = $x-tests
SUFFIXES = .pl
MAINTAINERCLEANFILES = $x-tests $(maint_gen)
CLEANFILES = $(run_gen)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES =
SCRIPTS = $(noinst_SCRIPTS)
DIST_COMMON = Makefile.am Makefile.in
PACKAGE = @PACKAGE@
VERSION = @VERSION@
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) \
$(TEXINFOS) $(MANS) $(EXTRA_DIST)
TAR = tar
default: all
.SUFFIXES:
.SUFFIXES: .pl
$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL)
cd $(top_srcdir) && automake --gnu tests/tail/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = tests/tail
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file; \
done
check-TESTS: $(TESTS)
@failed=0; all=0; \
srcdir=$(srcdir); export srcdir; \
for tst in $(TESTS); do \
all=`expr $$all + 1`; \
if test -f $$tst; then dir=.; \
else dir="$(srcdir)"; fi; \
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
echo "PASS: $$tst"; \
else \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
echo "========================"; \
echo "All $$all tests passed"; \
echo "========================"; \
else \
echo "$$failed of $$all tests failed"; \
fi
info:
dvi:
check: all
$(MAKE) check-TESTS
installcheck:
install-exec:
$(NORMAL_INSTALL)
install-data:
$(NORMAL_INSTALL)
install: install-exec install-data all
@:
uninstall:
all: $(SCRIPTS) Makefile
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs:
mostlyclean-generic:
test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic:
test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
rm -f Makefile $(DISTCLEANFILES)
rm -f config.cache config.log stamp-h
test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-generic
clean: clean-generic mostlyclean
distclean: distclean-generic clean
rm -f config.status
maintainer-clean: maintainer-clean-generic distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
.PHONY: default tags distdir check-TESTS info dvi installcheck \
install-exec install-data install uninstall all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
$x-tests: @MAINT@mk-script Test.pm
./mk-script ../../src/$x > $@.n
mv $@.n $@
chmod 755 $@
.pl:
rm -f $@ $@.tmp
$(editpl) $< > $@.tmp
chmod +x-w $@.tmp
mv $@.tmp $@
@MAINT@rebuild-check: Test.pm mk-script
@MAINT@ rb=rb-check; rm -f $rb; \
@MAINT@ m_template=../Makefile.am.in; \
@MAINT@ sed -n '1,/^##test-files-begin/p' $$m_template > $$rb; \
@MAINT@ tool=`echo $(subdir)|sed 's/^tests.//;s/-test//'`; \
@MAINT@ echo "x = $$tool" >> $$rb; \
@MAINT@ ./mk-script --list >> $$rb; \
@MAINT@ sed -n '/^##test-files-end/,$$p' $$m_template >> $$rb; \
@MAINT@ diff -u Makefile.am $$rb && echo ok || echo no
# 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:

78
tests/tail/Test.pm Executable file
View File

@@ -0,0 +1,78 @@
package Test;
require 5.002;
use strict;
$Test::input_via_stdin = 1;
my @tv = (
# test name, options, input, expected output, expected return code
#
['obs-c1', '+2c', 'abcd', 'bcd', 0],
['obs-c2', '+8c', 'abcd', '', 0],
['obs-c3', '-1c', 'abcd', 'd', 0],
['obs-c4', '-9c', 'abcd', 'abcd', 0],
['obs-c5', '-12c', 'x' . ('y' x 12) . 'z', ('y' x 11) . 'z', 0],
['obs-l1', '-1l', 'x', 'x', 0],
['obs-l2', '-1l', "x\ny\n", "y\n", 0],
['obs-l3', '-1l', "x\ny", "y", 0],
['obs-l4', '+1l', "x\ny\n", "x\ny\n", 0],
['obs-l5', '+2l', "x\ny\n", "y\n", 0],
# Same as -l tests, but without the `l'.
['obs-1', '-1', 'x', 'x', 0],
['obs-2', '-1', "x\ny\n", "y\n", 0],
['obs-3', '-1', "x\ny", "y", 0],
['obs-4', '+1', "x\ny\n", "x\ny\n", 0],
['obs-5', '+2', "x\ny\n", "y\n", 0],
# This is equivalent to +10c
['obsx-1', '+c', 'x' . ('y' x 10) . 'z', 'yyz', 0],
# This is equivalent to +10l
['obsx-2', '+l', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0],
# With no number, this is like -10l
['obs-l', '-l', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
# This should get `tail: +cl: No such file or directory'
['err-1', '+cl', '', '', 1],
# This should get `tail: l: invalid number of bytes'
['err-2', '-cl', '', '', 1],
# This should get `tail: z: invalid suffix character in obsolescent option'
['err-3', '+2cz', '', '', 1],
# This should get `tail: X: invalid suffix character in obsolescent option'
['err-4', '-2cX', '', '', 1],
# Since the number is larger than 2^64, this should provoke
# the diagnostic: `tail: 99999999999999999999: number of bytes is so large \
# that it is not representable' on all systems... probably, for now, maybe.
['err-5', '-c99999999999999999999', '', '', 1],
['err-6', '-c', '', '', 1],
# Same as -n 10
['minus-1', '-', '', '', 0],
['minus-2', '-', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
['n-1', '-n 10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
['n-2', '-n -10', "x\n" . ("y\n" x 10) . 'z', ("y\n" x 9) . 'z', 0],
['n-3', '-n +10', "x\n" . ("y\n" x 10) . 'z', "y\ny\nz", 0],
# Accept +0 as synonym for +1.
['n-4', '-n +0', "y\n" x 5, "y\n" x 5, 0],
['n-4a', '-n +1', "y\n" x 5, "y\n" x 5, 0],
# Note that -0 is *not* a synonym for -1.
['n-5', '-n -0', "y\n" x 5, '', 0],
['n-5a', '-n -1', "y\n" x 5, "y\n", 0],
['n-5b', '-n 0', "y\n" x 5, '', 0],
);
sub test_vector
{
return @tv;
}
1;

596
tests/tail/tail-tests Executable file
View File

@@ -0,0 +1,596 @@
#! /bin/sh
# This script was generated automatically by build-script.
case $# in
0) xx='../../src/tail';;
*) xx="$1";;
esac
test "$VERBOSE" && echo=echo || echo=:
$echo testing program: $xx
errors=0
test "$srcdir" || srcdir=.
test "$VERBOSE" && $xx --version 2> /dev/null
$xx +2c < $srcdir/tobs-c1.in > tobs-c1.out 2> tobs-c1.err
code=$?
if test $code != 0 ; then
$echo "Test obs-c1 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-c1.out $srcdir/tobs-c1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-c1"; fi ;;
1) $echo "Test obs-c1 failed: files tobs-c1.out and $srcdir/tobs-c1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-c1 may have failed." 1>&2;
$echo The command "cmp tobs-c1.out $srcdir/tobs-c1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-c1.err || rm -f tobs-c1.err
$xx +8c < $srcdir/tobs-c2.in > tobs-c2.out 2> tobs-c2.err
code=$?
if test $code != 0 ; then
$echo "Test obs-c2 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-c2.out $srcdir/tobs-c2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-c2"; fi ;;
1) $echo "Test obs-c2 failed: files tobs-c2.out and $srcdir/tobs-c2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-c2 may have failed." 1>&2;
$echo The command "cmp tobs-c2.out $srcdir/tobs-c2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-c2.err || rm -f tobs-c2.err
$xx -1c < $srcdir/tobs-c3.in > tobs-c3.out 2> tobs-c3.err
code=$?
if test $code != 0 ; then
$echo "Test obs-c3 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-c3.out $srcdir/tobs-c3.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-c3"; fi ;;
1) $echo "Test obs-c3 failed: files tobs-c3.out and $srcdir/tobs-c3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-c3 may have failed." 1>&2;
$echo The command "cmp tobs-c3.out $srcdir/tobs-c3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-c3.err || rm -f tobs-c3.err
$xx -9c < $srcdir/tobs-c4.in > tobs-c4.out 2> tobs-c4.err
code=$?
if test $code != 0 ; then
$echo "Test obs-c4 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-c4.out $srcdir/tobs-c4.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-c4"; fi ;;
1) $echo "Test obs-c4 failed: files tobs-c4.out and $srcdir/tobs-c4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-c4 may have failed." 1>&2;
$echo The command "cmp tobs-c4.out $srcdir/tobs-c4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-c4.err || rm -f tobs-c4.err
$xx -12c < $srcdir/tobs-c5.in > tobs-c5.out 2> tobs-c5.err
code=$?
if test $code != 0 ; then
$echo "Test obs-c5 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-c5.out $srcdir/tobs-c5.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-c5"; fi ;;
1) $echo "Test obs-c5 failed: files tobs-c5.out and $srcdir/tobs-c5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-c5 may have failed." 1>&2;
$echo The command "cmp tobs-c5.out $srcdir/tobs-c5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-c5.err || rm -f tobs-c5.err
$xx -1l < $srcdir/tobs-l1.in > tobs-l1.out 2> tobs-l1.err
code=$?
if test $code != 0 ; then
$echo "Test obs-l1 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-l1.out $srcdir/tobs-l1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-l1"; fi ;;
1) $echo "Test obs-l1 failed: files tobs-l1.out and $srcdir/tobs-l1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-l1 may have failed." 1>&2;
$echo The command "cmp tobs-l1.out $srcdir/tobs-l1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-l1.err || rm -f tobs-l1.err
$xx -1l < $srcdir/tobs-l2.in > tobs-l2.out 2> tobs-l2.err
code=$?
if test $code != 0 ; then
$echo "Test obs-l2 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-l2.out $srcdir/tobs-l2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-l2"; fi ;;
1) $echo "Test obs-l2 failed: files tobs-l2.out and $srcdir/tobs-l2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-l2 may have failed." 1>&2;
$echo The command "cmp tobs-l2.out $srcdir/tobs-l2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-l2.err || rm -f tobs-l2.err
$xx -1l < $srcdir/tobs-l3.in > tobs-l3.out 2> tobs-l3.err
code=$?
if test $code != 0 ; then
$echo "Test obs-l3 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-l3.out $srcdir/tobs-l3.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-l3"; fi ;;
1) $echo "Test obs-l3 failed: files tobs-l3.out and $srcdir/tobs-l3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-l3 may have failed." 1>&2;
$echo The command "cmp tobs-l3.out $srcdir/tobs-l3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-l3.err || rm -f tobs-l3.err
$xx +1l < $srcdir/tobs-l4.in > tobs-l4.out 2> tobs-l4.err
code=$?
if test $code != 0 ; then
$echo "Test obs-l4 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-l4.out $srcdir/tobs-l4.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-l4"; fi ;;
1) $echo "Test obs-l4 failed: files tobs-l4.out and $srcdir/tobs-l4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-l4 may have failed." 1>&2;
$echo The command "cmp tobs-l4.out $srcdir/tobs-l4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-l4.err || rm -f tobs-l4.err
$xx +2l < $srcdir/tobs-l5.in > tobs-l5.out 2> tobs-l5.err
code=$?
if test $code != 0 ; then
$echo "Test obs-l5 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-l5.out $srcdir/tobs-l5.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-l5"; fi ;;
1) $echo "Test obs-l5 failed: files tobs-l5.out and $srcdir/tobs-l5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-l5 may have failed." 1>&2;
$echo The command "cmp tobs-l5.out $srcdir/tobs-l5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-l5.err || rm -f tobs-l5.err
$xx -1 < $srcdir/tobs-1.in > tobs-1.out 2> tobs-1.err
code=$?
if test $code != 0 ; then
$echo "Test obs-1 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-1.out $srcdir/tobs-1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-1"; fi ;;
1) $echo "Test obs-1 failed: files tobs-1.out and $srcdir/tobs-1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-1 may have failed." 1>&2;
$echo The command "cmp tobs-1.out $srcdir/tobs-1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-1.err || rm -f tobs-1.err
$xx -1 < $srcdir/tobs-2.in > tobs-2.out 2> tobs-2.err
code=$?
if test $code != 0 ; then
$echo "Test obs-2 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-2.out $srcdir/tobs-2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-2"; fi ;;
1) $echo "Test obs-2 failed: files tobs-2.out and $srcdir/tobs-2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-2 may have failed." 1>&2;
$echo The command "cmp tobs-2.out $srcdir/tobs-2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-2.err || rm -f tobs-2.err
$xx -1 < $srcdir/tobs-3.in > tobs-3.out 2> tobs-3.err
code=$?
if test $code != 0 ; then
$echo "Test obs-3 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-3.out $srcdir/tobs-3.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-3"; fi ;;
1) $echo "Test obs-3 failed: files tobs-3.out and $srcdir/tobs-3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-3 may have failed." 1>&2;
$echo The command "cmp tobs-3.out $srcdir/tobs-3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-3.err || rm -f tobs-3.err
$xx +1 < $srcdir/tobs-4.in > tobs-4.out 2> tobs-4.err
code=$?
if test $code != 0 ; then
$echo "Test obs-4 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-4.out $srcdir/tobs-4.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-4"; fi ;;
1) $echo "Test obs-4 failed: files tobs-4.out and $srcdir/tobs-4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-4 may have failed." 1>&2;
$echo The command "cmp tobs-4.out $srcdir/tobs-4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-4.err || rm -f tobs-4.err
$xx +2 < $srcdir/tobs-5.in > tobs-5.out 2> tobs-5.err
code=$?
if test $code != 0 ; then
$echo "Test obs-5 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-5.out $srcdir/tobs-5.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-5"; fi ;;
1) $echo "Test obs-5 failed: files tobs-5.out and $srcdir/tobs-5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-5 may have failed." 1>&2;
$echo The command "cmp tobs-5.out $srcdir/tobs-5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-5.err || rm -f tobs-5.err
$xx +c < $srcdir/tobsx-1.in > tobsx-1.out 2> tobsx-1.err
code=$?
if test $code != 0 ; then
$echo "Test obsx-1 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobsx-1.out $srcdir/tobsx-1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obsx-1"; fi ;;
1) $echo "Test obsx-1 failed: files tobsx-1.out and $srcdir/tobsx-1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obsx-1 may have failed." 1>&2;
$echo The command "cmp tobsx-1.out $srcdir/tobsx-1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobsx-1.err || rm -f tobsx-1.err
$xx +l < $srcdir/tobsx-2.in > tobsx-2.out 2> tobsx-2.err
code=$?
if test $code != 0 ; then
$echo "Test obsx-2 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobsx-2.out $srcdir/tobsx-2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obsx-2"; fi ;;
1) $echo "Test obsx-2 failed: files tobsx-2.out and $srcdir/tobsx-2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obsx-2 may have failed." 1>&2;
$echo The command "cmp tobsx-2.out $srcdir/tobsx-2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobsx-2.err || rm -f tobsx-2.err
$xx -l < $srcdir/tobs-l.in > tobs-l.out 2> tobs-l.err
code=$?
if test $code != 0 ; then
$echo "Test obs-l failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tobs-l.out $srcdir/tobs-l.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed obs-l"; fi ;;
1) $echo "Test obs-l failed: files tobs-l.out and $srcdir/tobs-l.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test obs-l may have failed." 1>&2;
$echo The command "cmp tobs-l.out $srcdir/tobs-l.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tobs-l.err || rm -f tobs-l.err
$xx +cl < $srcdir/terr-1.in > terr-1.out 2> terr-1.err
code=$?
if test $code != 1 ; then
$echo "Test err-1 failed: ../../src/tail return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp terr-1.out $srcdir/terr-1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed err-1"; fi ;;
1) $echo "Test err-1 failed: files terr-1.out and $srcdir/terr-1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test err-1 may have failed." 1>&2;
$echo The command "cmp terr-1.out $srcdir/terr-1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s terr-1.err || rm -f terr-1.err
$xx -cl < $srcdir/terr-2.in > terr-2.out 2> terr-2.err
code=$?
if test $code != 1 ; then
$echo "Test err-2 failed: ../../src/tail return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp terr-2.out $srcdir/terr-2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed err-2"; fi ;;
1) $echo "Test err-2 failed: files terr-2.out and $srcdir/terr-2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test err-2 may have failed." 1>&2;
$echo The command "cmp terr-2.out $srcdir/terr-2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s terr-2.err || rm -f terr-2.err
$xx +2cz < $srcdir/terr-3.in > terr-3.out 2> terr-3.err
code=$?
if test $code != 1 ; then
$echo "Test err-3 failed: ../../src/tail return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp terr-3.out $srcdir/terr-3.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed err-3"; fi ;;
1) $echo "Test err-3 failed: files terr-3.out and $srcdir/terr-3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test err-3 may have failed." 1>&2;
$echo The command "cmp terr-3.out $srcdir/terr-3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s terr-3.err || rm -f terr-3.err
$xx -2cX < $srcdir/terr-4.in > terr-4.out 2> terr-4.err
code=$?
if test $code != 1 ; then
$echo "Test err-4 failed: ../../src/tail return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp terr-4.out $srcdir/terr-4.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed err-4"; fi ;;
1) $echo "Test err-4 failed: files terr-4.out and $srcdir/terr-4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test err-4 may have failed." 1>&2;
$echo The command "cmp terr-4.out $srcdir/terr-4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s terr-4.err || rm -f terr-4.err
$xx -c99999999999999999999 < $srcdir/terr-5.in > terr-5.out 2> terr-5.err
code=$?
if test $code != 1 ; then
$echo "Test err-5 failed: ../../src/tail return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp terr-5.out $srcdir/terr-5.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed err-5"; fi ;;
1) $echo "Test err-5 failed: files terr-5.out and $srcdir/terr-5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test err-5 may have failed." 1>&2;
$echo The command "cmp terr-5.out $srcdir/terr-5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s terr-5.err || rm -f terr-5.err
$xx -c < $srcdir/terr-6.in > terr-6.out 2> terr-6.err
code=$?
if test $code != 1 ; then
$echo "Test err-6 failed: ../../src/tail return code $code differs from expected value 1" 1>&2
errors=`expr $errors + 1`
else
cmp terr-6.out $srcdir/terr-6.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed err-6"; fi ;;
1) $echo "Test err-6 failed: files terr-6.out and $srcdir/terr-6.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test err-6 may have failed." 1>&2;
$echo The command "cmp terr-6.out $srcdir/terr-6.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s terr-6.err || rm -f terr-6.err
$xx - < $srcdir/tminus-1.in > tminus-1.out 2> tminus-1.err
code=$?
if test $code != 0 ; then
$echo "Test minus-1 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tminus-1.out $srcdir/tminus-1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed minus-1"; fi ;;
1) $echo "Test minus-1 failed: files tminus-1.out and $srcdir/tminus-1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test minus-1 may have failed." 1>&2;
$echo The command "cmp tminus-1.out $srcdir/tminus-1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tminus-1.err || rm -f tminus-1.err
$xx - < $srcdir/tminus-2.in > tminus-2.out 2> tminus-2.err
code=$?
if test $code != 0 ; then
$echo "Test minus-2 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tminus-2.out $srcdir/tminus-2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed minus-2"; fi ;;
1) $echo "Test minus-2 failed: files tminus-2.out and $srcdir/tminus-2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test minus-2 may have failed." 1>&2;
$echo The command "cmp tminus-2.out $srcdir/tminus-2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tminus-2.err || rm -f tminus-2.err
$xx -n 10 < $srcdir/tn-1.in > tn-1.out 2> tn-1.err
code=$?
if test $code != 0 ; then
$echo "Test n-1 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-1.out $srcdir/tn-1.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-1"; fi ;;
1) $echo "Test n-1 failed: files tn-1.out and $srcdir/tn-1.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-1 may have failed." 1>&2;
$echo The command "cmp tn-1.out $srcdir/tn-1.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-1.err || rm -f tn-1.err
$xx -n -10 < $srcdir/tn-2.in > tn-2.out 2> tn-2.err
code=$?
if test $code != 0 ; then
$echo "Test n-2 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-2.out $srcdir/tn-2.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-2"; fi ;;
1) $echo "Test n-2 failed: files tn-2.out and $srcdir/tn-2.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-2 may have failed." 1>&2;
$echo The command "cmp tn-2.out $srcdir/tn-2.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-2.err || rm -f tn-2.err
$xx -n +10 < $srcdir/tn-3.in > tn-3.out 2> tn-3.err
code=$?
if test $code != 0 ; then
$echo "Test n-3 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-3.out $srcdir/tn-3.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-3"; fi ;;
1) $echo "Test n-3 failed: files tn-3.out and $srcdir/tn-3.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-3 may have failed." 1>&2;
$echo The command "cmp tn-3.out $srcdir/tn-3.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-3.err || rm -f tn-3.err
$xx -n +0 < $srcdir/tn-4.in > tn-4.out 2> tn-4.err
code=$?
if test $code != 0 ; then
$echo "Test n-4 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-4.out $srcdir/tn-4.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-4"; fi ;;
1) $echo "Test n-4 failed: files tn-4.out and $srcdir/tn-4.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-4 may have failed." 1>&2;
$echo The command "cmp tn-4.out $srcdir/tn-4.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-4.err || rm -f tn-4.err
$xx -n +1 < $srcdir/tn-4a.in > tn-4a.out 2> tn-4a.err
code=$?
if test $code != 0 ; then
$echo "Test n-4a failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-4a.out $srcdir/tn-4a.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-4a"; fi ;;
1) $echo "Test n-4a failed: files tn-4a.out and $srcdir/tn-4a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-4a may have failed." 1>&2;
$echo The command "cmp tn-4a.out $srcdir/tn-4a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-4a.err || rm -f tn-4a.err
$xx -n -0 < $srcdir/tn-5.in > tn-5.out 2> tn-5.err
code=$?
if test $code != 0 ; then
$echo "Test n-5 failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-5.out $srcdir/tn-5.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-5"; fi ;;
1) $echo "Test n-5 failed: files tn-5.out and $srcdir/tn-5.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-5 may have failed." 1>&2;
$echo The command "cmp tn-5.out $srcdir/tn-5.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-5.err || rm -f tn-5.err
$xx -n -1 < $srcdir/tn-5a.in > tn-5a.out 2> tn-5a.err
code=$?
if test $code != 0 ; then
$echo "Test n-5a failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-5a.out $srcdir/tn-5a.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-5a"; fi ;;
1) $echo "Test n-5a failed: files tn-5a.out and $srcdir/tn-5a.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-5a may have failed." 1>&2;
$echo The command "cmp tn-5a.out $srcdir/tn-5a.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-5a.err || rm -f tn-5a.err
$xx -n 0 < $srcdir/tn-5b.in > tn-5b.out 2> tn-5b.err
code=$?
if test $code != 0 ; then
$echo "Test n-5b failed: ../../src/tail return code $code differs from expected value 0" 1>&2
errors=`expr $errors + 1`
else
cmp tn-5b.out $srcdir/tn-5b.exp
case $? in
0) if test "$VERBOSE" ; then $echo "passed n-5b"; fi ;;
1) $echo "Test n-5b failed: files tn-5b.out and $srcdir/tn-5b.exp differ" 1>&2;
errors=`expr $errors + 1` ;;
2) $echo "Test n-5b may have failed." 1>&2;
$echo The command "cmp tn-5b.out $srcdir/tn-5b.exp" failed. 1>&2 ;
errors=`expr $errors + 1` ;;
esac
fi
test -s tn-5b.err || rm -f tn-5b.err
if test $errors = 0 ; then
$echo Passed all 34 tests. 1>&2
else
$echo Failed $errors tests. 1>&2
fi
test $errors = 0 || errors=1
exit $errors

View File

@@ -9,21 +9,25 @@ tc.in tc.exp td.in td.exp te.in te.exp tf.in tf.exp tg.in tg.exp th.in th.exp \
ti.in ti.exp tj.in tj.exp tk.in tk.exp tl.in tl.exp tm.in tm.exp tn.in tn.exp \
to.in to.exp tp.in tp.exp tq.in tq.exp tr.in tr.exp ts.in ts.exp tt.in tt.exp \
tu.in tu.exp tv.in tv.exp tw.in tw.exp tx.in tx.exp ty.in ty.exp tz.in tz.exp \
tA.in tA.exp tB.in tB.exp tC.in tC.exp tD.in tD.exp tE.in tE.exp tF.in tF.exp \
tG.in tG.exp tH.in tH.exp tI.in tI.exp tR0.0.in tR0.0.exp tR0.1.in tR0.1.exp \
tR1.0.in tR1.0.exp tR1.1.in tR1.1.exp tR2.in tR2.exp tR3.in tR3.exp tR4.in \
tR4.exp tR5.in tR5.exp tR6.in tR6.exp
trange-a-a.in trange-a-a.exp tnull.in tnull.exp tupcase.in tupcase.exp \
tdncase.in tdncase.exp trep-cclass.in trep-cclass.exp trep-1.in trep-1.exp \
trep-2.in trep-2.exp trep-3.in trep-3.exp tesc.in tesc.exp tross-0a.in \
tross-0a.exp tross-0b.in tross-0b.exp tross-1a.in tross-1a.exp tross-1b.in \
tross-1b.exp tross-2.in tross-2.exp tross-3.in tross-3.exp tross-4.in \
tross-4.exp tross-5.in tross-5.exp tross-6.in tross-6.exp
run_gen = t1.out t1.err t2.out t2.err t3.out t3.err t4.out t4.err t5.out \
t5.err t6.out t6.err t7.out t7.err t8.out t8.err t9.out t9.err ta.out ta.err \
tb.out tb.err tc.out tc.err td.out td.err te.out te.err tf.out tf.err tg.out \
tg.err th.out th.err ti.out ti.err tj.out tj.err tk.out tk.err tl.out tl.err \
tm.out tm.err tn.out tn.err to.out to.err tp.out tp.err tq.out tq.err tr.out \
tr.err ts.out ts.err tt.out tt.err tu.out tu.err tv.out tv.err tw.out tw.err \
tx.out tx.err ty.out ty.err tz.out tz.err tA.out tA.err tB.out tB.err tC.out \
tC.err tD.out tD.err tE.out tE.err tF.out tF.err tG.out tG.err tH.out tH.err \
tI.out tI.err tR0.0.out tR0.0.err tR0.1.out tR0.1.err tR1.0.out tR1.0.err \
tR1.1.out tR1.1.err tR2.out tR2.err tR3.out tR3.err tR4.out tR4.err tR5.out \
tR5.err tR6.out tR6.err
tx.out tx.err ty.out ty.err tz.out tz.err trange-a-a.out trange-a-a.err \
tnull.out tnull.err tupcase.out tupcase.err tdncase.out tdncase.err \
trep-cclass.out trep-cclass.err trep-1.out trep-1.err trep-2.out trep-2.err \
trep-3.out trep-3.err tesc.out tesc.err tross-0a.out tross-0a.err \
tross-0b.out tross-0b.err tross-1a.out tross-1a.err tross-1b.out tross-1b.err \
tross-2.out tross-2.err tross-3.out tross-3.err tross-4.out tross-4.err \
tross-5.out tross-5.err tross-6.out tross-6.err
##test-files-end
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)

View File

@@ -50,21 +50,25 @@ tc.in tc.exp td.in td.exp te.in te.exp tf.in tf.exp tg.in tg.exp th.in th.exp \
ti.in ti.exp tj.in tj.exp tk.in tk.exp tl.in tl.exp tm.in tm.exp tn.in tn.exp \
to.in to.exp tp.in tp.exp tq.in tq.exp tr.in tr.exp ts.in ts.exp tt.in tt.exp \
tu.in tu.exp tv.in tv.exp tw.in tw.exp tx.in tx.exp ty.in ty.exp tz.in tz.exp \
tA.in tA.exp tB.in tB.exp tC.in tC.exp tD.in tD.exp tE.in tE.exp tF.in tF.exp \
tG.in tG.exp tH.in tH.exp tI.in tI.exp tR0.0.in tR0.0.exp tR0.1.in tR0.1.exp \
tR1.0.in tR1.0.exp tR1.1.in tR1.1.exp tR2.in tR2.exp tR3.in tR3.exp tR4.in \
tR4.exp tR5.in tR5.exp tR6.in tR6.exp
trange-a-a.in trange-a-a.exp tnull.in tnull.exp tupcase.in tupcase.exp \
tdncase.in tdncase.exp trep-cclass.in trep-cclass.exp trep-1.in trep-1.exp \
trep-2.in trep-2.exp trep-3.in trep-3.exp tesc.in tesc.exp tross-0a.in \
tross-0a.exp tross-0b.in tross-0b.exp tross-1a.in tross-1a.exp tross-1b.in \
tross-1b.exp tross-2.in tross-2.exp tross-3.in tross-3.exp tross-4.in \
tross-4.exp tross-5.in tross-5.exp tross-6.in tross-6.exp
run_gen = t1.out t1.err t2.out t2.err t3.out t3.err t4.out t4.err t5.out \
t5.err t6.out t6.err t7.out t7.err t8.out t8.err t9.out t9.err ta.out ta.err \
tb.out tb.err tc.out tc.err td.out td.err te.out te.err tf.out tf.err tg.out \
tg.err th.out th.err ti.out ti.err tj.out tj.err tk.out tk.err tl.out tl.err \
tm.out tm.err tn.out tn.err to.out to.err tp.out tp.err tq.out tq.err tr.out \
tr.err ts.out ts.err tt.out tt.err tu.out tu.err tv.out tv.err tw.out tw.err \
tx.out tx.err ty.out ty.err tz.out tz.err tA.out tA.err tB.out tB.err tC.out \
tC.err tD.out tD.err tE.out tE.err tF.out tF.err tG.out tG.err tH.out tH.err \
tI.out tI.err tR0.0.out tR0.0.err tR0.1.out tR0.1.err tR1.0.out tR1.0.err \
tR1.1.out tR1.1.err tR2.out tR2.err tR3.out tR3.err tR4.out tR4.err tR5.out \
tR5.err tR6.out tR6.err
tx.out tx.err ty.out ty.err tz.out tz.err trange-a-a.out trange-a-a.err \
tnull.out tnull.err tupcase.out tupcase.err tdncase.out tdncase.err \
trep-cclass.out trep-cclass.err trep-1.out trep-1.err trep-2.out trep-2.err \
trep-3.out trep-3.err tesc.out tesc.err tross-0a.out tross-0a.err \
tross-0b.out tross-0b.err tross-1a.out tross-1a.err tross-1b.out tross-1b.err \
tross-2.out tross-2.err tross-3.out tross-3.err tross-4.out tross-4.err \
tross-5.out tross-5.err tross-6.out tross-6.err
EXTRA_DIST = mk-script.pl Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests

View File

@@ -67,34 +67,35 @@ my @tv = (
['x', '-s ' . q|'abcdefghijklmn' '[:*016]'|, 'abcdefghijklmnop', ':op', 0],
['y', '-d ' . q|'a-z'|, 'abc $code', ' $', 0],
['z', '-ds ' . q|'a-z' '$.'|, 'a.b.c $$$$code\\', '. $\\', 0],
# Make sure that a-a is accepted, even though POSIX 1001.2 says it is illegal.
['A', q|'a-a' 'z'|, 'abc', 'zbc', 0],
['range-a-a', q|'a-a' 'z'|, 'abc', 'zbc', 0],
#
['B', q|'a' ''''|, '', '', 1],
['C', q|'[:lower:]' '[:upper:]'|, 'abcxyzABCXYZ', 'ABCXYZABCXYZ', 0],
['D', q|'[:upper:]' '[:lower:]'|, 'abcxyzABCXYZ', 'abcxyzabcxyz', 0],
['null', q|'a' ''''|, '', '', 1],
['upcase',q|'[:lower:]' '[:upper:]'|, 'abcxyzABCXYZ', 'ABCXYZABCXYZ', 0],
['dncase', q|'[:upper:]' '[:lower:]'|, 'abcxyzABCXYZ', 'abcxyzabcxyz', 0],
#
['E', q|'a[=*2][=c=]' 'xyyz'|, 'a=c', 'xyz', 0],
['F', q|'[:*3][:digit:]' 'a-m'|, ':1239', 'cefgm', 0],
['G', q|'a[b*512]c' '1[x*]2'|, 'abc', '1x2', 0],
['H', q|'a[b*513]c' '1[x*]2'|, 'abc', '1x2', 0],
['I', q|'a\-z' 'A-Z'|, 'abc-z', 'AbcBC', 0],
['rep-cclass', q|'a[=*2][=c=]' 'xyyz'|, 'a=c', 'xyz', 0],
['rep-1', q|'[:*3][:digit:]' 'a-m'|, ':1239', 'cefgm', 0],
['rep-2', q|'a[b*512]c' '1[x*]2'|, 'abc', '1x2', 0],
['rep-3', q|'a[b*513]c' '1[x*]2'|, 'abc', '1x2', 0],
['esc', q|'a\-z' 'A-Z'|, 'abc-z', 'AbcBC', 0],
#
# From Ross
['R0.0', '-cs ' . q|'[:upper:]' 'X[Y*]'|, '', '', 1],
['R0.1', '-cs ' . q|'[:cntrl:]' 'X[Y*]'|, '', '', 1],
['R1.0', '-cs ' . q|'[:upper:]' '[X*]'|, 'AMZamz123.-+AMZ', 'AMZXAMZ', 0],
['R1.1', '-cs ' . q|'[:upper:][:digit:]' '[Z*]'|, '', '', 0],
['R2', '-dcs ' . q|'[:lower:]' 'n-rs-z'|, 'amzAMZ123.-+amz', 'amzamz', 0],
['R3', '-ds ' . q|'[:xdigit:]' '[:alnum:]'|,
['ross-0a', '-cs ' . q|'[:upper:]' 'X[Y*]'|, '', '', 1],
['ross-0b', '-cs ' . q|'[:cntrl:]' 'X[Y*]'|, '', '', 1],
['ross-1a', '-cs ' . q|'[:upper:]' '[X*]'|, 'AMZamz123.-+AMZ', 'AMZXAMZ', 0],
['ross-1b', '-cs ' . q|'[:upper:][:digit:]' '[Z*]'|, '', '', 0],
['ross-2', '-dcs ' . q|'[:lower:]' 'n-rs-z'|, 'amzAMZ123.-+amz', 'amzamz', 0],
['ross-3', '-ds ' . q|'[:xdigit:]' '[:alnum:]'|,
'.ZABCDEFGzabcdefg.0123456788899.GG', '.ZGzg..G', 0],
['R4', '-dcs ' . q|'[:alnum:]' '[:digit:]'|, '', '', 0],
['R5', '-dc ' . q|'[:lower:]'|, '', '', 0],
['R6', '-dc ' . q|'[:upper:]'|, '', '', 0],
['ross-4', '-dcs ' . q|'[:alnum:]' '[:digit:]'|, '', '', 0],
['ross-5', '-dc ' . q|'[:lower:]'|, '', '', 0],
['ross-6', '-dc ' . q|'[:upper:]'|, '', '', 0],
);
sub test_vector

File diff suppressed because it is too large Load Diff