dslinux/user/rl AUTHORS COPYING ChangeLog INSTALL Makefile.am Makefile.in NEWS README TODO aclocal.m4 alloc.c alloc.h buffer.c buffer.h config.guess config.h.in config.sub configure configure.ac depcomp getopt_long.c getopt_long.h install-sh missing mkinstalldirs random.c random.h rl.1.in rl.c rl.h rl.lsm.in rl.spec.in
stsp
stsp at user.in-berlin.de
Sun Oct 15 12:21:41 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/rl
In directory antilope:/tmp/cvs-serv6893
Added Files:
AUTHORS COPYING ChangeLog INSTALL Makefile.am Makefile.in NEWS
README TODO aclocal.m4 alloc.c alloc.h buffer.c buffer.h
config.guess config.h.in config.sub configure configure.ac
depcomp getopt_long.c getopt_long.h install-sh missing
mkinstalldirs random.c random.h rl.1.in rl.c rl.h rl.lsm.in
rl.spec.in
Log Message:
Adding pristine copy of rl so I can branch from it.
--- NEW FILE: mkinstalldirs ---
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2005-06-29.22
# Original author: Noah Friedman <friedman at prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake at gnu.org> or send patches to
# <automake-patches at gnu.org>.
errstatus=0
dirmode=
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake at gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit $?
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit $?
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
for file
do
case $file in
/*) pathcomp=/ ;;
*) pathcomp= ;;
esac
oIFS=$IFS
IFS=/
set fnord $file
shift
IFS=$oIFS
for d
do
test "x$d" = x && continue
pathcomp=$pathcomp$d
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp=$pathcomp/
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
--- NEW FILE: configure ---
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.60a for rl 0.2.5.
#
# Report bugs to <arthur at ch.tudelft.nl>.
#
# Copyright (C) 2002, 2003, 2004, 2005, 2006 Arthur de Jong
#
# This configure script is derived from configure.ac which 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
# of the License, or (at your option) any later version.
# See the configure.ac file for more details.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## --------------------- ##
[...8858 lines suppressed...]
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
--- NEW FILE: rl.lsm.in ---
Begin3
Title: rl
Version: @VERSION@
Entered-date: @ISODATE@
Description: Randomize Lines.
@configure_input@
rl reads lines from a input file or stdin, randomizes the lines and outputs a specified number of lines. It does this with only a single pass over the input while trying to use as little memory as possible.
Keywords: randomize lines textutil
Author: arthur at tiefighter.et.tudelft.nl (Arthur de Jong)
Maintained-by: arthur at tiefighter.et.tudelft.nl (Arthur de Jong)
Primary-site: tiefighter.et.tudelft.nl /~arthur/rl
0k rl- at VERSION@.tar.gz
500 rl.lsm
Alternate-site:
Original-site:
Platforms:
Copying-policy: GNU copyleft
End
--- NEW FILE: missing ---
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2005-06-08.21
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
# 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake at gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case "$1" in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
--- NEW FILE: Makefile.in ---
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# Makefile.am - use automake to generate Makefile.in
# Copyright (C) 2001, 2002, 2003, 2005, 2006 Arthur de Jong
#
# 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
bin_PROGRAMS = rl$(EXEEXT)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in $(srcdir)/rl.1.in \
$(srcdir)/rl.lsm.in $(srcdir)/rl.spec.in \
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
TODO config.guess config.sub depcomp getopt_long.c install-sh \
missing mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = rl.lsm rl.spec rl.1
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_rl_OBJECTS = rl.$(OBJEXT) alloc.$(OBJEXT) buffer.$(OBJEXT) \
random.$(OBJEXT)
rl_OBJECTS = $(am_rl_OBJECTS)
rl_DEPENDENCIES = @LIBOBJS@
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(rl_SOURCES)
DIST_SOURCES = $(rl_SOURCES)
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(man_MANS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RELEASE_MONTH = @RELEASE_MONTH@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
rl_SOURCES = rl.c rl.h \
alloc.c alloc.h \
buffer.c buffer.h \
random.c random.h \
aclocal.m4
rl_LDADD = @LIBOBJS@
EXTRA_DIST = rl.lsm.in rl.spec.in getopt_long.c getopt_long.h \
debian/control debian/changelog debian/rules debian/docs \
debian/copyright debian/compat
# install the man pages
man_MANS = rl.1
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
cd $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
rl.lsm: $(top_builddir)/config.status $(srcdir)/rl.lsm.in
cd $(top_builddir) && $(SHELL) ./config.status $@
rl.spec: $(top_builddir)/config.status $(srcdir)/rl.spec.in
cd $(top_builddir) && $(SHELL) ./config.status $@
rl.1: $(top_builddir)/config.status $(srcdir)/rl.1.in
cd $(top_builddir) && $(SHELL) ./config.status $@
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
rl$(EXEEXT): $(rl_OBJECTS) $(rl_DEPENDENCIES)
@rm -f rl$(EXEEXT)
$(LINK) $(rl_LDFLAGS) $(rl_OBJECTS) $(rl_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt_long.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/alloc.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/buffer.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/random.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rl.Po at am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
uninstall-info-am:
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
$(mkdir_p) $(distdir)/. $(distdir)/debian
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS) config.h
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(DEPDIR) ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am: install-binPROGRAMS
install-info: install-info-am
install-man: install-man1
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf $(DEPDIR) ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man
uninstall-man: uninstall-man1
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man1 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-info-am uninstall-man uninstall-man1
# targets for debian package
deb: distdir
cd $(distdir) && \
fakeroot debian/rules binary
rm -rf $(distdir)
signeddeb: distdir
cd $(distdir) && \
debuild
rm -rf $(distdir)
changelog:
svn2cl -i
# 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:
--- NEW FILE: rl.h ---
/*
rl.h - definitions of all functions
Copyright (C) 2001, 2002 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _RL_H
#define _RL_H 1
/* from system.h: */
#ifdef ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else /* not ENABLE_NLS */
# undef bindtextdomain
# define bindtextdomain(Domain, Directory)
# undef textdomain
# define textdomain(Domain)
# define _(Text) Text
#endif /* not ENABLE_NLS */
/* the average length of a line */
#define AVGLINELEN 50
/* the size in which to load files */
#define BLOCKSIZE 8192
/* from rl.c */
/* flag to indicate output */
extern int quiet;
#endif /* _RL_H */
--- NEW FILE: AUTHORS ---
Arthur de Jong <arthur at ch.tudelft.nl>
--- NEW FILE: configure.ac ---
# configure.ac - process this file with autoconf to produce configure
# Copyright (C) 2002, 2003, 2004, 2005, 2006 Arthur de Jong
#
# 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
AC_PREREQ(2.60a)
AC_COPYRIGHT(
[Copyright (C) 2002, 2003, 2004, 2005, 2006 Arthur de Jong
This configure script is derived from configure.ac which 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
of the License, or (at your option) any later version.
See the configure.ac file for more details.])
# initialize and set version and bugreport address
AC_INIT([rl],[0.2.5],[arthur at ch.tudelft.nl])
RELEASE_MONTH="Sep 2006"
AC_SUBST(RELEASE_MONTH)
AC_CONFIG_SRCDIR(rl.c)
# display notice and initialize automake
AC_MSG_NOTICE([configuring AC_PACKAGE_TARNAME AC_PACKAGE_VERSION])
AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME,AC_PACKAGE_VERSION)
# create a config.h file (Automake will add -DHAVE_CONFIG_H)
AC_CONFIG_HEADERS(config.h)
# AJ_CHECK_VALUE(decl, [includes])
# my cusom test (based on AC_CHECK_SIZEOF)
AC_DEFUN([AJ_CHECK_VALUE],
[AS_LITERAL_IF([$1], [],
[AC_FATAL([$0: requires literal arguments])])
AC_COMPUTE_INT([value of $1],[aj_cv_value_$1],
[(long)($1)],[AC_INCLUDES_DEFAULT([$2])],
[AC_MSG_FAILURE([cannot compute value ($1), 77])])
])# AJ_CHECK_VALUE
# checks for programs
AC_PROG_INSTALL
AC_PROG_CC
# checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(getopt.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(errno.h)
AC_CHECK_HEADERS(stdio.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(limits.h)
AC_CHECK_HEADERS(libintl.h)
AC_HEADER_TIME
# checks for library functions
AC_CHECK_FUNCS([gettimeofday strdup strerror strtol malloc realloc])
AC_REPLACE_FUNCS(getopt_long)
# do some value checks
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(int)
AC_CHECK_DECL(INT_MAX,,,[#include <limits.h>])
AJ_CHECK_VALUE(INT_MAX,[#include <limits.h>])
AC_CHECK_DECL(RAND_MAX)
AJ_CHECK_VALUE(RAND_MAX)
AC_C_CONST
AC_HEADER_TIME
# GCC compiler options
AC_C_INLINE
if test x$CC = xgcc; then
CFLAGS="$CFLAGS -Wall"
fi
# check for options
AC_ARG_ENABLE(debug,
AS_HELP_STRING(--enable-debug,enable extensive debugging to stderr),
CFLAGS="-DDEBUG $CFLAGS")
# check for extra compiler warnings
AC_ARG_ENABLE(warnings,
AS_HELP_STRING(--enable-warnings,enable extra compiler warnings (gcc only)),
[if test "x$enableval" != "no" ; then CFLAGS="$CFLAGS -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Waggregate-return -Wmissing-declarations" ; fi])
# check which random number generator to use
WHICH_RNG="rand"
AC_ARG_WITH(rng,
AS_HELP_STRING([--with-rng@<:@=NAME@:>@],
[choose rng (rand,dev)]),
[WHICH_RNG="$withval"])
case "$WHICH_RNG" in
rand)
AC_MSG_NOTICE([using system rand() function])
AC_DEFINE_UNQUOTED(USE_RAND_RNG,1,[use standard rand() rng])
;;
dev)
AC_MSG_NOTICE([using system /dev/urandom random device])
AC_DEFINE_UNQUOTED(USE_DEV_RNG,1,[use /dev/urandom rng])
;;
*)
AC_MSG_ERROR([*** illegal value specified for --with-rng ***])
;;
esac
# what files to output
AC_CONFIG_FILES(Makefile rl.lsm rl.spec rl.1)
AC_OUTPUT
--- NEW FILE: depcomp ---
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2005-07-09.11
# Copyright (C) 1999, 2000, 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake at gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mecanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
--- NEW FILE: rl.spec.in ---
Name: @PACKAGE@
Summary: Randomize Lines
Version: @VERSION@
Release: 1
Vendor: Arthur de Jong
Packager: Arthur de Jong arthur at ch.tudelft.nl
URL: http://ch.tudelft.nl/~arthur/rl/
Source: %{name}-%{version}.tar.gz
Group: Application/Generic
Copyright: GPL
BuildRoot: /var/tmp/%{name}-%{version}
%description
rl is a command-line tool that reads lines from an input file or stdin,
randomizes the lines and outputs a specified number of lines. It does this
with only a single pass over the input while trying to use as little memory
as possible.
Currently randomize-lines is under development and command-line arguments
may change slightly until a 1.0 release is made.
%prep
%setup -n %{name}-%{version}
#%patch -p1
%build
./configure --prefix=%{_prefix} --mandir=%{_mandir} CFLAGS="$RPM_OPT_FLAGS"
make
%install
[ "$RPM_BUILD_ROOT" = "/" ] || rm -rf "$RPM_BUILD_ROOT"
mkdir -p $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean
[ "$RPM_BUILD_ROOT" = "/" ] || rm -rf $RPM_BUILD_ROOT
%files
%doc README TODO AUTHORS NEWS COPYING
%{_mandir}/man1/rl.1*
/usr/bin/rl
--- NEW FILE: rl.c ---
/*
rl - Select a random line from stdin or file.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else /* not HAVE_GETOPT_H */
#include <unistd.h>
#endif /* not HAVE_GETOPT_H */
#ifndef HAVE_GETOPT_LONG
#include "getopt_long.h"
#endif /* not HAVE_GETOPT_LONG */
#include "rl.h"
#include "alloc.h"
#include "buffer.h"
#include "random.h"
/* the name of the program */
static char *program_name;
/* flag to indicate output */
int quiet=0;
/* Option flags and variables */
static struct option const long_options[] =
{
{"count",required_argument,NULL,'c'},
{"reselect",no_argument,NULL,'r'},
{"output",required_argument,NULL,'o'},
{"delimiter",required_argument,NULL,'d'},
{"null",no_argument,NULL,'0'},
{"line-number",no_argument,NULL,'n'},
{"line-numbers",no_argument,NULL,'n'},
{"quiet",no_argument,NULL,'q'},
{"silent",no_argument,NULL,'q'},
{"help",no_argument,NULL,'h'},
{"version",no_argument,NULL,'V'},
{NULL,0,NULL,0}
};
/* for adding options you should add to
long_options[] (directly above)
OPTION_STRING (directly below)
display_usage() (below)
main() (for the handling of the option) */
#define OPTION_STRING "c:ro:d:0nqhV"
/* display usage information */
static void
display_usage(FILE *fp)
{
fprintf(fp,_("Usage: %s [OPTION]... [FILE]...\n"),program_name);
fprintf(fp,_("Randomize the lines of a file (or stdin).\n\n"));
fprintf(fp,_(" -c, --count=N select N lines from the file\n"));
fprintf(fp,_(" -r, --reselect lines may be selected multiple times\n"));
fprintf(fp,_(" -o, --output=FILE\n"
" send output to file\n"));
fprintf(fp,_(" -d, --delimiter=DELIM\n"
" specify line delimiter (one character)\n"));
fprintf(fp,_(" -0, --null set line delimiter to null character\n"
" (useful with find -print0)\n"));
fprintf(fp,_(" -n, --line-number\n"
" print line number with output lines\n"));
fprintf(fp,_(" -q, --quiet, --silent\n"
" do not output any errors or warnings\n"));
fprintf(fp,_(" -h, --help display this help and exit\n"));
fprintf(fp,_(" -V, --version output version information and exit\n"));
}
/* display a use --help notice */
static void
display_tryhelp(FILE *fp)
{
fprintf(fp,_("Try `%s --help' for more information.\n"),program_name);
}
/* display version information */
static void
display_version(FILE *fp)
{
fprintf(fp,"rl %s\n",VERSION);
fprintf(fp,_("Written by Arthur de Jong.\n\n"));
fprintf(fp,_("Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Arthur de Jong.\n"
"This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"));
}
/* read the whole file and pick out count random lines and dump to out
all arguments are assumed to be reasonable values
any line has an equal chance of getting picked
and lines may be selected multiple times
lines are delimited by delim */
static void
rl_withreplace(FILE *in,FILE *out,int count,char delim,int print_linenumbers)
{
struct buffer *lines; /* array of lines */
struct buffer current; /* currently read line */
int line=0; /* the number of the current line */
int i; /* counter for loops */
/* initialize buffers */
lines=xxmalloc(struct buffer,count);
for (i=0;i<count;i++)
{
buffer_init(lines+i,AVGLINELEN*2);
}
buffer_init(¤t,AVGLINELEN*2);
/* read all the lines one by one */
while (buffer_readline(in,¤t,delim)!=NULL)
{
line++;
current.linenumber=line;
/* count times see if we want to include this line */
for (i=0;i<count;i++)
{
if (random_draw(1,line))
{
/* copy line into result buffer */
buffer_copy(lines+i,¤t);
}
}
}
/* check for read errors */
if (ferror(in))
{
fprintf(stderr,_("%s: read error: %s\n"),program_name,strerror(errno));
exit(1);
}
/* dump the result (if any lines were read) */
if (line>0)
{
for (i=0;i<count;i++)
{
/* print line number */
if (print_linenumbers)
fprintf(out,"%d: ",lines[i].linenumber);
/* output line */
if ( fwrite(lines[i].buf,sizeof(char),lines[i].len,out)!=lines[i].len ||
ferror(out) )
{
fprintf(stderr,_("%s: write error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
}
/* free the memory! */
buffer_free(¤t);
for (i=0;i<count;i++)
{
buffer_free(lines+i);
}
xfree(lines);
}
/* read the whole file and pick out count random lines and dump to out
all arguments are assumed to be reasonable values
(maybe a better functionname, my English is not that good )
any line can only be picked once
lines are delimited by delim */
static void
rl_withoutreplace(FILE *in,FILE *out,int count,char delim,int print_linenumbers)
{
struct buffer **result; /* array of pointers to selected lines */
struct buffer *t=NULL; /* temporary pointer for swapping lines */
struct buffer *current; /* currently read line */
int line=0; /* the number of the current line */
int i; /* counter for loops */
int j; /* for swapping */
/* initialize result */
result=xxmalloc(struct buffer *,count);
/* first read count lines */
while ( (line<count) && ((result[line]=buffer_readline(in,NULL,delim))!=NULL) )
{
result[line]->linenumber=line+1;
line++;
}
/* check for read errors */
if (ferror(in))
{
fprintf(stderr,_("%s: read error: %s\n"),program_name,strerror(errno));
exit(1);
}
/* randomize these lines */
for (i=0;i<line;i++)
{
j=random_below(line);
t=result[i];
result[i]=result[j];
result[j]=t;
}
t=NULL;
/* check if the buffer is filled */
if (line<count)
{
if (!quiet)
fprintf(stderr,_("%s: less than %d lines were read.\n"),program_name,count);
}
else
{
/* read the lines one by one */
current=NULL;
while ((current=buffer_readline(in,current,delim))!=NULL)
{
line++;
current->linenumber=line;
if (random_draw(count,line))
{
i=random_below(count);
/* swap current with result[i] */
t=result[i];
result[i]=current;
current=t;
}
}
/* check for read errors */
if (ferror(in))
{
fprintf(stderr,_("%s: read error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
/* dump the result (if any lines were read) */
for (i=0;(i<line)&&(i<count);i++)
{
/* print line number */
if (print_linenumbers)
fprintf(out,"%d: ",result[i]->linenumber);
/* output line */
if ( fwrite(result[i]->buf,sizeof(char),result[i]->len,out)!=result[i]->len ||
ferror(out) )
{
fprintf(stderr,_("%s: write error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
/* free the memory! */
if (t!=NULL) /* t accidentaly points to the last current */
{
buffer_free(t);
xfree(t);
}
for (i=0;(i<line)&&(i<count);i++)
{
if (result[i]!=NULL)
{
buffer_free(result[i]);
xfree(result[i]);
}
}
xfree(result);
}
/* read file and randomize and output all lines
this is done in a way that any line will only be returned once */
static void
rl_randomizefile(FILE *in,FILE *out,char delim,int print_linenumbers)
{
struct buffer buffer; /* for reading the file */
int *result; /* array of pointers to selected lines */
struct buffer *lines; /* an array of all read lines */
int alloc; /* allocated size of result */
int line; /* number of lines in result */
int i; /* multi purpose */
int j; /* multi purpose */
int t; /* for swapping */
/* read the file */
buffer_init(&buffer,BLOCKSIZE*2);
buffer_readfile(in,&buffer);
/* check for read errors */
if (ferror(in))
{
fprintf(stderr,_("%s: read error: %s\n"),program_name,strerror(errno));
exit(1);
}
/* initialize result, guess number of lines */
alloc=buffer.len/AVGLINELEN+5;
result=xxmalloc(int,alloc);
lines=xxmalloc(struct buffer,alloc);
line=0;
/* split in lines */
for (i=0;i<buffer.len;)
{
/* check if realloc is needed */
if (line>=alloc)
{
alloc=alloc*2; /* *4/3 */ /* only slightly grow */
result=xxrealloc(result,int,alloc);
lines=xxrealloc(lines,struct buffer,alloc);
}
/* find the end of the line */
for (j=i;(j<buffer.len)&&(buffer.buf[j]!=delim);j++);
if (buffer.buf[j]==delim) j++;
/* build the line */
lines[line].buf=buffer.buf+i;
lines[line].alloc=0;
lines[line].len=j-i;
lines[line].linenumber=line+1;
result[line]=line;
/* ready for the next line */
i=j; /* continue from end of line */
line++;
}
/* randomize lines */
for (i=0;i<line;i++)
{
j=random_below(line);
/* swap entries */
t=result[i];
result[i]=result[j];
result[j]=t;
}
/* dump the result */
for (i=0;i<line;i++)
{
j=result[i];
/* print line number */
if (print_linenumbers)
fprintf(out,"%d: ",lines[j].linenumber);
/* output line */
if ( fwrite(lines[j].buf,sizeof(char),lines[j].len,out)!=lines[j].len ||
ferror(out) )
{
fprintf(stderr,_("%s: write error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
/* free the memory! */
xfree(result);
xfree(lines);
buffer_free(&buffer);
}
/* the main program */
int
main(int argc,char **argv)
{
int c; /* option charaters */
FILE *fp; /* for reading command-line specified files */
char *outputf=NULL; /* name of file to send output to */
FILE *output; /* where to write random lines to */
int count=-1; /* the command-line parameter */
char *endptr; /* used for command-line parsing */
int uniq=1; /* wether to return same lines or not */
char delim='\n'; /* line delimiter */
int print_linenumbers=0; /* wether to output line numbers */
program_name=argv[0];
/* parse command-line options */
while ((c=getopt_long(argc,argv,OPTION_STRING,
long_options,(int *)NULL))!=-1)
{
/* find out which option was specified */
switch (c)
{
case 'V': /* -V, --version */
display_version(stdout);
exit(0);
case 'h': /* -h, --help */
display_usage(stdout);
exit(0);
case 'c': /* -c, --count=N */
count=strtol(optarg,&endptr,0);
if ( (optarg[0]=='\0') || (endptr[0]!='\0') ||
(count<1) )
{
if (!quiet)
{
fprintf(stderr,_("%s: invalid argument to %s option\n"),program_name,"count");
display_tryhelp(stderr);
}
exit(1);
}
break;
case 'r': /* -r, --reselect */
uniq=0;
break;
case 'o': /* -o, --output=FILE */
if (outputf!=NULL)
{
if (!quiet)
fprintf(stderr,_("%s: can only specify --output once\n"),program_name);
exit(1);
}
outputf=strdup(optarg);
break;
case 'd': /* -d, --delimiter=DELIM */
if ( (optarg[0]=='\0' || optarg[1]!='\0') )
{
if (!quiet)
{
fprintf(stderr,_("%s: invalid argument to %s option\n"),program_name,"delim");
display_tryhelp(stderr);
}
exit(1);
}
delim=optarg[0];
break;
case '0': /* -0, --null */
delim='\0';
break;
case 'n': /* -n, --line-number */
print_linenumbers=1; /* true */
break;
case 'q': /* -q, --quiet, --silent */
quiet=1; /* true */
opterr=0; /* disable error-reporting of getopt() */
break;
case ':': /* missing parameter of an option */
case '?': /* unknown option */
default: /* undefined */
if (!quiet)
display_tryhelp(stderr);
exit(1);
}
}
/* intialize the random-number generator */
randomize();
/* open the output if specified */
if ( (outputf!=NULL) && (strcmp(outputf,"-")!=0) )
{
if ((output=fopen(outputf,"w"))==NULL)
{
if (!quiet)
fprintf(stderr,_("%s: error opening %s: %s\n"),program_name,outputf,strerror(errno));
exit(1);
}
}
else
{
output=stdout;
}
/* rest of parameters are filenames */
if (optind>=argc)
{
if (count<=0)
rl_randomizefile(stdin,output,delim,print_linenumbers);
else if (uniq)
rl_withoutreplace(stdin,output,count,delim,print_linenumbers);
else
rl_withreplace(stdin,output,count,delim,print_linenumbers);
}
else
{
for (;optind<argc;optind++)
{
if (strncmp("-",argv[optind],2)==0)
{
if (count<=0)
rl_randomizefile(stdin,output,delim,print_linenumbers);
else if (uniq)
rl_withoutreplace(stdin,output,count,delim,print_linenumbers);
else
rl_withreplace(stdin,output,count,delim,print_linenumbers);
}
else
{
if ((fp=fopen(argv[optind],"r"))==NULL)
{
if (!quiet)
fprintf(stderr,_("%s: error opening %s: %s\n"),program_name,argv[optind],strerror(errno));
}
else
{
if (count<=0)
rl_randomizefile(fp,output,delim,print_linenumbers);
else if (uniq)
rl_withoutreplace(fp,output,count,delim,print_linenumbers);
else
rl_withreplace(fp,output,count,delim,print_linenumbers);
/* check for read errors */
if (fclose(fp))
{
fprintf(stderr,_("%s: read error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
}
}
}
/* close output when we're done */
if ( (outputf!=NULL) && (strcmp(outputf,"-")!=0) )
{
if (fclose(output))
{
fprintf(stderr,_("%s: write error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
else
{
if (fflush(output))
{
fprintf(stderr,_("%s: write error: %s\n"),program_name,strerror(errno));
exit(1);
}
}
exit(0);
}
--- NEW FILE: aclocal.m4 ---
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.9.6])])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 7
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 12
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.58])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
# test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" &&
test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
])
])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$1 | $1:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"$am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
#
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
# created by `make install' are always world readable, even if the
# installer happens to have an overly restrictive umask (e.g. 077).
# This was a mistake. There are at least two reasons why we must not
# use `-m 0755':
# - it causes special bits like SGID to be ignored,
# - it may be too restrictive (some setups expect 775 directories).
#
# Do not use -m 0755 and let people choose whatever they expect by
# setting umask.
#
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
# Some implementations (such as Solaris 8's) are not thread-safe: if a
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
# concurrently, both version can detect that a/ is missing, but only
# one can create it and the other will error out. Consequently we
# restrict ourselves to GNU make (using the --version option ensures
# this.)
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
# We used to keeping the `.' as first argument, in order to
# allow $(mkdir_p) to be used without argument. As in
# $(mkdir_p) $(somedir)
# where $(somedir) is conditionally defined. However this is wrong
# for two reasons:
# 1. if the package is installed by a user who cannot write `.'
# make install will fail,
# 2. the above comment should most certainly read
# $(mkdir_p) $(DESTDIR)$(somedir)
# so it does not work when $(somedir) is undefined and
# $(DESTDIR) is not.
# To support the latter case, we have to write
# test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
# so the `.' trick is pointless.
mkdir_p='mkdir -p --'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
for d in ./-p ./--version;
do
test -d $d && rmdir $d
done
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
if test -f "$ac_aux_dir/mkinstalldirs"; then
mkdir_p='$(mkinstalldirs)'
else
mkdir_p='$(install_sh) -d'
fi
fi
AC_SUBST([mkdir_p])])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
--- NEW FILE: NEWS ---
changes from 0.2.4 to 0.2.5
---------------------------
* implemented --line-number option to dump line numbers
* changed email address and homepage location, new homepage is at
http://ch.tudelft.nl/~arthur/rl/
* documentation improvements (mainly spelling)
changes from 0.2.3 to 0.2.4
---------------------------
* add checks for correct reading and writing of lines
changes from 0.2.2 to 0.2.3
---------------------------
* improved documentation
* update to newer autoconf and automake
* make it possible to choose random number source at configure time
* added extra tests to configure script
changes from 0.2.1 to 0.2.2
---------------------------
* Debian package fixes
changes from 0.2.0 to 0.2.1
---------------------------
* some small documentation improvements
* improvements to header includes
* removed maximum to --count command line option
* upgraded autoconf and automake files
* rpm spec file improvements
changes from 0.1.7 to 0.2.0
---------------------------
* add --reselect option to replace --uniq option and change
default behaviour to select lines only once instead of
multiple times (incompatible change)
* added --output, --delimiter and --null command line options
* added examples to manual page
* organized code better
* added --enable-warnings in configure and enable by default in
Debian package building
changes from 0.1.6 to 0.1.7
---------------------------
* added simple docs to Debian package
* fixed bug in Debian package rules
* initial package for Debian/unstable
changes from 0.1.5 to 0.1.6
---------------------------
* made Debian package
* tried to abide by GNU coding standards
* fixed typo in manual page
changes from 0.1.4 to 0.1.5
---------------------------
* improved README, manual and command line --help
* added buffer.c with functions for manipulating struct buffer
(used to be struct line)
* improved memory management with about halving number of malloc() calls
* fixed small memory leak (not a real problem for command-line tools)
* cleared up some code and ended up with smaller code
* actually created this Changelog (still looking for a good way to
create one from the cvs logs
changes from 0.1.3 to 0.1.4
---------------------------
* added more info to README
* added debugging code to alloc.c
* added --enable-debug to configure
* fix so that -Wall is only used on gcc
* renamed randomize.c to random.c and moved all random related
functions there
* added xxmalloc() and xxrealloc() macros for readable malloc()s
* improved memory management
* added function for randomizing all lines in a file (changes
default behaviour of rl)
* more code cleanup
* actually tested on all mentioned platforms before release
* fixed nasty bug on systems with a low RAND_MAX
changes from 0.1.2 to 0.1.3
---------------------------
* added configure generated config.h
* created rl.h with definitions of all functions in all files
* created alloc.c with malloc() realloc() and free() wrappers
* lines do not have a maximum length anymore
* code cleanup
* changed randomize() to not try to read /dev/random but
use pid + time in milliseconds
changes from 0.1.1 to 0.1.2
---------------------------
* easier emulation of getopt_long() (now in getopt_long.c)
* moved randomzize() function to randomize.c
changes from 0.1.0 to 0.1.1
---------------------------
* added emulation for getopt_long() on platforms that don't have it
* better working --quiet
--- NEW FILE: TODO ---
* add rl.spec by Chris Knowles
* maybe add optimization using seek() in file
* maybe add smarter memory management allocating the buffers only once
* work out if the arithmetic holds for large values
* automatically (configure) select the best way to seed the random number
generator
* add error checking of streams using ferror()
* maybe implement linked list construction for arrays that might grow fast and
need a lot of realloc()'s
* implement sanity checks for testing program
* implement internationalisation with GNU gettext
* try using temporary files with pointer into files
* add options:
--dbm use Berkeley DB for operation instead of using memory. This is useful
when FILE is too large to fit into memory. Little cpu/memory usage
but much slower
-s, --skip-blank skip blank lines
* move sources to src directory
* experiment with different random number generators
* Find out for which file sizes the random numbers produce accurate
results. This really needs some work since some systems (HP-UX and
Solaris) have a very low RAND_MAX.
* add a test suite
* split on words (split on regexp)
--- NEW FILE: Makefile.am ---
# Makefile.am - use automake to generate Makefile.in
# Copyright (C) 2001, 2002, 2003, 2005, 2006 Arthur de Jong
#
# 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
bin_PROGRAMS=rl
rl_SOURCES=rl.c rl.h \
alloc.c alloc.h \
buffer.c buffer.h \
random.c random.h \
aclocal.m4
rl_LDADD=@LIBOBJS@
EXTRA_DIST=rl.lsm.in rl.spec.in getopt_long.c getopt_long.h \
debian/control debian/changelog debian/rules debian/docs \
debian/copyright debian/compat
# install the man pages
man_MANS=rl.1
# targets for debian package
deb: distdir
cd $(distdir) && \
fakeroot debian/rules binary
rm -rf $(distdir)
signeddeb: distdir
cd $(distdir) && \
debuild
rm -rf $(distdir)
changelog:
svn2cl -i
--- NEW FILE: config.h.in ---
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the `malloc' function. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `realloc' function. */
#undef HAVE_REALLOC
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* use /dev/urandom rng */
#undef USE_DEV_RNG
/* use standard rand() rng */
#undef USE_RAND_RNG
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
--- NEW FILE: COPYING ---
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
--- NEW FILE: buffer.c ---
/*
buffer.c - functions for handling buffers
Copyright (C) 2001, 2002, 2003, 2005 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "rl.h"
#include "buffer.h"
#include "alloc.h"
/* intialize struct buffer and allocate memory for it */
void
buffer_init(struct buffer *line,int alloc)
{
line->alloc=alloc;
line->buf=xxmalloc(char,line->alloc);
line->len=0;
}
/* change the size of the line */
void
buffer_grow(struct buffer *line,int alloc)
{
line->alloc=alloc;
line->buf=xxrealloc(line->buf,char,line->alloc);
}
/* free allocated memory */
void
buffer_free(struct buffer *line)
{
if (line->buf==NULL)
return; /* not allocated so not freed */
xfree(line->buf);
line->buf=NULL;
line->alloc=0;
}
/* make a copy of the src buffer into dst buffer
optionaly growing or allocating dst
the orriginal content of dst is lost and a pointer
to the result (dst or a new buffer if dst==NULL)
is returned */
struct buffer *
buffer_copy(struct buffer *dst,struct buffer *src)
{
if (dst==NULL)
{
dst=xxmalloc(struct buffer,1);
buffer_init(dst,src->len+AVGLINELEN/2);
}
else if (dst->alloc<src->len)
{
buffer_grow(dst,src->len+AVGLINELEN/2);
}
memcpy(dst->buf,src->buf,src->len);
dst->len=src->len;
dst->linenumber=src->linenumber;
return dst;
}
/* read a single line from the file
this function returns a buffer structure containing
the read line with newline or NULL on EOF
lines are delimited by the delim char
if line is not NULL a new buffer is initialized
and returned, otherwise the lines is read in the line buffer */
struct buffer *
buffer_readline(FILE *in,struct buffer *line,char delim)
{
int c; /* the char read */
struct buffer *orr;
/* initialize new line if NULL */
orr=line;
if (line==NULL)
{
/* make a new line */
line=xxmalloc(struct buffer,1);
buffer_init(line,AVGLINELEN*2);
}
line->len=0;
while ( ((c=fgetc(in))!=EOF) )
{
/* check allocated memory */
if (line->alloc<(line->len+1))
buffer_grow(line,line->alloc*2);
/* store */
line->buf[line->len++]=c;
/* check for delim */
if (c==delim)
break; /* exit while */
}
/* check if anything was read */
if (line->len==0)
{
/* free the line if it was created here */
if (orr==NULL)
{
buffer_free(line);
xfree(line);
}
return NULL;
}
/* the line was read */
return line;
}
/* read a complete file into a buffer */
struct buffer *
buffer_readfile(FILE *in,struct buffer *buf)
{
int i;
/* initialize buffer */
if (buf==NULL)
{
buf=xxmalloc(struct buffer,1);
buffer_init(buf,BLOCKSIZE*2);
}
/* read the file */
buf->len=0;
do
{
/* grow buffer if needed */
if (buf->alloc<=buf->len+BLOCKSIZE)
buffer_grow(buf,buf->alloc*2);
i=fread(buf->buf+buf->len,sizeof(char),BLOCKSIZE,in);
buf->len+=i;
}
while (i==BLOCKSIZE);
return buf;
}
--- NEW FILE: INSTALL ---
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. 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.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, 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
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
--- NEW FILE: ChangeLog ---
2006-09-30 07:52 arthur
* [r185] .: also ignore .build files
2006-09-30 07:50 arthur
* [r184] Makefile.am: switch to using debuild
2006-09-30 07:49 arthur
* [r183] debian/control: upgrade to standards-version 3.7.2 (no
changes needed)
2006-09-29 21:40 arthur
* [r182] README, TODO, rl.1.in: some documentation (wrapping and
other) improvements
2006-09-29 18:41 arthur
* [r181] INSTALL, autogen.sh, config.guess, config.sub,
configure.ac, depcomp, install-sh, missing, mkinstalldirs:
upgrade to autoconf 2.60a and automake 1.9.6 (makeing
configure.ac simpler and more readable)
2006-09-29 10:26 arthur
* [r180] debian/control: include link to homepage in package
description
2006-09-29 09:49 arthur
* [r179] debian/copyright: add a notice as to where rl can be
downloaded
2006-09-29 09:48 arthur
* [r178] README, configure.ac, debian/copyright, rl.1.in, rl.c:
update copyright year (as a preperation for a release that is
scheduled somewhere this year)
2006-09-29 09:46 arthur
* [r177] Makefile.am: include revision numbers in ChangeLog
2006-09-29 09:20 arthur
* [r176] NEWS, README, TODO, debian/changelog: fix some spelling
problems
2006-09-29 09:18 arthur
* [r175] debian: ignore backup files
2006-09-29 09:13 arthur
* [r174] .: ignore backup files
2006-09-29 09:03 arthur
* [r173] rl.1.in: fix some typos
2005-07-29 09:48 arthur
* [r172] AUTHORS, README, configure.ac, rl.spec.in: change email
address from arthur at tiefighter.et.tudelft.nl to
arthur at ch.tudelft.nl (including urls etc)
2005-07-29 09:46 arthur
* [r171] rl.1.in: remove email address from manual page
2005-06-25 21:42 arthur
* [r170] COPYING, Makefile.am, README, alloc.c, alloc.h, buffer.c,
buffer.h, configure.ac, getopt_long.c, getopt_long.h, random.c,
random.h, rl.1.in, rl.c, rl.h: update COPYING from the FSF
(postal address change) and update copyright headers along with
it (also correcting indenting)
2005-05-17 13:51 arthur
* [r169] buffer.c, buffer.h, rl.1.in, rl.c: implement --line-number
option to dump line numbers (plus some consitency code fixes)
2005-04-23 15:51 arthur
* [r166] ChangeLog: check in latest changes for release
2005-04-23 15:51 arthur
* [r165] NEWS, configure.ac, debian/changelog: bump version number
to 0.2.4
2005-04-23 15:48 arthur
* [r164] rl.1.in: add note about specifying multiple input files to
bugs section
2005-04-22 20:13 arthur
* [r163] Makefile.am: use svn2cl to generate ChangeLog
2005-04-22 19:57 arthur
* [r162] rl.c: check for errors during and after reading input
2005-04-22 19:16 arthur
* [r161] rl.c: check results of write operations, thanks to Zygo
Blaxell <zblaxell at ashura.furryterror.org> for reporting this
problem
2005-04-02 11:46 arthur
* [r159] ChangeLog: check in latest changes for ChangeLog
2005-04-02 11:45 arthur
* [r158] ChangeLog, NEWS, TODO, configure.ac, debian/changelog:
bump version number for release 0.2.3
2005-04-02 11:41 arthur
* [r157] Makefile.am: do not ship rl.1 since it is generated
2005-04-01 21:44 arthur
* [r156] rl.c: upgrade copyrights notice
2005-04-01 21:10 arthur
* [r155] README: remove cvs section since we're not using it any
more
2005-04-01 21:03 arthur
* [r154] README, debian/copyright, rl.1.in: upgrade copyrights
notices
2005-04-01 20:20 arthur
* [r153] ChangeLog: regenerate ChangeLog using svn2cl
2005-04-01 20:15 arthur
* [r152] INSTALL, autogen.sh, config.guess, config.sub,
configure.ac, depcomp, install-sh, missing, mkinstalldirs:
upgrade to automake 1.9 and most recent autoconf
2005-04-01 20:10 arthur
* [r151] debian/control: bump dephelper dependency to 4
2005-04-01 19:01 arthur
* [r150] Makefile.am: clean up makefile
2005-04-01 18:55 arthur
* [r149] debian/control: start short description with lower case
letter (thanks lintian)
2004-11-28 00:16 arthur
* [r148] configure.ac, random.c: make it possible to choose random
number generator at configure time
2004-11-27 19:56 arthur
* [r147] configure.ac: check sizeof(int) instead of sizeof(int *)
2004-11-26 16:47 arthur
* [r146] ., .cvsignore, debian, debian/.cvsignore: remove cvsignore
files
2004-11-21 16:26 arthur
* [r145] rl.1.in: add a BUGS section documenting some of the
current shortcomings
2004-11-21 16:24 arthur
* [r144] configure.ac: also print some extra information in
configure run (wrote my own test_
2004-11-21 15:06 arthur
* [r143] README: remove section that is now in manual page and some
small improvements
2004-11-21 15:05 arthur
* [r142] config.guess, config.sub, depcomp, install-sh,
mkinstalldirs: upgrade file from automake/autoconf
2004-11-21 15:00 arthur
* [r141] ChangeLog: cvs generated Changelog (changes up to r139)
2004-03-15 19:32 arthur
* [r139] autogen.sh, depcomp, install-sh, missing, mkinstalldirs:
upgrade to automake 1.8
2004-01-31 20:02 arthur
* [r138] config.guess, config.sub, configure.ac: upgrade to using
autoconf 2.59
2004-01-31 19:50 arthur
* [r137] rl.c: fix typo and update copyrights notice
2004-01-31 19:47 arthur
* [r136] README: rl is not really alpha software any more but keep
warning on command line options changes, update copyrights and
find usage of debian
2003-10-13 18:46 arthur
* [r134] ChangeLog, NEWS, configure.ac, debian/changelog: release
0.2.2
2003-10-13 18:38 arthur
* [r133] debian, debian/.cvsignore: clean out .cvsignore file
2003-10-13 18:36 arthur
* [r132] ChangeLog: regenerated ChangeLog and compacted some parts
2003-10-13 18:24 arthur
* [r131] debian/docs: do not ship ChangeLog along with binary
2003-10-13 18:22 arthur
* [r130] Makefile.am: also ship debian/compat in source tarballs so
comaptibility is actually set and rl is included as binary
2003-10-12 19:59 arthur
* [r128] ChangeLog, NEWS, TODO, configure.ac, debian/changelog:
release 0.2.1
2003-10-12 16:22 arthur
* [r127] ., .cvsignore: generate rl manual page from rl.1.in to
easily set version and month
2003-10-12 16:13 arthur
* [r126] rl.spec.in: redid cpec file for rpm building also based on
suggestions by Chris Knowles <knowlesc at scaredsheep.net>
2003-10-12 16:11 arthur
* [r125] configure.ac, rl.1, rl.1.in: generate rl manual page from
rl.1.in to easily set version and month
2003-10-12 16:06 arthur
* [r124] debian/control: upgrade to standards-version 3.6.1 (no
changes needed)
2003-10-12 16:06 arthur
* [r123] debian/control: modify package description slightly
2003-10-12 16:05 arthur
* [r122] debian/rules: pass --build and --host options to configure
2003-10-12 16:04 arthur
* [r121] debian/compat, debian/rules: save debhelper compatibily
level in debian/compat
2003-10-12 15:50 arthur
* [r120] Makefile.am, README, alloc.c, buffer.c, debian/copyright,
rl.1, rl.c, rl.h: updated copyrights
2003-10-12 15:44 arthur
* [r119] autogen.sh, config.guess, config.sub, configure.ac,
depcomp, install-sh, missing, mkinstalldirs: upgrade to autoconf
2.57 and automake 1.7
2003-09-21 20:03 arthur
* [r118] Makefile.am, debian/control: change maintainer address to
adejong at debian.org
2003-05-18 18:11 arthur
* [r117] configure.ac: check for all used headers
2003-05-18 18:10 arthur
* [r116] buffer.c: also include string.h for memcpy()
2003-05-18 18:07 arthur
* [r115] README, TODO: moved TODO items from README to TODO
2003-05-18 18:02 arthur
* [r114] README: updated cvs section
2003-05-18 17:27 arthur
* [r113] rl.c: removed maximum to --count command line option
2002-10-27 17:00 arthur
* [r111] ChangeLog, NEWS, TODO, configure.ac, debian/changelog:
release 0.2.0
2002-10-27 16:47 arthur
* [r110] getopt_long.h: remove unneeded spaces and update copyright
2002-10-27 16:38 arthur
* [r109] rl.1, rl.c: add --reselect option to replace --uniq option
and change default behaviour to select lines only once instead of
multiple times
2002-10-27 16:21 arthur
* [r108] Makefile.am, random.c, random.h, rl.c, rl.h: move
definitions of random related funtions from rl.h to random.h
2002-10-27 16:16 arthur
* [r107] debian/rules: enable extra compiler warnings by default
2002-10-27 16:14 arthur
* [r106] rl.c, rl.h: updated function declarations
2002-10-27 16:04 arthur
* [r105] INSTALL, config.guess, config.sub, install-sh: newer
versions from autoconf and automake
2002-10-27 15:54 arthur
* [r104] rl.1: add example section to manual
2002-10-27 15:54 arthur
* [r103] rl.1, rl.c: add --output, --delimiter and --null command
line options
2002-10-27 15:53 arthur
* [r102] autogen.sh: add warnings when calling autoheader and
autoconf
2002-10-19 23:15 arthur
* [r101] Makefile.am, buffer.c, buffer.h, rl.c, rl.h: add delimiter
paramater to buffer_readline() function and move definitions of
buffer functions to buffer.h
2002-10-19 23:05 arthur
* [r100] Makefile.am, alloc.c, alloc.h, buffer.c, getopt_long.c,
random.c, rl.c, rl.h: add xstrdup() function, move alloc function
definitions to alloc.h, fix copyright notices and include
"config.h" instead of <config.h>
2002-10-13 17:52 arthur
* [r99] debian/control: fixed typo
2002-10-06 19:12 arthur
* [r97] debian/changelog: release 0.1.7
2002-10-06 19:05 arthur
* [r96] ChangeLog, NEWS, TODO, configure.ac, debian/changelog:
release 0.1.7
2002-10-06 19:03 arthur
* [r95] config.guess, config.sub: newer versions
2002-10-06 18:50 arthur
* [r94] debian/docs: added NEWS file to docs
2002-10-06 18:49 arthur
* [r93] debian/control: made description a bit more verbose
2002-10-06 14:39 arthur
* [r92] ., .cvsignore: ignore new package name
2002-10-06 14:32 arthur
* [r91] debian/changelog, debian/control, debian/rules: renamed
debian package to randomize-lines
2002-09-26 11:41 arthur
* [r90] README, rl.c: updated copyright statements
2002-09-26 11:36 arthur
* [r89] NEWS: changed layout
2002-09-26 11:35 arthur
* [r88] debian/rules: cleaned out old stuff and installing
debian/changelog
2002-09-26 11:34 arthur
* [r87] Makefile.am, debian/copyright: added debian/copyright file
describing copyright info
2002-09-15 16:43 arthur
* [r86] ., .cvsignore, INSTALL, autogen.sh, config.guess,
config.sub, configure.ac, configure.in, missing: latest versions
of autoconf, automake and related files
2002-09-15 16:22 arthur
* [r85] rl.c: --help string is now better OPTIONS->OPTION
2002-09-15 16:19 arthur
* [r84] Makefile.am: make deb now doesn't use dpkg-buildpackage any
more
2002-09-15 16:18 arthur
* [r83] ChangeLog, Makefile.am, NEWS: ChangeLog file renamed to
NEWS and Changelog is now generated by make changelog
2001-10-05 11:30 arthur
* [r82] ChangeLog, Makefile.am, debian/docs: * added simple docs to
debian package
2001-10-05 11:28 arthur
* [r81] ChangeLog, debian/rules: * fixed bug installing debian
package wrong
2001-10-01 20:33 arthur
* [r79] ChangeLog, TODO, configure.in, debian/changelog: * general
stuff for release 0.1.6
2001-10-01 20:26 arthur
* [r78] rl.1: * fixed typo
2001-10-01 17:36 arthur
* [r77] ., .cvsignore, Makefile.am, debian, debian/.cvsignore,
debian/changelog, debian/control, debian/rules: added debian
package stuff
2001-07-18 19:39 arthur
* [r76] alloc.c, buffer.c, getopt_long.c, getopt_long.h, random.c,
rl.c, rl.h: * tried to abide by GNU coding standards
2001-03-25 23:20 arthur
* [r74] ChangeLog, configure.in: * changes for release 0.1.5
2001-03-25 23:19 arthur
* [r73] rl.1: * improved documentation
2001-03-25 20:30 arthur
* [r72] TODO: * added even more to TODO
2001-03-25 20:30 arthur
* [r71] README: * improved README
2001-03-25 20:30 arthur
* [r70] rl.c: * improved --help messages
2001-03-23 13:12 arthur
* [r69] ChangeLog: * first real Changelog
2001-03-23 13:11 arthur
* [r68] TODO: *** empty log message ***
2001-03-22 23:59 arthur
* [r67] buffer.c, rl.c, rl.h: * added buffer_readfile() to buffer.c
* moved BLOCKSIZE to rl.h
* used buffer_readfile() in randomizefile()
2001-03-22 23:44 arthur
* [r66] rl.c: * moved struct buffer (was struct line) functions
from rl.c to buffer.c
* renamed struct line to struct buffer and renamed some functions
2001-03-22 23:44 arthur
* [r65] rl.h: * moved struct buffer (was struct line) functions
from rl.c to buffer.c
2001-03-22 23:43 arthur
* [r64] Makefile.am: * added buffer.c
2001-03-22 23:42 arthur
* [r63] buffer.c: * initial commit
* moved struct buffer (was struct line) functions from rl.c to
buffer.c
2001-03-22 20:25 arthur
* [r62] rl.c: * renamed result to lines in rl_withreplace() for
consistency
2001-03-22 20:20 arthur
* [r61] rl.c: * fixed a small memory leak and halved the number of
malloc() calls in rl_withreplace()
* smaller and clearer code (saved about 15 lines) in
rl_withreplace()
2001-03-21 22:11 arthur
* [r59] configure.in: * release -> 0.1.4
2001-03-21 22:11 arthur
* [r58] rl.c: * code cleanup
2001-03-21 22:06 arthur
* [r57] TODO: *** empty log message ***
2001-03-21 21:03 arthur
* [r56] configure.in: * added --enable-debug flag to configure
2001-03-21 21:02 arthur
* [r55] alloc.c: * renamed DEBUG_ALLOC to just DEBUG
2001-03-21 20:58 arthur
* [r54] rl.c: * used random_below() and random_draw() to do random
stuff
2001-03-21 20:57 arthur
* [r53] random.c, rl.h: * added random_below() to return a number
in a range
* added random_draw() to return true or false with a ceirtain
chance
2001-03-21 20:35 arthur
* [r52] autogen.sh: * initial commit
2001-03-21 20:25 arthur
* [r51] Makefile.am, configure.in: * moved -Wall flag for gcc from
Makefile.am to configure.in so it is only used with gcc
2001-03-21 20:22 arthur
* [r50] Makefile.am, random.c, randomize.c, rl.h: * renamed
randomize.c to random.c
2001-03-20 21:30 arthur
* [r49] alloc.c: * added optional debugging code
2001-03-19 21:00 arthur
* [r48] rl.c: * added rl_randomizefile() function to randomize the
lines of a complete file
* made randomizing complete input default if no --count is given
2001-03-19 20:31 arthur
* [r47] rl.c: * added some comments
* changed to use xxmalloc() and xxrealloc() for cleaner code
* added init_line(), grow_line() and free_line() functions for
better memory management
2001-03-19 19:28 arthur
* [r46] TODO: *** empty log message ***
2001-03-19 18:32 arthur
* [r45] rl.h: * added xxmalloc() and xxrealloc() macros with
storage type parameter
2001-03-17 22:45 arthur
* [r44] AUTHORS, ChangeLog, README, rl.1, rl.lsm.in, rl.spec.in: *
changed email address to arthur at tiefighter.et.tudelft.nl
* updated document to include a real description
2001-03-15 01:07 arthur
* [r42] rl.c: * fixed another initialisation bug
(it sure has been a long time since useing malloc()
I've been spoiled by Java)
2001-03-15 00:56 arthur
* [r41] rl.c: * use xfree() instead of free()
* added describing comment to copyline()
* fixed several memory problems
2001-03-15 00:53 arthur
* [r40] rl.h: * added xfree() to alloc.c
2001-03-15 00:52 arthur
* [r39] alloc.c: * added xfree() mainly for easy debugging
2001-03-13 22:52 arthur
* [r38] configure.in: * version ->0.1.3
2001-03-13 22:46 arthur
* [r37] TODO: *** empty log message ***
2001-03-13 22:35 arthur
* [r36] randomize.c: * disabled reading from /dev/?random since
srand() and rand() are bad anyway
(currently only pid+time in millis is used)
2001-03-13 22:30 arthur
* [r35] getopt_long.c: * fixed missing include string.h
* fixed unused var
2001-03-13 17:56 arthur
* [r34] Makefile.am, alloc.c, rl.h: * moved x*alloc() functions to
alloc.c (definitions to rl.h)
* all definitions of functions are now in rl.h
2001-03-13 17:55 arthur
* [r33] rl.c: * moved x*alloc() functions to alloc.c (definitions
to rl.h)
* all definitions of functions are now in rl.h
* quiet is no longer static so it can be shared
2001-03-13 17:52 arthur
* [r32] randomize.c, randomize.h: * moved exported definitions from
randomize.c to rl.h (was randomize.h)
2001-03-12 00:04 arthur
* [r31] randomize.h: * fixed wrong define _RANDOMIZE_H
2001-03-12 00:03 arthur
* [r30] rl.c: * changed to have arbitraty length lines
* -u now randomizes order of lines (not only which lines apear)
2001-03-12 00:00 arthur
* [r29] rl.c: * fixed includes and excess parameter in --help
2001-03-11 23:52 arthur
* [r28] Makefile.am: * added -Wall to CFLAGS (is this the right
place?)
2001-03-07 22:29 arthur
* [r27] ., .cvsignore: * stamp-h* -> stamp-*
2001-03-07 22:24 arthur
* [r26] configure.in: * added config.h
* removed unuser stuff
2001-03-07 22:24 arthur
* [r25] ., .cvsignore, getopt_long.c, randomize.c, rl.c: * added
config.h
2001-03-07 21:24 arthur
* [r24] getopt_long.c: * forgot to compare strncmp() to 0
2001-03-06 23:52 arthur
* [r22] Makefile.am, TODO, configure.in, getopt_long.c,
getopt_long.h, randomize.c, randomize.h, rl.c: * renamed
initrandom() to randomize() and moved to randomize.c
* implemented getopt_long() in getopt_long.c and done some fancy
configure work to auto-link it when needed
* new release (0.1.2)
2001-03-05 23:44 arthur
* [r20] TODO, configure.in: * added emulation (poor) of
getopt_long()
2001-03-05 23:44 arthur
* [r19] rl.c: * added emulation (poor) of getopt_long()
* --quiet now works on getopt() too
2001-03-05 22:51 arthur
* [r17] TODO: real version
2001-03-05 22:50 arthur
* [r16] configure.in: GNU version of getopt is required
2001-03-04 15:57 arthur
* [r15] rl.c: * added -q, --quiet, --silent option to suppres
errors and warnings
2001-03-04 15:56 arthur
* [r14] rl.c: * added -u, --uniq option to use rl_withoutreplace()
2001-03-04 15:52 arthur
* [r13] rl.c: * several layout changes
* added rl_withoutreplace()
2001-03-04 15:45 arthur
* [r12] rl.c: * added free()-ing of malloc()-ed memory (oops)
2001-03-04 14:05 arthur
* [r11] rl.c: * added getline() method to read lines (simplifies
code)
2001-03-04 13:46 arthur
* [r10] rl.c: * --count now works
* renamed randomline() to rl_withreplace()
2001-03-04 12:49 arthur
* [r9] rl.1: first REAL attempt at a manual page
2001-03-04 12:49 arthur
* [r8] rl.c: removed --verbose
2001-03-04 12:24 arthur
* [r7] rl.c: * small changes to code
* added extra sanity checks on --count
2001-03-04 12:17 arthur
* [r6] AUTHORS, ChangeLog, README, rl.1, rl.c, rl.lsm.in,
rl.spec.in: changed to read full name
2001-03-04 12:11 arthur
* [r5] ., .cvsignore: added tgz file
2001-03-03 01:58 arthur
* [r4] rl.c: * cleaned up include and define code
* removed EXIT_FAILURE macro
* removed references to x* functions
* moved TODO to TODO file
2001-03-03 01:56 arthur
* [r3] TODO: added TODO
2001-03-03 01:44 arthur
* [r2] ., .cvsignore, AUTHORS, COPYING, ChangeLog, INSTALL,
Makefile.am, NEWS, README, config.guess, config.sub,
configure.in, install-sh, missing, mkinstalldirs, rl.1, rl.c,
rl.lsm.in, rl.spec.in: initial commit
2001-03-03 01:44
* [r1] branches, ., tags: New repository initialized by cvs2svn.
--- NEW FILE: config.guess ---
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
timestamp='2006-07-02'
# This file 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 of the License, 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
[...1461 lines suppressed...]
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = ${UNAME_MACHINE}
UNAME_RELEASE = ${UNAME_RELEASE}
UNAME_SYSTEM = ${UNAME_SYSTEM}
UNAME_VERSION = ${UNAME_VERSION}
EOF
exit 1
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
--- NEW FILE: config.sub ---
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
timestamp='2006-07-02'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file 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 of the License, 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
[...1569 lines suppressed...]
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
--- NEW FILE: random.c ---
/*
random.c - implementation of all random number related functions
Copyright (C) 2001, 2002, 2004 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <limits.h>
#include "rl.h"
#include "random.h"
#if defined(USE_RAND_RNG)
/* initialize the random number generator with a sensible value
this calls srand() so rand() can be used */
void
randomize()
{
struct timeval tv;
gettimeofday(&tv,NULL);
srand(((unsigned int)(tv.tv_usec))^((unsigned int)getpid()));
}
/* returns a random number x where 0 <= x < max */
int
random_below(int max)
{
int i;
int j;
i=RAND_MAX/max;
/* there realy should be a better way for this */
/* TODO: fix with something smart so that this even works for large values
(on systems with a low RAND_MAX maybe two calls
to rand() could be used) */
/* TODO: add range checking 0<max<RAND_MAX */
do
{
j=rand()/i;
}
while (j>=max);
return j;
}
#elif defined(USE_DEV_RNG)
#define RANDOM_DEVICE "/dev/urandom"
/* the file pointer that is used to read from the random device */
static FILE *random_fp;
/* open random device for reading */
void
randomize()
{
random_fp=fopen(RANDOM_DEVICE,"rb");
}
/* returns a random number x where 0 <= x < max */
int
random_below(int max)
{
int i;
int j;
int r;
i=INT_MAX/max;
/* TODO: check same problems as above */
do
{
if (fread(&r,sizeof(int),1,random_fp)!=1)
{
fprintf(stderr,_("Error reading from %s\n"),RANDOM_DEVICE);
exit(1);
}
j=(r&INT_MAX)/i;
}
while (j>=max);
return j;
}
#else
#error invalid random number generator selected
#endif
/* thow the dice and return true (1)
with a chance of x/y (false=0) */
int
random_draw(int x,int y)
{
return random_below(y)<x;
}
--- NEW FILE: rl.1.in ---
.\" Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Arthur de Jong
.\"
.\" 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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
.TH "rl" "1" "@RELEASE_MONTH@" "Version @VERSION@" "User Commands"
.nh
.SH NAME
rl \- Randomize Lines.
.SH SYNOPSIS
.B rl
.RI [ OPTION ]...
.RI [ FILE ]...
.SH DESCRIPTION
\fBrl\fP reads lines from a input file or stdin, randomizes the lines and outputs a specified number of lines.
It does this with only a single pass over the input while trying to use as little memory as possible.
.TP
.B \-c, \-\-count=N
Select the number of lines to be returned in the output.
If this argument is omitted all the lines in the file will be returned in random order.
If the input contains less lines than specified and the \-\-reselect option below is not specified a warning is printed and all lines are returned in random order.
.TP
.B \-r, \-\-reselect
When using this option a single line may be selected multiple times.
The default behaviour is that any input line will only be selected once.
This option makes it possible to specify a \-\-count option with more lines than the file actually holds.
.TP
.B \-o, \-\-output=FILE
Send randomized lines to FILE instead of stdout.
.TP
.B \-d, \-\-delimiter=DELIM
Use specified character as a "line" delimiter instead of the newline character.
.TP
.B \-0, \-\-null
Input lines are terminated by a null character.
This option is useful to process the output of the GNU find \-print0 option.
.TP
.B \-n, \-\-line-number
Output lines are numbered with the line number from the input file.
.TP
.B \-q, \-\-quiet, \-\-silent
Be quiet about any errors or warnings.
.TP
.B \-h, \-\-help
Show short summary of options.
.TP
.B \-v, \-\-version
Show version of program.
.SH "EXAMPLES"
Some simple demonstrations of how rl can help you do everyday tasks.
Warning: some of these examples may affect the operation of your system.
Play a random sound after 4 minutes (perfect for toast):
.ft B
sleep 240 ; play `find /sounds \-name '*.au' \-print | rl \-\-count=1`
.ft R
Re-nice all the processes of a random logged\-in user:
.ft B
renice +5 \-u `who | cut '\-d ' \-f 1 | sort \-u | rl \-\-count=1`
.ft R
Kill a random process on your computer.
.ft B
kill \-9 `ps \-A | awk '{print $1}' | rl \-\-count=1`
.ft R
.br
Do this as root and see how long your system keeps working.
Increase the \-\-count for extra effect.
(you may need to change the ps and awk parameters depending on your system)
Find all movies and play them in random order.
.ft B
find . \-name '*.avi' \-print0 | rl \-0 | xargs \-n 1 \-0 mplayer
.ft R
.br
Because \-0 is used filenames with spaces (even newlines and other unusual characters) in them work.
.SH BUGS
The program currently does not have very smart memory management.
If you feed it huge files and expect it to fully randomize all lines it will completely read the file in memory. If you specify the \-\-count option it will only use the memory required for storing the specified number of lines.
Improvements on this area are on the TODO list.
The program uses the rand() system random function.
This function returns a number between 0 and RAND_MAX, which may not be very large on some systems.
This will result in non-random results for files containing more lines than RAND_MAX.
Note that if you specify multiple input files they are randomized per file.
This is a different result from when you cat all the files and pipe the result into rl.
.SH COPYRIGHT
Copyright \(co 2001, 2002, 2003, 2004, 2005, 2006 Arthur de Jong.
.br
This is free software; see the license for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--- NEW FILE: getopt_long.c ---
/*
getopt_long.c - implementation of getopt_long() for systems that lack it
Copyright (C) 2002 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "getopt_long.h"
/* this is a (poor) getopt_long() replacement for systems that don't have it
(this is generaly a GNU extention)
this implementation is by no meens flawless, especialy the optional arguments
to options and options following filenames is not quite right, allso
minimal error checking
*/
int
getopt_long(int argc,char * const argv[],
const char *optstring,
const struct option *longopts,int *longindex)
{
int i; /* for looping through options */
int l; /* for length */
/* first check if there realy is a -- option */
if ((optind>0)&&(optind<argc)&&(strncmp(argv[optind],"--",2)==0)&&(argv[optind][2]!='\0'))
{
/* check the longopts list for a valid option */
for (i=0;longopts[i].name!=NULL;i++)
{
/* save the length for later */
l=strlen(longopts[i].name);
if (strncmp(argv[optind]+2,longopts[i].name,l)==0)
{
/* we have a match */
if ((longopts[i].has_arg==no_argument)&&(argv[optind][2+l]=='\0'))
{
optind++;
return longopts[i].val;
}
else if ((longopts[i].has_arg==required_argument)&&(argv[optind][2+l]=='='))
{
optarg=argv[optind]+3+l;
optind++;
return longopts[i].val;
}
else if ((longopts[i].has_arg==required_argument)&&(argv[optind][2+l]=='\0'))
{
optarg=argv[optind+1];
optind+=2;
return longopts[i].val;
}
else if ((longopts[i].has_arg==optional_argument)&&(argv[optind][2+l]=='='))
{
optarg=argv[optind]+3+l;
optind++;
return longopts[i].val;
}
else if ((longopts[i].has_arg==optional_argument)&&(argv[optind][2+l]=='\0'))
{
optind++;
return longopts[i].val;
}
}
}
}
/* if all else fails use plain getopt() */
return getopt(argc,argv,optstring);
}
--- NEW FILE: alloc.c ---
/*
alloc.c - functions for clean memory management
Copyright (C) 2001, 2002 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "rl.h"
#include "alloc.h"
/* allocate memory with error-checking */
void *
xmalloc(size_t size)
{
void *res;
res=malloc(size);
if (res==NULL)
{
if (!quiet)
fprintf(stderr,_("Error allocating memory!\n"));
exit(1);
}
#ifdef DEBUG
fprintf(stderr,"DEBUG: allocated %p (%d)\n",res,size);
#endif /* DEBUG */
return res;
}
/* resize allocated memory */
void *
xrealloc(void *ptr,size_t size)
{
void *res;
res=realloc(ptr,size);
if ((res==NULL)&&(size!=0))
{
if (!quiet)
fprintf(stderr,_("Error allocating memory!\n"));
exit(1);
}
#ifdef DEBUG
fprintf(stderr,"DEBUG: reallocated %p to %p (%d)\n",ptr,res,size);
#endif /* DEBUG */
return res;
}
/* free the memory */
void
xfree(void *ptr)
{
free(ptr);
#ifdef DEBUG
fprintf(stderr,"DEBUG: freed %p\n",ptr);
#endif /* DEBUG */
}
/* strdup() wrapper */
char *
xstrdup(const char *str)
{
char *res;
res=strdup(str);
if (res==NULL)
{
if (!quiet)
fprintf(stderr,_("Error allocating memory!\n"));
exit(1);
}
return res;
}
--- NEW FILE: buffer.h ---
/*
buffer.h - functions for handling buffers
Copyright (C) 2002, 2005 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _BUFFER_H
#define _BUFFER_H 1
/* structure for holding a string */
struct buffer
{
char *buf; /* pointer to allocated memory */
int alloc; /* size of allocated memory */
int len; /* amount of memory in use */
int linenumber; /* number of the line */
};
/* intialize struct buffer and allocate memory for it */
void buffer_init(struct buffer *line,int alloc);
/* change the size of the line */
void buffer_grow(struct buffer *line,int alloc);
/* free allocated memory */
void buffer_free(struct buffer *line);
/* make a copy of the sc line into dst line
optionaly growing of allocationg dst
the orriginal content of dst is lost and a pointer
to the result (dst or a new line if dst==NULL) */
struct buffer *buffer_copy(struct buffer *dst,struct buffer *src);
/* read a single line from the file
this function returns a struct buffer structure containing
the read line with newline or NULL on EOF
lines are delimited by the delim char */
struct buffer *buffer_readline(FILE *in,struct buffer *line,char delim);
/* read a complete file into a buffer */
struct buffer *buffer_readfile(FILE *in,struct buffer *buf);
#endif /* _BUFFER_H */
--- NEW FILE: README ---
rl - Randomize Lines
rl reads lines from a input file or stdin, randomizes the lines and outputs a
specified number of lines. It does this with only a single pass over the input
while trying to use as little memory as possible.
I wrote rl in my spare time mainly to be able to select a random audio file to
play when my toast is done (script in combination with find and sleep).
Another reason was to familiarize myself with autoconf and friends.
The most recent version of rl can be found at
http://ch.tudelft.nl/~arthur/rl/
Warning: The command line options and default behaviour may change between
releases until a 1.0 release is made.
Another Warning: I have mostly lost interest in this project and am not
planning on doing much development on it any more. I will however still accept
patches and fix important bugs (this more or less contradicts the previous
warning).
COPYRIGHT NOTICE
----------------
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
INSTALLATION INSTRUCTIONS
-------------------------
rl should compile fine on most Unix-like operating systems. It is written to
be as portable as possible.
rl is developed on Debian GNU/Linux 3.1 (sarge) and unstable (sid) and tested
on Solaris 8 (once in a while), OpenBSD 2.7 (hardly ever) and HP-UX 10 (a long
time ago).
rl uses a configure script to guess build parameters for your system.
Configuration, compilation and installation should be as simple as this:
% ./configure (use --help for options)
% make (compile)
% make install (install)
For more details read the INSTALL file.
PLANS / TODO
------------
rl is still in development and there are more features to implement. The
development is currently based on the "it works for me" principle. For a list
of items that should still be done see the TODO file.
If you want any features added to rl or you have comments or questions you can
email me at arthur at ch.tudelft.nl. Patches for bug fixes and feature extensions
are appreciated.
--- NEW FILE: install-sh ---
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2005-05-14.22
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
shift
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit 1; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
--- NEW FILE: random.h ---
/*
random.h - definitions of all random number related functions
Copyright (C) 2002 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _RANDOM_H
#define _RANDOM_H 1
/* initialize the random number generator with a sensible value
this calls srand() so rand() can be used */
void randomize(void);
/* returns a random number x where 0 <= x < max */
int random_below(int max);
/* thow the dice and return true (1)
with a chance of x/y (false=0) */
int random_draw(int x,int y);
#endif /* _RANDOM_H */
--- NEW FILE: alloc.h ---
/*
alloc.h - functions for clean memory management
Copyright (C) 2002 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _ALLOC_H
#define _ALLOC_H 1
/* allocate memory with error-checking */
void *xmalloc(size_t size);
/* allocate size for a specific type */
#define xxmalloc(type,size) (type *)xmalloc(sizeof(type)*(size))
/* resize allocated memory */
void *xrealloc(void *ptr,size_t size);
/* realloc for a specific type */
#define xxrealloc(ptr,type,size) (type *)xrealloc(ptr,sizeof(type)*(size))
/* free the memory */
void xfree(void *ptr);
/* strdup() wrapper */
char *xstrdup(const char *s);
#endif /* _ALLOC_H */
--- NEW FILE: getopt_long.h ---
/*
getopt_long.h - definition of getopt_long() for systems that lack it
Copyright (C) 2002 Arthur de Jong
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 of the License, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _GETOPT_LONG_H
#define _GETOPT_LONG_H 1
#define no_argument 0
#define required_argument 1
#define optional_argument 2
struct option {
const char *name;
int has_arg;
int *flag;
int val;
};
/* this is a (poor) getopt_long() replacement for systems that don't have it
(this is generaly a GNU extention)
this implementation is by no meens flawless, especialy the optional arguments
to options and options following filenames is not quite right, allso
minimal error checking
*/
int getopt_long(int argc,char * const argv[],
const char *optstring,
const struct option *longopts,int *longindex);
#endif /* _GETOPT_LONG_H */
More information about the dslinux-commit
mailing list