Home | History | Annotate | Download | only in libedit
History log of /src/lib/libedit/chared.c
RevisionDateAuthorComments
 1.64  29-Jun-2024  christos Prevent testing out of bounds memory. From Robert Morris
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279762
 1.63  30-Oct-2022  christos improvements in malloc/free handling.
 1.62  08-Feb-2022  rillig libedit: fix typos, apply KNF to newly imported code (PR/56693)

No binary change.
 1.61  08-Feb-2022  christos PR/56693: Walter Lozano: Add support for rl_delete_text and rl_set_key
 1.60  11-Jan-2022  christos PR/56618: Walter Lozano: Improve libedit compatibility with readline by
implementing:

rl_copy_text, rl_erase_empty_line, rl_message, rl_on_new_line,
rl_replace_line, rl_restore_prompt, rl_save_prompt
 1.59  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.58  23-Jul-2019  christos PR/54400: S�ren Tempel: out-of-bounds read in libedit c_delbefore
 1.57  11-Oct-2017  abhinav branches: 1.57.4;
Fix typo in comment
 1.56  22-May-2016  christos 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.55  09-May-2016  christos s/protected/libedit_private/g
 1.54  18-Apr-2016  christos From Ingo Schwarze:
* Replace fcns.c by a shorter and simpler func.h
and include it only in the one file needing it, map.c.
* Combine help.h and help.c into a simplified help.h
and include it only in the one file needing it, map.c.
* Check the very simple, static files editline.c, historyn.c, and
tokenizern.c into CVS rather than needlessly generating them.
* So we no longer autogenerate any C files. :-)
* Shorten and simplify makelist by deleting the options -n, -e, -bc,
and -m; the latter was unused and useless in the first place.
* Move the declaration of el_func_t from fcns.h to the header
actually needing it, map.h. Since that header is already
included by el.h for unrelated reasons, that makes el_func_t
just as globally available as before.
* No longer include the simplified fcns.h into el.h,
include it directly into the *.c files needing it.
 1.53  11-Apr-2016  christos Get rid of private/public; keep protected (Ingo Schwarze)
 1.52  11-Apr-2016  christos Char -> wchar_t from Ingo Schwarze.
 1.51  11-Apr-2016  christos more macro WIDECHAR undoing from Ingo Schwarze.
 1.50  09-Apr-2016  christos More WIDECHAR elimination (Ingo Schwarze)
 1.49  24-Feb-2016  christos A very simple, non-intrusive patch to fix a segfault (and a
functional error) in c_gets(), file chared.c.

Run any program using libedit in the default way. At the el_[w]gets()
prompt, invoke ed-command (for example, in emacs mode, press the
escape key, then type the letter 'x'). You should see a ": " prompt.
Type the letter 'x' again. Now press the backspace key a few times,
looking at the screen after each key press:

- The 1st BS deletes the 'x'.
- The 2nd BS deletes the blank after the prompt.
- The 3rd BS deletes the colon of the prompt.
- The 4th BS moves the cursor up one line.
- The 5th BS gives me "Segmentation fault (core dumped)".

Depending on your platform, it might take a few more or a few less
backspaces for the buffer underrun to trigger the segfault, but
you should be able to hit it sooner or later no matter what.

Run the same program again, connect again and invoke ed-command again.
Now type: 'b', backspace, 'i', backspace, 'n', backspace, 'd', enter.
The "bind" command gets executed, even though you deleted what you
typed before hitting enter.

From Ingo Schwatze.
 1.48  24-Feb-2016  christos Get split el_getc and el_wgetc completely and call el_wgetc internally.
Change some character constants to they wide versions. (Ingo Schwarze)
 1.47  17-Feb-2016  christos whitespace and header sorting changes (Ingo Schwarze). No functional changes.
 1.46  16-Feb-2016  christos More header cleanups from Ingo Schwarze.
 1.45  16-Feb-2016  christos more include file cleanup (Ingo Schwarze)
 1.44  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.43  16-Feb-2016  christos cleanup chartype.h includes (Ingo Schwarze)
 1.42  16-Feb-2016  christos cleanup inclusion of histedit.h (Ingo Schwarze)
 1.41  14-Feb-2016  christos From Ingo Schwarze:

As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.

Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.

Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.

With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.

This only changes internal interfaces; public ones remain unchanged.
 1.40  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.39  12-Jul-2013  christos branches: 1.39.4;
cast to avoid warning.
 1.38  12-Jul-2013  christos Add a function to move the cursor.
 1.37  18-Jul-2012  christos branches: 1.37.2;
From Kamil Dudka: fix crash of el_insertstr() on incomplete multi-byte
 1.36  23-Oct-2011  christos branches: 1.36.2;
Fixed misplaced parenthesis (Nirbhay Choubey)
 1.35  16-Aug-2011  christos re-enable -Wconversion
 1.34  29-Jul-2011  christos pass -Wconversion
 1.33  29-Jul-2011  christos kill ifdef notdef
 1.32  29-Jul-2011  christos KNF return (\1); -> return \1;
 1.31  28-Jul-2011  christos kill ptr_t and ioctl_t, add * sizeof(*foo) to all allocations.
 1.30  28-Jul-2011  christos term -> terminal
XXX: need to rename key_ too.
 1.29  28-Aug-2010  christos 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.28  30-Dec-2009  christos Wide character support (UTF-8) from Johny Mattsson; currently disabled.
 1.27  15-Feb-2009  christos pass lint on _LP64.
 1.26  06-Feb-2009  sketch branches: 1.26.2;
de-__P()
 1.25  08-Aug-2005  christos The previous commit removed too much and forgot to reset the history event
number. From Kouichirou Hiratsuka, many thanks!
 1.24  01-Aug-2005  christos Don't reset the macro strings each time we enter el_gets(), otherwise
el_push() is unusable programmatically.
 1.23  01-Jun-2005  lukem Don't use non-standard uint or u_int.
 1.22  13-Aug-2004  mycroft Delete-previous-char and delete-next-char without an argument are not supposed
to modify the yank buffer in Emacs. Make it so.
 1.21  02-Nov-2003  christos Always use el->el_buffer, because newbuffer could have moved. From
Gerry Swislow gerry at certif dot com
 1.20  18-Oct-2003  christos change allocation policy in el_push to allocate the string itself.
fix issues with strdup.
 1.19  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.18  20-Nov-2002  christos Fix problem with previous patches that broke vi history.
- c_gets() was usually returning a length, but sometimes
one of the CC_xxx values (which are small +ve integers)!
- fixed c_gets() by putting a ' ' under the cursor.
From David Laight.
 1.17  15-Nov-2002  christos PR/18995: David Laight: libedit fixes for posix conformant sh

The posix 'sh' specification defines vi-mode editing quite tightly.
The netbsd libedit code (used by sh to do this) was missing several
features, there were also minor errors in others.

Compare netbsd sh to the definition available from:
http://www.opengroup.org/onlinepubs/007904975/utilities/sh.html
In particular the following were not supported:
U - undo all changes to line
| - goto column
Y - yank to end of line
y - yank
# - comment out current line
@ - take input from shell alias [1]
G - goto numbered line in history buffer
v - edit history line with vi
_ - append word from last input line
. - redo last command
Other minor changes have also been made.

[1] This needs the shell to define an appropriate routine to
return the text of the alias. There is no requirement that
such a function exist.
 1.16  27-Oct-2002  christos vi mode and memory fixes from david laight.
 1.15  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.14  17-May-2001  christos PR/12963:Jason Waterman: Fix signed cast problems.
 1.13  13-Apr-2001  lukem knf ch_enlargebufs(), to be *consistent* with the rest of this file...
 1.12  10-Jan-2001  jdolecek Enlarge editline buffers as needed to support arbitrary length lines.
This also addresses lib/9712 by Phil Nelson.
 1.11  04-Jan-2001  christos consistently check for allocation failures and return -1, if we could not
get more memory.
 1.10  11-Nov-2000  christos - add support for home and end keys.
- improve debugging support
 1.9  04-Sep-2000  lukem convert to new style guide, which includes:
- ansi prototypes & features (such as stdargs)
- 8 space indents
 1.8  28-Feb-2000  chopps el_insertstr takes a "const char *" not "char *" now as it doesn't modify
the argument.
 1.7  02-Jul-1999  simonb More trailing white space.
 1.6  05-Feb-1999  christos delint.
 1.5  12-Dec-1998  christos delint
 1.4  03-Feb-1998  perry remove obsolete register declarations
 1.3  06-Jul-1997  christos Fix compiler warnings.
 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.26.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.36.2.2  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.36.2.1  30-Oct-2012  yamt sync with head
 1.37.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.4.1  10-Aug-2014  tls Rebase.
 1.57.4.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411

RSS XML Feed