Home | History | Annotate | Download | only in libedit
History log of /src/lib/libedit/el.c
RevisionDateAuthorComments
 1.102  03-Jan-2025  rillig libedit: remove redundant break statements after EL_ABORT
 1.101  30-Oct-2022  christos improvements in malloc/free handling.
 1.100  15-Aug-2021  christos Disable attempts to handle EINTR and non-blocking I/O by default. It is
confusing to other programs and unexpected behavior. Reported by Ingo Schwarze.
This behavior is now controlled with EL_SAFEREAD.
 1.99  23-Jul-2019  christos PR/54399: S�ren Tempel: Uninitialized memory access in libedit history.
Initialize the buffer using calloc. While here change all malloc(a * sizeof(b))
to calloc(a, sizeof(b)). XXX: should fix realloc similarly.
 1.98  26-Apr-2019  christos Follow the man page for EL_GETTC and not require a NULL terminated argument
list: https://reviews.llvm.org/D61191
 1.97  18-Nov-2018  christos Remove utf-8 requirement (Yuichiro NAITO)
 1.96  01-Jan-2018  christos branches: 1.96.2; 1.96.4;
Only FLUSH if we are ending libedit; DRAIN if we suspend for readline.
This allows pasting multiline buffers (Gerry Swislow)
 1.95  05-Sep-2017  christos For readline emulation, don't reset the tty to "sane" (cooked) mode if we
did not start this way. Also set and reset the tty on entry and exit from
readline() since this is what readline does.
 1.94  27-Jun-2017  christos add literal escape sequence support, patterned after the tcsh ones.
 1.93  27-Jun-2017  kre Make the default editrc file be $EDITRC (from env) if set, falling back
to $HOME/.editrc otherwise. Better support for this in sh coming.
 1.92  22-May-2016  christos branches: 1.92.8;
Stop the read module from poking the el_chared.c_macro data structure
currently belonging to the chared module. The read module does so
from three of its functions, while no other module uses the macro
data, not even the chared module itself. That's quite logical
because macros are a feature of input handling, all of which is
done by the read module, and none by the chared module. So move
the data into the read modules's own opaque data structure, struct
el_read_t.

That simplifies internal interfaces in several respects: The
semi-public chared.h has one fewer struct, one fewer #define, and
one fewer member in struct el_chared_t; all three move to one single
C file, read.c, and are now module-local. And the internal interface
function ch_reset() needs one fewer argument, making the code of many
functions in various modules more readable.

The price is one additional internal interface function, read_end(),
10 lines long including comments, called publicly from exactly one
place: el_end() in el.c. That's hardly an increase in complexity
since most other modules already have their *_end() function, read.c
was the odd one out not having one.

From Ingo Schwarze
 1.91  09-May-2016  christos s/protected/libedit_private/g
 1.90  02-May-2016  christos eliminate static buffer with custom resizing code.
 1.89  19-Apr-2016  christos From Ingo Schwarze:
- Put the data type el_rfunc_t into the public header <histedit.h>.
- Make el_read in struct editline an opaque pointer rather
than an embedded struct.
- Do not include "read.h" everywhere, but only in the two files
needing access to el_read, read.c and el.c.
- To functions that don't need more, pass the struct el_read_t *
rather than the full EditLine *.
- Of course, that means that read_init() can now fail from
memory exhaustion, but it's easy to clean up after that.
 1.88  11-Apr-2016  christos Get rid of private/public; keep protected (Ingo Schwarze)
 1.87  11-Apr-2016  christos Char -> wchar_t from Ingo Schwarze.
 1.86  11-Apr-2016  christos more macro WIDECHAR undoing from Ingo Schwarze.
 1.85  09-Apr-2016  christos More WIDECHAR elimination (Ingo Schwarze)
 1.84  23-Mar-2016  christos Start removing the WIDECHAR ifdefs; building without it has stopped working
anyway. (Ingo Schwarze)
 1.83  24-Feb-2016  christos Make the read_char function always take a wchar_t * argument (Ingo Schwarze)
 1.82  17-Feb-2016  christos whitespace and header sorting changes (Ingo Schwarze). No functional changes.
 1.81  16-Feb-2016  christos more include file cleanup (Ingo Schwarze)
 1.80  16-Feb-2016  christos From Ingo Scharze:
Let "el.h" include everything needed for struct editline,
and don't include that stuff multiple times. That also improves
consistency, also avoids circular inclusions, and also makes it
easier to follow what is going on, even though not quite as nice.
But it seems like the best we can do...
 1.79  16-Feb-2016  christos cleanup chartype.h includes (Ingo Schwarze)
 1.78  16-Feb-2016  christos cleanup inclusion of histedit.h (Ingo Schwarze)
 1.77  15-Feb-2016  christos Use getline for better portability.
 1.76  15-Feb-2016  christos use fparseln() to avoid needing to deal with missing \n in the last line
and also to handle comments automatically.
 1.75  11-Feb-2016  christos - Add some more Char casts
- reduce ifdefs by providing empty defs for nls functions (Ingo Schwarze)
 1.74  08-Dec-2015  christos Only reset the terminal if we have a tty (Boris Ranto)
 1.73  18-Jun-2014  christos Don't depend on weak aliases to define the vi "alias" expansion function,
provide an API instead to set it.
 1.72  22-Jan-2013  christos branches: 1.72.6;
provide an el_init_fd function.
 1.71  11-Sep-2012  christos branches: 1.71.2;
PR/46942: Steffen Nurpmeso: editline(3): el_get(): fix UNBUFFERED return
 1.70  11-Mar-2012  christos use arraycount
 1.69  18-Nov-2011  christos remove unrecheable code (Kamil Dudka)
 1.68  29-Jul-2011  christos branches: 1.68.2;
KNF return (\1); -> return \1;
 1.67  28-Jul-2011  christos kill ptr_t and ioctl_t, add * sizeof(*foo) to all allocations.
 1.66  28-Jul-2011  christos Rename key to keymacro to avoid conflicts with term.h. The renaming of term
to terminal was again to avoid conflicts with term.h. term.h is a moving
namespace violation.
 1.65  28-Jul-2011  christos avoid shadowed variable
 1.64  28-Jul-2011  christos term -> terminal
eliminate MAXPATHLEN
 1.63  26-Jul-2011  christos don't stop reading after empty lines from: Nirbhay Choubey
 1.62  20-Mar-2011  bouyer Fix use-after-free. Discovered by running tests with MALLOC_OPTIONS=J
(should this be the default for tests ?), pointed out by njoly@
 1.61  27-Jan-2011  christos don't turn on editing if stdout is not a tty.
 1.60  28-Aug-2010  christos branches: 1.60.2;
setup a callback to be invoked on resize buffers so that readline can
reset rl_line_buffer which unfortunately some applications use it directly.
 1.59  15-Apr-2010  christos From Jess Thrysoee
- use nl_langinfo to test for UTF-8, because some locales are UTF-8 without
reflecting it in their names.
 1.58  31-Dec-2009  christos - Document and enable wide character support.
- Fix read function compatibility.
 1.57  30-Dec-2009  christos Fix wide build, test it, but don't turn it on yet.
 1.56  30-Dec-2009  christos Wide character support (UTF-8) from Johny Mattsson; currently disabled.
 1.55  25-Jul-2009  christos Ignore comment lines in .editrc from Jess Thrysoee
 1.54  22-Jul-2009  christos Only need path if we have issetugid... From Anon Ymous
 1.53  22-Jul-2009  christos Move filename to the scope it is being used.
From Michael Cook mcook at bbn dot com
 1.52  11-May-2009  christos restore binary compatibility by providing new prompt functions that take
an extra literal character.
 1.51  31-Mar-2009  christos Implement literal prompt sequences. Now someone can implement
RL_PROMPT_START_LITERAL/RL_PROMPT_END_LITERAL :-)
 1.50  21-Feb-2009  christos back out all prompt changes. they are not needed.
 1.49  19-Feb-2009  cube Order of evaluation of arguments is undefined, so call va_arg() in an
explicit order. Fixes a segfault with bc reported by Patrick Welche on
current-users.
 1.48  17-Feb-2009  christos allow for a prompt argument.
 1.47  18-Jan-2009  lukem branches: 1.47.2;
fix -Wsign-compare issues
 1.46  10-Sep-2008  christos Allow a single process to control multiple ttys (for pthreads using _REENTRANT)
using multiple EditLine objects. Mostly from Preston A. Elder.
 1.45  05-Apr-2008  christos branches: 1.45.4;
add EL_REFRESH for the benefit of readline
 1.44  15-Dec-2006  christos add EL_GETFP, and EL_SETFP.
 1.43  25-Nov-2006  freza s/el->errfile/el->el_errfile/g in debug code, fixes MKDEBUGLIB build.
 1.42  24-Nov-2006  christos - Add more readline functions, enough for gdb-6.5
- Make el_get varyadic, and implement EL_GETTC.
- XXX: the EL_SETTC api will change in the future.
 1.41  19-Aug-2005  christos PR/31012: Barry Naujok: libedit el_get with EL_EDITOR op does not work
Fixed as suggested.
 1.40  01-Aug-2005  christos Don't reset the macro strings each time we enter el_gets(), otherwise
el_push() is unusable programmatically.
 1.39  08-Jul-2004  christos PR/23486: Andreas Gustafsson: gdb no longer works with emacs
- make sure that we keep previous contents of the buffer in unbuffered mode.
- when turning editing on and off keep tty consistent.
 1.38  27-Feb-2004  christos branches: 1.38.2;
Better fix for rl_prep_terminal() from Gerry Swislow.
 1.37  21-Feb-2004  christos Separate tty separation from the prompt printing function. From Gerry Swislow.
 1.36  18-Oct-2003  christos change allocation policy in el_push to allocate the string itself.
fix issues with strdup.
 1.35  16-Oct-2003  christos More libedit readline emulation functions from: Gerry Swislow
<gerry at certif dot com>
 1.34  26-Sep-2003  christos Implement enough of readline's 4.0 async mode to make gdb happy. This is
not complete yet, but it seems to work...
This required to introduce an unbuffered mode to el_gets(), but that was
a minor change.
 1.33  14-Sep-2003  christos - provide enough hooks to compile gdb-5.3
- fix el_get(e, EL_TERMINAL, (char **))
 1.32  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.31  19-Jun-2003  christos From michael@moria.de:
- use __attribute__((__unused__)) in arguments where appropriate.
- some int -> size_t and char * to const char * conversions.
 1.30  12-Nov-2002  thorpej Avoid strict alias warning.
 1.29  18-Mar-2002  christos - constify; passes all gcc and lint strict checks.
- add config.h [Jason Evans], to create a portable version of libedit that
can be easily compiled on other OS's.
 1.28  03-Feb-2002  christos Don't use HAVE_ yet.
 1.27  03-Feb-2002  christos Fix a warning.
 1.26  08-Nov-2001  mycroft Remove an unused variable.
 1.25  02-Nov-2001  christos If term_init() fails, cleanup and return NULL. This avoids other lossage.
Pointed by charles.
 1.24  09-Oct-2001  christos PR/14188: Anthony Mallet: Provide an opaque data pointer to client programs.
 1.23  27-Sep-2001  christos PR/14067: Anthony Mallet: Provide a programmatic way to set the read_char
function via a new el_set() operation.
Thanks, nicely done :-)
 1.22  24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.21  05-Jan-2001  christos depoison the pure editline code from readline compatibility hacks.
 1.20  11-Nov-2000  christos - add support for home and end keys.
- improve debugging support
 1.19  04-Sep-2000  lukem convert to new style guide, which includes:
- ansi prototypes & features (such as stdargs)
- 8 space indents
 1.18  02-Aug-2000  chuck make xxgdb and a gdb linked with libedit's readline emulation work
properly together. xxgdb communicates with a gdb running on a pty
that it sets to -echo,-onlcr prior to forking the gdb process.
GNU readline preserves the -echo setting while libedit was undoing it
(setting the tty to a sane state and totally confusing xxgdb's parser).

this diff simply disables libedit if both readline emulation and
"stty -echo" are used/set. that is enough to make xxgdb work once
again, but (XXX) this is not how GNU readline handles stty -echo (it
does not echo anything, but editing commands like ^A,^K, etc.
still work), so the readline emulation isn't perfect.

change reviewed by christos.
 1.17  28-Jun-2000  sommerfeld Only look in home directory for .editrc. (Discussed with Christos.)
 1.16  15-May-2000  christos branches: 1.16.4;
don't dump core on empty files.
 1.15  12-Nov-1999  lukem - implement printing a right-side prompt. code derived from similar work
I wrote for tcsh(1) three years ago.
- implement EL_RPROMPT, which allows a setting/getting of a function which
returns a string to be used as the right-side prompt.
- improve HISTORY and AUTHORS sections in editline(3).
- bump shlib minor version for EL_RPROMPT.

XXX: due to an implementation issue, the rprompt has a 1 space gap before the
edge of the logical screen. editline's logical screen is 1 space less
than the full screen width, so there's a 2 space gap between the rprompt
and the right end of the physical screen. i'm not concerned about this.
 1.14  21-Sep-1999  lukem branches: 1.14.4;
* in el_source():
- don't reopen fp if it was successfully opened in a previous check
- use strlcpy()/strlcat() instead of snprintf() to build a pathname,
since the former are more portable to other systems than the latter
* whitespace fascism
 1.13  02-Jul-1999  simonb More trailing white space.
 1.12  12-Dec-1998  christos branches: 1.12.2;
delint
 1.11  28-Sep-1998  christos fix core-dump caused by maps not being initialized before tty is called.
 1.10  29-Jul-1998  lukem * add more checks for NULL pointers in passed arguments
* implement el_get(EditLine *, int op, void *result), which does the
inverse of el_set()
* add EL_EDITMODE operation to el_set and el_get; if non zero editing
is enabled (the default).
* add "edit on | off" editrc command, which modifies EL_EDITMODE.
users can now add '*:edit off' in ~/.editrc as an advisory to
disable editing.

NOTE: at this time EL_EDITMODE is just an indication of the
state of the 'edit' command. It's up to the application to check
this after el_source() or el_parse() to determine if editing is still
required.
 1.9  20-May-1998  christos el_init takes a third stream argument and add el_beep.
 1.8  20-Dec-1997  christos Small optimization. Don't call isatty() on every invocation of el_gets, but
remember if the tty setup failed... Also trim the input line of trailing \r's.
 1.7  06-Jul-1997  christos Fix compiler warnings.
 1.6  24-Apr-1997  christos Handle properly the case where the last line in the sourced file does
not have a trailing '\n'. From Jeffrey C Honig.
 1.5  11-Apr-1997  christos Portability fixes:
__const -> const
BADSIG -> SIG_ERR
int flags -> u_int flags
#if __STDC__ -> #ifdef __STDC__
 1.4  20-Mar-1997  christos Fix potential stack overflow; from Keith Bostic.
 1.3  17-Jan-1997  lukem fix el_source() - a block needed braces around it (the indenting fooled me)
 1.2  11-Jan-1997  lukem RCSid police
editline first appeared in 4.4BSD not NetBSD1.0
 1.1  06-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1  06-May-1994  cgd libedit!
 1.12.2.1  29-Jun-2000  he Pull up revision 1.17 (via patch, requested by sommerfeld):
Only read .editrc from home directory.
 1.14.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.4.2  02-Aug-2000  chuck pull up 1.18 (approved by thorpej). allows a gdb linked with libedit's
readline emulation to work properly with xxgdb.
 1.16.4.1  28-Jun-2000  sommerfeld Pull up 1.17 (approved by thorpej): only look for .editrc in /d1/sommerfeld
 1.38.2.1  10-Jul-2004  tron Pull up revision 1.39 (requested by christos in ticket #620):
PR/23486: Andreas Gustafsson: gdb no longer works with emacs
- make sure that we keep previous contents of the buffer in unbuffered mode.
- when turning editing on and off keep tty consistent.
 1.45.4.1  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.47.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.60.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.68.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.68.2.2  30-Oct-2012  yamt sync with head
 1.68.2.1  17-Apr-2012  yamt sync with head
 1.71.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.2.1  25-Feb-2013  tls resync with head
 1.72.6.1  10-Aug-2014  tls Rebase.
 1.92.8.1  23-Jul-2017  snj Pull up following revision(s) (requested by kre in ticket #102):
lib/libedit/Makefile: 1.64-1.65
lib/libedit/editline.3: 1.94-1.96
lib/libedit/editrc.5: 1.33
lib/libedit/el.c: 1.93-1.94
lib/libedit/el.h: 1.42
lib/libedit/literal.c: 1.1-1.3
lib/libedit/literal.h: 1.1-1.2
lib/libedit/prompt.c: 1.27
lib/libedit/read.c: 1.103
lib/libedit/refresh.c: 1.52-1.54
lib/libedit/refresh.h: 1.11
lib/libedit/terminal.c: 1.33
Make the default editrc file be $EDITRC (from env) if set, falling back
to $HOME/.editrc otherwise. Better support for this in sh coming.
--
Include EDITRC in doc.
--
mention the limitation of the literal sequence delimiter.
--
- handle literal escape sequence printing.
- factor out common code in allocation and freeing of the display.
--
- add literal sequence handling.
--
remove unused variable
--
add literal escape sequence support, patterned after the tcsh ones.
--
fix comment
--
Fix an obvious, but almost invisible typo (avoid some core dumps).
--
Allow wide characters (properly encoded as byte strings according to LC_CTYPE)
to be (perhaps part of) the "invisible" characters in a prompt, or the
required prompt character which follows the literal sequence (this character
must be one with a printing column width >= 1). The literal indicator
character (which is just a marker, and not printed anywhere) (the PSlit
parameter in sh(1)) can also be a wide char (passed to libedit as a wchar_t,
encoded as that by sh(1) or other applications that support this.)
Note: this has currently only been tested with everything ascii (C locale).
--
Remove workaround for ancient HTML generation code.
 1.96.4.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.96.4.1  10-Jun-2019  christos Sync with HEAD
 1.96.2.1  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts

RSS XML Feed