mirror of
https://github.com/troglobit/editline.git
synced 2025-09-17 17:58:07 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
85e606d093 | ||
![]() |
9cc0cc1ccd | ||
![]() |
08b7f57c98 | ||
![]() |
29b7f91165 |
14
NEWS
14
NEWS
@@ -1,14 +0,0 @@
|
||||
Notable Changes
|
||||
|
||||
* v1.13.0 - Adaptations to Debian editline package
|
||||
** Major version number bump, adapt to Jum Studt's v1.12
|
||||
** Import debian/ directory and adapt it to configure et al.
|
||||
** Change library name to libeditline to distinguish it from BSD libedit.
|
||||
|
||||
* 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.
|
||||
|
50
NEWS.md
Normal file
50
NEWS.md
Normal file
@@ -0,0 +1,50 @@
|
||||
ChangeLog
|
||||
=========
|
||||
Notable Changes
|
||||
|
||||
* v1.14.2 - Bug fixes only
|
||||
- Fix `el_no_echo` bug causing secrets to leak when disabling no-echo
|
||||
- Handle `EINTR` in syscalls better
|
||||
|
||||
* v1.14.1 - Minor fixes and additions
|
||||
- Don't print status message on `stderr` in key binding funcions
|
||||
- Export `el_del_char()`
|
||||
- Check for and return pending signals when detected
|
||||
- Allow custom key bindings ...
|
||||
- Bug fixes ...
|
||||
|
||||
* v1.14.0 - Major cleanups and further merges with Debian editline package
|
||||
- Merge in changes to `debian/` from editline_1.12-6.debian.tar.gz
|
||||
- Migrate to use libtool
|
||||
- Cleanups and fixes thanks to the Sparse static code analysis tool
|
||||
- Make `UNIQUE_HISTORY` configurable
|
||||
- Make scrollback history (`HIST_SIZE`) configurable
|
||||
- Configure options for toggling terminal bell and `SIGSTOP` (Ctrl-Z)
|
||||
- Configure option for using termcap to read/control terminal size
|
||||
- Merge `el_no_echo` patch from Festival speech-tools
|
||||
- Rename Signal to `el_intr_pending`, from Festival speech-tools
|
||||
- Merge support for capitalizing words (`M-c`) from Festival
|
||||
speech-tools by Alan W Black <awb()cstr!ed!ac!uk>
|
||||
- Merge fixes from Heimdal project
|
||||
- Completely refactor `rl_complete()` and `rl_list_possib()` with
|
||||
fixes from the Heimdal project. Use `rl_set_complete_func()` and
|
||||
`rl_set_list_possib_func()`. Default completion callbacks are now
|
||||
available as a configure option `--enable-default-complete`
|
||||
- Memory leak fixes
|
||||
- Fallback backspace handling, in case `tgetstr("le")` fails
|
||||
- Actually fix 8-bit handling by reverting old Debian patch
|
||||
- Merge patch to improve compatibility with GNU readline, thanks to
|
||||
Steve Tell from way back in 1997 and 1998
|
||||
|
||||
* v1.13.0 - Adaptations to Debian editline package
|
||||
- Major version number bump, adapt to Jum Studt's v1.12
|
||||
- Import `debian/` directory and adapt it to configure et al.
|
||||
- Change library name to libeditline to distinguish it from BSD libedit
|
||||
|
||||
* 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
|
||||
|
36
README
36
README
@@ -1,36 +0,0 @@
|
||||
README -*-text-*-
|
||||
|
||||
This is a line editing library. It can be linked into almost any program to
|
||||
provide command-line editing and history. It is call-compatible with the FSF
|
||||
readline library, but is a fraction of the size (and offers fewer features).
|
||||
|
||||
The editline library was created by Simmule Turner and Rich Salz back in 1992.
|
||||
At the time they chose to distribute the code under a "C News-like" copyright,
|
||||
see the file LICENSE for details.
|
||||
|
||||
The small size (<30k), lack of dependencies (no ncurses needed!) and the free
|
||||
license should make this library interesting to many embedded developers.
|
||||
|
||||
Configuration is made by supplying different options to the GNU configure
|
||||
script. In the examples/ directory you can find some small code snippets used
|
||||
for testing.
|
||||
|
||||
This version of the editline library is a fork off the Minix3 sources. Other
|
||||
know versions, often based off of the original comp.sources.unix posting are:
|
||||
|
||||
* Debian libeditline, http://packages.qa.debian.org/e/editline.html
|
||||
* Heimdal, http://www.h5l.org
|
||||
* Festival speech-tools, http://festvox.org/festival/
|
||||
* Steve Tell's editline patches, http://www.cs.unc.edu/~tell/dist.html
|
||||
|
||||
The most intersting patches and bug fixes from each fork have been merged here.
|
||||
Outstanding issues are listed in the TODO file.
|
||||
|
||||
An explanation of the version numbering may be in order. I didn't know about
|
||||
the Debian version for quite some time, so I kept a different name for the
|
||||
package and a different versioning scheme. In June 2009, I decided to line up
|
||||
alongside Debian, with the intent of merging the efforts.
|
||||
|
||||
Enjoy,
|
||||
Joachim Nilsson <troglobit()gmail!com>
|
||||
|
37
README.md
Normal file
37
README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
editline
|
||||
========
|
||||
|
||||
This is a line editing library. It can be linked into almost any program to
|
||||
provide command-line editing and history. It is call-compatible with the FSF
|
||||
readline library, but is a fraction of the size (and offers fewer features).
|
||||
|
||||
The editline library was created by Simmule Turner and Rich Salz back in 1992.
|
||||
At the time they chose to distribute the code under a "C News-like" copyright,
|
||||
see the file LICENSE for details.
|
||||
|
||||
The small size (<30k), lack of dependencies (no ncurses needed!) and the free
|
||||
license should make this library interesting to many embedded developers.
|
||||
|
||||
Configuration is made by supplying different options to the GNU configure
|
||||
script. In the `examples/` directory you can find some small code snippets used
|
||||
for testing.
|
||||
|
||||
This version of the editline library is a fork off the Minix3 sources. Other
|
||||
know versions, often based off of the original comp.sources.unix posting are:
|
||||
|
||||
* Debian [libeditline](http://packages.qa.debian.org/e/editline.html)
|
||||
* [Heimdal](http://www.h5l.org)
|
||||
* [Festival speech-tools](http://festvox.org/festival/)
|
||||
* Steve Tell's [editline patches](http://www.cs.unc.edu/~tell/dist.html)
|
||||
|
||||
The most intersting patches and bug fixes from each fork have been merged here.
|
||||
Outstanding issues are listed in the TODO file.
|
||||
|
||||
An explanation of the version numbering may be in order. I didn't know about
|
||||
the Debian version for quite some time, so I kept a different name for the
|
||||
package and a different versioning scheme. In June 2009, I decided to line up
|
||||
alongside Debian, with the intent of merging the efforts.
|
||||
|
||||
----
|
||||
Joachim Nilsson <[troglobit()gmail!com](mailto:troglobit@gmail!com)>
|
||||
|
20
configure
vendored
20
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for editline 1.14.1.
|
||||
# Generated by GNU Autoconf 2.69 for editline 1.14.2.
|
||||
#
|
||||
# Report bugs to <troglobit@gmail.com>.
|
||||
#
|
||||
@@ -590,8 +590,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='editline'
|
||||
PACKAGE_TARNAME='editline'
|
||||
PACKAGE_VERSION='1.14.1'
|
||||
PACKAGE_STRING='editline 1.14.1'
|
||||
PACKAGE_VERSION='1.14.2'
|
||||
PACKAGE_STRING='editline 1.14.2'
|
||||
PACKAGE_BUGREPORT='troglobit@gmail.com'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@@ -1317,7 +1317,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 editline 1.14.1 to adapt to many kinds of systems.
|
||||
\`configure' configures editline 1.14.2 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1387,7 +1387,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of editline 1.14.1:";;
|
||||
short | recursive ) echo "Configuration of editline 1.14.2:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1499,7 +1499,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
editline configure 1.14.1
|
||||
editline configure 1.14.2
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -1922,7 +1922,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 editline $as_me 1.14.1, which was
|
||||
It was created by editline $as_me 1.14.2, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -2743,7 +2743,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='editline'
|
||||
VERSION='1.14.1'
|
||||
VERSION='1.14.2'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@@ -12594,7 +12594,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by editline $as_me 1.14.1, which was
|
||||
This file was extended by editline $as_me 1.14.2, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -12660,7 +12660,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
editline config.status 1.14.1
|
||||
editline config.status 1.14.2
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(editline, 1.14.1, troglobit@gmail.com)
|
||||
AC_INIT(editline, 1.14.2, troglobit@gmail.com)
|
||||
AC_CONFIG_SRCDIR([src/editline.c])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
8
debian/changelog
vendored
8
debian/changelog
vendored
@@ -1,3 +1,11 @@
|
||||
editline (1.14.2-1) unstable; urgency=low
|
||||
|
||||
* Minor bugfix release:
|
||||
+ Fix `el_no_echo` bug causing secrets to leak when disabling no-echo
|
||||
+ Handle `EINTR` in syscalls better
|
||||
|
||||
-- Joachim Nilsson <troglobit@gmail.com> Sun, 14 Sep 2014 04:27:25 +0200
|
||||
|
||||
editline (1.14.1-1) unstable; urgency=low
|
||||
|
||||
* New release.
|
||||
|
@@ -167,6 +167,9 @@ static void tty_flush(void)
|
||||
|
||||
static void tty_put(const char c)
|
||||
{
|
||||
if (el_no_echo)
|
||||
return;
|
||||
|
||||
Screen[ScreenCount] = c;
|
||||
if (++ScreenCount >= ScreenSize - 1) {
|
||||
ScreenSize += SCREEN_INC;
|
||||
@@ -1180,9 +1183,11 @@ char *readline(const char *prompt)
|
||||
free(Screen);
|
||||
free(H.Lines[--H.Size]);
|
||||
|
||||
/* Always add history, if it's a sane line. */
|
||||
/* Add to history, unless no-echo mode ... */
|
||||
if (!el_no_echo) {
|
||||
if (line != NULL && *line != '\0')
|
||||
hist_add(line);
|
||||
}
|
||||
|
||||
if (el_intr_pending > 0) {
|
||||
int s = el_intr_pending;
|
||||
|
@@ -18,20 +18,75 @@
|
||||
* ever read sources, credits must appear in the documentation.
|
||||
* 4. This notice may not be removed or altered.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "editline.h"
|
||||
|
||||
#ifndef HAVE_TCGETATTR
|
||||
/* Wrapper for ioctl syscalls to restart on signal */
|
||||
static int ioctl_wrap(int fd, int req, void *arg)
|
||||
{
|
||||
int result, retries = 3;
|
||||
|
||||
while (-1 == (result = ioctl(fd, req, arg)) && retries > 0) {
|
||||
retries--;
|
||||
|
||||
if (EINTR == errno)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Prefer termios over the others since it is likely the most portable. */
|
||||
#if defined(HAVE_TCGETATTR)
|
||||
#include <termios.h>
|
||||
|
||||
/* Wrapper for tcgetattr */
|
||||
static int getattr(int fd, struct termios *arg)
|
||||
{
|
||||
int result, retries = 3;
|
||||
|
||||
while (-1 == (result = tcgetattr(fd, arg)) && retries > 0) {
|
||||
retries--;
|
||||
|
||||
if (EINTR == errno)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Wrapper for tcgetattr */
|
||||
static int setattr(int fd, int opt, const struct termios *arg)
|
||||
{
|
||||
int result, retries = 3;
|
||||
|
||||
while (-1 == (result = tcsetattr(fd, opt, arg)) && retries > 0) {
|
||||
retries--;
|
||||
|
||||
if (EINTR == errno)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void rl_ttyset(int Reset)
|
||||
{
|
||||
static struct termios old;
|
||||
struct termios new;
|
||||
|
||||
if (!Reset) {
|
||||
if (-1 == tcgetattr(0, &old))
|
||||
perror("Failed tcgetattr");
|
||||
if (-1 == getattr(0, &old))
|
||||
perror("Failed tcgetattr()");
|
||||
rl_erase = old.c_cc[VERASE];
|
||||
rl_kill = old.c_cc[VKILL];
|
||||
rl_eof = old.c_cc[VEOF];
|
||||
@@ -50,11 +105,11 @@ void rl_ttyset(int Reset)
|
||||
new.c_iflag &= ~ISTRIP;
|
||||
new.c_cc[VMIN] = 1;
|
||||
new.c_cc[VTIME] = 0;
|
||||
if (-1 == tcsetattr(0, TCSADRAIN, &new))
|
||||
perror("Failed tcsetattr");
|
||||
if (-1 == setattr(0, TCSADRAIN, &new))
|
||||
perror("Failed tcsetattr(TCSADRAIN)");
|
||||
} else {
|
||||
if (-1 == tcsetattr(0, TCSADRAIN, &old))
|
||||
perror("Failed tcsetattr");
|
||||
if (-1 == setattr(0, TCSADRAIN, &old))
|
||||
perror("Failed tcsetattr(TCSADRAIN)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +122,7 @@ void rl_ttyset(int Reset)
|
||||
struct termio new;
|
||||
|
||||
if (!Reset) {
|
||||
if (-1 == ioctl(0, TCGETA, &old))
|
||||
if (-1 == ioctl_wrap(0, TCGETA, &old))
|
||||
perror("Failed ioctl(TCGETA)");
|
||||
rl_erase = old.c_cc[VERASE];
|
||||
rl_kill = old.c_cc[VKILL];
|
||||
@@ -88,10 +143,10 @@ void rl_ttyset(int Reset)
|
||||
|
||||
new.c_cc[VMIN] = 1;
|
||||
new.c_cc[VTIME] = 0;
|
||||
if (-1 == ioctl(0, TCSETAW, &new))
|
||||
if (-1 == ioctl_wrap(0, TCSETAW, &new))
|
||||
perror("Failed ioctl(TCSETAW)");
|
||||
} else {
|
||||
if (-1 == ioctl(0, TCSETAW, &old))
|
||||
if (-1 == ioctl_wrap(0, TCSETAW, &old))
|
||||
perror("Failed ioctl(TCSETAW)");
|
||||
}
|
||||
}
|
||||
@@ -110,19 +165,19 @@ void rl_ttyset(int Reset)
|
||||
#endif
|
||||
|
||||
if (!Reset) {
|
||||
if (-1 == ioctl(0, TIOCGETP, &old_sgttyb))
|
||||
if (-1 == ioctl_wrap(0, TIOCGETP, &old_sgttyb))
|
||||
perror("Failed TIOCGETP");
|
||||
rl_erase = old_sgttyb.sg_erase;
|
||||
rl_kill = old_sgttyb.sg_kill;
|
||||
|
||||
if (-1 == ioctl(0, TIOCGETC, &old_tchars))
|
||||
if (-1 == ioctl_wrap(0, TIOCGETC, &old_tchars))
|
||||
perror("Failed TIOCGETC");
|
||||
rl_eof = old_tchars.t_eofc;
|
||||
rl_intr = old_tchars.t_intrc;
|
||||
rl_quit = old_tchars.t_quitc;
|
||||
|
||||
#ifdef CONFIG_SIGSTOP
|
||||
if (-1 == ioctl(0, TIOCGLTC, &old_ltchars))
|
||||
if (-1 == ioctl_wrap(0, TIOCGLTC, &old_ltchars))
|
||||
perror("Failed TIOCGLTC");
|
||||
rl_susp = old_ltchars.t_suspc;
|
||||
#endif
|
||||
@@ -134,17 +189,17 @@ void rl_ttyset(int Reset)
|
||||
new_sgttyb.sg_flags &= ~PASS8;
|
||||
else
|
||||
new_sgttyb.sg_flags |= PASS8;
|
||||
if (-1 == ioctl(0, TIOCSETP, &new_sgttyb))
|
||||
if (-1 == ioctl_wrap(0, TIOCSETP, &new_sgttyb))
|
||||
perror("Failed TIOCSETP");
|
||||
new_tchars = old_tchars;
|
||||
new_tchars.t_intrc = -1;
|
||||
new_tchars.t_quitc = -1;
|
||||
if (-1 == ioctl(0, TIOCSETC, &new_tchars))
|
||||
if (-1 == ioctl_wrap(0, TIOCSETC, &new_tchars))
|
||||
perror("Failed TIOCSETC");
|
||||
} else {
|
||||
if (-1 == ioctl(0, TIOCSETP, &old_sgttyb))
|
||||
if (-1 == ioctl_wrap(0, TIOCSETP, &old_sgttyb))
|
||||
perror("Failed TIOCSETP");
|
||||
if (-1 == ioctl(0, TIOCSETC, &old_tchars))
|
||||
if (-1 == ioctl_wrap(0, TIOCSETC, &old_tchars))
|
||||
perror("Failed TIOCSETC");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user