diff options
| author | peter <peter@pmikkelsen.com> | 2026-08-30 20:52:43 +0000 |
|---|---|---|
| committer | peter <peter@pmikkelsen.com> | 2026-08-30 20:52:43 +0000 |
| commit | 729964bea692f9683860978b89848784a7fc2f46 (patch) | |
| tree | ba5b37a61206142fce18214c7af341ac837a7923 /src/lib/syntax.c | |
| parent | 04827577ea502a9f0edc69e00e008751c8119cbc (diff) | |
Still a lot to be done, but I'm going to bed.
Two remaining big issues:
* aplwc (the parameter passed "everywhere") - should it move or not?
* values returned from the public API should not move.
FossilOrigin-Name: 31ab3154b8f3d5ac167218496e9e204324bf0ac9d36b7bada8fe2a6c8f93d51c
Diffstat (limited to 'src/lib/syntax.c')
| -rw-r--r-- | src/lib/syntax.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/syntax.c b/src/lib/syntax.c index 75d6c14..ae52343 100644 --- a/src/lib/syntax.c +++ b/src/lib/syntax.c @@ -240,15 +240,17 @@ scan_string(struct aplwc *aplwc, struct string *text, int oneline) struct token_list *tokens; size_t n, i; + MEMPTRS(aplwc, 1); + MEMPTR(0, text); + + tokens = NULL; rc = check(text, &n); - if(rc != APLWC_OK){ - aplwc->last_error = rc; - return NULL; - } + if(rc != APLWC_OK) + goto end; tokens = memory_alloc_token_list(aplwc, n); if(tokens == NULL) - return NULL; + goto end; tokens->text = text; tokens->length = n; scan(text, tokens); @@ -258,11 +260,17 @@ scan_string(struct aplwc *aplwc, struct string *text, int oneline) continue; for(i++; i < n; i++){ - if(tokens->tokens[i].tag != TOKEN_TAG_NEWLINE) - return NULL; + if(tokens->tokens[i].tag != TOKEN_TAG_NEWLINE){ + rc = APLWC_INVALID_SYNTAX; + tokens = NULL; + goto end; + } } } +end: + aplwc->last_error = rc; + MEMPTRS_EXIT(aplwc); return tokens; } |