From aa51adcfc9a79c606aa4435dc64dd5f160efbde1 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 20 Sep 2026 20:58:10 +0000 Subject: Start working on migrating to autoconf/automake instead of cmake FossilOrigin-Name: d870487495106763d2a4e416f1ddbf4c795081a6b77100d34063591e385692e0 --- src/lib/Makefile.am | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/lib/Makefile.am (limited to 'src/lib') diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 0000000..c95fe1c --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,13 @@ +lib_LIBRARIES += libaplwc.a + +libaplwc_a_SOURCES = \ + src/lib/aplwc_internal.h \ + src/lib/eval.c \ + src/lib/main.c \ + src/lib/memory.c \ + src/lib/module.c \ + src/lib/string.c \ + src/lib/symtab.c \ + src/lib/syntax.c + +EXTRA_DIST += src/lib/boot.aplwc -- cgit v1.2.3 From ea381bac43f3ce78be5fa3ea10810810670dfb89 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 22 Sep 2026 18:26:55 +0000 Subject: Check for flexible array member support via autoconf FossilOrigin-Name: 4d8f080ee14f63ea5cb2c0aa87be1519e7b74e3c42de2370e90ae1e1f9268cd0 --- src/lib/aplwc_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/aplwc_internal.h b/src/lib/aplwc_internal.h index 328b5de..8c13dfe 100644 --- a/src/lib/aplwc_internal.h +++ b/src/lib/aplwc_internal.h @@ -67,7 +67,7 @@ struct aplwc_line { struct string { size_t bytes; size_t chars; - uint8_t utf8[1]; + uint8_t utf8[FLEXIBLE_ARRAY_MEMBER]; }; enum token_tag { @@ -100,7 +100,7 @@ struct token { struct token_list { struct string *text; size_t length; - struct token tokens[1]; + struct token tokens[FLEXIBLE_ARRAY_MEMBER]; }; enum value_tag { -- cgit v1.2.3 From 949896e24ef16d703ee07fb3e489f2a986050d5b Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 22 Sep 2026 19:18:35 +0000 Subject: Final changes to be able to switch over to an autotools based setup FossilOrigin-Name: 6a01b406226d3f60ea7d86fc177296f8e0a6c1e0816264bac807e30d78edbf21 --- src/lib/memory.c | 46 +++++++++++++++++++++++++--------------------- src/lib/module.c | 1 + src/lib/syntax.c | 1 + 3 files changed, 27 insertions(+), 21 deletions(-) (limited to 'src/lib') diff --git a/src/lib/memory.c b/src/lib/memory.c index 051acba..a8317c7 100644 --- a/src/lib/memory.c +++ b/src/lib/memory.c @@ -41,7 +41,9 @@ struct chunk { unsigned int last:1; }; +#if APLWC_BUILD_TYPE_DEBUG static void debug_check_mem(struct aplwc *); +#endif /* APLWC_BUILD_TYPE_DEBUG */ void memory_init(struct aplwc *aplwc) @@ -436,27 +438,6 @@ compact(struct aplwc *aplwc) } } -static void -debug_check_mem(struct aplwc *aplwc) -{ - uint64_t size; - struct chunk *c, *prev; - - size = 0; - prev = NULL; - for(c = (struct chunk *)aplwc->data; c; prev = c, c = next(c)){ - assert(((uint8_t*)c) < (aplwc->data+aplwc->size)); - assert((c->size % ALIGNMENT) == 0); - assert(c->stack == NULL); - size += c->size; - assert((c->last == 0) != (size == aplwc->size)); - if(c->tag == CHUNK_TAG_FREE) - assert((prev == NULL) || (prev->tag != CHUNK_TAG_FREE)); - } - - assert(size == aplwc->size); -} - static void * alloc(struct aplwc *aplwc, size_t size, enum chunk_tag tag) { @@ -653,3 +634,26 @@ valid_ref(struct aplwc_ref *ref) { return (ref->aplwc != NULL) && (ref->ptr != NULL); } + +#if APLWC_BUILD_TYPE_DEBUG +static void +debug_check_mem(struct aplwc *aplwc) +{ + uint64_t size; + struct chunk *c, *prev; + + size = 0; + prev = NULL; + for(c = (struct chunk *)aplwc->data; c; prev = c, c = next(c)){ + assert(((uint8_t*)c) < (aplwc->data+aplwc->size)); + assert((c->size % ALIGNMENT) == 0); + assert(c->stack == NULL); + size += c->size; + assert((c->last == 0) != (size == aplwc->size)); + if(c->tag == CHUNK_TAG_FREE) + assert((prev == NULL) || (prev->tag != CHUNK_TAG_FREE)); + } + + assert(size == aplwc->size); +} +#endif /* APLWC_BUILD_TYPE_DEBUG */ diff --git a/src/lib/module.c b/src/lib/module.c index 2ef5ba3..aaa9634 100644 --- a/src/lib/module.c +++ b/src/lib/module.c @@ -67,6 +67,7 @@ read_keyword_decl(struct aplwc *aplwc, struct aplwc_module *module, size_t offse max = module->tokens->length - offset - 1; + len = -1; assert(t(0).tag == TOKEN_TAG_KEYWORD); switch(t(0).data.keyword){ case KW_MODULE: diff --git a/src/lib/syntax.c b/src/lib/syntax.c index 4850b1a..1740a4e 100644 --- a/src/lib/syntax.c +++ b/src/lib/syntax.c @@ -425,6 +425,7 @@ scan_string(struct aplwc *aplwc, struct string *text, int oneline) MEMPTR(0, text); tokens = NULL; + n = 0; if((rc = check(aplwc, text, &n)) != APLWC_OK) goto end; -- cgit v1.2.3