10 Commits
0.1.2 ... 0.2.2

Author SHA1 Message Date
Joachim Nilsson
62e900a061 Change rl_complete() and rl_list_possib() to be function pointers instead.
This is a much cleaner design and also works with or without the configure
--enable-default-complete option.

See the examples for details.
2008-10-02 09:09:09 +02:00
Joachim Nilsson
5c9f0047bb Basic support for custom completion handlers with the two "standard"
rl_complete() and rl_list_possib().  Simply leave out complete.o from
the default build and in all programs require these two functions to
be supplied.

A better alternative would be to use function pointers and check those
for NULL in the running code.  With this code, and no completion handler
the editline code will die.
2008-10-02 01:52:40 +02:00
Joachim Nilsson
4a3fbd9187 Add note on custom completion support. 2008-08-10 21:50:00 +02:00
Joachim Nilsson
05f4234310 Update reminder of adding support for escape sequences. 2008-06-10 07:29:06 +02:00
Joachim Nilsson
b935808b7d Minix editline v0.2.1
=====================

Fix Debian batch mode reader, read_redirected(), which is activated
when input comes from a file rather than a tty.  

The implementation of read_redirected() did not support lines longer
than 64 chars.  It tried to realloc(), but goofed up and instead
truncated all the first 64 chars.  The result was that each read
line only contained the reminder of a a division with 64... :-)
2008-06-09 22:55:13 +02:00
Joachim Nilsson
64cc1b5325 Minix editline v0.2.0
=====================

This marks the inclusion of the first set of Debian patches
and a fully working testit on an ARM Xscale target machine.
2008-06-09 21:40:41 +02:00
Joachim Nilsson
f7b2ea938d Check for tcgetattr() to enable HAVE_TCGETATTR in sysunix.c this seems
to work better on embedded targets running off the initial console.

Also, first merge of patches from Debian.  This part holds all of the
sysunix.c changes and some 8-bit patches and SIGSTP patches in the
editline.c file.
2008-06-09 21:37:01 +02:00
Joachim Nilsson
9a94fc9d4d Minix editline v0.1.4
=====================

Last bugfix of include/editline.h did the trick -- now it's all good!
2008-06-09 00:36:59 +02:00
Joachim Nilsson
cab8f18472 Fix return type of rl_reset_terminal() 2008-06-09 00:30:45 +02:00
Joachim Nilsson
06a7f578d5 Minix editline v0.1.3
=====================

Fix another build warning for Arm cross-gcc, which actually was v4.1.2
This time getpid() was missing unistd.h, but kill() was also missing 
signal.h.  Added test for signal.h, but left out unistd.h since we
already define SYS_UNIX -- which we should really check for instead...

The rest are cosmetic prototype or automake/autoconf fixes.
2008-06-09 00:17:48 +02:00
19 changed files with 361 additions and 64 deletions

8
TODO
View File

@@ -4,3 +4,11 @@ TODO
* Add --enable-FEATURE for features defined in Makefile-minix.in
* Add support for custom completion, rl_attempted_completion_function.
* Add support for inhibiting completion: rl_inhibit_completion
* Add support for arrow keys, home, end, etc. See the following URL
for how to catch complex key strokes such as escape sequences:
http://www.unixwiz.net/techtips/termios-vmin-vtime.html

View File

@@ -22,6 +22,9 @@
/* Define to 1 if you have the <sgtty.h> header file. */
#undef HAVE_SGTTY_H
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
@@ -61,6 +64,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `tcgetattr' function. */
#undef HAVE_TCGETATTR
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H

69
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for Minix editline 0.1.2.
# Generated by GNU Autoconf 2.61 for Minix editline 0.2.2.
#
# Report bugs to <joachim@vmlinux.org>.
#
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='Minix editline'
PACKAGE_TARNAME='minix-editline'
PACKAGE_VERSION='0.1.2'
PACKAGE_STRING='Minix editline 0.1.2'
PACKAGE_VERSION='0.2.2'
PACKAGE_STRING='Minix editline 0.2.2'
PACKAGE_BUGREPORT='joachim@vmlinux.org'
ac_unique_file="src/editline.c"
@@ -695,6 +695,8 @@ CPP
GREP
EGREP
LIBOBJS
COMPLETE_TRUE
COMPLETE_FALSE
LTLIBOBJS'
ac_subst_files=''
ac_precious_vars='build_alias
@@ -1208,7 +1210,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures Minix editline 0.1.2 to adapt to many kinds of systems.
\`configure' configures Minix editline 0.2.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1274,7 +1276,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of Minix editline 0.1.2:";;
short | recursive ) echo "Configuration of Minix editline 0.2.2:";;
esac
cat <<\_ACEOF
@@ -1283,6 +1285,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--enable-default-complete Enable default completion handler.
Some influential environment variables:
CC C compiler command
@@ -1358,7 +1361,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
Minix editline configure 0.1.2
Minix editline configure 0.2.2
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1372,7 +1375,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by Minix editline $as_me 0.1.2, which was
It was created by Minix editline $as_me 0.2.2, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -2067,7 +2070,7 @@ fi
# Define the identity of the package.
PACKAGE='minix-editline'
VERSION='0.1.2'
VERSION='0.2.2'
cat >>confdefs.h <<_ACEOF
@@ -4290,7 +4293,8 @@ done
for ac_header in malloc.h sgtty.h stdlib.h string.h termio.h termios.h
for ac_header in malloc.h signal.h sgtty.h stdlib.h string.h termio.h termios.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -4874,7 +4878,8 @@ fi
for ac_func in strchr strdup strrchr
for ac_func in strchr strdup strrchr tcgetattr
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -4968,6 +4973,35 @@ fi
done
# Check whether --enable-default-complete was given.
if test "${enable_default_complete+set}" = set; then
enableval=$enable_default_complete;
case "${enableval}" in
yes)
complete=true
;;
no)
complete=false
;;
*)
{ { echo "$as_me:$LINENO: error: bad value ${enableval} for --enable-default-complete" >&5
echo "$as_me: error: bad value ${enableval} for --enable-default-complete" >&2;}
{ (exit 1); exit 1; }; }
;;
esac
else
complete=false
fi
if test x$complete = xtrue; then
COMPLETE_TRUE=
COMPLETE_FALSE='#'
else
COMPLETE_TRUE='#'
COMPLETE_FALSE=
fi
ac_config_files="$ac_config_files Makefile src/Makefile include/Makefile man/Makefile examples/Makefile"
cat >confcache <<\_ACEOF
@@ -5080,6 +5114,13 @@ echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "${COMPLETE_TRUE}" && test -z "${COMPLETE_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"COMPLETE\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
echo "$as_me: error: conditional \"COMPLETE\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
@@ -5380,7 +5421,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by Minix editline $as_me 0.1.2, which was
This file was extended by Minix editline $as_me 0.2.2, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5433,7 +5474,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
Minix editline config.status 0.1.2
Minix editline config.status 0.2.2
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -5696,10 +5737,12 @@ CPP!$CPP$ac_delim
GREP!$GREP$ac_delim
EGREP!$EGREP$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
COMPLETE_TRUE!$COMPLETE_TRUE$ac_delim
COMPLETE_FALSE!$COMPLETE_FALSE$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 81; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 83; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(Minix editline, 0.1.2, joachim@vmlinux.org)
AC_INIT(Minix editline, 0.2.2, joachim@vmlinux.org)
AC_CONFIG_SRCDIR([src/editline.c])
AC_CONFIG_HEADER([config.h])
@@ -20,7 +20,7 @@ AC_HEADER_DIRENT
AC_HEADER_STDC
# Check for malloc.h instead of AC_FUNC_MALLOC/REALLOC AIX and others
# mess up the traditional malloc check.
AC_CHECK_HEADERS([malloc.h sgtty.h stdlib.h string.h termio.h termios.h])
AC_CHECK_HEADERS([malloc.h signal.h sgtty.h stdlib.h string.h termio.h termios.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
@@ -38,6 +38,21 @@ AC_PROG_GCC_TRADITIONAL
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([strchr strdup strrchr])
AC_CHECK_FUNCS([strchr strdup strrchr tcgetattr])
AC_ARG_ENABLE([default-complete],
[ --enable-default-complete Enable default completion handler.],[
case "${enableval}" in
yes)
complete=true
;;
no)
complete=false
;;
*)
AC_MSG_ERROR([bad value ${enableval} for --enable-default-complete])
;;
esac],[complete=false])
AM_CONDITIONAL([COMPLETE], [test x$complete = xtrue])
AC_OUTPUT(Makefile src/Makefile include/Makefile man/Makefile examples/Makefile)

View File

@@ -1,8 +1,7 @@
AUTOMAKE_OPTIONS = foreign
LDADD = $(top_builddir)/src/libedit.a
AM_CFLAGS = -I$(top_srcdir)/src
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
# TODO: Port "fileman" example from BSD editline
noinst_PROGRAMS = testit
testit_SOURCES = testit.c
#fileman_SOURCES = fileman.c
noinst_PROGRAMS = testit cli

View File

@@ -30,7 +30,7 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
noinst_PROGRAMS = testit$(EXEEXT)
noinst_PROGRAMS = testit$(EXEEXT) cli$(EXEEXT)
subdir = examples
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -41,8 +41,12 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(noinst_PROGRAMS)
am_testit_OBJECTS = testit.$(OBJEXT)
testit_OBJECTS = $(am_testit_OBJECTS)
cli_SOURCES = cli.c
cli_OBJECTS = cli.$(OBJEXT)
cli_LDADD = $(LDADD)
cli_DEPENDENCIES = $(top_builddir)/src/libedit.a
testit_SOURCES = testit.c
testit_OBJECTS = testit.$(OBJEXT)
testit_LDADD = $(LDADD)
testit_DEPENDENCIES = $(top_builddir)/src/libedit.a
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -52,8 +56,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(testit_SOURCES)
DIST_SOURCES = $(testit_SOURCES)
SOURCES = cli.c testit.c
DIST_SOURCES = cli.c testit.c
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -142,9 +146,9 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
LDADD = $(top_builddir)/src/libedit.a
AM_CFLAGS = -I$(top_srcdir)/src
testit_SOURCES = testit.c
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
all: all-am
.SUFFIXES:
@@ -158,9 +162,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu examples/Makefile
$(AUTOMAKE) --foreign examples/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -181,6 +185,9 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
clean-noinstPROGRAMS:
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
cli$(EXEEXT): $(cli_OBJECTS) $(cli_DEPENDENCIES)
@rm -f cli$(EXEEXT)
$(LINK) $(cli_OBJECTS) $(cli_LDADD) $(LIBS)
testit$(EXEEXT): $(testit_OBJECTS) $(testit_DEPENDENCIES)
@rm -f testit$(EXEEXT)
$(LINK) $(testit_OBJECTS) $(testit_LDADD) $(LIBS)
@@ -191,6 +198,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cli.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testit.Po@am__quote@
.c.o:
@@ -380,7 +388,6 @@ uninstall-am:
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am
#fileman_SOURCES = fileman.c
# 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:

80
examples/cli.c Normal file
View File

@@ -0,0 +1,80 @@
/* Custom CLI command completion. */
#include "editline.h"
#include <string.h>
char *list[] = {
"foo ", "bar ", "bsd ", "cli ", "ls ", "cd ", "malloc ", "tee ", NULL
};
/*
** Attempt to complete the pathname, returning an allocated copy.
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
*/
char *my_rl_complete(char *token, int *match)
{
int i;
int index = -1;
int matchlen = 0;
int count = 0;
for (i = 0; list[i]; i++)
{
int partlen = strlen (token); /* Part of token */
if (!strncmp (list[i], token, partlen))
{
index = i;
matchlen = partlen;
count ++;
}
}
if (count == 1)
{
*match = 1;
return strdup (list[index] + matchlen);
}
return NULL;
}
/*
** Return all possible completions.
*/
int my_rl_list_possib(char *token, char ***av)
{
int i, num, total = 0;
char **copy;
for (num = 0; list[num]; num++)
;
copy = (char **) malloc (num * sizeof(char *));
for (i = 0; i < num; i++)
{
if (!strncmp (list[i], token, strlen (token)))
{
copy[total] = strdup (list[i]);
total ++;
}
}
*av = copy;
return total;
}
int main(int ac, char *av[])
{
char *line;
char *prompt = "cli> ";
/* Setup callbacks */
rl_complete = &my_rl_complete;
rl_list_possib = &my_rl_list_possib;
while ((line = readline(prompt)) != NULL) {
(void)printf("\t\t\t|%s|\n", line);
free(line);
}
return 0;
}

View File

@@ -1,2 +1,4 @@
AUTOMAKE_OPTIONS = foreign
library_includedir=$(includedir)
library_include_HEADERS = editline.h

View File

@@ -139,6 +139,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
library_includedir = $(includedir)
library_include_HEADERS = editline.h
all: all-am
@@ -153,9 +154,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu include/Makefile
$(AUTOMAKE) --foreign include/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \

View File

@@ -2,10 +2,15 @@
#ifndef __EDITLINE_H__
#define __EDITLINE_H__
/* Assign these to get command completion, see cli.c for
* example usage. */
char *(*rl_complete)(char *token, int *match);
int (*rl_list_possib)(char *token, char ***av);
/*
** For compatibility with FSF readline.
*/
extern rl_reset_terminal(char *p);
extern void rl_reset_terminal(char *p);
extern void rl_initialize(void);
extern char *readline(const char *prompt);

View File

@@ -1,2 +1,4 @@
AUTOMAKE_OPTIONS = foreign
man3_MANS = editline.3
dist_man_MANS = $(man3_MANS)

View File

@@ -131,6 +131,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
man3_MANS = editline.3
dist_man_MANS = $(man3_MANS)
all: all-am
@@ -145,9 +146,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu man/Makefile
$(AUTOMAKE) --foreign man/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \

View File

@@ -1,4 +1,10 @@
AUTOMAKE_OPTIONS = foreign
lib_LIBRARIES = libedit.a
libedit_a_SOURCES = editline.c editline.h complete.c sysunix.c unix.h
libedit_a_SOURCES = editline.c editline.h sysunix.c unix.h
if COMPLETE
# Built-in completion handler.
libedit_a_SOURCES += complete.c
AM_CPPFLAGS = -DCOMPLETE
endif

View File

@@ -30,6 +30,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
# Built-in completion handler.
@COMPLETE_TRUE@am__append_1 = complete.c
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -52,8 +54,11 @@ AR = ar
ARFLAGS = cru
libedit_a_AR = $(AR) $(ARFLAGS)
libedit_a_LIBADD =
am_libedit_a_OBJECTS = editline.$(OBJEXT) complete.$(OBJEXT) \
sysunix.$(OBJEXT)
am__libedit_a_SOURCES_DIST = editline.c editline.h sysunix.c unix.h \
complete.c
@COMPLETE_TRUE@am__objects_1 = complete.$(OBJEXT)
am_libedit_a_OBJECTS = editline.$(OBJEXT) sysunix.$(OBJEXT) \
$(am__objects_1)
libedit_a_OBJECTS = $(am_libedit_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -63,7 +68,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libedit_a_SOURCES)
DIST_SOURCES = $(libedit_a_SOURCES)
DIST_SOURCES = $(am__libedit_a_SOURCES_DIST)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -152,8 +157,11 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
lib_LIBRARIES = libedit.a
libedit_a_SOURCES = editline.c editline.h complete.c sysunix.c unix.h
libedit_a_SOURCES = editline.c editline.h sysunix.c unix.h \
$(am__append_1)
@COMPLETE_TRUE@AM_CPPFLAGS = -DCOMPLETE
all: all-am
.SUFFIXES:
@@ -167,9 +175,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
$(AUTOMAKE) --foreign src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \

View File

@@ -161,7 +161,7 @@ SplitPath(path, dirpart, filepart)
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
*/
char *
rl_complete(pathname, unique)
default_rl_complete(pathname, unique)
char *pathname;
int *unique;
{
@@ -233,7 +233,7 @@ rl_complete(pathname, unique)
** Return all possible completions.
*/
int
rl_list_possib(pathname, avp)
default_rl_list_possib(pathname, avp)
char *pathname;
char ***avp;
{

View File

@@ -20,6 +20,8 @@
#define META(x) ((x) | 0x80)
#define ISMETA(x) ((x) & 0x80)
#define UNMETA(x) ((x) & 0x7F)
#define MAPSIZE 33
#define METAMAPSIZE 17
#if !defined(HIST_SIZE)
#define HIST_SIZE 20
#endif /* !defined(HIST_SIZE) */
@@ -63,6 +65,9 @@ int rl_erase;
int rl_intr;
int rl_kill;
int rl_quit;
#if defined(DO_SIGTSTP)
int rl_susp;
#endif /* defined(DO_SIGTSTP) */
STATIC CHAR NIL[] = "";
STATIC CONST CHAR *Input = NIL;
@@ -80,8 +85,8 @@ STATIC int Point;
STATIC int PushBack;
STATIC int Pushed;
STATIC int Signal;
FORWARD KEYMAP Map[33];
FORWARD KEYMAP MetaMap[17];
FORWARD KEYMAP Map[MAPSIZE];
FORWARD KEYMAP MetaMap[METAMAPSIZE];
STATIC SIZE_T Length;
STATIC SIZE_T ScreenCount;
STATIC SIZE_T ScreenSize;
@@ -90,18 +95,22 @@ STATIC int TTYwidth;
STATIC int TTYrows;
/* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */
int rl_meta_chars = 0;
int rl_meta_chars = 1;
/* User definable callbacks. */
char *(*rl_complete)(char *token, int *match);
int (*rl_list_possib)(char *token, char ***av);
/*
** Declarations.
*/
STATIC CHAR *editinput();
extern int read();
extern int write();
#if defined(USE_TERMCAP)
extern char *getenv();
extern char *tgetstr();
extern int tgetent();
extern int tgetnum();
#endif /* defined(USE_TERMCAP) */
/*
@@ -119,7 +128,7 @@ TTYflush()
STATIC void
TTYput(c)
CHAR c;
CONST CHAR c;
{
Screen[ScreenCount] = c;
if (++ScreenCount >= ScreenSize - 1) {
@@ -864,12 +873,16 @@ emacs(c)
STATUS s;
KEYMAP *kp;
#if 0 /* Debian patch removes this to be able to handle 8-bit input */
/* This test makes it impossible to enter eight-bit characters when
* meta-char mode is enabled. */
OldPoint = Point;
if (rl_meta_chars && ISMETA(c)) {
Pushed = 1;
PushBack = UNMETA(c);
return meta();
}
#endif /* Debian patch removal. */
for (kp = Map; kp->Function; kp++)
if (kp->Key == c)
break;
@@ -884,7 +897,7 @@ STATIC STATUS
TTYspecial(c)
unsigned int c;
{
if (ISMETA(c))
if (rl_meta_chars && ISMETA(c))
return CSdispatch;
if (c == rl_erase || c == DEL)
@@ -907,6 +920,12 @@ TTYspecial(c)
Signal = SIGQUIT;
return CSeof;
}
#if defined(DO_SIGTSTP)
if (c == rl_susp) {
Signal = SIGTSTP;
return CSsignal;
}
#endif /* defined(DO_SIGTSTP) */
return CSdispatch;
}
@@ -973,6 +992,39 @@ hist_add(p)
H.Pos = H.Size - 1;
}
STATIC char *
read_redirected(void)
{
int size = MEM_INC;
char *p;
char *line;
char *end;
p = line = NEW(char, size);
end = p + size;
while (1) {
if (p == end) {
int oldpos = end - line;
size += MEM_INC;
p = RENEW(line, char, size);
end = p + size;
p += oldpos; /* Continue where we left off... */
}
if (read(0, p, 1) <= 0) {
/* Ignore "incomplete" lines at EOF, just like we do for a tty. */
free(line);
return NULL;
}
if (*p == '\n')
break;
p++;
}
*p = '\0';
return line;
}
/*
** For compatibility with FSF readline.
*/
@@ -986,6 +1038,20 @@ rl_reset_terminal(p)
void
rl_initialize(void)
{
#ifdef COMPLETE
int done = 0;
if (!done)
{
if (!rl_complete)
rl_complete = &default_rl_complete;
if (!rl_list_possib)
rl_list_possib = &default_rl_list_possib;
done = 1;
}
#endif
}
char *
@@ -995,6 +1061,14 @@ readline(prompt)
CHAR *line;
int s;
/* Unless called by the user already. */
rl_initialize ();
if (!isatty(0)) {
TTYflush();
return read_redirected();
}
if (Line == NULL) {
Length = MEM_INC;
if ((Line = NEW(CHAR, Length)) == NULL)
@@ -1119,12 +1193,16 @@ find_word()
}
STATIC STATUS
c_possible()
c_possible(void)
{
CHAR **av;
CHAR *word;
int ac;
if (!rl_list_possib) {
return ring_bell();
}
word = find_word();
ac = rl_list_possib((char *)word, (char ***)&av);
if (word)
@@ -1140,7 +1218,7 @@ c_possible()
}
STATIC STATUS
c_complete()
c_complete(void)
{
CHAR *p, *q;
CHAR *word, *new;
@@ -1148,6 +1226,10 @@ c_complete()
int unique;
STATUS s;
if (!rl_complete) {
return ring_bell();
}
word = find_word();
p = (CHAR *)rl_complete((char *)word, &unique);
if (word)

View File

@@ -2,6 +2,9 @@
**
** Internal header file for editline library.
*/
#ifndef __PRIVATE_EDITLINE_H__
#define __PRIVATE_EDITLINE_H__
#include <config.h>
#include <stdio.h>
#ifdef HAVE_MALLOC_H
@@ -16,6 +19,9 @@
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef SYS_UNIX
#include "unix.h"
#endif /* defined(SYS_UNIX) */
@@ -64,8 +70,13 @@ extern int rl_erase;
extern int rl_intr;
extern int rl_kill;
extern int rl_quit;
extern char *rl_complete();
extern int rl_list_possib();
#if defined(DO_SIGTSTP)
extern int rl_susp;
#endif /* defined(DO_SIGTSTP) */
#ifdef COMPLETE
extern char *default_rl_complete();
extern int default_rl_list_possib(char *pathname, char ***avp);
#endif
extern void rl_ttyset();
extern void rl_add_slash();
@@ -78,6 +89,7 @@ extern char *strcat();
extern char *strchr();
extern char *strrchr();
extern char *strcpy();
extern char *strdup();
extern int strcmp();
extern int strlen();
extern int strncmp();
@@ -86,3 +98,6 @@ extern int strncmp();
#if defined(NEED_STRDUP)
extern char *strdup();
#endif
#include "../include/editline.h"
#endif /* __PRIVATE_EDITLINE_H__ */

View File

@@ -15,19 +15,22 @@ rl_ttyset(Reset)
struct termios new;
if (Reset == 0) {
(void)tcgetattr(0, &old);
if (tcgetattr(0, &old) < 0) perror("tcgetattr");
rl_erase = old.c_cc[VERASE];
rl_kill = old.c_cc[VKILL];
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
#if defined(DO_SIGTSTP)
rl_susp = old.c_cc[VSUSP];
#endif /* defined(DO_SIGTSTP) */
new = old;
new.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
new.c_iflag &= ~(ICRNL);
new.c_lflag &= ~(ECHO | ICANON | ISIG);
new.c_iflag &= ~(ISTRIP | INPCK);
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
(void)tcsetattr(0, TCSADRAIN, &new);
if (tcsetattr(0, TCSADRAIN, &new) < 0) perror("tcsetattr");
}
else
(void)tcsetattr(0, TCSADRAIN, &old);
@@ -51,11 +54,13 @@ rl_ttyset(Reset)
rl_eof = old.c_cc[VEOF];
rl_intr = old.c_cc[VINTR];
rl_quit = old.c_cc[VQUIT];
#if defined(DO_SIGTSTP)
rl_susp = old.c_cc[VSUSP];
#endif /* defined(DO_SIGTSTP) */
new = old;
new.c_cc[VINTR] = -1;
new.c_cc[VQUIT] = -1;
new.c_lflag &= ~(ECHO | ICANON);
new.c_lflag &= ~(ECHO | ICANON | ISIG);
new.c_iflag &= ~(ISTRIP | INPCK);
new.c_cc[VMIN] = 1;
new.c_cc[VTIME] = 0;
(void)ioctl(0, TCSETAW, &new);
@@ -75,6 +80,9 @@ rl_ttyset(Reset)
static struct tchars old_tchars;
struct sgttyb new_sgttyb;
struct tchars new_tchars;
#if defined(DO_SIGTSTP)
struct ltchars old_ltchars;
#endif /* defined(DO_SIGTSTP) */
if (Reset == 0) {
(void)ioctl(0, TIOCGETP, &old_sgttyb);
@@ -86,9 +94,17 @@ rl_ttyset(Reset)
rl_intr = old_tchars.t_intrc;
rl_quit = old_tchars.t_quitc;
#if defined(DO_SIGTSTP)
(void)ioctl(0, TIOCGLTC, &old_ltchars);
rl_susp = old_ltchars.t_suspc;
#endif /* defined(DO_SIGTSTP) */
new_sgttyb = old_sgttyb;
new_sgttyb.sg_flags &= ~ECHO;
new_sgttyb.sg_flags |= RAW;
#if defined(PASS8)
new_sgttyb.sg_flags |= PASS8;
#endif /* defined(PASS8) */
(void)ioctl(0, TIOCSETP, &new_sgttyb);
new_tchars = old_tchars;

View File

@@ -8,6 +8,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#if defined(USE_DIRENT)
#include <dirent.h>