diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2025-03-23 14:40:51 +0100 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2025-03-23 14:40:51 +0100 |
| commit | 50da512936a9af6ad9aa808531af8f316a381dd4 (patch) | |
| tree | 385253a4db800cabf3aae93693ee53ce7f6e52b8 /src/parse.c | |
| parent | 6e1eaaf13a13584294c6a090ef40500cd786f56f (diff) | |
Start expirimenting with some real xml
Diffstat (limited to 'src/parse.c')
| -rw-r--r-- | src/parse.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/parse.c b/src/parse.c index 6ab2007..31a93a6 100644 --- a/src/parse.c +++ b/src/parse.c @@ -5,6 +5,7 @@ #include <ctype.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "log.h" @@ -31,6 +32,10 @@ static bool alnum(struct ParseCtx *ctx) { return isalnum(ctx->cursor[0]); } +static bool wspace(struct ParseCtx *ctx) { + return strchr(" \n\t", ctx->cursor[0]) != NULL; +} + static int read_STag(struct ParseCtx *ctx, bool *self_close, size_t nodeId) { // Record start position of the tag if (ctx->phase == PHASE_BUILD) { @@ -40,7 +45,8 @@ static int read_STag(struct ParseCtx *ctx, bool *self_close, size_t nodeId) { if(*ctx->cursor != '<') return 1; ctx->cursor++; - while(isalnum(*ctx->cursor) || *ctx->cursor == ' ' || *ctx->cursor == '"' || *ctx->cursor == '=') ctx->cursor++; + // @COMP Does xml allow all whitespace in the tag? + while(alnum(ctx) || *ctx->cursor == ' ' || *ctx->cursor == '"' || *ctx->cursor == '=') ctx->cursor++; // Check for self-closing tag if(*ctx->cursor == '/') { @@ -70,7 +76,7 @@ static int read_Content(struct ParseCtx *ctx, size_t nodeId) { *imat_nid(ctx->tree->adj, children, nodeId) = childId+1; children++; - } else if(alnum(ctx)) { + } else if(alnum(ctx) || wspace(ctx)) { ctx->cursor++; } else { break; |
