all repos — hex @ 2b6b1692b4209e912def22635ec18bc9725c0c0e

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

Fixes.
h3rald h3rald@h3rald.com
Thu, 19 Dec 2024 20:05:05 +0000
commit

2b6b1692b4209e912def22635ec18bc9725c0c0e

parent

eb9fd391617954ab620820ee38cbb8f9615f66ee

1 files changed, 6 insertions(+), 14 deletions(-)

jump to
M src/utils.csrc/utils.c

@@ -254,7 +254,7 @@ }

char *hex_bytes_to_string(const uint8_t *bytes, size_t size) { - char *str = (char *)malloc(size * 4 + 1); // Allocate enough space for worst case + char *str = (char *)malloc(size * 6 + 1); // Allocate enough space for worst case (\uXXXX format) if (!str) { return NULL; // Allocation failed

@@ -294,24 +294,16 @@ case '\v':

*ptr++ = '\\'; *ptr++ = 'v'; break; - case '\\': - *ptr++ = '\\'; - *ptr++ = '\\'; - break; + //case '\\': + // *ptr++ = '\\'; // Correctly handle backslash + // *ptr++ = '\\'; + // break; case '\"': *ptr++ = '\\'; *ptr++ = '\"'; break; default: - if (byte < 32 || byte > 126) - { - // Escape non-printable characters as hex (e.g., \x1F) - ptr += sprintf(ptr, "\\x%02x", byte); - } - else - { - *ptr++ = byte; - } + *ptr++ = byte; // Copy printable ASCII characters as is break; } }