diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-11-10 00:15:22 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-11-10 00:15:22 +0100 |
| commit | 6abc1299927860a3d433119c9632cf780ac79c7b (patch) | |
| tree | 131b10de1ea60bebace017d9500a31498a61035a /src/error.h | |
| parent | 427c9da3281950f3e37011e31b30985332c95345 (diff) | |
rewrote number parsing: convert only completely parsed numbers
* We are now buffering until the end of the number constant before converting
it to an integer or float.
* This way, the integer part of a floating point number does not necessarily
have to fit into an teco_int_t -- floats can approximate very large numbers.
When detecting a floating point number, we're parsing into floats from the
very beginning.
The behavior has been compared with Lua 5.4 and a test case has been added.
* Also, integers constants are now checked for overflows.
Otherwise, constants could be arbitrarily long and the result would
be unpredictable.
Operations on integers are still not checked for overflows, though, since
you might want to rely on it, e.g. for overlapping integers. But that
might actually be pretty useless, especially with signed integers, so we
might want to change that in the future.
* Having both overflow checks and increased floating point constant range
is the reason we cannot practically immediately parse into a number,
not even if we kept both an integer and float accumulator at the same time.
* Also fixes a memory corruption issue that existed since
4aa2b717f9e050783b567540d9bb0193d692e3e9.
You must emit undo tokens for fields in state machines only if
ctx->parent.must_undo, i.e. if the state machine is not temporary as
during a macro call.
A test case has been added.
Diffstat (limited to 'src/error.h')
| -rw-r--r-- | src/error.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/error.h b/src/error.h index 1306feb..19b707e 100644 --- a/src/error.h +++ b/src/error.h @@ -42,6 +42,7 @@ typedef enum { TECO_ERROR_SYNTAX, TECO_ERROR_MODIFIER, TECO_ERROR_ARGEXPECTED, + TECO_ERROR_RADIX, TECO_ERROR_LABEL, TECO_ERROR_CODEPOINT, TECO_ERROR_MOVE, @@ -95,6 +96,14 @@ teco_error_argexpected_set(GError **error, const gchar *cmd) } static inline void +teco_error_radix_set(GError **error, gchar chr, teco_int_t radix) +{ + g_set_error(error, TECO_ERROR, TECO_ERROR_RADIX, + "Digit \"%c\" not allowed in radix %" TECO_INT_FORMAT, + chr, radix); +} + +static inline void teco_error_label_set(GError **error, const gchar *name, gsize len) { g_autofree gchar *label_printable = teco_string_echo(name, len); |
