mirror of
https://github.com/troglobit/editline.git
synced 2025-09-18 02:08:08 +08:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5b27b6ce4f | ||
![]() |
e828182cb0 | ||
![]() |
c1b3d17926 | ||
![]() |
69e01d11d4 | ||
![]() |
4898413730 | ||
![]() |
b1e74f3de2 | ||
![]() |
6d8d857dd4 | ||
![]() |
77d483da02 | ||
![]() |
62e900a061 | ||
![]() |
5c9f0047bb | ||
![]() |
4a3fbd9187 | ||
![]() |
05f4234310 | ||
![]() |
b935808b7d | ||
![]() |
64cc1b5325 | ||
![]() |
f7b2ea938d | ||
![]() |
9a94fc9d4d | ||
![]() |
cab8f18472 | ||
![]() |
06a7f578d5 |
16
.bzrignore
Normal file
16
.bzrignore
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Makefile
|
||||||
|
archive
|
||||||
|
autom4te.cache
|
||||||
|
config.h
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
stamp-h1
|
||||||
|
examples/.deps
|
||||||
|
examples/Makefile
|
||||||
|
examples/cli
|
||||||
|
examples/testit
|
||||||
|
man/Makefile
|
||||||
|
man/Makefile
|
||||||
|
include/Makefile
|
||||||
|
src/.deps
|
||||||
|
src/Makefile
|
@@ -32,7 +32,7 @@ POST_UNINSTALL = :
|
|||||||
subdir = .
|
subdir = .
|
||||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||||
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
|
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
|
||||||
$(top_srcdir)/configure TODO depcomp install-sh missing
|
$(top_srcdir)/configure NEWS TODO depcomp install-sh missing
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||||
|
9
NEWS
Normal file
9
NEWS
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Notable Changes
|
||||||
|
|
||||||
|
* v0.3.0
|
||||||
|
** Support for ANSI arrow keys using --enable-arrow-keys
|
||||||
|
|
||||||
|
* v0.2.x
|
||||||
|
** Patches from Debian package merged.
|
||||||
|
** Support for custom command completion.
|
||||||
|
|
3
TODO
3
TODO
@@ -1,6 +1,5 @@
|
|||||||
TODO
|
TODO
|
||||||
|
|
||||||
* Merge in useful patches from Debian package
|
|
||||||
|
|
||||||
* Add --enable-FEATURE for features defined in Makefile-minix.in
|
* Add --enable-FEATURE for features defined in Makefile-minix.in
|
||||||
|
* Add support for inhibiting completion: rl_inhibit_completion
|
||||||
|
|
||||||
|
12
config.h.in
12
config.h.in
@@ -1,5 +1,8 @@
|
|||||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
|
/* Define to include ANSI arrow keys support in minix-editline */
|
||||||
|
#undef ANSI_ARROWS
|
||||||
|
|
||||||
/* Define to 1 if the `closedir' function returns void instead of `int'. */
|
/* Define to 1 if the `closedir' function returns void instead of `int'. */
|
||||||
#undef CLOSEDIR_VOID
|
#undef CLOSEDIR_VOID
|
||||||
|
|
||||||
@@ -19,9 +22,15 @@
|
|||||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||||
#undef HAVE_NDIR_H
|
#undef HAVE_NDIR_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `perror' function. */
|
||||||
|
#undef HAVE_PERROR
|
||||||
|
|
||||||
/* Define to 1 if you have the <sgtty.h> header file. */
|
/* Define to 1 if you have the <sgtty.h> header file. */
|
||||||
#undef HAVE_SGTTY_H
|
#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
|
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||||
zero-length file name argument. */
|
zero-length file name argument. */
|
||||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||||
@@ -61,6 +70,9 @@
|
|||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
#undef HAVE_SYS_TYPES_H
|
#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. */
|
/* Define to 1 if you have the <termios.h> header file. */
|
||||||
#undef HAVE_TERMIOS_H
|
#undef HAVE_TERMIOS_H
|
||||||
|
|
||||||
|
89
configure
vendored
89
configure
vendored
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# 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.3.0.
|
||||||
#
|
#
|
||||||
# Report bugs to <joachim@vmlinux.org>.
|
# Report bugs to <joachim@vmlinux.org>.
|
||||||
#
|
#
|
||||||
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
|||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='Minix editline'
|
PACKAGE_NAME='Minix editline'
|
||||||
PACKAGE_TARNAME='minix-editline'
|
PACKAGE_TARNAME='minix-editline'
|
||||||
PACKAGE_VERSION='0.1.2'
|
PACKAGE_VERSION='0.3.0'
|
||||||
PACKAGE_STRING='Minix editline 0.1.2'
|
PACKAGE_STRING='Minix editline 0.3.0'
|
||||||
PACKAGE_BUGREPORT='joachim@vmlinux.org'
|
PACKAGE_BUGREPORT='joachim@vmlinux.org'
|
||||||
|
|
||||||
ac_unique_file="src/editline.c"
|
ac_unique_file="src/editline.c"
|
||||||
@@ -695,6 +695,8 @@ CPP
|
|||||||
GREP
|
GREP
|
||||||
EGREP
|
EGREP
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
|
COMPLETE_TRUE
|
||||||
|
COMPLETE_FALSE
|
||||||
LTLIBOBJS'
|
LTLIBOBJS'
|
||||||
ac_subst_files=''
|
ac_subst_files=''
|
||||||
ac_precious_vars='build_alias
|
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.
|
# 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.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures Minix editline 0.1.2 to adapt to many kinds of systems.
|
\`configure' configures Minix editline 0.3.0 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
@@ -1274,7 +1276,7 @@ fi
|
|||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of Minix editline 0.1.2:";;
|
short | recursive ) echo "Configuration of Minix editline 0.3.0:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
@@ -1283,6 +1285,8 @@ Optional Features:
|
|||||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||||
--disable-dependency-tracking speeds up one-time build
|
--disable-dependency-tracking speeds up one-time build
|
||||||
--enable-dependency-tracking do not reject slow dependency extractors
|
--enable-dependency-tracking do not reject slow dependency extractors
|
||||||
|
--enable-default-complete Enable default completion handler.
|
||||||
|
--enable-arrow-keys Enable ANSI arrow keys.
|
||||||
|
|
||||||
Some influential environment variables:
|
Some influential environment variables:
|
||||||
CC C compiler command
|
CC C compiler command
|
||||||
@@ -1358,7 +1362,7 @@ fi
|
|||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
Minix editline configure 0.1.2
|
Minix editline configure 0.3.0
|
||||||
generated by GNU Autoconf 2.61
|
generated by GNU Autoconf 2.61
|
||||||
|
|
||||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||||
@@ -1372,7 +1376,7 @@ cat >config.log <<_ACEOF
|
|||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
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.3.0, which was
|
||||||
generated by GNU Autoconf 2.61. Invocation command line was
|
generated by GNU Autoconf 2.61. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
@@ -2067,7 +2071,7 @@ fi
|
|||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE='minix-editline'
|
PACKAGE='minix-editline'
|
||||||
VERSION='0.1.2'
|
VERSION='0.3.0'
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
@@ -4290,7 +4294,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
|
do
|
||||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
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
|
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
|
||||||
@@ -4874,7 +4879,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in strchr strdup strrchr
|
|
||||||
|
|
||||||
|
for ac_func in strchr strdup strrchr tcgetattr perror
|
||||||
do
|
do
|
||||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
|
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||||
@@ -4968,6 +4975,52 @@ fi
|
|||||||
done
|
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_enable_arrow_keys=no
|
||||||
|
# Check whether --enable-arrow-keys was given.
|
||||||
|
if test "${enable_arrow_keys+set}" = set; then
|
||||||
|
enableval=$enable_arrow_keys; ac_enable_arrow_keys=$enableval
|
||||||
|
else
|
||||||
|
ac_enable_arrow_keys=no
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test "x${ac_enable_arrow_keys}" = xyes ; then
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define ANSI_ARROWS
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile src/Makefile include/Makefile man/Makefile examples/Makefile"
|
ac_config_files="$ac_config_files Makefile src/Makefile include/Makefile man/Makefile examples/Makefile"
|
||||||
|
|
||||||
cat >confcache <<\_ACEOF
|
cat >confcache <<\_ACEOF
|
||||||
@@ -5080,6 +5133,13 @@ echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
|
|||||||
Usually this means the macro was only invoked conditionally." >&2;}
|
Usually this means the macro was only invoked conditionally." >&2;}
|
||||||
{ (exit 1); exit 1; }; }
|
{ (exit 1); exit 1; }; }
|
||||||
fi
|
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}
|
: ${CONFIG_STATUS=./config.status}
|
||||||
ac_clean_files_save=$ac_clean_files
|
ac_clean_files_save=$ac_clean_files
|
||||||
@@ -5380,7 +5440,7 @@ exec 6>&1
|
|||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
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.3.0, which was
|
||||||
generated by GNU Autoconf 2.61. Invocation command line was
|
generated by GNU Autoconf 2.61. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
@@ -5433,7 +5493,7 @@ Report bugs to <bug-autoconf@gnu.org>."
|
|||||||
_ACEOF
|
_ACEOF
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF
|
cat >>$CONFIG_STATUS <<_ACEOF
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
Minix editline config.status 0.1.2
|
Minix editline config.status 0.3.0
|
||||||
configured by $0, generated by GNU Autoconf 2.61,
|
configured by $0, generated by GNU Autoconf 2.61,
|
||||||
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
||||||
|
|
||||||
@@ -5696,10 +5756,12 @@ CPP!$CPP$ac_delim
|
|||||||
GREP!$GREP$ac_delim
|
GREP!$GREP$ac_delim
|
||||||
EGREP!$EGREP$ac_delim
|
EGREP!$EGREP$ac_delim
|
||||||
LIBOBJS!$LIBOBJS$ac_delim
|
LIBOBJS!$LIBOBJS$ac_delim
|
||||||
|
COMPLETE_TRUE!$COMPLETE_TRUE$ac_delim
|
||||||
|
COMPLETE_FALSE!$COMPLETE_FALSE$ac_delim
|
||||||
LTLIBOBJS!$LTLIBOBJS$ac_delim
|
LTLIBOBJS!$LTLIBOBJS$ac_delim
|
||||||
_ACEOF
|
_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
|
break
|
||||||
elif $ac_last_try; then
|
elif $ac_last_try; then
|
||||||
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
|
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
|
||||||
@@ -6298,3 +6360,4 @@ if test "$no_create" != yes; then
|
|||||||
$ac_cs_success || { (exit 1); exit 1; }
|
$ac_cs_success || { (exit 1); exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
32
configure.ac
32
configure.ac
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.61)
|
AC_PREREQ(2.61)
|
||||||
AC_INIT(Minix editline, 0.1.2, joachim@vmlinux.org)
|
AC_INIT(Minix editline, 0.3.0, joachim@vmlinux.org)
|
||||||
AC_CONFIG_SRCDIR([src/editline.c])
|
AC_CONFIG_SRCDIR([src/editline.c])
|
||||||
AC_CONFIG_HEADER([config.h])
|
AC_CONFIG_HEADER([config.h])
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ AC_HEADER_DIRENT
|
|||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
# Check for malloc.h instead of AC_FUNC_MALLOC/REALLOC AIX and others
|
# Check for malloc.h instead of AC_FUNC_MALLOC/REALLOC AIX and others
|
||||||
# mess up the traditional malloc check.
|
# 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.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_HEADER_STAT
|
AC_HEADER_STAT
|
||||||
@@ -38,6 +38,32 @@ AC_PROG_GCC_TRADITIONAL
|
|||||||
#AC_FUNC_MALLOC
|
#AC_FUNC_MALLOC
|
||||||
#AC_FUNC_REALLOC
|
#AC_FUNC_REALLOC
|
||||||
AC_FUNC_STAT
|
AC_FUNC_STAT
|
||||||
AC_CHECK_FUNCS([strchr strdup strrchr])
|
AC_CHECK_FUNCS([strchr strdup strrchr tcgetattr perror])
|
||||||
|
|
||||||
|
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_enable_arrow_keys=no
|
||||||
|
AC_ARG_ENABLE(arrow-keys,
|
||||||
|
[ --enable-arrow-keys Enable ANSI arrow keys.],
|
||||||
|
[ ac_enable_arrow_keys=$enableval ], [ ac_enable_arrow_keys=no])
|
||||||
|
|
||||||
|
if test "x${ac_enable_arrow_keys}" = xyes ; then
|
||||||
|
AC_DEFINE([ANSI_ARROWS], [],
|
||||||
|
[Define to include ANSI arrow keys support in minix-editline])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_OUTPUT(Makefile src/Makefile include/Makefile man/Makefile examples/Makefile)
|
AC_OUTPUT(Makefile src/Makefile include/Makefile man/Makefile examples/Makefile)
|
||||||
|
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
LDADD = $(top_builddir)/src/libedit.a
|
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
|
# TODO: Port "fileman" example from BSD editline
|
||||||
noinst_PROGRAMS = testit
|
noinst_PROGRAMS = testit cli
|
||||||
|
|
||||||
testit_SOURCES = testit.c
|
|
||||||
#fileman_SOURCES = fileman.c
|
|
||||||
|
@@ -30,7 +30,7 @@ POST_INSTALL = :
|
|||||||
NORMAL_UNINSTALL = :
|
NORMAL_UNINSTALL = :
|
||||||
PRE_UNINSTALL = :
|
PRE_UNINSTALL = :
|
||||||
POST_UNINSTALL = :
|
POST_UNINSTALL = :
|
||||||
noinst_PROGRAMS = testit$(EXEEXT)
|
noinst_PROGRAMS = testit$(EXEEXT) cli$(EXEEXT)
|
||||||
subdir = examples
|
subdir = examples
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
@@ -41,8 +41,12 @@ mkinstalldirs = $(install_sh) -d
|
|||||||
CONFIG_HEADER = $(top_builddir)/config.h
|
CONFIG_HEADER = $(top_builddir)/config.h
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
PROGRAMS = $(noinst_PROGRAMS)
|
PROGRAMS = $(noinst_PROGRAMS)
|
||||||
am_testit_OBJECTS = testit.$(OBJEXT)
|
cli_SOURCES = cli.c
|
||||||
testit_OBJECTS = $(am_testit_OBJECTS)
|
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_LDADD = $(LDADD)
|
||||||
testit_DEPENDENCIES = $(top_builddir)/src/libedit.a
|
testit_DEPENDENCIES = $(top_builddir)/src/libedit.a
|
||||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||||
@@ -52,8 +56,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
|||||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
CCLD = $(CC)
|
CCLD = $(CC)
|
||||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
SOURCES = $(testit_SOURCES)
|
SOURCES = cli.c testit.c
|
||||||
DIST_SOURCES = $(testit_SOURCES)
|
DIST_SOURCES = cli.c testit.c
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
CTAGS = ctags
|
CTAGS = ctags
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
@@ -142,9 +146,9 @@ sysconfdir = @sysconfdir@
|
|||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
LDADD = $(top_builddir)/src/libedit.a
|
LDADD = $(top_builddir)/src/libedit.a
|
||||||
AM_CFLAGS = -I$(top_srcdir)/src
|
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include
|
||||||
testit_SOURCES = testit.c
|
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@@ -158,9 +162,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||||||
exit 1;; \
|
exit 1;; \
|
||||||
esac; \
|
esac; \
|
||||||
done; \
|
done; \
|
||||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
|
||||||
cd $(top_srcdir) && \
|
cd $(top_srcdir) && \
|
||||||
$(AUTOMAKE) --gnu examples/Makefile
|
$(AUTOMAKE) --foreign examples/Makefile
|
||||||
.PRECIOUS: Makefile
|
.PRECIOUS: Makefile
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@case '$?' in \
|
@case '$?' in \
|
||||||
@@ -181,6 +185,9 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
|||||||
|
|
||||||
clean-noinstPROGRAMS:
|
clean-noinstPROGRAMS:
|
||||||
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
|
-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)
|
testit$(EXEEXT): $(testit_OBJECTS) $(testit_DEPENDENCIES)
|
||||||
@rm -f testit$(EXEEXT)
|
@rm -f testit$(EXEEXT)
|
||||||
$(LINK) $(testit_OBJECTS) $(testit_LDADD) $(LIBS)
|
$(LINK) $(testit_OBJECTS) $(testit_LDADD) $(LIBS)
|
||||||
@@ -191,6 +198,7 @@ mostlyclean-compile:
|
|||||||
distclean-compile:
|
distclean-compile:
|
||||||
-rm -f *.tab.c
|
-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@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testit.Po@am__quote@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@@ -380,7 +388,6 @@ uninstall-am:
|
|||||||
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
||||||
uninstall-am
|
uninstall-am
|
||||||
|
|
||||||
#fileman_SOURCES = fileman.c
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
# 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.
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
.NOEXPORT:
|
.NOEXPORT:
|
||||||
|
80
examples/cli.c
Normal file
80
examples/cli.c
Normal 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 __attribute__ ((unused)), char *av[] __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
@@ -3,25 +3,35 @@
|
|||||||
** A "micro-shell" to test editline library.
|
** A "micro-shell" to test editline library.
|
||||||
** If given any arguments, commands aren't executed.
|
** If given any arguments, commands aren't executed.
|
||||||
*/
|
*/
|
||||||
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(HAVE_STDLIB)
|
#if defined(HAVE_STDLIB_H)
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif /* defined(HAVE_STDLIB) */
|
#endif
|
||||||
|
#if defined(HAVE_STRING_H)
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_UNISTD_H)
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char *readline();
|
extern char *readline();
|
||||||
extern void add_history();
|
extern void add_history();
|
||||||
|
|
||||||
#if !defined(HAVE_STDLIB)
|
#if !defined(HAVE_STDLIB_H)
|
||||||
extern int chdir();
|
|
||||||
extern int free();
|
extern int free();
|
||||||
extern int strncmp();
|
|
||||||
extern int system();
|
extern int system();
|
||||||
extern void exit();
|
extern void exit();
|
||||||
extern char *getenv();
|
extern char *getenv();
|
||||||
#endif /* !defined(HAVE_STDLIB) */
|
#endif /* !defined(HAVE_STDLIB) */
|
||||||
|
#if !defined(HAVE_STRING_H)
|
||||||
|
extern int strncmp();
|
||||||
|
#endif
|
||||||
|
#if !defined(HAVE_UNISTD_H)
|
||||||
|
extern int chdir();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_PERROR)
|
||||||
#if defined(NEED_PERROR)
|
|
||||||
void
|
void
|
||||||
perror(s)
|
perror(s)
|
||||||
char *s;
|
char *s;
|
||||||
@@ -37,7 +47,7 @@ perror(s)
|
|||||||
int
|
int
|
||||||
main(ac, av)
|
main(ac, av)
|
||||||
int ac;
|
int ac;
|
||||||
char *av[];
|
char *av[] __attribute__ ((unused));
|
||||||
{
|
{
|
||||||
char *prompt;
|
char *prompt;
|
||||||
char *p;
|
char *p;
|
||||||
@@ -45,7 +55,7 @@ main(ac, av)
|
|||||||
|
|
||||||
doit = ac == 1;
|
doit = ac == 1;
|
||||||
if ((prompt = getenv("TESTPROMPT")) == NULL)
|
if ((prompt = getenv("TESTPROMPT")) == NULL)
|
||||||
prompt = "testit> ";
|
prompt = "testit> ";
|
||||||
|
|
||||||
while ((p = readline(prompt)) != NULL) {
|
while ((p = readline(prompt)) != NULL) {
|
||||||
(void)printf("\t\t\t|%s|\n", p);
|
(void)printf("\t\t\t|%s|\n", p);
|
||||||
|
@@ -1,2 +1,4 @@
|
|||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
library_includedir=$(includedir)
|
library_includedir=$(includedir)
|
||||||
library_include_HEADERS = editline.h
|
library_include_HEADERS = editline.h
|
||||||
|
@@ -139,6 +139,7 @@ sysconfdir = @sysconfdir@
|
|||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
library_includedir = $(includedir)
|
library_includedir = $(includedir)
|
||||||
library_include_HEADERS = editline.h
|
library_include_HEADERS = editline.h
|
||||||
all: all-am
|
all: all-am
|
||||||
@@ -153,9 +154,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||||||
exit 1;; \
|
exit 1;; \
|
||||||
esac; \
|
esac; \
|
||||||
done; \
|
done; \
|
||||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
|
||||||
cd $(top_srcdir) && \
|
cd $(top_srcdir) && \
|
||||||
$(AUTOMAKE) --gnu include/Makefile
|
$(AUTOMAKE) --foreign include/Makefile
|
||||||
.PRECIOUS: Makefile
|
.PRECIOUS: Makefile
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@case '$?' in \
|
@case '$?' in \
|
||||||
|
@@ -2,10 +2,15 @@
|
|||||||
#ifndef __EDITLINE_H__
|
#ifndef __EDITLINE_H__
|
||||||
#define __EDITLINE_H__
|
#define __EDITLINE_H__
|
||||||
|
|
||||||
|
/* Assign these to get command completion, see cli.c for
|
||||||
|
* example usage. */
|
||||||
|
extern char *(*rl_complete)(char *token, int *match);
|
||||||
|
extern int (*rl_list_possib)(char *token, char ***av);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** For compatibility with FSF readline.
|
** For compatibility with FSF readline.
|
||||||
*/
|
*/
|
||||||
extern rl_reset_terminal(char *p);
|
extern void rl_reset_terminal(char *p);
|
||||||
extern void rl_initialize(void);
|
extern void rl_initialize(void);
|
||||||
|
|
||||||
extern char *readline(const char *prompt);
|
extern char *readline(const char *prompt);
|
||||||
|
@@ -1,2 +1,4 @@
|
|||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
man3_MANS = editline.3
|
man3_MANS = editline.3
|
||||||
dist_man_MANS = $(man3_MANS)
|
dist_man_MANS = $(man3_MANS)
|
||||||
|
@@ -131,6 +131,7 @@ sysconfdir = @sysconfdir@
|
|||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
man3_MANS = editline.3
|
man3_MANS = editline.3
|
||||||
dist_man_MANS = $(man3_MANS)
|
dist_man_MANS = $(man3_MANS)
|
||||||
all: all-am
|
all: all-am
|
||||||
@@ -145,9 +146,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||||||
exit 1;; \
|
exit 1;; \
|
||||||
esac; \
|
esac; \
|
||||||
done; \
|
done; \
|
||||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
|
||||||
cd $(top_srcdir) && \
|
cd $(top_srcdir) && \
|
||||||
$(AUTOMAKE) --gnu man/Makefile
|
$(AUTOMAKE) --foreign man/Makefile
|
||||||
.PRECIOUS: Makefile
|
.PRECIOUS: Makefile
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@case '$?' in \
|
@case '$?' in \
|
||||||
|
@@ -1,4 +1,10 @@
|
|||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
lib_LIBRARIES = libedit.a
|
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
|
||||||
|
@@ -30,6 +30,8 @@ POST_INSTALL = :
|
|||||||
NORMAL_UNINSTALL = :
|
NORMAL_UNINSTALL = :
|
||||||
PRE_UNINSTALL = :
|
PRE_UNINSTALL = :
|
||||||
POST_UNINSTALL = :
|
POST_UNINSTALL = :
|
||||||
|
# Built-in completion handler.
|
||||||
|
@COMPLETE_TRUE@am__append_1 = complete.c
|
||||||
subdir = src
|
subdir = src
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
@@ -52,8 +54,11 @@ AR = ar
|
|||||||
ARFLAGS = cru
|
ARFLAGS = cru
|
||||||
libedit_a_AR = $(AR) $(ARFLAGS)
|
libedit_a_AR = $(AR) $(ARFLAGS)
|
||||||
libedit_a_LIBADD =
|
libedit_a_LIBADD =
|
||||||
am_libedit_a_OBJECTS = editline.$(OBJEXT) complete.$(OBJEXT) \
|
am__libedit_a_SOURCES_DIST = editline.c editline.h sysunix.c unix.h \
|
||||||
sysunix.$(OBJEXT)
|
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)
|
libedit_a_OBJECTS = $(am_libedit_a_OBJECTS)
|
||||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||||
@@ -63,7 +68,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
|||||||
CCLD = $(CC)
|
CCLD = $(CC)
|
||||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
SOURCES = $(libedit_a_SOURCES)
|
SOURCES = $(libedit_a_SOURCES)
|
||||||
DIST_SOURCES = $(libedit_a_SOURCES)
|
DIST_SOURCES = $(am__libedit_a_SOURCES_DIST)
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
CTAGS = ctags
|
CTAGS = ctags
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
@@ -152,8 +157,11 @@ sysconfdir = @sysconfdir@
|
|||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
lib_LIBRARIES = libedit.a
|
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
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@@ -167,9 +175,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||||||
exit 1;; \
|
exit 1;; \
|
||||||
esac; \
|
esac; \
|
||||||
done; \
|
done; \
|
||||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
|
||||||
cd $(top_srcdir) && \
|
cd $(top_srcdir) && \
|
||||||
$(AUTOMAKE) --gnu src/Makefile
|
$(AUTOMAKE) --foreign src/Makefile
|
||||||
.PRECIOUS: Makefile
|
.PRECIOUS: Makefile
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@case '$?' in \
|
@case '$?' in \
|
||||||
|
280
src/complete.c
280
src/complete.c
@@ -5,35 +5,31 @@
|
|||||||
#include "editline.h"
|
#include "editline.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(NEED_STRDUP)
|
#if defined(NEED_STRDUP)
|
||||||
/*
|
/*
|
||||||
** Return an allocated copy of a string.
|
** Return an allocated copy of a string.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
strdup(p)
|
strdup(p)
|
||||||
char *p;
|
char *p;
|
||||||
{
|
{
|
||||||
char *new;
|
char *new;
|
||||||
|
|
||||||
if ((new = NEW(char, strlen(p) + 1)) != NULL)
|
if ((new = NEW(char, strlen(p) + 1)) != NULL)
|
||||||
(void)strcpy(new, p);
|
(void)strcpy(new, p);
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
#endif /* defined(NEED_STRDUP) */
|
#endif /* defined(NEED_STRDUP) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** strcmp-like sorting predicate for qsort.
|
** strcmp-like sorting predicate for qsort.
|
||||||
*/
|
*/
|
||||||
STATIC int
|
static int
|
||||||
compare(p1, p2)
|
compare(void *p1, void *p2)
|
||||||
CONST void *p1;
|
|
||||||
CONST void *p2;
|
|
||||||
{
|
{
|
||||||
CONST char **v1;
|
char **v1 = (char **)p1;
|
||||||
CONST char **v2;
|
char **v2 = (char **)p2;
|
||||||
|
|
||||||
v1 = (CONST char **)p1;
|
|
||||||
v2 = (CONST char **)p2;
|
|
||||||
return strcmp(*v1, *v2);
|
return strcmp(*v1, *v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,25 +37,25 @@ compare(p1, p2)
|
|||||||
** Fill in *avp with an array of names that match file, up to its length.
|
** Fill in *avp with an array of names that match file, up to its length.
|
||||||
** Ignore . and .. .
|
** Ignore . and .. .
|
||||||
*/
|
*/
|
||||||
STATIC int
|
static int
|
||||||
FindMatches(dir, file, avp)
|
FindMatches(dir, file, avp)
|
||||||
char *dir;
|
char *dir;
|
||||||
char *file;
|
char *file;
|
||||||
char ***avp;
|
char ***avp;
|
||||||
{
|
{
|
||||||
char **av;
|
char **av;
|
||||||
char **new;
|
char **new;
|
||||||
char *p;
|
char *p;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
DIRENTRY *ep;
|
DIRENTRY *ep;
|
||||||
SIZE_T ac;
|
SIZE_T ac;
|
||||||
SIZE_T len;
|
SIZE_T len;
|
||||||
SIZE_T choices;
|
SIZE_T choices;
|
||||||
SIZE_T total;
|
SIZE_T total;
|
||||||
#define MAX_TOTAL (256 << sizeof(char *))
|
#define MAX_TOTAL (256 << sizeof(char *))
|
||||||
|
|
||||||
if ((dp = opendir(dir)) == NULL)
|
if ((dp = opendir(dir)) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
av = NULL;
|
av = NULL;
|
||||||
ac = 0;
|
ac = 0;
|
||||||
@@ -67,56 +63,56 @@ FindMatches(dir, file, avp)
|
|||||||
choices = 0;
|
choices = 0;
|
||||||
total = 0;
|
total = 0;
|
||||||
while ((ep = readdir(dp)) != NULL) {
|
while ((ep = readdir(dp)) != NULL) {
|
||||||
p = ep->d_name;
|
p = ep->d_name;
|
||||||
if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')))
|
if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')))
|
||||||
continue;
|
continue;
|
||||||
if (len && strncmp(p, file, len) != 0)
|
if (len && strncmp(p, file, len) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
choices++;
|
choices++;
|
||||||
if ((total += strlen(p)) > MAX_TOTAL) {
|
if ((total += strlen(p)) > MAX_TOTAL) {
|
||||||
/* This is a bit too much. */
|
/* This is a bit too much. */
|
||||||
while (ac > 0) DISPOSE(av[--ac]);
|
while (ac > 0) DISPOSE(av[--ac]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ac % MEM_INC) == 0) {
|
if ((ac % MEM_INC) == 0) {
|
||||||
if ((new = NEW(char*, ac + MEM_INC)) == NULL) {
|
if ((new = NEW(char*, ac + MEM_INC)) == NULL) {
|
||||||
total = 0;
|
total = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ac) {
|
if (ac) {
|
||||||
COPYFROMTO(new, av, ac * sizeof (char **));
|
COPYFROMTO(new, av, ac * sizeof (char **));
|
||||||
DISPOSE(av);
|
DISPOSE(av);
|
||||||
}
|
}
|
||||||
*avp = av = new;
|
*avp = av = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((av[ac] = strdup(p)) == NULL) {
|
if ((av[ac] = strdup(p)) == NULL) {
|
||||||
if (ac == 0)
|
if (ac == 0)
|
||||||
DISPOSE(av);
|
DISPOSE(av);
|
||||||
total = 0;
|
total = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ac++;
|
ac++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up and return. */
|
/* Clean up and return. */
|
||||||
(void)closedir(dp);
|
(void)closedir(dp);
|
||||||
if (total > MAX_TOTAL) {
|
if (total > MAX_TOTAL) {
|
||||||
char many[sizeof(total) * 3];
|
char many[sizeof(total) * 3];
|
||||||
p = many + sizeof(many);
|
p = many + sizeof(many);
|
||||||
*--p = '\0';
|
*--p = '\0';
|
||||||
while (choices > 0) {
|
while (choices > 0) {
|
||||||
*--p = '0' + choices % 10;
|
*--p = '0' + choices % 10;
|
||||||
choices /= 10;
|
choices /= 10;
|
||||||
}
|
}
|
||||||
while (p > many + sizeof(many) - 8) *--p = ' ';
|
while (p > many + sizeof(many) - 8) *--p = ' ';
|
||||||
if ((p = strdup(p)) != NULL) av[ac++] = p;
|
if ((p = strdup(p)) != NULL) av[ac++] = p;
|
||||||
if ((p = strdup("choices")) != NULL) av[ac++] = p;
|
if ((p = strdup("choices")) != NULL) av[ac++] = p;
|
||||||
} else {
|
} else {
|
||||||
if (ac)
|
if (ac)
|
||||||
qsort(av, ac, sizeof (char **), compare);
|
qsort(av, ac, sizeof (char **), compare);
|
||||||
}
|
}
|
||||||
return ac;
|
return ac;
|
||||||
}
|
}
|
||||||
@@ -124,32 +120,32 @@ FindMatches(dir, file, avp)
|
|||||||
/*
|
/*
|
||||||
** Split a pathname into allocated directory and trailing filename parts.
|
** Split a pathname into allocated directory and trailing filename parts.
|
||||||
*/
|
*/
|
||||||
STATIC int
|
static int
|
||||||
SplitPath(path, dirpart, filepart)
|
SplitPath(path, dirpart, filepart)
|
||||||
char *path;
|
char *path;
|
||||||
char **dirpart;
|
char **dirpart;
|
||||||
char **filepart;
|
char **filepart;
|
||||||
{
|
{
|
||||||
static char DOT[] = ".";
|
static char DOT[] = ".";
|
||||||
char *dpart;
|
char *dpart;
|
||||||
char *fpart;
|
char *fpart;
|
||||||
|
|
||||||
if ((fpart = strrchr(path, '/')) == NULL) {
|
if ((fpart = strrchr(path, '/')) == NULL) {
|
||||||
if ((dpart = strdup(DOT)) == NULL)
|
if ((dpart = strdup(DOT)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
if ((fpart = strdup(path)) == NULL) {
|
if ((fpart = strdup(path)) == NULL) {
|
||||||
DISPOSE(dpart);
|
DISPOSE(dpart);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((dpart = strdup(path)) == NULL)
|
if ((dpart = strdup(path)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
dpart[fpart - path + 1] = '\0';
|
dpart[fpart - path + 1] = '\0';
|
||||||
if ((fpart = strdup(++fpart)) == NULL) {
|
if ((fpart = strdup(++fpart)) == NULL) {
|
||||||
DISPOSE(dpart);
|
DISPOSE(dpart);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*dirpart = dpart;
|
*dirpart = dpart;
|
||||||
*filepart = fpart;
|
*filepart = fpart;
|
||||||
@@ -161,70 +157,70 @@ SplitPath(path, dirpart, filepart)
|
|||||||
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
|
** Fill in *unique if we completed it, or set it to 0 if ambiguous.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
rl_complete(pathname, unique)
|
default_rl_complete(pathname, unique)
|
||||||
char *pathname;
|
char *pathname;
|
||||||
int *unique;
|
int *unique;
|
||||||
{
|
{
|
||||||
char **av;
|
char **av;
|
||||||
char *dir;
|
char *dir;
|
||||||
char *file;
|
char *file;
|
||||||
char *new;
|
char *new;
|
||||||
char *p;
|
char *p;
|
||||||
SIZE_T ac;
|
SIZE_T ac;
|
||||||
SIZE_T end;
|
SIZE_T end;
|
||||||
SIZE_T i;
|
SIZE_T i;
|
||||||
SIZE_T j;
|
SIZE_T j;
|
||||||
SIZE_T len;
|
SIZE_T len;
|
||||||
|
|
||||||
if (SplitPath(pathname, &dir, &file) < 0)
|
if (SplitPath(pathname, &dir, &file) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((ac = FindMatches(dir, file, &av)) == 0) {
|
if ((ac = FindMatches(dir, file, &av)) == 0) {
|
||||||
DISPOSE(dir);
|
DISPOSE(dir);
|
||||||
DISPOSE(file);
|
DISPOSE(file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = NULL;
|
p = NULL;
|
||||||
len = strlen(file);
|
len = strlen(file);
|
||||||
if (ac == 1) {
|
if (ac == 1) {
|
||||||
/* Exactly one match -- finish it off. */
|
/* Exactly one match -- finish it off. */
|
||||||
*unique = 1;
|
*unique = 1;
|
||||||
j = strlen(av[0]) - len + 2;
|
j = strlen(av[0]) - len + 2;
|
||||||
if ((p = NEW(char, j + 1)) != NULL) {
|
if ((p = NEW(char, j + 1)) != NULL) {
|
||||||
COPYFROMTO(p, av[0] + len, j);
|
COPYFROMTO(p, av[0] + len, j);
|
||||||
if ((new = NEW(char, strlen(dir) + strlen(av[0]) + 2)) != NULL) {
|
if ((new = NEW(char, strlen(dir) + strlen(av[0]) + 2)) != NULL) {
|
||||||
(void)strcpy(new, dir);
|
(void)strcpy(new, dir);
|
||||||
(void)strcat(new, "/");
|
(void)strcat(new, "/");
|
||||||
(void)strcat(new, av[0]);
|
(void)strcat(new, av[0]);
|
||||||
rl_add_slash(new, p);
|
rl_add_slash(new, p);
|
||||||
DISPOSE(new);
|
DISPOSE(new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*unique = 0;
|
*unique = 0;
|
||||||
if (len) {
|
if (len) {
|
||||||
/* Find largest matching substring. */
|
/* Find largest matching substring. */
|
||||||
for (i = len, end = strlen(av[0]); i < end; i++)
|
for (i = len, end = strlen(av[0]); i < end; i++)
|
||||||
for (j = 1; j < ac; j++)
|
for (j = 1; j < ac; j++)
|
||||||
if (av[0][i] != av[j][i])
|
if (av[0][i] != av[j][i])
|
||||||
goto breakout;
|
goto breakout;
|
||||||
breakout:
|
breakout:
|
||||||
if (i > len) {
|
if (i > len) {
|
||||||
j = i - len + 1;
|
j = i - len + 1;
|
||||||
if ((p = NEW(char, j)) != NULL) {
|
if ((p = NEW(char, j)) != NULL) {
|
||||||
COPYFROMTO(p, av[0] + len, j);
|
COPYFROMTO(p, av[0] + len, j);
|
||||||
p[j - 1] = '\0';
|
p[j - 1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean up and return. */
|
/* Clean up and return. */
|
||||||
DISPOSE(dir);
|
DISPOSE(dir);
|
||||||
DISPOSE(file);
|
DISPOSE(file);
|
||||||
for (i = 0; i < ac; i++)
|
for (i = 0; i < ac; i++)
|
||||||
DISPOSE(av[i]);
|
DISPOSE(av[i]);
|
||||||
DISPOSE(av);
|
DISPOSE(av);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -233,16 +229,16 @@ rl_complete(pathname, unique)
|
|||||||
** Return all possible completions.
|
** Return all possible completions.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
rl_list_possib(pathname, avp)
|
default_rl_list_possib(pathname, avp)
|
||||||
char *pathname;
|
char *pathname;
|
||||||
char ***avp;
|
char ***avp;
|
||||||
{
|
{
|
||||||
char *dir;
|
char *dir;
|
||||||
char *file;
|
char *file;
|
||||||
int ac;
|
int ac;
|
||||||
|
|
||||||
if (SplitPath(pathname, &dir, &file) < 0)
|
if (SplitPath(pathname, &dir, &file) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
ac = FindMatches(dir, file, avp);
|
ac = FindMatches(dir, file, avp);
|
||||||
DISPOSE(dir);
|
DISPOSE(dir);
|
||||||
DISPOSE(file);
|
DISPOSE(file);
|
||||||
|
1620
src/editline.c
1620
src/editline.c
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,9 @@
|
|||||||
**
|
**
|
||||||
** Internal header file for editline library.
|
** Internal header file for editline library.
|
||||||
*/
|
*/
|
||||||
|
#ifndef __PRIVATE_EDITLINE_H__
|
||||||
|
#define __PRIVATE_EDITLINE_H__
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_MALLOC_H
|
#ifdef HAVE_MALLOC_H
|
||||||
@@ -16,6 +19,9 @@
|
|||||||
#ifdef HAVE_DIRENT_H
|
#ifdef HAVE_DIRENT_H
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SIGNAL_H
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#ifdef SYS_UNIX
|
#ifdef SYS_UNIX
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
#endif /* defined(SYS_UNIX) */
|
#endif /* defined(SYS_UNIX) */
|
||||||
@@ -29,21 +35,6 @@
|
|||||||
|
|
||||||
typedef unsigned char CHAR;
|
typedef unsigned char CHAR;
|
||||||
|
|
||||||
#if defined(HIDE)
|
|
||||||
#define STATIC static
|
|
||||||
#else
|
|
||||||
#define STATIC /* NULL */
|
|
||||||
#endif /* !defined(HIDE) */
|
|
||||||
|
|
||||||
#if !defined(CONST)
|
|
||||||
#if defined(__STDC__)
|
|
||||||
#define CONST const
|
|
||||||
#else
|
|
||||||
#define CONST
|
|
||||||
#endif /* defined(__STDC__) */
|
|
||||||
#endif /* !defined(CONST) */
|
|
||||||
|
|
||||||
|
|
||||||
#define MEM_INC 64
|
#define MEM_INC 64
|
||||||
#define SCREEN_INC 256
|
#define SCREEN_INC 256
|
||||||
|
|
||||||
@@ -64,8 +55,13 @@ extern int rl_erase;
|
|||||||
extern int rl_intr;
|
extern int rl_intr;
|
||||||
extern int rl_kill;
|
extern int rl_kill;
|
||||||
extern int rl_quit;
|
extern int rl_quit;
|
||||||
extern char *rl_complete();
|
#if defined(DO_SIGTSTP)
|
||||||
extern int rl_list_possib();
|
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_ttyset();
|
||||||
extern void rl_add_slash();
|
extern void rl_add_slash();
|
||||||
|
|
||||||
@@ -78,6 +74,7 @@ extern char *strcat();
|
|||||||
extern char *strchr();
|
extern char *strchr();
|
||||||
extern char *strrchr();
|
extern char *strrchr();
|
||||||
extern char *strcpy();
|
extern char *strcpy();
|
||||||
|
extern char *strdup();
|
||||||
extern int strcmp();
|
extern int strcmp();
|
||||||
extern int strlen();
|
extern int strlen();
|
||||||
extern int strncmp();
|
extern int strncmp();
|
||||||
@@ -86,3 +83,6 @@ extern int strncmp();
|
|||||||
#if defined(NEED_STRDUP)
|
#if defined(NEED_STRDUP)
|
||||||
extern char *strdup();
|
extern char *strdup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../include/editline.h"
|
||||||
|
#endif /* __PRIVATE_EDITLINE_H__ */
|
||||||
|
142
src/sysunix.c
142
src/sysunix.c
@@ -4,64 +4,69 @@
|
|||||||
*/
|
*/
|
||||||
#include "editline.h"
|
#include "editline.h"
|
||||||
|
|
||||||
#if defined(HAVE_TCGETATTR)
|
#if defined(HAVE_TCGETATTR)
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
rl_ttyset(Reset)
|
rl_ttyset(Reset)
|
||||||
int Reset;
|
int Reset;
|
||||||
{
|
{
|
||||||
static struct termios old;
|
static struct termios old;
|
||||||
struct termios new;
|
struct termios new;
|
||||||
|
|
||||||
if (Reset == 0) {
|
if (Reset == 0) {
|
||||||
(void)tcgetattr(0, &old);
|
if (tcgetattr(0, &old) < 0) perror("tcgetattr");
|
||||||
rl_erase = old.c_cc[VERASE];
|
rl_erase = old.c_cc[VERASE];
|
||||||
rl_kill = old.c_cc[VKILL];
|
rl_kill = old.c_cc[VKILL];
|
||||||
rl_eof = old.c_cc[VEOF];
|
rl_eof = old.c_cc[VEOF];
|
||||||
rl_intr = old.c_cc[VINTR];
|
rl_intr = old.c_cc[VINTR];
|
||||||
rl_quit = old.c_cc[VQUIT];
|
rl_quit = old.c_cc[VQUIT];
|
||||||
|
#if defined(DO_SIGTSTP)
|
||||||
|
rl_susp = old.c_cc[VSUSP];
|
||||||
|
#endif /* defined(DO_SIGTSTP) */
|
||||||
|
|
||||||
new = old;
|
new = old;
|
||||||
new.c_lflag &= ~(ECHO | ICANON | ISIG | IEXTEN);
|
new.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||||
new.c_iflag &= ~(ICRNL);
|
new.c_iflag &= ~(ISTRIP | INPCK);
|
||||||
new.c_cc[VMIN] = 1;
|
new.c_cc[VMIN] = 1;
|
||||||
new.c_cc[VTIME] = 0;
|
new.c_cc[VTIME] = 0;
|
||||||
(void)tcsetattr(0, TCSADRAIN, &new);
|
if (tcsetattr(0, TCSADRAIN, &new) < 0) perror("tcsetattr");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
(void)tcsetattr(0, TCSADRAIN, &old);
|
(void)tcsetattr(0, TCSADRAIN, &old);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#if defined(HAVE_TERMIO_H)
|
#if defined(HAVE_TERMIO_H)
|
||||||
#include <termio.h>
|
#include <termio.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
rl_ttyset(Reset)
|
rl_ttyset(Reset)
|
||||||
int Reset;
|
int Reset;
|
||||||
{
|
{
|
||||||
static struct termio old;
|
static struct termio old;
|
||||||
struct termio new;
|
struct termio new;
|
||||||
|
|
||||||
if (Reset == 0) {
|
if (Reset == 0) {
|
||||||
(void)ioctl(0, TCGETA, &old);
|
(void)ioctl(0, TCGETA, &old);
|
||||||
rl_erase = old.c_cc[VERASE];
|
rl_erase = old.c_cc[VERASE];
|
||||||
rl_kill = old.c_cc[VKILL];
|
rl_kill = old.c_cc[VKILL];
|
||||||
rl_eof = old.c_cc[VEOF];
|
rl_eof = old.c_cc[VEOF];
|
||||||
rl_intr = old.c_cc[VINTR];
|
rl_intr = old.c_cc[VINTR];
|
||||||
rl_quit = old.c_cc[VQUIT];
|
rl_quit = old.c_cc[VQUIT];
|
||||||
|
#if defined(DO_SIGTSTP)
|
||||||
|
rl_susp = old.c_cc[VSUSP];
|
||||||
|
#endif /* defined(DO_SIGTSTP) */
|
||||||
|
|
||||||
new = old;
|
new = old;
|
||||||
new.c_cc[VINTR] = -1;
|
new.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||||
new.c_cc[VQUIT] = -1;
|
new.c_iflag &= ~(ISTRIP | INPCK);
|
||||||
new.c_lflag &= ~(ECHO | ICANON);
|
new.c_cc[VMIN] = 1;
|
||||||
new.c_cc[VMIN] = 1;
|
new.c_cc[VTIME] = 0;
|
||||||
new.c_cc[VTIME] = 0;
|
(void)ioctl(0, TCSETAW, &new);
|
||||||
(void)ioctl(0, TCSETAW, &new);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
(void)ioctl(0, TCSETAW, &old);
|
(void)ioctl(0, TCSETAW, &old);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -69,50 +74,61 @@ rl_ttyset(Reset)
|
|||||||
|
|
||||||
void
|
void
|
||||||
rl_ttyset(Reset)
|
rl_ttyset(Reset)
|
||||||
int Reset;
|
int Reset;
|
||||||
{
|
{
|
||||||
static struct sgttyb old_sgttyb;
|
static struct sgttyb old_sgttyb;
|
||||||
static struct tchars old_tchars;
|
static struct tchars old_tchars;
|
||||||
struct sgttyb new_sgttyb;
|
struct sgttyb new_sgttyb;
|
||||||
struct tchars new_tchars;
|
struct tchars new_tchars;
|
||||||
|
#if defined(DO_SIGTSTP)
|
||||||
|
struct ltchars old_ltchars;
|
||||||
|
#endif /* defined(DO_SIGTSTP) */
|
||||||
|
|
||||||
if (Reset == 0) {
|
if (Reset == 0) {
|
||||||
(void)ioctl(0, TIOCGETP, &old_sgttyb);
|
(void)ioctl(0, TIOCGETP, &old_sgttyb);
|
||||||
rl_erase = old_sgttyb.sg_erase;
|
rl_erase = old_sgttyb.sg_erase;
|
||||||
rl_kill = old_sgttyb.sg_kill;
|
rl_kill = old_sgttyb.sg_kill;
|
||||||
|
|
||||||
(void)ioctl(0, TIOCGETC, &old_tchars);
|
(void)ioctl(0, TIOCGETC, &old_tchars);
|
||||||
rl_eof = old_tchars.t_eofc;
|
rl_eof = old_tchars.t_eofc;
|
||||||
rl_intr = old_tchars.t_intrc;
|
rl_intr = old_tchars.t_intrc;
|
||||||
rl_quit = old_tchars.t_quitc;
|
rl_quit = old_tchars.t_quitc;
|
||||||
|
|
||||||
new_sgttyb = old_sgttyb;
|
#if defined(DO_SIGTSTP)
|
||||||
new_sgttyb.sg_flags &= ~ECHO;
|
(void)ioctl(0, TIOCGLTC, &old_ltchars);
|
||||||
new_sgttyb.sg_flags |= RAW;
|
rl_susp = old_ltchars.t_suspc;
|
||||||
(void)ioctl(0, TIOCSETP, &new_sgttyb);
|
#endif /* defined(DO_SIGTSTP) */
|
||||||
|
|
||||||
new_tchars = old_tchars;
|
new_sgttyb = old_sgttyb;
|
||||||
new_tchars.t_intrc = -1;
|
new_sgttyb.sg_flags &= ~ECHO;
|
||||||
new_tchars.t_quitc = -1;
|
new_sgttyb.sg_flags |= RAW;
|
||||||
(void)ioctl(0, TIOCSETC, &new_tchars);
|
#if defined(PASS8)
|
||||||
|
new_sgttyb.sg_flags |= PASS8;
|
||||||
|
#endif /* defined(PASS8) */
|
||||||
|
(void)ioctl(0, TIOCSETP, &new_sgttyb);
|
||||||
|
|
||||||
|
new_tchars = old_tchars;
|
||||||
|
new_tchars.t_intrc = -1;
|
||||||
|
new_tchars.t_quitc = -1;
|
||||||
|
(void)ioctl(0, TIOCSETC, &new_tchars);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(void)ioctl(0, TIOCSETP, &old_sgttyb);
|
(void)ioctl(0, TIOCSETP, &old_sgttyb);
|
||||||
(void)ioctl(0, TIOCSETC, &old_tchars);
|
(void)ioctl(0, TIOCSETC, &old_tchars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* defined(HAVE_TERMIO_H) */
|
#endif /* defined(HAVE_TERMIO_H) */
|
||||||
#endif /* defined(HAVE_TCGETATTR) */
|
#endif /* defined(HAVE_TCGETATTR) */
|
||||||
|
|
||||||
void
|
void
|
||||||
rl_add_slash(path, p)
|
rl_add_slash(path, p)
|
||||||
char *path;
|
char *path;
|
||||||
char *p;
|
char *p;
|
||||||
{
|
{
|
||||||
struct stat Sb;
|
struct stat Sb;
|
||||||
|
|
||||||
if (stat(path, &Sb) >= 0)
|
if (stat(path, &Sb) >= 0)
|
||||||
(void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
|
(void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(USE_DIRENT)
|
#if defined(USE_DIRENT)
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
Reference in New Issue
Block a user