Skip to content

Commit

Permalink
Initial revision
Browse files Browse the repository at this point in the history
  • Loading branch information
meyering committed Oct 31, 1992
0 parents commit 14fd34b
Show file tree
Hide file tree
Showing 51 changed files with 14,198 additions and 0 deletions.
111 changes: 111 additions & 0 deletions INSTALL
@@ -0,0 +1,111 @@
This is a generic INSTALL file for utilities distributions.
If this package does not come with, e.g., installable documentation or
data files, please ignore the references to them below.

To compile this package:

1. Configure the package for your system. In the directory that this
file is in, type `./configure'. If you're using `csh' on an old
version of System V, you might need to type `sh configure' instead to
prevent `csh' from trying to execute `configure' itself.

The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation, and
creates the Makefile(s) (one in each subdirectory of the source
directory). In some packages it creates a C header file containing
system-dependent definitions. It also creates a file `config.status'
that you can run in the future to recreate the current configuration.

Running `configure' takes a minute or two. While it is running, it
prints some messages that tell what it is doing. If you don't want to
see the messages, run `configure' with its standard output redirected
to `/dev/null'; for example, `./configure >/dev/null'.

To compile the package in a different directory from the one
containing the source code, you must use a version of make that
supports the VPATH variable, such as GNU make. `cd' to the directory
where you want the object files and executables to go and run
`configure'. `configure' automatically checks for the source code in
the directory that `configure' is in and in `..'. If for some reason
`configure' is not in the source code directory that you are
configuring, then it will report that it can't find the source code.
In that case, run `configure' with the option `--srcdir=DIR', where
DIR is the directory that contains the source code.

By default, `make install' will install the package's files in
/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify
an installation prefix other than /usr/local by giving `configure' the
option `--prefix=PATH'. Alternately, you can do so by giving a value
for the `prefix' variable when you run `make', e.g.,
make prefix=/usr/gnu

You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If
you give `configure' the option `--exec_prefix=PATH' or set the
`make' variable `exec_prefix' to PATH, the package will use PATH as
the prefix for installing programs and libraries. Data files and
documentation will still use the regular prefix. Normally, all files
are installed using the regular prefix.

You can tell `configure' to figure out the configuration for your
system, and record it in `config.status', without actually configuring
the package (creating `Makefile's and perhaps a configuration header
file). To do this, give `configure' the `--no-create' option. Later,
you can run `./config.status' to actually configure the package. This
option is useful mainly in `Makefile' rules for updating `config.status'
and `Makefile'. You can also give `config.status' the `--recheck'
option, which makes it re-run `configure' with the same arguments you
used before. This is useful if you change `configure'.

`configure' ignores any other arguments that you give it.

If your system requires unusual options for compilation or linking
that `configure' doesn't know about, you can give `configure' initial
values for some variables by setting them in the environment. In
Bourne-compatible shells, you can do that on the command line like
this:
CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure

The `make' variables that you might want to override with environment
variables when running `configure' are:

(For these variables, any value given in the environment overrides the
value that `configure' would choose:)
CC C compiler program.
Default is `cc', or `gcc' if `gcc' is in your PATH.
INSTALL Program to use to install files.
Default is `install' if you have it, `cp' otherwise.

(For these variables, any value given in the environment is added to
the value that `configure' chooses:)
DEFS Configuration options, in the form `-Dfoo -Dbar ...'
LIBS Libraries to link with, in the form `-lfoo -lbar ...'

If you need to do unusual things to compile the package, we encourage
you to figure out how `configure' could check whether to do them, and
mail diffs or instructions to the address given in the README so we
can include them in the next release.

2. Type `make' to compile the package. If you want, you can override
the `make' variables CFLAGS and LDFLAGS like this:

make CFLAGS=-O2 LDFLAGS=-s

3. If the package comes with self-tests and you want to run them,
type `make check'. If you're not sure whether there are any, try it;
if `make' responds with something like
make: *** No way to make target `check'. Stop.
then the package does not come with self-tests.

4. Type `make install' to install programs, data files, and
documentation.

5. You can remove the program binaries and object files from the
source directory by typing `make clean'. To also remove the
Makefile(s), the header file containing system-dependent definitions
(if the package uses one), and `config.status' (all the files that
`configure' created), type `make distclean'.

The file `configure.in' is used as a template to create `configure' by
a program called `autoconf'. You will only need it if you want to
regenerate `configure' using a newer version of `autoconf'.
98 changes: 98 additions & 0 deletions lib/Makefile.in
@@ -0,0 +1,98 @@
# Makefile for library files used by GNU fileutils.
# Do not use this makefile directly, but only from `../Makefile'.
# Copyright (C) 1990, 1991, 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA.

SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

SOURCES = argmatch.c backupfile.c basename.c dirname.c eaccess.c \
error.c filemode.c fsusage.c getopt.c getopt1.c \
getversion.c idcache.c isdir.c makepath.c \
modechange.c mountlist.c savedir.c \
stripslash.c xgetcwd.c xmalloc.c xstrdup.c userspec.c yesno.c \
getdate.y posixtm.y \
fileblocks.c fnmatch.c ftruncate.c mkdir.c mktime.c rename.c stpcpy.c \
strdup.c strstr.c alloca.c

OBJECTS = argmatch.o backupfile.o basename.o dirname.o eaccess.o \
error.o filemode.o getopt.o getopt1.o \
getversion.o idcache.o isdir.o makepath.o \
modechange.o savedir.o \
stripslash.o xgetcwd.o xmalloc.o xstrdup.o userspec.o yesno.o \
getdate.o posixtm.o @LIBOBJS@ @ALLOCA@

DISTFILES = Makefile.in backupfile.h getopt.h modechange.h \
fnmatch.h fsusage.h mountlist.h pathmax.h system.h $(SOURCES)

all: libfu.a

.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(DEFS) -I$(srcdir) $<

install: all

uninstall:

TAGS: $(SOURCES)
etags $(SOURCES)

clean:
rm -f *.a *.o

mostlyclean: clean

distclean: clean
rm -f Makefile *.tab.c getdate.c *posixtm.c

realclean: distclean
rm -f TAGS

dist:
ln $(DISTFILES) ../`cat ../.fname`/lib

libfu.a: $(OBJECTS)
rm -f $@
$(AR) cr $@ $(OBJECTS)
-$(RANLIB) $@

# Since this directory contains two parsers, using bison without -y
# is the only way to reliably do a parallel make.
getdate.c: getdate.y
@echo expect 9 shift/reduce conflicts
-bison -o getdate.c $(srcdir)/getdate.y || yacc $(srcdir)/getdate.y
test ! -f y.tab.c || mv y.tab.c getdate.c

# Make the rename atomic, in case sed is interrupted and later rerun.
posixtm.c: posixtm.y
-bison -o posixtm.tab.c $(srcdir)/posixtm.y || yacc $(srcdir)/posixtm.y
test ! -f y.tab.c || mv y.tab.c posixtm.tab.c
sed -e 's/yy/zz/g' posixtm.tab.c > tposixtm.c
mv tposixtm.c posixtm.c
rm -f posixtm.tab.c

backupfile.o getversion.o: backupfile.h
fnmatch.o: fnmatch.h
fsusage.o: fsusage.h
getopt1.o: getopt.h
modechange.o: modechange.h
mountlist.o: mountlist.h
xgetcwd.o: pathmax.h

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
83 changes: 83 additions & 0 deletions lib/argmatch.c
@@ -0,0 +1,83 @@
/* argmatch.c -- find a match for a string in an array
Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */

/* Written by David MacKenzie <djm@ai.mit.edu> */

#include <stdio.h>
#ifdef STDC_HEADERS
#include <string.h>
#endif

extern char *program_name;

/* If ARG is an unambiguous match for an element of the
null-terminated array OPTLIST, return the index in OPTLIST
of the matched element, else -1 if it does not match any element
or -2 if it is ambiguous (is a prefix of more than one element). */

int
argmatch (arg, optlist)
char *arg;
char **optlist;
{
int i; /* Temporary index in OPTLIST. */
int arglen; /* Length of ARG. */
int matchind = -1; /* Index of first nonexact match. */
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */

arglen = strlen (arg);

/* Test all elements for either exact match or abbreviated matches. */
for (i = 0; optlist[i]; i++)
{
if (!strncmp (optlist[i], arg, arglen))
{
if (strlen (optlist[i]) == arglen)
/* Exact match found. */
return i;
else if (matchind == -1)
/* First nonexact match found. */
matchind = i;
else
/* Second nonexact match found. */
ambiguous = 1;
}
}
if (ambiguous)
return -2;
else
return matchind;
}

/* Error reporting for argmatch.
KIND is a description of the type of entity that was being matched.
VALUE is the invalid value that was given.
PROBLEM is the return value from argmatch. */

void
invalid_arg (kind, value, problem)
char *kind;
char *value;
int problem;
{
fprintf (stderr, "%s: ", program_name);
if (problem == -1)
fprintf (stderr, "invalid");
else /* Assume -2. */
fprintf (stderr, "ambiguous");
fprintf (stderr, " %s `%s'\n", kind, value);
}

0 comments on commit 14fd34b

Please sign in to comment.