aboutsummaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-16 00:09:57 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-16 00:09:57 -0400
commita2d2916e3220ec333122afb9cdef0f5c1eda84f7 (patch)
treed06b95f8d7bec5439eb804a3ff3045907a218d31 /src/parse.c
parente5420471a7364a92521575e7abd3a29a9318001b (diff)
Fixes to get the compiler to build with -O3
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/parse.c b/src/parse.c
index 93a2dcdd..4eae21e5 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -309,7 +309,9 @@ PUREFUNC static INLINE int64_t get_indent(parse_ctx_t *ctx, const char *pos)
{
int64_t line_num = get_line_number(ctx->file, pos);
const char *line = get_line(ctx->file, line_num);
- if (*line == ' ') {
+ if (line == NULL) {
+ return 0;
+ } else if (*line == ' ') {
int64_t spaces = (int64_t)strspn(line, " ");
if (line[spaces] == '\t')
parser_err(ctx, line + spaces, line + spaces + 1, "This is a tab following spaces, and you can't mix tabs and spaces");
@@ -873,8 +875,8 @@ PARSER(parse_reduction) {
);
if (progress) key = new_term;
}
- if (key->tag == Var) key = NULL;
- else pos = key->end;
+ if (key && key->tag == Var) key = NULL;
+ else if (key) pos = key->end;
whitespace(&pos);
if (!match(&pos, ":")) return NULL;
@@ -1662,8 +1664,8 @@ static ast_t *parse_infix_expr(parse_ctx_t *ctx, const char *pos, int min_tightn
);
if (progress) key = new_term;
}
- if (key->tag == Var) key = NULL;
- else pos = key->end;
+ if (key && key->tag == Var) key = NULL;
+ else if (key) pos = key->end;
}
whitespace(&pos);