Merge branch 'master' of github.com:h3rald/hex
h3rald h3rald@h3rald.com
Fri, 20 Dec 2024 07:24:23 +0100
3 files changed,
11 insertions(+),
19 deletions(-)
M
src/symbols.c
→
src/symbols.c
@@ -1561,8 +1561,8 @@ result = 1;
} else { - result = hex_push_string(ctx, str); - free(str); + hex_item_t item = {.type = HEX_TYPE_STRING, .data.str_value = str}; + result = HEX_PUSH(ctx, item); } } free(buffer);
M
src/utils.c
→
src/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; } }
M
web/contents/home.html
→
web/contents/home.html
@@ -1,7 +1,7 @@
<article> <h2>Welcome to the <em>hex</em> programming language</h2> <p><strong>hex</strong> is a tiny, minimalist, concatenative, stack-based and slightly-esoteric programming language - that can run on many platforms (including <a href="/play">the browser</a>) and can be used as an embedded + that can run on many platforms (including <a href="/play">modern browsers</a>) and can be used as an embedded language, to create shell scripts, or simply to learn more about concatenative programming.</p> <p>Its syntax is heavily inspired by the <a href="https://min-lang.org" target="_blank">min</a> programming language, and features@@ -18,10 +18,10 @@ comparison of integers, read/write from/to stdin/stdout/stderr, read and write files, execute external
processes, work with quotations and strings, create and delete user symbols (variables), error handling, and manipulate the stack.</li> <li>Fully <strong>homoiconic</strong> (everything is data).</li> - <li>Implements a simple virtual machine with a bytecode compiler and interpreter.</li> + <li>Implements a simple <strong>virtual machine</strong> with a bytecode compiler and interpreter.</li> <li>Includes a simple <strong>REPL</strong>.</li> <li>Includes an integrated <strong>help system</strong>.</li> - <li>Distributable through a single, amalgamated C file, making it easier to embed in other programs and port to + <li>Distributable through <strong>one single, amalgamated C file</strong>, making it easier to embed in other programs and port to different platforms.</li> </ul> <h3>Example</h3>