all repos — hex @ fdf9da1894987b9e66c14da0dde981094b1ff752

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Fixed dec symbol to correctly print negative numbers as well.
h3rald h3rald@h3rald.com
Wed, 18 Dec 2024 09:02:54 +0100
commit

fdf9da1894987b9e66c14da0dde981094b1ff752

parent

b0fc7a5054d826e04500cd3e0d8c30e006112c84

2 files changed, 5 insertions(+), 2 deletions(-)

jump to
M scripts/test.hexscripts/test.hex

@@ -219,6 +219,8 @@ (("t" chr) (error) try "Symbol 'chr' requires an integer" ==)

((() chr) (error) try "Symbol 'chr' requires an integer" ==) ;120 + (0xffffffff dec "-1" ==) + ) "tests" :
M src/symbols.csrc/symbols.c

@@ -540,7 +540,6 @@ }

int hex_symbol_dec(hex_context_t *ctx) { - HEX_POP(ctx, a); if (a.type == HEX_TYPE_INVALID) {

@@ -549,7 +548,9 @@ return 1;

} if (a.type == HEX_TYPE_INTEGER) { - return hex_push_string(ctx, hex_itoa_dec(a.data.int_value)); + char buffer[32]; + snprintf(buffer, sizeof(buffer), "%d", a.data.int_value); + return hex_push_string(ctx, buffer); } hex_error(ctx, "Symbol 'dec' requires an integer"); HEX_FREE(ctx, a);