Age | Commit message (Collapse) | Author | Files | Lines |
|
* Practically all calls to teco_expressions_args() must be preceded by teco_expressions_eval().
* In code paths where we know that teco_expressions_args() > 0, it is safe
to call teco_expressions_pop_num(0) instead of teco_expressions_pop_num_calc().
This is both easier and faster.
* teco_expressions_pop_num_calc() is for simple applications where you just want to get
a command argument with default (implied) values.
Since it includes teco_expressions_eval(), we can avoid superfluous calls.
* -EC...$ turned out to be broken and is fixed now.
A test case has been added.
|
|
* Added some keywords.
* Consistently added command variants with all modifiers.
In principle including modifiers in the topics is unnecessary -
you can always strip the modifiers and look up the raw command.
However, looking up a command with modifiers can speed up the process
(compare looking up ?S<TAB> vs ?::S<TAB>
* The `@` modifier is listed only for commands without string arguments.
|
|
* Previously, deleting text after a text match or insertion
could result in wrong ^S/^Y results.
In particular, the amount of characters deleted by <FD> at the end of a buffer
couldn't be queried.
* This also fixes the M#rf (reflow paragraph) macro.
|
|
* It turns out that `bool` (_Bool) in bitfields may cause
padding to the next 32-bit word.
This was only observed on MinGW.
I am not entirely sure why, although the C standard does
not guarantee much with regard to bitfield memory layout
and there are 64-bit available due to passing anyway.
Actually, they could also be layed out in a different order.
* I am now consistently using guint instead of `bool` in bitfields
to prevent any potential surprises.
* The way that guint was aliased with bitfield structs
for undoing teco_machine_main_t and teco_machine_qregspec_t flags
was therefore insecure.
It was not guaranteed that the __flags field really "captures"
all of the bit field.
Even with `guint v : 1` fields, this was not guaranteed.
We would have required a static assertion for robustness.
Alternatively, we could have declared a `gsize __flags` variable
as well. This __should__ be safe since gsize should always be
pointer sized and correspond to the platform's alignment.
However, it's also not 100% guaranteed.
Using classic ANSI C enums with bit operations to encode multiple
fields and flags into a single integer also doesn't look very
attractive.
* Instead, we now define scalar types with their own teco_undo_push()
shortcuts for the bitfield structs.
This is in one way simpler and much more robust, but on the other
hand complicates access to the flag variables.
* It's a good question whether a `struct __attribute__((packed))` bitfield
with guint fields would be a reliable replacement for flag enums, that
are communicated with the "outside" (TECO) world.
I am not going to risk it until GCC gives any guarantees, though.
For the time being, bitfields are only used internally where
the concrete memory layout (bit positions) is not crucial.
* This fixes the test suite and therefore probably CI and nightly
builds on Windows.
* Test case: Rub out `@I//` or `@Xq` until before the `@`.
The parser doesn't know that `@` is still set and allows
all sorts of commands where `@` should be forbidden.
* It's unknown how long this has been broken on Windows - quite
possibly since v2.0.
|
|
Environment variables will of course never contain null-bytes.
However you can always set them later on from TECO code and include nulls.
We therefore everywhere check for null-bytes in all registers used as null-terminated strings
to avoid unexpected behavior.
|
|
|
|
::FS as well)
* The colon modifier can now occur 2 times.
Specifying `@` more than once or `:` more than twice is an error now.
* Commands do not check for excess colon modifiers - almost every command would have
to check it. Instead, a double colon will simply behave like a single colon on most
commands.
* All search commands inherit the anchored semantics, but it's not very useful in some combinations
like -::S, ::N or ::FK.
That's why the `::` variants are not documented everywhere.
* The lexer.checkheader macro could be simplified and should also be faster now,
speeding up startup.
Eventually this macro can be made superfluous, e.g. by using 1:FB or 0,1^Q::S.
|
|
lengths (refs #27)
* Allows storing pattern matches into Q-Registers (^YXq).
* You can also refer to subpatterns marked by ^E[...] by passing a number > 0.
This is equivalent to \0-9 references in many programming languages.
* It's especially useful for supporting TECO's equivalent of structural regular expressions.
This will be done with additional macros.
* You can also simply back up to the beginning of an insertion or search.
So I...$^SC leaves dot at the beginning of the insertion.
S...$^SC leaves dot before the found pattern.
This has been previously requested by users.
* Perhaps there should be ^Y string building characters as well to backreference
in search-replacement commands (TODO).
This means that the search commands would have to store the matched text itself
in teco_range_t structures since FR deletes the matched text before
processing the replacement string.
It could also be made into a FR/FS-specific construct,
so we don't fetch the substrings unnecessarily.
* This differs from DEC TECO in always returning the same range even after dot movements,
since we are storing start/end byte positions instead of only the length.
Also DEC TECO does not support fetching subpattern ranges.
|
|
|
|
Supposing that any monkey hitting keys on a typewriter, serving as a hardcopy
SciTECO terminal, will sooner or later trigger bugs and crash the application,
the new monkey-test.apl script emulates such a monkey.
In fact it's a bit more elaborate as the generated macro follows the frequency
distribution extracted from the corpus of SciTECO macro files (via monkey-parse.apl).
This it is hoped, increases the chance to get into "interesting" parser states.
This also adds a new hidden --sandbox argument, but it works only on FreeBSD (via Capsicum)
so far. In sandbox mode, we cannot open any file or execute external commands.
It is made sure, that SciTECO cannot assert in sandbox mode for scripts that would
run without --sandbox, since assertions are the kind of things we would like to detect.
SciTECO must be sandboxed during "infinite monkey" tests, so it cannot accidentally
do any harm on the system running the tests.
All macros in sandbox mode must currently be passed via --eval.
Alternatively, we could add a test compilation unit and generate the test data
directly in memory via C code.
The new scripts are written in GNU APL 1.9 and will probably work only under FreeBSD.
These scripts are not meant to be run by everyone.
|
|
* This was a regression introduced in 41ab5cf0289dab60ac1ddc97cf9680ee2468ea6c,
which changed the semantics of teco_doc_undo_set_string().
* Removed undo_append_string() Q-Reg virtual method.
append_string() now does its own undo token emission, so that we can
defer the teco_doc_undo_edit() after the point that the document
was initialized. This is important, so that we can configure the
default encoding on new registers.
|
|
* detected under FreeBSD
* It turns out that it's unsafe to make the GIOChannel blocking
even though the application has already terminated and the channel
should be closed automatically.
The channel does not report EOF, but instead we have to look for
zero reads - in complete contrast to the behavior on Windows.
Apparently, it's very tricky to use this API correctly
(ie. it sucks).
* fixup to e9bef20a8ad89d304fe3e8fafa00056d22de2326
|
|
* We now recreate the event loop with every call since
it turned out that the idle watcher wouldn't be invoked
after the event loop has been quit once.
This at least fixes interruption of ECbash -c 'while true; do true; done'$.
* Unfortunately, ECping -t 8.8.8.8$ still cannot be interrupted
(unless you manually kill the process from the task manager).
|
|
* This has only ever observed on Win32, probably because the spawning
behaves very differently.
* The stdout watcher could be invoked even after removing the source,
so we must be secured against it - this was causing some overflows
and invalid reads.
* Also, teco_eol_reader_convert() could return 0 even after process
termination, which would sometimes result in too few bytes being
inserted.
This could be provoked relatively easily by invoking ECdir$ repeatedly.
|
|
terminating process groups on Win32
* Sometimes already the job assignment failed in CI builds.
We now check whether the process is still alive before throwing an error.
* We now set the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag.
This theoretically shouldn't be necessary when using TerminateJobObject(),
but who knows.
|
|
current state machine
* The previous solution was not wrong, but unnecessarily complex. We already have a flag
for exactly this purpose.
* Avoid redundancies by introducing teco_machine_stringbuilding_set_codepage().
|
|
teco_machine_stringbuilding_t::codepage
* It's contained in teco_machine_main_t which is created per macro call frame.
So after macro calls, the machine no longer exists.
It is therefore unsafe to undo its members indiscriminately.
* On the other hand, we must undo the codepage setting when run interactively,
so it is now only undone when belonging to the commandline macro frame.
* This was actually causing memory corruptions on every fnkeys cursor movement, but never
caused crashes - probably because the invalid pointers are always pointing to unused
parts of the C call stack.
* Initially broken in b31b8871.
|
|
The following rules apply:
* All SciTECO macros __must__ be in valid UTF-8, regardless of the
the register's configured encoding.
This is checked against before execution, so we can use glib's non-validating
UTF-8 API afterwards.
* Things will inevitably get slower as we have to validate all macros first
and convert to gunichar for each and every character passed into the parser.
As an optimization, it may make sense to have our own inlineable version of
g_utf8_get_char() (TODO).
Also, Unicode glyphs in syntactically significant positions may be case-folded -
just like ASCII chars were. This is is of course slower than case folding
ASCII. The impact of this should be measured and perhaps we should restrict
case folding to a-z via teco_ascii_toupper().
* The language itself does not use any non-ANSI characters, so you don't have to
use UTF-8 characters.
* Wherever the parser expects a single character, it will now accept an arbitrary
Unicode/UTF-8 glyph as well.
In other words, you can call macros like M§ instead of having to write M[§].
You can also get the codepoint of any Unicode character with ^^x.
Pressing an Unicode character in the start state or in Ex and Fx will now
give a sane error message.
* When pressing a key which produces a multi-byte UTF-8 sequence, the character
gets translated back and forth multiple times:
1. It's converted to an UTF-8 string, either buffered or by IME methods (Gtk).
On Curses we could directly get a wide char using wget_wch(), but it's
not currently used, so we don't depend on widechar curses.
2. Parsed into gunichar for passing into the edit command callbacks.
This also validates the codepoint - everything later on can assume valid
codepoints and valid UTF-8 strings.
3. Once the edit command handling decides to insert the key into the command line,
it is serialized back into an UTF-8 string as the command line macro has
to be in UTF-8 (like all other macros).
4. The parser reads back gunichars without validation for passing into
the parser callbacks.
* Flickering in the Curses UI and Pango warnings in Gtk, due to incompletely
inserted and displayed UTF-8 sequences, are now fixed.
|
|
teco_interface_glyphs2bytes() and teco_interface_bytes2glyphs() (refs #5)
* for consistency with all the other teco_view wrappers in interface.h
|
|
* When enabled with bit 2 in the ED flags (0,4ED),
all registers and buffers will get the raw ANSI encoding (as if 0EE had been
called on them).
You can still manually change the encoding, eg. by calling 65001EE afterwards.
* Also the ANSI mode sets up character representations for all bytes >= 0x80.
This is currently done only depending on the ED flag, not when setting 0EE.
* Since setting 16,4ED for 8-bit clean editing in a macro can be tricky -
the default unnamed buffer will still be at UTF-8 and at least a bunch
of environment registers as well - we added the command line option
`--8bit` (short `-8`) which configures the ED flags very early on.
As another advantage you can mung the profile in 8-bit mode as well
when using SciTECO as a sort of interactive hex editor.
* Disable UTF-8 checks in 8-bit clean mode (sample.teco_ini).
|
|
* ^Uq however always sets an UTF8 register as the source
is supposed to be a SciTECO macro which is always UTF-8.
* :^Uq preserves the register's encoding
* teco_doc_set_string() now also sets the encoding
* instead of trying to restore the encoding in teco_doc_undo_set_string(),
we now swap out the document in a teco_doc_t and pass it to an undo token.
* The get_codepage() Q-Reg method has been removed as the same
can now be done with teco_doc_get_string() and the get_string() method.
|
|
or codepoints) (refs #5)
* This is trickier than it sounds because there isn't one single place to consult.
It depends on the context.
If the string argument relates to buffer contents - as in <I>, <S>, <FR> etc. -
the buffer's encoding is consulted.
If it goes into a register (EU), the register's encoding is consulted.
Everything else (O, EN, EC, ES...) expects only Unicode codepoints.
* This is communicated through a new field teco_machine_stringbuilding_t::codepage
which must be set in the states' initial callback.
* Seems overkill just for ^EUq, but it can be used for context-sensitive
processing of all the other string building constructs as well.
* ^V and ^W cannot be supported for Unicode characters for the time being without an Unicode-aware parser
|
|
* This works reasonably well unless lines are exceedingly long
(as on a line we always count characters).
The following test case is still slow (on Unicode buffers):
10000<@I/XX/> <%a-1:J;>
While the following is now also fast:
10000<@I/X^J/> <%a-1:J;>
* Commands with relative character offsets (C, R, A, D) have
a special optimization where they always count characters beginning
at dot, as long as the argument is now exceedingly large.
This means they are fast even on exceedingly long lines.
* The remaining commands (search, EC/EG, Xq) now accept glyph indexes.
|
|
|
|
* passing an empty command string down to the shell would always do nothing,
so it doesn't make sense to support that.
* for the time being, we generate a proper error
* in the future, it might make sense to define some special behavior like repeating
the last command - but EC does not currently save the command line anywhere.
* The generated documentation is currently ugly (FIXME).
mandatory parameters are not properly detected by tedoc and we cannot keep apart
Q-Registers from mandatory parameters either.
Also, we should allow <param> markup in command summaries.
|
|
for debug builds
* There is cleanup that is not strictly necessary, because it only frees memory
which is freed on program termination anyway.
* However, it helps to explicitly free everything for debugging memory leaks via Valgrind.
* The new macro reduces the number of #ifdef statements.
* On NDEBUG, the code of these functions will still be eliminated.
* If functions are referenced only from the destructor, there will be no unused function
warnings, even in NDEBUG.
|
|
* This especially fixes spawning on 0,128ED-mode broken since
f557af9a9112955d3b65f6ad0d54c0791189f961.
* The process is added to a job object now, which allows us to
kill the entire process tree.
Previously we we were leaving around orphaned processes.
|
|
|
|
* teco_interrupt() turned out to be unsuitable to kill child processes (eg. when <EB> hangs).
Instead, we have Win32-specific code now.
* Since SIGINT can be ignored on UNIX, pressing CTRL+C was not guaranteed to kill the
child process (eg. when <EB> hangs).
At the same time, it makes sense to send SIGINT first, so programs can terminate gracefully.
The behaviour has therefore been adapted: Interrupting with CTRL+C the first time will kill
gracefully. The second time, a more agressive signal is sent to kill the child process.
Unfortunately, this would be relatively tricky and complicated to do on Windows, so CTRL+C will always
"hard-kill" the child process.
* Moreover, teco_interrupt() killed the entire process on Windows when called the second time.
This resulted in any interruption to terminate SciTECO unexpectedly when tried the second time on Gtk/Win32.
* teco_sigint_occurred renamed to teco_interrupted:
There may be several different sources for setting this flag.
* Checking for CTRL+C on Gtk involves driving the main event loop repeatedly.
This is a very expensive operation. We now do that only every 100ms. This is still sufficient since
keyboard input comes from humans.
This optimization saves 75% runtime on Windows and 90% on Linux.
* The same optimization turned out to be contraproductive on PDCurses/WinGUI.
|
|
* test case: ECwhile true; do true; done$
* Some platforms require polling via teco_interface_is_interrupted()
for detecting interruptions, so we added an idle watcher to the
Glib event loop in spawn.c.
* On platforms that do not require polling key presses (like Unix/ncurses),
the idle watcher won't do any harm.
|
|
Scintilla now
* The patch avoids all automatic scrolling consistently, including in SCI_UNDO.
This speads up Undo (especially after interruptions).
* Also, the patch disables a very costly and pointless (in SciTECO) algorithm that
effectively made <Ix$> uninterruptible.
* Effectively reverts large parts of 8ef010da59743fcc4927c790f585ba414ec7b129.
I have never liked using unintuitive Scintilla messages to avoid scrolling.
|
|
|
|
registers
* An empty but valid teco_string_t can contain NULL pointers.
More precisely, a state's done_cb() can be invoked with such empty strings
in case of empty string arguments.
Also a registers get_string() can return the NULL pointer
for existing registers with uninitialized string parts.
* In all of these cases, the language should treat "uninitialized" strings
exactly like empty strings.
* Not doing so, resulted in a number of vulnerabilities.
* EN$$ crashed if "_" was uninitialized
* The ^E@q and ^ENq string building constructs would crash for existing but
uninitialized registers q.
* ?$ would crash
* ESSETILEXER$$ would crash
* This is now fixed.
Test cases have been added.
* I cannot guarantee that I have found all such cases.
Generally, it might be wise to change our definitions and make sure that
every teco_string_t must have an associated heap object to be valid.
All functions returning pointer+length pairs should consequently also never
return NULL pointers.
|
|
|
|
* avoid emitting SCI_UNDO undo tokens if the Scintilla undo action would actually be empty
|
|
once per keypress
* Esp. costly since Scintilla 5.
* We now avoid any Scintilla message that automatically scrolls the caret (makes the
caret visible) and instead call SCI_SCROLLCARET only once after every keypress in the
interface implementation.
* From nowon, use
* SCI_SETEMPTYSELECTION instead of SCI_GOTOPOS
* SCI_SETEMPTYSELECTION(SCI_POSITIONFROMLINE(...)) instead of SCI_GOTOLINE
* SCI_SETSELECTIONSTART and SCI_SETSELECTIONEND instead of SCI_SETSEL
* With these optimizations we are significantly faster than before
the Scintilla upgrade (6e67f5a682ff46d69888fec61b94bf45cec46721).
It is now even safe to execute the Gtk test suite during CI.
|
|
|
|
"optimized" code-path on UNIX
|
|
* Environment variables are case insensitive on Windows
while SciTECO variables are case sensitive.
We must therefore make sure that we first unset any $COMSPEC or $ComSpec
from the environment before resetting it, thereby fixing its case.
* Fixes command execution via <EC> on systems where the variable
was not called $ComSpec.
|
|
would be exceeded
* Checking whether the allocation succeeded may not prevent exceeding the memory
limit excessively.
* Even if the memory limit is not exceeded, the allocation can fail theoretically
and the program would terminate abnormally.
This however is true for all allocations in SciTECO (via glib).
* teco_memory_check() therefore now supports checking whether an allocation would
exceed the memory limit which will be useful before very large or variable allocations
in addition to the regular checking in teco_machine_main_step().
* As a sideeffect, this fixes the "Searching with large counts" test case on Mac OS
where too large allocations were not detected as expected (apparently Mac OS
happily gives out ridiculously large chunks of memory).
Now, all platforms are guaranteed to have the same behaviour.
|
|
This is a total conversion of SciTECO to plain C (GNU C11).
The chance was taken to improve a lot of internal datastructures,
fix fundamental bugs and lay the foundations of future features.
The GTK user interface is now in an useable state!
All changes have been squashed together.
The language itself has almost not changed at all, except for:
* Detection of string terminators (usually Escape) now takes
the string building characters into account.
A string is only terminated outside of string building characters.
In other words, you can now for instance write
I^EQ[Hello$world]$
This removes one of the last bits of shellisms which is out of
place in SciTECO where no tokenization/lexing is performed.
Consequently, the current termination character can also be
escaped using ^Q/^R.
This is used by auto completions to make sure that strings
are inserted verbatim and without unwanted sideeffects.
* All strings can now safely contain null-characters
(see also: 8-bit cleanliness).
The null-character itself (^@) is not (yet) a valid SciTECO
command, though.
An incomplete list of changes:
* We got rid of the BSD headers for RB trees and lists/queues.
The problem with them was that they used a form of metaprogramming
only to gain a bit of type safety. It also resulted in less
readble code. This was a C++ desease.
The new code avoids metaprogramming only to gain type safety.
The BSD tree.h has been replaced by rb3ptr by Jens Stimpfle
(https://github.com/jstimpfle/rb3ptr).
This implementation is also more memory efficient than BSD's.
The BSD list.h and queue.h has been replaced with a custom
src/list.h.
* Fixed crashes, performance issues and compatibility issues with
the Gtk 3 User Interface.
It is now more or less ready for general use.
The GDK lock is no longer used to avoid using deprecated functions.
On the downside, the new implementation (driving the Gtk event loop
stepwise) is even slower than the old one.
A few glitches remain (see TODO), but it is hoped that they will
be resolved by the Scintilla update which will be performed soon.
* A lot of program units have been split up, so they are shorter
and easier to maintain: core-commands.c, qreg-commands.c,
goto-commands.c, file-utils.h.
* Parser states are simply structs of callbacks now.
They still use a kind of polymorphy using a preprocessor trick.
TECO_DEFINE_STATE() takes an initializer list that will be
merged with the default list of field initializers.
To "subclass" states, you can simply define new macros that add
initializers to existing macros.
* Parsers no longer have a "transitions" table but the input_cb()
may use switch-case statements.
There are also teco_machine_main_transition_t now which can
be used to implement simple transitions. Additionally, you
can specify functions to execute during transitions.
This largely avoids long switch-case-statements.
* Parsers are embeddable/reusable now, at least in parse-only mode.
This does not currently bring any advantages but may later
be used to write a Scintilla lexer for TECO syntax highlighting.
Once parsers are fully embeddable, it will also be possible
to run TECO macros in a kind of coroutine which would allow
them to process string arguments in real time.
* undo.[ch] still uses metaprogramming extensively but via
the C preprocessor of course. On the downside, most undo
token generators must be initiated explicitly (theoretically
we could have used embedded functions / trampolines to
instantiate automatically but this has turned out to be
dangereous).
There is a TECO_DEFINE_UNDO_CALL() to generate closures for
arbitrary functions now (ie. to call an arbitrary function
at undo-time). This simplified a lot of code and is much
shorter than manually pushing undo tokens in many cases.
* Instead of the ridiculous C++ Curiously Recurring Template
Pattern to achieve static polymorphy for user interface
implementations, we now simply declare all functions to
implement in interface.h and link in the implementations.
This is possible since we no longer hace to define
interface subclasses (all state is static variables in
the interface's *.c files).
* Headers are now significantly shorter than in C++ since
we can often hide more of our "class" implementations.
* Memory counting is based on dlmalloc for most platforms now.
Unfortunately, there is no malloc implementation that
provides an efficient constant-time memory counter that
is guaranteed to decrease when freeing memory.
But since we use a defined malloc implementation now,
malloc_usable_size() can be used safely for tracking memory use.
malloc() replacement is very tricky on Windows, so we
use a poll thread on Windows. This can also be enabled
on other supported platforms using --disable-malloc-replacement.
All in all, I'm still not pleased with the state of memory
limiting. It is a mess.
* Error handling uses GError now. This has the advantage that
the GError codes can be reused once we support error catching
in the SciTECO language.
* Added a few more test suite cases.
* Haiku is no longer supported as builds are instable and
I did not manage to debug them - quite possibly Haiku bugs
were responsible.
* Glib v2.44 or later are now required.
The GTK UI requires Gtk+ v3.12 or later now.
The GtkFlowBox fallback and sciteco-wrapper workaround are
no longer required.
* We now extensively use the GCC/Clang-specific g_auto
feature (automatic deallocations when leaving the current
code block).
* Updated copyright to 2021.
SciTECO has been in continuous development, even though there
have been no commits since 2018.
* Since these changes are so significant, the target release has
been set to v2.0.
It is planned that beginning with v3.0, the language will be
kept stable.
|