Technically we seem to be compiling with `-std=c++2a` which (if I
understand correctly) is "all the features we have from 23 and up.
But 20 is the earliest version that compiles for me (with clang). 14 and 17 didn't work.
On macOS, backspace reportedly no longer works after <c-z> and fg.
The value of m_original_termios.c_cc[VERASE] seems to be wrong
in a static lambda that captures a singleton "this".
Not sure what's the problem. I thought that it is guaranteed that
"static auto convert = [this]() { ... }" is initialized lazily,
hence it should capture the correct address. Maybe the address
changes somehow or it's UB / a compiler bug.
This reverts commit ad36585b7aCloses#5155
On FreeBSD and NetBSD, sysctl() can return -1 when the path is too long,
leaving the buffer unitialised.
On macOS, both _NSGetExecutablePath() and realpath() can fail with
pathological paths or if memory is exhausted.
On Haiku, the kak_assert(status == B_OK) check will be compiled out in
non-debug builds.
Detect all of these cases and error out, reshaping get_kak_binary_path()
to avoid multiple repetitions of the same fatal error message.
On Linux, Hurd, Cygwin, DragonFly BSD and Solaris/Illumos, Kakoune obtains
a path to its binary by reading the appropriate /proc symlink target.
readlink() can fail or it can fill the entire buffer, silently truncating
the path if the buffer is too small.
kak_assert() is compiled out in non-debug builds so we ignore a readlink()
failure, corrupt the stack by writing to buffer[-1] then return a string
from the uninitialised buffer.
If readlink() succeeds and the binary path is sizeof(buffer) long, we write
a \0 terminator beyond its end. If it is longer, we also truncate the path.
Throw a fatal error on startup in all these unlikely failure cases.
ASan shows that we resolve a face spec owned by a freed stack variable.
=================================================================
==2263300==ERROR: AddressSanitizer: stack-use-after-return on address 0x7a9316c33918 at pc 0x633ea421d8ea bp 0x7ffca001e980 sp 0x7ffca001e970
READ of size 8 at 0x7a9316c33918 thread T0
...
#6 0x633ea421d8e9 in Kakoune::FaceRegistry::resolve_spec(Kakoune::FaceSpec const&) const src/face_registry.cc:128
...
Address 0x7a9316c33918 is located in stack of thread T0 at offset 2328 in frame
#0 0x633ea427a095 in operator() src/commands.cc:2267
This frame has 26 object(s):
[32, 36) '<unknown>'
...
[544, 560) 'disable_hooks' (line 2269)
...
[928, 2432) 'local_scope' (line 2271) <== Memory access at offset 2328 is inside this variable
I dedicate any and all copyright interest in this software to the
public domain. I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors. I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
When using `eval` a new scope named 'local' gets pushed for the
whole evaluation, this makes it possible to temporarily set
an option/hook/alias...
Local scopes nest so nested evals do work as expected.
Remove the now trivial with-option command
MacOS uses an old GNU make that does not support the != syntax.
That syntax is not Posix (yet, it is accepted for next standard) but
we really need a way to call the shell from a Makefile. Hopefully we
can remove this soon (not holding my breath though)
Fixes#5117