Home | History | Annotate | Download | only in libedit
History log of /src/lib/libedit/chartype.c
RevisionDateAuthorComments
 1.37  10-Aug-2023  mrg avoid various use-after-free issues.

create a ptrdiff_t offset between the start of an allocation region and
some interesting pointer, so it can be adjusted with this offset after
realloc() returns.

found by GCC 12.
 1.36  30-Oct-2022  christos improvements in malloc/free handling.
 1.35  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.34  25-Nov-2018  christos From Yuichiro Naito (FreeBSD):
hrs@ says that wctomb(3) has an internal shift state,
if wctomb(3) is called outside of libedit,
the internal state can be changed and causes miscalculate multibyte size.

So in this part, wcrtomb(3) should be used.
wcrtomb(3) requires that shift state is given in the argument.
We always initialize the shift state in ct_enc_width() to keep independent
from outside of libedit.
 1.33  18-Nov-2018  christos fix compilation
 1.32  18-Nov-2018  christos Remove utf-8 requirement (Yuichiro NAITO)
 1.31  09-Jan-2017  christos branches: 1.31.12; 1.31.14;
Make sure that argv is NULL terminated since functions like tty_stty rely
on it to be so (Gerry Swinslow)
 1.30  09-May-2016  christos branches: 1.30.2;
s/protected/libedit_private/g
 1.29  02-May-2016  christos eliminate static buffer with custom resizing code.
 1.28  11-Apr-2016  christos Get rid of private/public; keep protected (Ingo Schwarze)
 1.27  11-Apr-2016  christos chartype cleanups from Ingo Schwarze:

- The file tokenizer.c no longer uses chartype.h,
so don't include the header.

- The dummy definitions of ct_{de,en}code_string() for the
NARROWCHAR case are only used in history.c, so move them there.

- Now the whole content of chartype.h is for the wide character
case only. So remove the NARROWCHAR ifdef and include the
header only in the wide character case.

- In chartype.h, move ct_encode_char() below the comment explaining it.

- No more need for underscores before ct_{de,en}code_string().

- Make the conversion buffer resize functions private.
They are only called from the decoding and encoding functions
inside chartype.c, and no need can possibly arise to call them
from anywhere else.
 1.26  11-Apr-2016  christos Char -> wchar_t from Ingo Schwarze.
 1.25  09-Apr-2016  christos More WIDECHAR elimination (Ingo Schwarze)
 1.24  23-Mar-2016  christos Start removing the WIDECHAR ifdefs; building without it has stopped working
anyway. (Ingo Schwarze)
 1.23  28-Feb-2016  christos remove 4 clause licenses.
 1.22  24-Feb-2016  christos Tuck in mbstate_t to the wide char version only to avoid exposing the zeroing
hack and doing it in the narrow case.
 1.21  24-Feb-2016  christos Make the read_char function always take a wchar_t * argument (Ingo Schwarze)
 1.20  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.19  17-Feb-2016  christos whitespace and header sorting changes (Ingo Schwarze). No functional changes.
 1.18  16-Feb-2016  christos More header cleanups from Ingo Schwarze.
 1.17  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.16  16-Feb-2016  christos cleanup chartype.h includes (Ingo Schwarze)
 1.15  16-Feb-2016  christos cleanup inclusion of histedit.h (Ingo Schwarze)
 1.14  14-Feb-2016  christos From Ingo Schwartze:

Next step: Remove #ifdef'ing in read_char(), in the same style
as we did for setlocale(3) in el.c.

A few remarks are required to explain the choices made.

* On first sight, handling mbrtowc(3) seems a bit less trivial
than handling setlocale(3) because its prototype uses the data
type mbstate_t from <wchar.h>. However, it turns out that
"histedit.h" already includes <wchar.h> unconditionally (i don't
like headers including other headers, but that ship has sailed,
people are by now certainly used to the fact that including
"histedit.h" doesn't require including <wchar.h> before), and
"histedit.h" is of course included all over the place. So from
that perspective, there is no problem with using mbrtowc(3)
unconditionally ever for !WIDECHAR.

* However, <wchar.h> also defines the mbrtowc(3) prototype,
so we cannot just #define mbrtowc away, or including the header
will break. It would also be a bad idea to porovide a local
implementation of mbrtowc() and hope that it overrides the one
in libc. Besides, the required prototype is subtly different:
While mbrtowc(3) takes "wchar_t *" as its first argument, we
need a function that takes "Char *". So unfortunately, we have
to keep a ct_mbrtowc #define, at least until we can maybe get
rid of "Char *" in the more remote future.

* After getting rid of the #else clause in read_char(), we can
pull "return 1;" into the default: clause. After that, we can
get rid of the ugly "goto again_lastbyte;" and just "break;".
As a bonus, that also gets rid of the ugly CONSTCOND.

* While here, delete the unused ct_mbtowc() from chartype.h.
 1.13  11-Feb-2016  christos - Add some more Char casts
- reduce ifdefs by providing empty defs for nls functions (Ingo Schwarze)
 1.12  22-Feb-2015  christos split the allocation functions, their mixed usage was too confusing.
 1.11  22-Feb-2015  christos PR/49683: Amir Plivatsky: Off-by-one comparison in ct_decode_string() leading
to out of bounds referrence.
XXX: pullup-7
 1.10  16-Aug-2011  christos branches: 1.10.20;
re-enable -Wconversion
 1.9  29-Jul-2011  christos pass -Wconversion
 1.8  29-Jul-2011  christos KNF return (\1); -> return \1;
 1.7  28-Jul-2011  christos kill ptr_t and ioctl_t, add * sizeof(*foo) to all allocations.
 1.6  28-Jul-2011  christos - fix memory allocation botch in wide strings
- check mbstowcs return code
 1.5  27-Jul-2011  christos fix buffer growing code.
 1.4  15-Apr-2010  christos From Jess Thrysoee
expose ct_enc_width()
 1.3  12-Jan-2010  christos - in the argv conversion, handle NULL as NULL
- when printing tab/nl print them, don't handle them specially.
 1.2  31-Dec-2009  christos expose the encode and decode string functions for the benefit of history
and readline.
 1.1  30-Dec-2009  christos Wide character support (UTF-8) from Johny Mattsson; currently disabled.
 1.10.20.1  14-Apr-2015  snj Pull up following revision(s) (requested by christos in ticket #679):
lib/libedit/chartype.c: revisions 1.11, 1.12
lib/libedit/chartype.h: revisions 1.12, 1.13
PR/49683: Amir Plivatsky: Off-by-one comparison in ct_decode_string() leading
to out of bounds referrence.
--
split the allocation functions, their mixed usage was too confusing.
 1.30.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.31.14.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.31.14.1  10-Jun-2019  christos Sync with HEAD
 1.31.12.1  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts

RSS XML Feed