Commits

Alex Bolotov committed 946d875

Version 3.4p has been reworked so that it can be configured with configure.sh, and has the additional minor feature that it better supports consoles and GUI windows that come in different sizes.

  • Participants
  • Parent commits 07cf488
  • Tags 3.4p

Comments (0)

Files changed (36)

File Makefile

-# makefile for Levee
-
-CFLAGS = -O -DSIZE=256000L -Wall
-#LIBES=-lncurses
-LIBES=-ltermcap
-
-OBJS = blockio.o display.o editcor.o exec.o find.o \
-    unixcall.o globals.o insert.o main.o misc.o \
-    modify.o move.o ucsd.o undo.o wildargs.o
-
-lev: $(OBJS)
-	$(CC) $(CFLAGS) -o lev $(OBJS) $(LIBES)
-
-clean:
-	rm -f *.o lev
-
-# Dependencies
-
-blockio.o    : levee.h extern.h blockio.c
-display.o    : levee.h extern.h termcap.i display.c
-editcor.o    : levee.h extern.h editcor.c
-exec.o       : levee.h extern.h exec.c
-find.o       : levee.h extern.h grep.h find.c
-globals.o    : levee.h globals.c
-insert.o     : levee.h extern.h insert.c
-main.o       : levee.h extern.h main.c
-misc.o       : levee.h extern.h misc.c
-modify.o     : levee.h extern.h grep.h modify.c
-move.o       : levee.h extern.h move.c
-rmxcall.o    : levee.h rmxcall.c
-ucsd.o       : levee.h extern.h ucsd.c
-undo.o       : levee.h extern.h undo.c
+# makefile for Levee
+
+exedir=@exedir@
+mandir=@mandir@
+CC=@CC@
+
+CFLAGS += -Wall
+
+OBJS = blockio.o display.o editcor.o exec.o find.o \
+    unixcall.o globals.o insert.o main.o misc.o \
+    modify.o move.o ucsd.o undo.o wildargs.o
+
+lev: $(OBJS)
+	$(CC) $(CFLAGS) -o lev $(OBJS) @LIBS@
+
+clean:
+	rm -f *.o lev
+
+distclean spotless: clean
+	rm -f @GENERATED_FILES@ @CONFIGURE_FILES@
+
+install: install.bin install.man
+
+install.bin: lev
+	@INSTALL_DIR@ $(PREFIX)$(exedir)
+	@INSTALL_PROGRAM@ lev $(PREFIX)$(exedir)/levee
+	@NOMK@ @LN_S@ -f levee $(PREFIX)$(exedir)/lv
+
+install.man:
+	@INSTALL_DIR@ $(PREFIX)$(mandir)/man1
+	@INSTALL_DATA@ lv.1 $(PREFIX)$(mandir)/man1/levee.1
+	@NOMK@ @INSTALL_DATA@ lv.1 $(PREFIX)$(mandir)/man1/lv.1
+	@NOMK@ echo ".so man1/levee.1" > $(PREFIX)$(mandir)/man1/lv.1
+
+# Dependencies
+
+blockio.o    : levee.h extern.h blockio.c config.h
+display.o    : levee.h extern.h termcap.i display.c config.h
+editcor.o    : levee.h extern.h editcor.c config.h
+exec.o       : levee.h extern.h exec.c config.h
+find.o       : levee.h extern.h grep.h find.c config.h
+globals.o    : levee.h globals.c config.h
+insert.o     : levee.h extern.h insert.c config.h
+main.o       : levee.h extern.h main.c config.h
+misc.o       : levee.h extern.h misc.c config.h
+modify.o     : levee.h extern.h grep.h modify.c config.h
+move.o       : levee.h extern.h move.c config.h
+rmxcall.o    : levee.h rmxcall.c config.h
+ucsd.o       : levee.h extern.h ucsd.c config.h
+undo.o       : levee.h extern.h undo.c config.h
+unixcall.o   : levee.h extern.h unixcall.c config.h
+wildargs.o   : levee.h extern.h wildargs.c config.h

File Mastodon.build

-#! /bin/sh
-#
-# Mastodon buildfile for Levee (3.4m)
-#
-
-. ./Mastodon.inc
-exedir BIN
-
-make clean
-CC="$SYSCC" make || exit 1
-
-install -d $BIN/usr/bin
-install -d -o man -g man $BIN/usr/man/man1
-
-install -m 511 -o bin -g bin -s -c lev $BIN/usr/bin/levee
-install -m 444 -o man -g man -c lv.1 $BIN/usr/man/man1/levee.1
-
-(   cd $BIN/usr/bin
-#    ln -fs levee vi
-    ln levee lv
-)
-(   cd $BIN/usr/man/man1
-#    ln -fs levee.1 vi.1
-    ln levee.1 lv.1
-)
-exit 0

File Mastodon.inc

-/Mastodon/Mastodon.inc
-3.4o
+3.4p
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
  */
 #include "levee.h"
 
-#if ST
+#if OS_ATARI
 #include <atari\osbind.h>
 
 char sound[] = {
     }
     Super(ssp);
 }
-#endif /*ST*/
+#endif /*OS_ATARI*/
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 bool PROC
 putfile(f, start, endd)
 register FILE *f;
-register start, endd;
+register int start, endd;
 {
     return write(fileno(f), core+start, endd-start) == (endd-start);
 }

File configure.inc

+#   @(#) configure.inc 1.38@(#)
+#   Copyright (c) 1999-2004 David Parsons. All rights reserved.
+#   
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. My name may not be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#     
+#  THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
+#  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+#  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+#  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
+#  PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+#  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+#  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+#  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+#  THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+#
+# this preamble code is executed when this file is sourced and it picks
+# interesting things off the command line.
+#
+ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
+
+ac_standard="--src=DIR		where the source lives (.)
+--prefix=DIR		where to install the final product (/usr/local)
+--execdir=DIR		where to put executables (prefix/bin)
+--sbindir=DIR		where to put static executables (prefix/sbin)
+--confdir=DIR		where to put configuration information (/etc)
+--libdir=DIR		where to put libraries (prefix/lib)
+--libexecdir=DIR	where to put private executables
+--mandir=DIR		where to put manpages"
+
+__fail=exit
+
+if dirname B/A 2>/dev/null >/dev/null; then
+__ac_dirname() {
+    dirname "$1"
+}
+else
+__ac_dirname() {
+    echo "$1" | sed -e 's:/[^/]*$::'
+}
+fi
+
+ac_progname=$0
+ac_configure_command=
+Q=\'
+for x in "$@"; do
+    ac_configure_command="$ac_configure_command $Q$x$Q"
+done
+# ac_configure_command="$*"
+
+__d=`__ac_dirname "$ac_progname"`
+if [ "$__d" = "$ac_progname" ]; then
+    AC_SRCDIR=`pwd`
+else
+    AC_SRCDIR=`cd $__d;pwd`
+fi
+
+__ac_dir() {
+    if test -d "$1"; then
+	(cd "$1";pwd)
+    else
+	echo "$1";
+    fi
+}
+
+while [ $# -gt 0 ]; do
+    unset matched
+
+    case X"$1" in
+    X--src|X--srcdir)
+	AC_SRCDIR=`__ac_dir "$2"`
+	_set_srcdir=1
+	shift 2;;
+
+    X--src=*|X--srcdir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_SRCDIR=`__ac_dir "$__d"`
+	_set_srcdir=1
+	shift 1 ;;
+
+    X--prefix)
+	AC_PREFIX=`__ac_dir "$2"`
+	_set_prefix=1
+	shift 2;;
+
+    X--prefix=*)
+	__d=`echo "$1"| sed -e 's/^[^=]*=//'`
+	AC_PREFIX=`__ac_dir "$__d"`
+	_set_prefix=1
+	shift 1;;
+
+    X--confdir)
+	AC_CONFDIR=`__ac_dir "$2"`
+	_set_confdir=1
+	shift 2;;
+
+    X--confdir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_CONFDIR=`__ac_dir "$__d"`
+	_set_confdir=1
+	shift 1;;
+
+    X--libexec|X--libexecdir)
+	AC_LIBEXEC=`__ac_dir "$2"`
+	_set_libexec=1
+	shift 2;;
+
+    X--libexec=*|X--libexecdir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_LIBEXEC=`__ac_dir "$__d"`
+	_set_libexec=1
+	shift 1;;
+
+    X--lib|X--libdir)
+	AC_LIBDIR=`__ac_dir "$2"`
+	_set_libdir=1
+	shift 2;;
+
+    X--lib=*|X--libdir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_LIBDIR=`__ac_dir "$__d"`
+	_set_libdir=1
+	shift 1;;
+
+    X--exec|X--execdir)
+	AC_EXECDIR=`__ac_dir "$2"`
+	_set_execdir=1
+	shift 2;;
+
+    X--exec=*|X--execdir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_EXECDIR=`__ac_dir "$__d"`
+	_set_execdir=1
+	shift 1;;
+
+    X--sbin|X--sbindir)
+	AC_SBINDIR=`__ac_dir "$2"`
+	_set_sbindir=1
+	shift 2;;
+
+    X--sbin=*|X--sbindir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_SBINDIR=`__ac_dir "$__d"`
+	_set_sbindir=1
+	shift 1;;
+
+    X--man|X--mandir)
+	AC_MANDIR=`__ac_dir "$2"`
+	_set_mandir=1
+	shift 2;;
+
+    X--man=*|X--mandir=*)
+	__d=`echo "$1" | sed -e 's/^[^=]*=//'`
+	AC_MANDIR=`__ac_dir "$__d"`
+	_set_mandir=1
+	shift 1;;
+
+    X--use-*=*)
+	_var=`echo "$1"| sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
+	if [ "$_var" ]; then
+	    _val=`echo "$1" | sed -e 's/^--use-[^=]*=\(.*\)$/\1/'`
+	    _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+	    case X"$_val" in
+	    X[Yy][Ee][Ss]|X[Tt][Rr][Uu][Ee]) eval USE_${_v}=T ;;
+	    X[Nn][Oo]|X[Ff][Aa][Ll][Ss][Ee]) eval unset USE_${_v} ;;
+	    *) echo "Bad value for --use-$_var ; must be yes or no"
+	       exit 1 ;;
+	    esac
+	else
+	    echo "Bad option $1.   Use --help to show options" 1>&2
+	    exit 1
+	fi
+	shift 1 ;;
+
+    X--use-*)
+        _var=`echo "$1"|sed -n 's/^--use-\([A-Za-z][-A-Za-z0-9_]*\)$/\1/p'`
+	_v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+	eval USE_${_v}=T
+	shift 1;;
+
+    X--with-*=*)
+	_var=`echo "$1"| sed -n 's/^--with-\([A-Za-z][-A-Za-z0-9_]*\)=.*$/\1/p'`
+	if [ "$_var" ]; then
+	    _val=`echo "$1" | sed -e 's/^--with-[^=]*=\(.*\)$/\1/'`
+	    _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+	    eval WITH_${_v}=\"$_val\"
+	else
+	    echo "Bad option $1.   Use --help to show options" 1>&2
+	    exit 1
+	fi
+	shift 1 ;;
+
+    X--with-*)
+	_var=`echo "$1" | sed -n 's/^--with-\([A-Za-z][A-Za-z0-9_-]*\)$/\1/p'`
+	if [ "$_var" ]; then
+	    _v=`echo $_var | tr '[a-z]' '[A-Z]' | tr '-' '_'`
+	    eval WITH_${_v}=1
+	else
+	    echo "Bad option $1.   Use --help to show options" 1>&2
+	    exit 1
+	fi
+	shift 1 ;;
+
+    X--help)
+	echo "$ac_standard"
+	test "$ac_help" && echo "$ac_help"
+	exit 0;;
+
+    *)	if [ "$LOCAL_AC_OPTIONS" ]; then
+	    eval "$LOCAL_AC_OPTIONS"
+	else
+	    ac_error=T
+	fi
+	if [ "$ac_error" ]; then
+	    echo "Bad option $1.   Use --help to show options" 1>&2
+	    exit 1
+	fi ;;
+    esac
+done
+
+
+#
+# echo w/o newline
+#
+echononl()
+{
+    ${ac_echo:-echo} "${@}$ac_echo_nonl"
+}
+
+#
+# log something to the terminal and to a logfile.
+#
+LOG () {
+    echo "$@"
+    echo "$@" 1>&5
+}
+
+#
+# log something to the terminal without a newline, and to a logfile with
+# a newline
+#
+LOGN () {
+    echononl "$@" 1>&5
+    echo "$@"
+}
+
+#
+# log something to the terminal
+#
+TLOG () {
+    echo "$@" 1>&5
+}
+
+#
+# log something to the terminal, no newline
+#
+TLOGN () {
+    echononl "$@" 1>&5
+}
+
+
+#
+# AC_CONTINUE tells configure not to bomb if something fails, but to
+# continue blithely along
+#
+AC_CONTINUE () {
+    __fail="return"
+}
+
+#
+# Emulate gnu autoconf's AC_CHECK_HEADERS() function
+#
+AC_CHECK_HEADERS () {
+    AC_PROG_CC
+
+    echo "/* AC_CHECK_HEADERS */" > /tmp/ngc$$.c
+    for hdr in $*; do
+	echo "#include <$hdr>" >> /tmp/ngc$$.c
+    done
+    echo "main() { }" >> /tmp/ngc$$.c
+
+    LOGN "checking for header $hdr"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c; then
+	AC_DEFINE 'HAVE_'`echo $hdr | tr 'a-z' 'A-Z' | tr './' '_'` 1
+	TLOG " (found)"
+	rc=0
+    else
+	TLOG " (not found)"
+	rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# emulate GNU autoconf's AC_CHECK_FUNCS function
+#
+AC_CHECK_FUNCS () {
+    AC_PROG_CC
+
+F=$1
+shift
+rm -f /tmp/ngc$$.c
+
+while [ "$1" ]; do
+    echo "#include <$1>" >> /tmp/ngc$$.c
+    shift
+done
+
+    cat >> /tmp/ngc$$.c << EOF
+main()
+{
+    $F();
+}
+EOF
+
+    LOGN "checking for the $F function"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS; then
+	AC_DEFINE `echo ${2:-HAVE_$F} | tr 'a-z' 'A-Z'` 1
+	TLOG " (found)"
+	rc=0
+    else
+	echo "offending command was:"
+	cat /tmp/ngc$$.c
+	echo "$AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $LIBS"
+	TLOG " (not found)"
+	rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# check to see if some structure exists
+#
+# usage: AC_CHECK_STRUCT structure {include ...}
+#
+AC_CHECK_STRUCT () {
+    AC_PROG_CC
+    struct=$1
+    shift
+
+    rm -f /tmp/ngc$$.c
+
+    for include in $*; do
+	echo "#include <$include>" >> /tmp/ngc$$.c
+    done
+
+    cat >> /tmp/ngc$$.c << EOF
+main()
+{
+    struct $struct foo;
+}
+EOF
+
+    LOGN "checking for struct $struct"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
+	AC_DEFINE HAVE_STRUCT_`echo ${struct} | tr 'a-z' 'A-Z'`
+	TLOG " (found)"
+	rc=0
+    else
+	TLOG " (not found)"
+	rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# check to see if some structure contains a field
+#
+# usage: AC_CHECK_FIELD structure field {include ...}
+#
+AC_CHECK_FIELD () {
+    AC_PROG_CC
+
+    struct=$1
+    field=$2
+    shift 2
+
+    rm -f /tmp/ngc$$.c
+
+    for include in $*;do
+	echo "#include <$include>" >> /tmp/ngc$$.c
+    done
+
+    cat >> /tmp/ngc$$.c << EOF
+main()
+{
+    struct $struct foo;
+
+    foo.$field;
+}
+EOF
+
+    LOGN "checking that struct $struct has a $field field"
+
+    if $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c $AC_LIBS 2>>config.log; then
+	AC_DEFINE HAVE_`echo ${struct}_$field | tr 'a-z' 'A-Z'`
+	TLOG " (yes)"
+	rc=0
+    else
+	TLOG " (no)"
+	rc=1
+    fi
+    rm -f /tmp/ngc$$.c /tmp/ngc$$
+    return $rc
+}
+
+
+#
+# check that the C compiler works
+#
+AC_PROG_CC () {
+    test "$AC_CC" && return 0
+
+    cat > /tmp/ngc$$.c << \EOF
+#include <stdio.h>
+main()
+{
+    puts("hello, sailor");
+}
+EOF
+
+    TLOGN "checking the C compiler"
+
+    unset AC_CFLAGS AC_LDFLAGS
+
+    if [ "$CC" ] ; then
+	AC_CC="$CC"
+    elif [ "$WITH_PATH" ]; then
+	AC_CC=`acLookFor cc`
+    elif [ "`acLookFor cc`" ]; then
+	# don't specify the full path if the user is looking in their $PATH
+	# for a C compiler.
+	AC_CC=cc
+    fi
+
+    # finally check for POSIX c89
+    test "$AC_CC" || AC_CC=`acLookFor c89`
+
+    if [ ! "$AC_CC" ]; then
+	TLOG " (no C compiler found)"
+	$__fail 1
+    fi
+    echo "checking out the C compiler"
+
+    $AC_CC -o /tmp/ngc$$ /tmp/ngc$$.c
+    status=$?
+
+    TLOGN " ($AC_CC)"
+    if [ $status -eq 0 ]; then
+	TLOG " ok"
+
+	# check that the CFLAGS and LDFLAGS aren't bogus
+
+	unset AC_CFLAGS AC_LDFLAGS
+
+	if [ "$CFLAGS" ]; then
+	    test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
+	    if $AC_CC $CFLAGS -o /tmp/ngc$$.o /tmp/ngc$$.c ; then
+		AC_CFLAGS=${CFLAGS:-"-g"}
+		test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
+	    elif [ "$CFLAGS" ]; then
+		echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
+	    fi
+	else
+	    AC_CFLAGS=-g
+	fi
+	if [ "$LDFLAGS" ]; then
+	    test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
+	    if $AC_CC $LDFLAGS -o /tmp/ngc$$ /tmp/ngc$$.o; then
+		AC_LDFLAGS=${LDFLAGS:-"-g"}
+		test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
+	    elif [ "$LDFLAGS" ]; then
+		TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
+	    fi
+	else
+	    AC_LDFLAGS=${CFLAGS:-"-g"}
+	fi
+    else
+	AC_FAIL " does not compile code properly"
+    fi
+
+    AC_SUB 'CC' "$AC_CC"
+
+    rm -f /tmp/ngc$$ /tmp/ngc$$.c /tmp/ngc$$.o
+
+    return $status
+}
+
+
+#
+# acLookFor actually looks for a program, without setting anything.
+#
+acLookFor () {
+    path=${AC_PATH:-$ac_default_path}
+    case "X$1" in
+    X-[rx]) __mode=$1
+	    shift
+	    ;;
+    *)	    __mode=-x
+	    ;;
+    esac
+    oldifs="$IFS"
+    for program in $*; do
+	IFS=":"
+	for x in $path; do
+	    if [ $__mode $x/$program -a -f $x/$program ]; then
+		echo $x/$program
+		break 2
+	    fi
+	done
+    done
+    IFS="$oldifs"
+    unset __mode
+}
+
+
+#
+# check that a program exists and set its path
+#
+MF_PATH_INCLUDE () {
+    SYM=$1; shift
+
+    case X$1 in
+    X-[rx]) __mode=$1
+	    shift
+	    ;;
+    *)      unset __mode
+	    ;;
+    esac
+
+    TLOGN "looking for $1"
+
+    DEST=`acLookFor $__mode $*`
+
+    __sym=`echo "$SYM" | tr '[a-z]' '[A-Z]'`
+    if [ "$DEST" ]; then
+	TLOG " ($DEST)"
+	echo "$1 is $DEST"
+	AC_MAK $SYM
+	AC_DEFINE PATH_$__sym \""$DEST"\"
+	AC_SUB $__sym "$DEST"
+	eval CF_$SYM=$DEST
+	return 0
+    else
+	#AC_SUB $__sym ''
+	echo "$1 is not found"
+	TLOG " (not found)"
+	return 1
+    fi
+}
+
+
+#
+# AC_INIT starts the ball rolling
+#
+# After AC_INIT, fd's 1 and 2 point to config.log
+# and fd 5 points to what used to be fd 1
+#
+AC_INIT () {
+    __config_files="config.cmd config.sub config.h config.mak config.log"
+    rm -f $__config_files
+    __cwd=`pwd`
+    exec 5>&1 1>$__cwd/config.log 2>&1
+    AC_CONFIGURE_FOR=__AC_`echo $1 | sed -e 's/\..$//' | tr 'a-z' 'A-Z' | tr ' ' '_'`_D
+
+    # check to see whether to use echo -n or echo ...\c
+    #
+    echo -n hello > $$
+    echo world >> $$
+    if grep "helloworld" $$ >/dev/null; then
+	ac_echo="echo -n"
+	echo "[echo -n] works"
+    else
+	ac_echo="echo"
+	echo 'hello\c' > $$
+	echo 'world' >> $$
+	if grep "helloworld" $$ >/dev/null; then
+	    ac_echo_nonl='\c'
+	    echo "[echo ...\\c] works"
+	fi
+    fi
+    rm -f $$
+
+    LOG "Configuring for [$1]"
+
+    cat > $__cwd/config.h << EOF
+/*
+ * configuration for $1${2:+" ($2)"}, generated `date`
+ * by ${LOGNAME:-`whoami`}@`hostname`
+ */
+#ifndef $AC_CONFIGURE_FOR
+#define $AC_CONFIGURE_FOR 1
+
+
+EOF
+
+    unset __share
+    if [ -d $AC_PREFIX/share/man ]; then
+	for t in 1 2 3 4 5 6 7 8 9; do
+	    if [ -d $AC_PREFIX/share/man/man$t ]; then
+		__share=/share
+	    elif [ -d $AC_PREFIX/share/man/cat$t ]; then
+		__share=/share
+	    fi
+	done
+    else
+	__share=
+    fi
+
+    if [ -d $AC_PREFIX/libexec ]; then
+	__libexec=libexec
+    else
+	__libexec=lib
+    fi
+
+
+    AC_PREFIX=${AC_PREFIX:-/usr/local}
+    AC_EXECDIR=${AC_EXECDIR:-$AC_PREFIX/bin}
+    AC_SBINDIR=${AC_SBINDIR:-$AC_PREFIX/sbin}
+    AC_LIBDIR=${AC_LIBDIR:-$AC_PREFIX/lib}
+    AC_MANDIR=${AC_MANDIR:-$AC_PREFIX$__share/man}
+    AC_LIBEXEC=${AC_LIBEXEC:-$AC_PREFIX/$__libexec}
+    AC_CONFDIR=${AC_CONFDIR:-/etc}
+
+    AC_PATH=${WITH_PATH:-$PATH}
+    AC_PROG_CPP
+    AC_PROG_INSTALL
+
+    if [ -z "$ac_os" ]; then
+	ac_os=`uname -s`
+    fi
+    _os=`echo $ac_os | tr '[a-z]' '[A-Z]'`
+    AC_DEFINE OS_$_os	1
+    eval OS_${_os}=1
+    unset _os
+}
+
+
+#
+# AC_LIBRARY checks to see if a given library exists and contains the
+# given function.
+# usage: AC_LIBRARY function library [alternate ...]
+#
+AC_LIBRARY() {
+    SRC=$1
+    shift
+
+    # first see if the function can be found in any of the
+    # current libraries
+    AC_QUIET AC_CHECK_FUNCS $SRC && return 0
+
+    # then search through the list of libraries
+    __libs="$LIBS"
+    for x in $*; do
+	LIBS="$__libs $x"
+	if AC_QUIET AC_CHECK_FUNCS $SRC; then
+	    AC_LIBS="$AC_LIBS $x"
+	    return 0
+	fi
+    done
+    return 1
+}
+
+
+#
+# AC_PROG_LEX checks to see if LEX exists, and if it's lex or flex.
+#
+AC_PROG_LEX() {
+    TLOGN "looking for lex "
+
+    DEST=`acLookFor lex`
+    if [ "$DEST" ]; then
+	AC_MAK LEX
+	AC_DEFINE PATH_LEX \"$DEST\"
+	AC_SUB 'LEX' "$DEST"
+	echo "lex is $DEST"
+    else
+	DEST=`acLookFor flex`
+	if [ "$DEST" ]; then
+	    AC_MAK FLEX
+	    AC_DEFINE 'LEX' \"$DEST\"
+	    AC_SUB 'LEX', "$DEST"
+	    echo "lex is $DEST"
+	else
+	    AC_SUB LEX ''
+	    echo "neither lex or flex found"
+	    TLOG " (not found)"
+	    return 1
+	fi
+    fi
+
+    if AC_LIBRARY yywrap -ll -lfl; then
+	TLOG "($DEST)"
+	return 0
+    fi
+    TLOG "(no lex library found)"
+    return 1
+}
+
+
+#
+# AC_PROG_YACC checks to see if YACC exists, and if it's bison or
+# not.
+#
+AC_PROG_YACC () {
+
+    TLOGN "looking for yacc "
+
+    DEST=`acLookFor yacc`
+    if [ "$DEST" ]; then
+	AC_MAK YACC
+	AC_DEFINE PATH_YACC \"$DEST\"
+	AC_SUB 'YACC' "$DEST"
+	TLOG "($DEST)"
+	echo "yacc is $DEST"
+    else
+	DEST=`acLookFor bison`
+	if [ "$DEST" ]; then
+	    AC_MAK BISON
+	    AC_DEFINE 'YACC' \"$DEST\"
+	    AC_SUB 'YACC' "$DEST -y"
+	    echo "yacc is $DEST -y"
+	    TLOG "($DEST -y)"
+	else
+	    AC_SUB 'YACC' ''
+	    echo "neither yacc or bison found"
+	    TLOG " (not found)"
+	    return 1
+	fi
+    fi
+    return 0
+}
+
+
+#
+# AC_PROG_LN_S checks to see if ln exists, and, if so, if ln -s works
+#
+AC_PROG_LN_S () {
+    test "$AC_FIND_PROG" || AC_PROG_FIND
+
+    test "$AC_FIND_PROG" || return 1
+    
+    TLOGN "looking for \"ln -s\""
+    DEST=`acLookFor ln`
+
+    if [ "$DEST" ]; then
+	rm -f /tmp/b$$
+	$DEST -s /tmp/a$$ /tmp/b$$
+	if [ "`$AC_FIND_PROG /tmp/b$$ -type l -print`" ]; then
+	    TLOG " ($DEST)"
+	    echo "$DEST exists, and ln -s works"
+	    AC_SUB 'LN_S' "$DEST -s"
+	    rm -f /tmp/b$$
+	else
+	    AC_SUB 'LN_S' ''
+	    TLOG " ($DEST exists, but -s does not seem to work)"
+	    echo "$DEST exists, but ln -s doesn't seem to work"
+	    rm -f /tmp/b$$
+	    return 1
+	fi
+    else
+	AC_SUB 'LN_S' ''
+	echo "ln not found"
+	TLOG " (not found)"
+	return 1
+    fi
+}
+
+
+#
+# AC_PROG_FIND looks for the find program and sets the FIND environment
+# variable
+#
+AC_PROG_FIND () {
+    if test -z "$AC_FIND_PROG"; then
+	MF_PATH_INCLUDE FIND find
+	rc=$?
+	AC_FIND_PROG=$DEST
+	return $rc
+    fi
+    return 0
+}
+
+
+#
+# AC_PROG_AWK looks for the awk program and sets the AWK environment
+# variable
+#
+AC_PROG_AWK () {
+    if test -z "$AC_AWK_PROG"; then
+	MF_PATH_INCLUDE AWK awk
+	rc=$?
+	AC_AWK_PROG=$DEST
+	return $rc
+    fi
+    return 0
+}
+
+
+#
+# AC_PROG_SED looks for the sed program and sets the SED environment
+# variable
+#
+AC_PROG_SED () {
+    if test -z "$AC_SED_PROG"; then
+	MF_PATH_INCLUDE SED sed
+	rc=$?
+	AC_SED_PROG=$DEST
+	return $rc
+    fi
+    return 0
+}
+
+
+#
+# AC_HEADER_SYS_WAIT looks for sys/wait.h
+#
+AC_HEADER_SYS_WAIT () {
+    AC_CHECK_HEADERS sys/wait.h || return 1
+}
+
+#
+# AC_TYPE_PID_T checks to see if the pid_t type exists
+#
+AC_TYPE_PID_T () {
+    cat > /tmp/pd$$.c << EOF
+#include <sys/types.h>
+main() { pid_t me; }
+EOF
+
+    LOGN "checking for pid_t"
+
+    if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
+	TLOG " (found)"
+	rc=0
+    else
+	echo "typedef int pid_t;" >> $__cwd/config.h
+	TLOG " (not found)"
+	rc=1
+    fi
+    rm -f /tmp/pd$$.o /tmp/pd$$.c
+    return $rc
+}
+
+
+#
+# AC_C_CONST checks to see if the compiler supports the const keyword
+#
+AC_C_CONST () {
+    cat > /tmp/pd$$.c << EOF
+const char me=1;
+EOF
+    LOGN "checking for \"const\" keyword"
+
+    if $AC_CC -c /tmp/pd$$.c -o /tmp/pd$$.o; then
+	TLOG " (yes)"
+	rc=0
+    else
+	AC_DEFINE 'const' '/**/'
+	TLOG " (no)"
+	rc=1
+    fi
+    rm -f /tmp/pd$$.o /tmp/pd$$.c
+    return $rc
+}
+
+
+#
+# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
+#
+AC_SCALAR_TYPES () {
+    cat > /tmp/pd$$.c << EOF
+#include <stdio.h>
+main()
+{
+    unsigned long v_long;
+    unsigned int v_int;
+    unsigned short v_short;
+
+    if (sizeof v_long == 4)
+	puts("#define DWORD	unsigned long");
+    else if (sizeof v_int == 4)
+	puts("#define DWORD	unsigned int");
+    else
+	exit(1);
+
+    if (sizeof v_int == 2)
+	puts("#define WORD	unsigned int");
+    else if (sizeof v_short == 2)
+	puts("#define WORD	unsigned short");
+    else
+	exit(2);
+    puts("#define BYTE	unsigned char");
+    exit(0);
+}
+EOF
+    rc=1
+    LOGN "defining WORD & DWORD scalar types"
+    if $AC_CC /tmp/pd$$.c -o /tmp/pd$$; then
+	if /tmp/pd$$  >> $__cwd/config.h; then
+	    rc=0
+	fi
+    fi
+    case "$rc" in
+    0) TLOG "" ;;
+    *) TLOG " ** FAILED **" ;;
+    esac
+    rm -f /tmp/pd$$ /tmp/pd$$.c
+}
+
+
+#
+# AC_OUTPUT generates makefiles from makefile.in's
+#
+AC_OUTPUT () {
+    cd $__cwd
+    AC_SUB 'LIBS'    "$AC_LIBS"
+    AC_SUB 'CONFIGURE_FILES' "$__config_files"
+    AC_SUB 'GENERATED_FILES' "$*"
+    AC_SUB 'CFLAGS'  "$AC_CFLAGS"
+    AC_SUB 'LDFLAGS' "$AC_LDFLAGS"
+    AC_SUB 'srcdir'  "$AC_SRCDIR"
+    AC_SUB 'prefix'  "$AC_PREFIX"
+    AC_SUB 'exedir'  "$AC_EXECDIR"
+    AC_SUB 'sbindir' "$AC_SBINDIR"
+    AC_SUB 'libdir'  "$AC_LIBDIR"
+    AC_SUB 'libexec' "$AC_LIBEXEC"
+    AC_SUB 'confdir' "$AC_CONFDIR"
+    AC_SUB 'mandir'  "$AC_MANDIR"
+
+    if [ -r config.sub ]; then
+	test "$AC_SED_PROG" || AC_PROG_SED
+	test "$AC_SED_PROG" || return 1
+
+	echo                                   >> config.h
+	echo "#endif/* ${AC_CONFIGURE_FOR} */" >> config.h
+
+	rm -f config.cmd
+	Q=\'
+	cat - > config.cmd << EOF
+#! /bin/sh
+${CC:+CC=${Q}${CC}${Q}} ${CFLAGS:+CFLAGS=${Q}${CFLAGS}${Q}} $ac_progname $ac_configure_command
+EOF
+	chmod +x config.cmd
+
+	__d=$AC_SRCDIR
+	for makefile in $*;do
+	    if test -r $__d/${makefile}.in; then
+		LOG "generating $makefile"
+		./config.md `__ac_dirname ./$makefile` 2>/dev/null
+		$AC_SED_PROG -f config.sub < $__d/${makefile}.in > $makefile
+		__config_files="$__config_files $makefile"
+	    else
+		LOG "WARNING: ${makefile}.in does not exist!"
+	    fi
+	done
+	unset __d
+
+    else
+	echo 
+    fi
+}
+
+#
+# AC_CHECK_FLOCK checks to see if flock() exists and if the LOCK_NB argument
+# works properly.
+#
+AC_CHECK_FLOCK() {
+
+    AC_CHECK_HEADERS sys/types.h sys/file.h fcntl.h
+
+    cat << EOF > $$.c
+#include <stdio.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+main()
+{
+    int x = open("$$.c", O_RDWR, 0666);
+    int y = open("$$.c", O_RDWR, 0666);
+
+    if (flock(x, LOCK_EX) != 0)
+	exit(1);
+    if (flock(y, LOCK_EX|LOCK_NB) == 0)
+	exit(1);
+    exit(0);
+}
+EOF
+
+    LOGN "checking for flock()"
+    HAS_FLOCK=0
+    if $AC_CC -o flock $$.c ; then
+	if ./flock ; then
+	    LOG " (found)"
+	    HAS_FLOCK=1
+	    AC_DEFINE HAS_FLOCK
+	else
+	    LOG " (bad)"
+	fi
+    else
+	LOG " (no)"
+    fi
+
+    rm -f flock $$.c
+
+    case "$HAS_FLOCK" in
+    0) return 1 ;;
+    *) return 0 ;;
+    esac
+}
+
+
+#
+# AC_PROG_INSTALL finds the install program and guesses whether it's a 
+# Berkeley or GNU install program
+#
+AC_PROG_INSTALL () {
+
+    DEST=`acLookFor install`
+
+    LOGN "checking for install"
+    unset IS_BSD
+    if [ "$DEST" ]; then
+	# BSD install or GNU install?  Let's find out...
+	touch /tmp/a$$
+
+	$DEST /tmp/a$$ /tmp/b$$
+
+	if test -r /tmp/a$$; then
+	    LOG " ($DEST)"
+	else
+	    IS_BSD=1
+	    LOG " ($DEST) bsd install"
+	fi
+	rm -f /tmp/a$$ /tmp/b$$
+    else
+	DEST=`acLookFor ginstall`
+	if [ "$DEST" ]; then
+	    LOG " ($DEST)"
+	else
+	    DEST="false"
+	    LOG " (not found)"
+	fi
+    fi
+
+    if [ "$IS_BSD" ]; then
+	PROG_INSTALL="$DEST -c"
+    else
+	PROG_INSTALL="$DEST"
+    fi
+
+    AC_SUB 'INSTALL' "$PROG_INSTALL"
+    AC_SUB 'INSTALL_PROGRAM' "$PROG_INSTALL -s -m 755"
+    AC_SUB 'INSTALL_DATA' "$PROG_INSTALL -m 444"
+
+    # finally build a little directory installer
+    # if mkdir -p works, use that, otherwise use install -d,
+    # otherwise build a script to do it by hand.
+    # in every case, test to see if the directory exists before
+    # making it.
+
+    if mkdir -p $$a/b; then
+	# I like this method best.
+	__mkdir="mkdir -p"
+	rmdir $$a/b
+	rmdir $$a
+    elif $PROG_INSTALL -d $$a/b; then
+	__mkdir="$PROG_INSTALL -d"
+	rmdir $$a/b
+	rmdir $$a
+    fi
+
+    __config_files="$__config_files config.md"
+    AC_SUB 'INSTALL_DIR' "$__cwd/config.md"
+    echo "#! /bin/sh"                                   > $__cwd/config.md
+    echo "# script generated" `date` "by configure.sh" >> $__cwd/config.md
+    echo                                               >> $__cwd/config.md
+    if [ "$__mkdir" ]; then
+	echo "test -d \"\$1\" || $__mkdir \"\$1\""     >> $__cwd/config.md
+	echo "exit $?"                                 >> $__cwd/config.md
+    else
+	cat - >> $__cwd/config.md << \EOD
+pieces=`IFS=/; for x in $1; do echo $x; done`
+dir=
+for x in $pieces; do
+    dir="$dir$x"
+    mkdir $dir || exit 1
+    dir="$dir/"
+done
+exit 0
+EOD
+    fi
+    chmod +x $__cwd/config.md
+}
+
+#
+# acCheckCPP is a local that runs a C preprocessor with a given set of
+# compiler options
+#
+acCheckCPP () {
+	cat > /tmp/ngc$$.c << EOF
+#define FOO BAR
+
+FOO
+EOF
+
+    if $1 $2 /tmp/ngc$$.c > /tmp/ngc$$.o; then
+	if grep -v '#define' /tmp/ngc$$.o | grep -s BAR >/dev/null; then
+	    echo "CPP=[$1], CPPFLAGS=[$2]"
+	    AC_SUB 'CPP' "$1"
+	    AC_SUB 'CPPFLAGS' "$2"
+	    rm /tmp/ngc$$.c /tmp/ngc$$.o
+	    return 0
+	fi
+    fi
+    rm /tmp/ngc$$.c /tmp/ngc$$.o
+    return 1
+}
+
+
+#
+# AC_PROG_CPP checks for cpp, then checks to see which CPPFLAGS are needed
+# to run it as a filter.
+#
+AC_PROG_CPP () {
+    if [ "$AC_CPP_PROG" ]; then
+	DEST=$AC_CPP_PROG
+    else
+	__ac_path="$AC_PATH"
+	AC_PATH="/lib:/usr/lib:${__ac_path:-$ac_default_path}"
+	DEST=`acLookFor cpp`
+	AC_PATH="$__ac_path"
+    fi
+
+    unset fail
+    LOGN "Looking for cpp"
+    if [ "$DEST" ]; then
+	TLOGN " ($DEST)"
+	acCheckCPP $DEST "$CPPFLAGS" || \
+		 acCheckCPP $DEST -traditional-cpp -E || \
+		 acCheckCPP $DEST -E || \
+		 acCheckCPP $DEST -traditional-cpp -pipe || \
+	         acCheckCPP $DEST -pipe || fail=1
+
+	if [ "$fail" ]; then
+	    AC_FAIL " (can't run cpp as a pipeline)"
+	else
+	    TLOG " ok"
+	    return 0
+	fi
+    fi
+    AC_FAIL " (not found)"
+}
+
+#
+# AC_FAIL spits out an error message, then __fail's 
+AC_FAIL() {
+    LOG "$*" 
+    $__fail 1
+}
+
+#
+# AC_SUB writes a substitution into config.sub
+AC_SUB() {
+    (   echononl "s;@$1@;"
+	_subst=`echo $2 | sed -e 's/;/\\;/g'`
+	echononl "$_subst"
+	echo ';g' ) >> $__cwd/config.sub
+}
+
+#
+# AC_MAK writes a define into config.mak
+AC_MAK() {
+    echo "HAVE_$1 = 1" >> $__cwd/config.mak
+}
+
+#
+# AC_DEFINE adds a #define to config.h
+AC_DEFINE() {
+    echo "#define $1 ${2:-1}" >> $__cwd/config.h
+}
+
+#
+# AC_CONFIG adds a configuration setting to all the config files
+AC_CONFIG() {
+    AC_DEFINE "PATH_$1" \""$2"\"
+    AC_MAK "$1"
+    AC_SUB "$1" "$2"
+}
+
+#
+# AC_QUIET does something quietly
+AC_QUIET() {
+    eval $* 5>/dev/null
+}

File configure.sh

+#! /bin/sh
+
+# local options:  ac_help is the help message that describes them
+# and LOCAL_AC_OPTIONS is the script that interprets them.  LOCAL_AC_OPTIONS
+# is a script that's processed with eval, so you need to be very careful to
+# make certain that what you quote is what you want to quote.
+
+ac_help='
+--use-termcap		Link with termcap instead of curses, if possible
+--size=NNN		Use a NNN-byte edit buffer
+--dos			compile for ms-dos or microsoft windows
+--tos			compile for the Atari ST
+--rmx			compile for RMX
+--flexos		compile for FlexOS'
+
+LOCAL_AC_OPTIONS='
+case Z$1 in
+Z--dos)	    ac_os=DOS;;
+Z--tos)     ac_os=ATARI=1;;
+Z--flexos)  ac_os=FLEXOS=1;;
+Z--rmx)	    ac_os=RMX;;
+Z--size=*)  SIZE=$(echo Z$1 | sed -e 's/^Z--size=//') ;;
+*)          ac_error=1;;
+esac;shift'
+
+# load in the configuration file
+#
+TARGET=levee
+. ./configure.inc
+AC_INIT $TARGET
+
+# validate --size=
+#
+case "${SIZE:-1}" in
+[0-9][0-9]*)	;;
+[0-9][0-9]*[Ll]);;
+*)		AC_ERROR "--size=$SIZE is not a valid number" ;;
+esac
+
+AC_PROG_CC
+
+if [ "$OS_DOS" ]; then
+    AC_DEFINE	SIZE ${SIZE:-32000}
+    AC_DEFINE	PROC	_fastcall
+    AC_DEFINE	TTY_ANSI	1
+    AC_CHECK_FUNCS	basename
+elif [ "$OS_ATARI" ]; then
+    AC_DEFINE	SIZE ${SIZE:-32000}
+    AC_DEFINE	TTY_VT52	1
+    AC_DEFINE	HAVE_BLKFILL	1
+    AC_CHECK_FUNCS	basename
+elif [ "$OS_FLEXOS" ]; then
+    AC_DEFINE	SIZE ${SIZE:-256000}
+    AC_CHECK_FUNCS	basename
+else
+    AC_DEFINE	SIZE ${SIZE:-256000}
+    AC_DEFINE	OS_UNIX	1
+    if AC_PROG_LN_S; then
+	AC_SUB NOMK ''
+    else
+	AC_SUB NOMK '#'
+    fi
+
+    if AC_CHECK_HEADERS string.h; then
+	# Assume a mainly ANSI-compliant world, where the
+	# existance of string.h implies a memset() and strchr()
+	AC_DEFINE HAVE_MEMSET	1
+	AC_DEFINE HAVE_STRCHR	1
+    else
+	AC_CHECK_FUNCS memset
+	AC_CHECK_FUNCS strchr
+    fi
+
+    # for basename
+    if AC_CHECK_FUNCS basename; then
+	AC_CHECK_HEADERS libgen.h
+    fi
+
+    if AC_CHECK_HEADERS signal.h; then
+	# Assume a mainly sane world where the existance
+	# of signal.h means that signal() exists
+	AC_DEFINE HAVE_SIGNAL 1
+    fi
+
+    if [ "$USE_TERMCAP" ]; then
+	LIBORDER="-ltermcap -lcurses -lncurses"
+    else
+	LIBORDER="-lcurses -lncurses -ltermcap"
+    fi
+
+    if AC_LIBRARY tgetent $LIBORDER; then
+	AC_DEFINE USE_TERMCAP	1
+    else
+	# have to use a local termcap
+	AC_DEFINE TERMCAP_EMULATION	1
+	AC_DEFINE USE_TERMCAP	1
+    fi
+
+    AC_CHECK_HEADERS termios.h && AC_CHECK_FUNCS tcgetattr
+fi
+
+AC_OUTPUT Makefile
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 
 /* do a gotoXY -- allowing -1 for same row/column */
 
-#if TERMCAP | ST
+#if USE_TERMCAP | OS_ATARI
 
 #define MAXCOLS 160
 
-#if TERMCAP
+#if USE_TERMCAP
 #include "termcap.i"
 #endif
 
-#else /*!(TERMCAP | ST)*/
+#else /*!(USE_TERMCAP | OS_ATARI)*/
 
 #define MAXCOLS COLS
 
 mvcur(y,x)
 int y,x;
 {
-#if TERMCAP_EMULATION || ANSI
+#if TERMCAP_EMULATION || TTY_ANSI
     static char gt[30];
 #endif
    
     if (x >= COLS)
 	x = COLS-1;
 
-#if TERMCAP
 #if TERMCAP_EMULATION
     tgoto(gt,y,x);
     strput(gt);
-#else
+#elif USE_TERMCAP
     strput( tgoto(CM, x, y) );
-#endif
-#elif ZTERM
+#elif TTY_ZTERM
     zgoto(x,y);
-#elif ANSI
+#elif TTY_ANSI
     {	register char *p = gt;		/* make a ansi gotoXY string */
 	*p++ = 033;
 	*p++ = '[';
 	*p++ = 'H';
 	WRITE_TEXT(1, gt, (p-gt));
     }
-#elif VT52
+#elif TTY_VT52
     CM[2] = y+32;
     CM[3] = x+32;
     strput(CM);
     	return 2;
     }
     else {
-#if MSDOS
+#if OS_DOS
 	out[0] = c;
 	return 1;
 #else
 {
     int size,oxp = curpos.x;
     char buf[MAXCOLS+1];
-    register bi = 0;
+    register int bi = 0;
 
     while (*s && curpos.x < COLS) {
     	size = format(&buf[bi],*s++);
 int y,x,start;
 {
     int endd,oxp;
-    register size;
+    register int size;
     char buf[MAXCOLS+1];
-    register bi = 0;
+    register int bi = 0;
     
     endd = fseekeol(start);
     if (start==0 || core[start-1] == EOL)
 {
     int sp;
     
-#if ST
+#if OS_ATARI
     /* turn the cursor off */
     asm(" clr.l  -(sp)     ");
     asm(" move.w #21,-(sp) ");
 	    printch('~'); strput(CE);
 	    y++;
 	}
-#if ST
+#if OS_ATARI
     /* turn the cursor back on */
     asm(" clr.w  -(sp)     ");
     asm(" move.w #1,-(sp)  ");
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
  */
 #include "levee.h"
 
-#if MSDOS
+#if OS_DOS
 #include <glob.h>
 #include <dos.h>
 
     }
     return (char*)0;
 } /* glob */
-#endif /*MSDOS*/
+#endif /*OS_DOS*/
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
     else {
 	curr = bseekeol(max(0,nextline(FALSE, curr, count)));
 	i = bseekeol(max(0,nextline(FALSE, ptop, count)));
-	if (i < ptop)
+	if (i < ptop) {
 	    if (canUPSCROLL)
 		scrollback(i);
 	    else {
 		setend();
 		redisplay(TRUE);
 	    }
+	}
     }
     strput(CURon);
     setpos(skipws(curr));	/* initialize new position - first nonwhite */
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 args()
 /* args: print the argument list */
 {
-    register i;
+    register int i;
     mvcur(-1,0);
     for (i=0; i < argc; i++) {
 	if (curpos.x+strlen(argv[i]) >= COLS)
 	else if (i > 0)
 	    printch(' ');
 	if (pc == i) {			/* highlight the current filename.. */
-#if ST|FLEXOS
+#if OS_ATARI|OS_FLEXOS
 	    strput("\033p");
 #else
 	    printch('[');
 #endif
 	    prints(argv[i]);
-#if ST|FLEXOS
+#if OS_ATARI|OS_FLEXOS
 	    strput("\033q");
 #else
 	    printch(']');
 getname()
 {
     extern int wilderr;
-#if ST
+#if OS_ATARI
     extern int mapslash;
     register char *p;
 #endif
     register char *name;
 
     if ( (name = getarg()) ) {
-	if (strcmp(name,"#") == 0)
+	if ( 0 == strcmp(name,"#") ) {
 	    if (*altnm)
 		name = altnm;
 	    else {
 		wilderr++;
 		return NULL;
 	    }
-#if ST
+	}
+#if OS_ATARI
 	if (mapslash)
 	    for (p=name; *p; p++)
 		if (*p == '/')
     else {		/* append stuff to the buffer */
 	fixupline(bseekeol(curr));
 	onright = bufmax-low;
-#if MSDOS
+#if OS_DOS
 	high = SIZE;
 	high -= onright;
 #else
 char *name;
 {
     char back[80];
-#if !UNIX
+#if !OS_UNIX
     char *p;
 #endif
 
     strcpy(back, name);
-#if UNIX
+#if OS_UNIX
     strcat(back, "~");
 #else
     p = strrchr(basename(back), '.');
 /* check and see if it is ok to edit a new file */
 int writeold;	/* automatically write out changes? */
 {
-    if (modified && !affirm)
+    if (modified && !affirm) {
 	if (readonly) {
 	    errmsg(fisro);
 	    return NO;
 	    errmsg(fismod);
 	    return NO;
 	}
+    }
     return YES;
 } /* oktoedit */
 
 	    break;
 	case EX_XIT:
 	    clrmsg();
-	    if (modified)
+	    if (modified) {
 		if (readonly) {
 		    prints(fisro);
 		    break;
 		}
 		else if (!writefile())
 		    break;
+	    }
 
 	    if (!affirm && (argc-pc > 1)) {	/* any more files to edit? */
 		printch('(');
 	    zotscreen = YES;
 	    exprintln();
 	    if (*execstr) {
-#if ZTERM
+#if TTY_ZTERM
 		zclose();
 #endif
-#if FLEXOS|UNIX
+#if OS_FLEXOS|OS_UNIX
 		fixcon();
 #else
 		allowintr();
 #endif
 		system(execstr);
-#if FLEXOS|UNIX
+#if OS_FLEXOS|OS_UNIX
 		initcon();
 #else
 		nointr();
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 extern
 struct ybuf yank;		/* last deleted/yanked text */
 /* STATIC INITIALIZATIONS: */
+
 /* ttydef stuff */
-#if ST | TERMCAP
+#if OS_ATARI | USE_TERMCAP
 extern int LINES, COLS;
 #endif
-#if TERMCAP
+
+#if USE_TERMCAP
 extern bool CA, canUPSCROLL;
 extern char FkL,
 	    CurRT,
 	    CurLT,
 	    CurDN,
 	    CurUP;
-#endif /*TERMCAP*/
+#endif /*USE_TERMCAP*/
+
 extern char *TERMNAME,
 	    *HO,
 	    *UP,
 #define EXTERN_D
 #define wc(ch)	(scan(65,'=',(ch),wordset)<65)
 
-#if SYS5
+#if HAVE_STRING_H
 #include <string.h>
+#endif
 
+#if HAVE_MEMSET
 #define fillchar(p,l,c)	memset((p),(c),(l))
+#elif HAVE_BLKFILL
+#define fillchar(p,l,c)	blkfill((p),(c),(l))
+#endif
+#if HAVE_STRCHR
 #define index(s,c)	strchr((s),(c))
-#else /*!SYS5*/
-#if ST
-#define fillchar(p,l,c)	blkfill((p),(c),(l))
-#endif /*ST*/
-#endif /*SYS5*/
-		
+#endif
+
 extern findstates PROC findCP();
 extern exec_type PROC editcore();
 
 extern VOID PROC fillchar();
 #endif
 
-#if TERMCAP
+#if USE_TERMCAP
 extern void tc_init();
 #endif
 
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 omatch(pattern, cp, endp)
 char *pattern, **cp, *endp;
 {
-    register flag;
+    register int flag;
     extern int ignorecase;
 
     switch (*pattern) {
       case TOKENE:
 	  return !isalnum(**cp);
       case LITCHAR:
-#ifdef TOUPPER_FTN
-#undef toupper
-#endif
 	  if (ignorecase)
 	      flag = (toupper(**cp) == toupper(*(pattern+1)));
 	  else
 patsize(pattern)
 register char **pattern;
 {
-    register count;
+    register int count;
     
     switch (**pattern) {
       case LITCHAR:
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
  */
 #include "levee.h"
 
-#if FLEXOS
+#if OS_FLEXOS
 #include <flexos.h>
 #include <ctype.h>
 
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
  */
 #include "levee.h"
 
-#if ST
+#if OS_ATARI
 #include <atari\osbind.h>
 
 strput(s)
 	c = (((unsigned)(key>>16))|0x80) & 0xff;
     return c;
 } /* getKey */
-#endif /*ST*/
+#endif /*OS_ATARI*/
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 
 /* ttydef stuff */
 
-#if ST | TERMCAP
+#if OS_ATARI | USE_TERMCAP
 int LINES, COLS;
 #endif
 
-#if ZTERM
+#if TTY_ZTERM
 char *TERMNAME = "zterm",
      *HO  = "\001",	/* goto top of screen */
      *UP  = "\002",	/* move up 1 line? */
      *CURon;
 #endif /*ZTERM*/
 
-#if ANSI
-#if MSDOS
+#if TTY_ANSI
+#if OS_DOS
 char *TERMNAME = "braindamaged ansi",
 #else
 char *TERMNAME = "hardwired ansi",
      *UP  = "\033[A",
      *CE  = "\033[K",
      *CL  = "\033[H\033[J",
-#if MSDOS
+#if OS_DOS
      *OL  = NULL,
      *UpS = NULL,
 #else
      *CM  = "\033[%d;%dH",
      *CURoff,
      *CURon;
-#endif /*ANSI*/
+#endif /*TTY_ANSI*/
 
-#if VT52
-#if ST
+#if TTY_VT52
+#if OS_ATARI
 char *TERMNAME = "Atari ST",
 #else
-#if FLEXOS
+#if OS_FLEXOS
 char *TERMNAME = "Flexos console",
 #else
 char *TERMNAME = "hardwired vt52",
-#endif /*FLEXOS*/
-#endif /*ST*/
+#endif /*OS_FLEXOS*/
+#endif /*OS_ATARI*/
      *HO  = "\033H",
      *UP  = "\033A",
      *CE  = "\033K",
      *OL  = "\033L",
      *BELL= "\007",
      *CM  = "\033Y??",
-#if FLEXOS
+#if OS_FLEXOS
      *UpS = NULL,	/* Reverse scrolling is painfully slow */
 #else
      *UpS = "\033I",
 #endif
      *CURoff= "\033f",
      *CURon = "\033e";
-#endif /*VT52*/
+#endif /*TTY_VT52*/
 
-#if TERMCAP
+#if USE_TERMCAP
 bool CA, canUPSCROLL;
 char FkL, CurRT, CurLT, CurUP, CurDN;
 
      *UpS,
      *CURoff,
      *CURon;
-#endif /*TERMCAP*/
+#endif /*USE_TERMCAP*/
 
 char Erasechar = ERASE,			/* our erase character */
      eraseline = 'X'-'@';		/* and line-kill character */
 char spaces[] = { TAB,EOL,' ',0 };
 
 int shiftwidth = 4,
-#if TERMCAP | ST
+#if USE_TERMCAP | OS_ATARI
     dofscroll,
 #else
     dofscroll  = LINES/2,
     list       = NO,
     magic      = YES,
     bell       = YES,
-#if ST
+#if OS_ATARI
     mapslash,
 #endif
     ignorecase = NO;
     {"magic",	  "",	VBOOL,	0,		(void*)&magic      },
     {"ignorecase","ic",	VBOOL,	0,		(void*)&ignorecase },
     {"bell",      "",	VBOOL,	0,		(void*)&bell       },
-#if ST
+#if OS_ATARI
     {"mapslash",  "ms", VBOOL,	0,		(void*)&mapslash   },
 #endif
     {NULL}
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1982-1997 David L Parsons
+ * Copyright (c) 1982-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
     char cmd, c;
     int rp;		/* number of spaces to diddle */
     int	ts, ss;		/* tabs && spaces to insert */
-    register cp;	/* current position */
+    register int cp;	/* current position */
     int i;		/* random index */
     int	endd;		/* last open place */
-    register rsize;	/* size of upper buffer */
+    register int rsize;	/* size of upper buffer */
     int	currDLE = 0;	/* what DLE is now */
     int	len;		/* full insert size */
     bool Dflag;
 	}
 	if (autoindent)
 	    currDLE = findDLE(lstart, &i, skipws(lstart),0);
-	if (visual)
-#if VT52
+	if (visual) {
+#if TTY_VT52
 	    if (OL) {
 #else
 	    if (OL && (*yp) < LINES-2) {
 		mvcur(1+(*yp), 0);
 		strput(CE);
 	    }
+	}
 	mvcur(-1, currDLE);
     }
     else {
 	    strput(CE);				/* clear this line */
 	    println();
 	    if (visual) {
-#if RMX
+#if OS_RMX
 		/* at OL at bottom kludge... */
 		if (OL && (*yp) < LINES-2) {
 #else
 /*
  * LEVEE, or Captain Video;  A vi clone
  *
- * Copyright (c) 1980-1997 David L Parsons
+ * Copyright (c) 1980-2007 David L Parsons
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, without or
 #ifndef LEVEE_D
 
 #define LEVEE_D
-#define	TOUPPER_FTN	/* defined if the libraries support toupper as */
-			/* a function call */
+
+#include "config.h"
 
 #ifndef TRUE
 #define	TRUE	(1)	/* Nobody defines TRUE & FALSE, so I will do */
 
 /*
  * Compilation defines for different systems.
- * Choose only one from each group.
  */
-/* system you are compiling Levee on */
-#define ST	0
-#define RMX	0
-#define UNIX	1
-#define MSDOS	0
-#define	FLEXOS	0
 
-/* do your libraries follow system V standards? */
-#define SYS5	1
-
-/* what sort of terminal are you emulating? */
-#define TERMCAP	1		/* use termcap to get terminal information */
-#define TERMCAP_EMULATION 0	/* use our own termcap? */
-#define VT52	0		/* this must be nonzero for the Atari ST */
-#define ZTERM	0		/* fast nonportable x86 terminal */
-#define ANSI	0		/* ANSI.SYS PC terminal */
-
-#if ST
+#if OS_ATARI
 
 #include <stdio.h>
 
 extern char *malloc();
 extern long gemdos();
 
-#endif /*ST*/
+#endif /*OS_ATARI*/
 
-#if RMX
+#if OS_RMX
 #include <:inc:stdio.h>
 #include <:inc:udi.h>
 
 
 #define zwrite(p,s)	write(1,(p), (unsigned)(s))
 
-#endif /*RMX*/
+#endif /*OS_RMX*/
 
-#if MSDOS
+#if OS_DOS
 
 #include <stdio.h>
 #include <fcntl.h>
 
 #include "proto.h"
 
-#endif /*MSDOS*/
+#endif /*OS_DOS*/
 
-#if UNIX
+#if OS_UNIX