Commit Graph

42 Commits

Author SHA1 Message Date
christos
113f06a345 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.
2019-07-23 10:18:52 +00:00
christos
f04c2e3e34 Fix off by one <tsahara at iij> 2018-11-29 03:10:20 +00:00
christos
a2d6b270ec s/protected/libedit_private/g 2016-05-09 21:46:56 +00:00
christos
39e1d6f1ed Fix indentation, Ingo Schwarze 2016-04-11 22:30:14 +00:00
christos
469d44f8e7 Get rid of private/public; keep protected (Ingo Schwarze) 2016-04-11 18:56:31 +00:00
christos
0594af8028 Char -> wchar_t from Ingo Schwarze. 2016-04-11 00:50:13 +00:00
christos
0aefc7f9ad more macro WIDECHAR undoing from Ingo Schwarze. 2016-04-11 00:22:48 +00:00
christos
22383670cc whitespace and header sorting changes (Ingo Schwarze). No functional changes. 2016-02-17 19:47:49 +00:00
christos
e84df91e32 More header cleanups from Ingo Schwarze. 2016-02-16 22:53:14 +00:00
christos
747f681109 more include file cleanup (Ingo Schwarze) 2016-02-16 19:08:41 +00:00
christos
aefc1e4460 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...
2016-02-16 15:53:48 +00:00
christos
f09cb8c626 cleanup chartype.h includes (Ingo Schwarze) 2016-02-16 14:08:25 +00:00
christos
40850369f8 cleanup inclusion of histedit.h (Ingo Schwarze) 2016-02-16 14:06:05 +00:00
christos
f54e4f97f9 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.
2016-02-14 14:49:34 +00:00
christos
6af8d6733f - Add some more Char casts
- reduce ifdefs by providing empty defs for nls functions (Ingo Schwarze)
2016-02-11 19:21:04 +00:00
christos
80e781ab85 Bounds search for reallocated index, from OpenBSD via Andreas Fett 2014-07-06 18:15:34 +00:00
christos
3d802cf59d re-enable -Wconversion 2011-08-16 16:25:15 +00:00
christos
b71bed95b3 KNF return (\1); -> return \1; 2011-07-29 15:16:33 +00:00
christos
98c7cbebbc term -> terminal
XXX: need to rename key_ too.
2011-07-28 01:05:20 +00:00
christos
34e53048e6 Wide character support (UTF-8) from Johny Mattsson; currently disabled. 2009-12-30 22:37:40 +00:00
lukem
48753fbc85 Update for recent parse__escape() prototype change 2005-05-29 04:58:15 +00:00
christos
917b5f36b1 PR/25694: Luke Mewburn: Don't abuse unconstify'ing a string and writing to
it, because you'll core dump. Also remove extra const that gives pain to
the irix compiler.
2005-05-29 03:55:37 +00:00
lukem
a9beb0e443 Tokenization function enhancements:
* Make tok_init(), tok_end(), tok_reset(), tok_line() and tok_str()
  publically available in <histedit.h>
* Documented the public functions in editline(3)
* Renamed tok_line() -> tok_str()
* Added new tok_line() which takes a "const LineInfo *" instead of
  "const char *" (the former has "cursor" information), and optionally
  return the argv index ("int *cursorc") and offset within that index
  ("int *cursorv").  This means that completion routines can use the
  tokenization code to crack the line and easily find which word the
  cursor is at.  (mmm, context sensitive completion :)
* Fixed TEST/test.c when using "continuation" lines (unmatched quote
  or \ at EOL), and added some more DEBUG messages including highlighting
  where the cursor is (with a `_').
2003-12-05 13:37:48 +00:00
christos
d67d488ee2 Handle M- as escape. XXX: should probably select the meta-map instead.
From Gerry Swislow  gerry at certif com
2003-11-02 20:06:57 +00:00
christos
378865a426 don't limit ^c to alpha c, and add VIS_NOSLASH so that vis(3) does not
produce \^c
2003-10-15 18:08:40 +00:00
agc
eb7c1594f1 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22280, verified by myself.
2003-08-07 16:42:00 +00:00
christos
f24857bf36 Add a uniquefier for the history function. 2003-01-21 18:40:23 +00:00
christos
0e0ac6b723 - 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.
2002-03-18 16:00:50 +00:00
jdolecek
86ebf640b0 sprinkle couple const 2001-01-23 15:55:30 +00:00
lukem
d30d584a91 convert to new style guide, which includes:
- ansi prototypes & features (such as stdargs)
- 8 space indents
2000-09-04 22:06:28 +00:00
jdolecek
1f0ecc5ce4 include <stdlib.h> to get definition of malloc() and free(), so it's
possible to compile this file separately when debugging
2000-03-10 12:25:47 +00:00
simonb
1528b77539 More trailing white space. 1999-07-02 15:14:07 +00:00
christos
0d4dea9233 M-X:<enter> core-dumped. 1999-02-05 20:38:01 +00:00
christos
a6d4afba22 delint 1998-12-12 20:08:21 +00:00
lukem
f87d250404 * 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.
1998-07-29 02:26:00 +00:00
lukem
63177b84ae in el_parse(), use a temporary buffer to store the program name when
comparing, preventing trashing of argv[0]. remove note in man page
warning of former behaviour.
1998-01-21 11:12:34 +00:00
christos
54fac6850e Fix compiler warnings. 1997-07-06 18:25:21 +00:00
lukem
5785f63611 * document ^char and \ escape sequences
* when parsing ^char control chars, check the correct char when determining
  validity (previously, ^char was a NOP interpreted as the literal string
  because of this bug)
1997-01-11 09:57:06 +00:00
lukem
2543e3e651 RCSid police
editline first appeared in 4.4BSD not NetBSD1.0
1997-01-11 06:47:47 +00:00
lukem
258ebfd268 * in el_parse(), don't reference argv[0] if argc < 1 (return -1 instead)
* clarify return value of el_parse()
1997-01-11 06:26:30 +00:00
lukem
b59d3eaf10 * add a man page for the editline routines
* add a man page describing editrc
* fix bugs in el_parse():
	* didn't execute command when program name matched (test reversed)
	* was checking against empty string instead of program name
	* after checks, command to run also pointed to empty string

[christos - the author of libedit - ok-ed the man pages in general (which I
 wrote from scratch by RTFS) as well as the bugfix]
1997-01-09 13:12:14 +00:00
cgd
6dc2f1db52 libedit! 1994-05-06 06:01:42 +00:00