web not working (corrupted data?)
h3rald h3rald@h3rald.com
Sat, 28 Dec 2024 18:28:18 +0100
2 files changed,
28 insertions(+),
17 deletions(-)
M
scripts/web.hex
→
scripts/web.hex
@@ -1,4 +1,5 @@
-"2024" "meta-year" : + +"2024" "meta-year" : "0.3.0" "meta-release" : "web/assets" "d-assets" : "web/templates" "d-templates" :@@ -54,8 +55,8 @@ "t-text" :
0x0 "t-count" : (t-count highlight-delimiters len <) ( - t-text highlight-delimiters t-count get "t-delimiter" : - t-text highlight-replacements t-count get "t-replacement" : + highlight-delimiters t-count get "t-delimiter" : + highlight-replacements t-count get "t-replacement" : ; Find delimiter in text and replace it with the corresponding replacement (t-text t-delimiter index 0x0 >=) (@@ -224,7 +225,7 @@ )
while "_i" # ; Highlight syntax - new-content highlight "new-content" : + new-content highlight "new-content" : (fn-content "home.html" ==) ( ; Process home page
M
src/symbols.c
→
src/symbols.c
@@ -166,7 +166,7 @@ }
int hex_symbol_symbols(hex_context_t *ctx) { - hex_item_t **quotation = (hex_item_t **)malloc(ctx->registry->size * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(ctx->registry->size * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol symbols] Memory allocation failed");@@ -1550,7 +1550,7 @@ {
// Concatenate two quotations size_t newSize = list->quotation_size + value->quotation_size; hex_item_t **newQuotation = (hex_item_t **)realloc( - list->data.quotation_value, newSize * sizeof(hex_item_t *)); + list->data.quotation_value, newSize * sizeof(hex_item_t)); if (!newQuotation) { hex_error(ctx, "[symbol cat] Memory allocation failed");@@ -1892,7 +1892,7 @@ if (strlen(separator->data.str_value) == 0)
{ // Separator is an empty string: split into individual characters size_t size = strlen(str->data.str_value); - hex_item_t **quotation = (hex_item_t **)malloc(size * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(size * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol split] Memory allocation failed");@@ -1932,7 +1932,7 @@ // Separator is not empty: split as usual
char *token = strtok(str->data.str_value, separator->data.str_value); size_t capacity = 2; size_t size = 0; - hex_item_t **quotation = (hex_item_t **)malloc(capacity * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(capacity * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol split] Memory allocation failed");@@ -1945,7 +1945,7 @@ {
if (size >= capacity) { capacity *= 2; - quotation = (hex_item_t **)realloc(quotation, capacity * sizeof(hex_item_t *)); + quotation = (hex_item_t **)realloc(quotation, capacity * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol split] Memory allocation failed");@@ -2093,7 +2093,7 @@ {
size_t bytesRead = fread(buffer, 1, length, file); if (hex_is_binary(buffer, bytesRead)) { - hex_item_t **quotation = (hex_item_t **)malloc(bytesRead * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(bytesRead * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol read] Memory allocation failed");@@ -2319,7 +2319,7 @@
int hex_symbol_args(hex_context_t *ctx) { - hex_item_t **quotation = (hex_item_t **)malloc(ctx->argc * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(ctx->argc * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol args] Memory allocation failed");@@ -2548,7 +2548,7 @@ }
#endif // Push the return code, output, and error as a quotation - hex_item_t **quotation = (hex_item_t **)malloc(3 * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(3 * sizeof(hex_item_t)); quotation[0] = (hex_item_t *)malloc(sizeof(hex_item_t)); quotation[0]->type = HEX_TYPE_INTEGER; quotation[0]->data.int_value = return_code;@@ -2984,7 +2984,7 @@ return 1;
} result->type = HEX_TYPE_QUOTATION; - result->data.quotation_value = (hex_item_t **)malloc(sizeof(hex_item_t *)); + result->data.quotation_value = (hex_item_t **)malloc(sizeof(hex_item_t)); if (!result->data.quotation_value) { hex_error(ctx, "[symbol '] Memory allocation failed");@@ -3045,7 +3045,7 @@ return 1;
} else { - hex_item_t **quotation = (hex_item_t **)malloc(list->quotation_size * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc(list->quotation_size * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol map] Memory allocation failed");@@ -3174,14 +3174,24 @@ }
int hex_symbol_stack(hex_context_t *ctx) { - hex_item_t **quotation = (hex_item_t **)malloc((ctx->stack->top + 1) * sizeof(hex_item_t *)); + hex_item_t **quotation = (hex_item_t **)malloc((ctx->stack->top + 2) * sizeof(hex_item_t)); if (!quotation) { hex_error(ctx, "[symbol stack] Memory allocation failed"); return 1; } int count = 0; - for (size_t i = 0; i <= (size_t)ctx->stack->top; i++) + if (ctx->stack->top == -1) + { + if (hex_push_quotation(ctx, NULL, 0) != 0) + { + hex_error(ctx, "[symbol stack] An error occurred while pushing empty quotation"); + hex_free_list(ctx, quotation, count); + return 1; + } + return 0; + } + for (size_t i = 0; i <= (size_t)ctx->stack->top + 1; i++) { quotation[i] = hex_copy_item(ctx, ctx->stack->entries[i]); if (!quotation[i])@@ -3193,7 +3203,7 @@ }
count++; } - if (hex_push_quotation(ctx, quotation, ctx->stack->top + 1) != 0) + if (hex_push_quotation(ctx, quotation, ctx->stack->top + 2) != 0) { hex_error(ctx, "[symbol stack] An error occurred while pushing quotation"); hex_free_list(ctx, quotation, count);