diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 17:41:55 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 17:41:55 -0400 |
| commit | 0eae0e70b3475ab2cf3d8486dc3a609a22faa75a (patch) | |
| tree | ee8721509d4a92d44c90c0f9fc5c803f76b6c5f3 | |
| parent | 2538b1b7461f9b06d6a6f43acd5609d916b1addc (diff) | |
Fixesformatter
| -rw-r--r-- | src/ast.c | 2 | ||||
| -rw-r--r-- | src/formatter/args.h | 2 | ||||
| -rw-r--r-- | src/formatter/formatter.c | 5 | ||||
| -rw-r--r-- | src/formatter/utils.c | 2 |
4 files changed, 5 insertions, 6 deletions
@@ -323,7 +323,7 @@ const char *ast_to_sexp_str(ast_t *ast) { return Text$as_c_string(ast_to_sexp(as OptionalText_t ast_source(ast_t *ast) { if (ast == NULL || ast->start == NULL || ast->end == NULL) return NONE_TEXT; - return Text$from_strn(ast->start, (int64_t)(ast->end - ast->start)); + return Text$from_strn(ast->start, (size_t)(ast->end - ast->start)); } PUREFUNC bool is_idempotent(ast_t *ast) { diff --git a/src/formatter/args.h b/src/formatter/args.h index 42722f32..c902684b 100644 --- a/src/formatter/args.h +++ b/src/formatter/args.h @@ -9,5 +9,3 @@ OptionalText_t format_inline_arg(arg_ast_t *arg, Table_t comments); Text_t format_arg(arg_ast_t *arg, Table_t comments, Text_t indent); OptionalText_t format_inline_args(arg_ast_t *args, Table_t comments); Text_t format_args(arg_ast_t *args, Table_t comments, Text_t indent); -OptionalText_t format_inline_tag(tag_ast_t *tag, Table_t comments); -Text_t format_tag(tag_ast_t *tag, Table_t comments, Text_t indent); diff --git a/src/formatter/formatter.c b/src/formatter/formatter.c index 824a936a..60714945 100644 --- a/src/formatter/formatter.c +++ b/src/formatter/formatter.c @@ -33,7 +33,7 @@ typedef struct { Text_t quote, unquote, interp; } text_opts_t; -text_opts_t choose_text_options(ast_list_t *chunks) { +PUREFUNC text_opts_t choose_text_options(ast_list_t *chunks) { int double_quotes = 0, single_quotes = 0, backticks = 0; for (ast_list_t *chunk = chunks; chunk; chunk = chunk->next) { if (chunk->ast->tag == TextLiteral) { @@ -146,6 +146,7 @@ OptionalText_t format_inline_code(ast_t *ast, Table_t comments) { if (if_->else_body == NULL && if_->condition->tag != Declare) { ast_t *stmt = unwrap_block(if_->body); + if (!stmt) return Texts("pass ", if_condition); switch (stmt->tag) { case Return: case Skip: @@ -391,7 +392,7 @@ OptionalText_t format_inline_code(ast_t *ast, Table_t comments) { } } -static int64_t trailing_line_len(Text_t text) { +PUREFUNC static int64_t trailing_line_len(Text_t text) { TextIter_t state = NEW_TEXT_ITER_STATE(text); int64_t len = 0; for (int64_t i = text.length - 1; i >= 0; i--) { diff --git a/src/formatter/utils.c b/src/formatter/utils.c index 80445ec3..bbe74d7f 100644 --- a/src/formatter/utils.c +++ b/src/formatter/utils.c @@ -27,7 +27,7 @@ OptionalText_t next_comment(Table_t comments, const char **pos, const char *end) const char **comment_end = Table$get(comments, &p, parse_comments_info); if (comment_end) { *pos = *comment_end; - return Text$from_strn(p, (int64_t)(*comment_end - p)); + return Text$from_strn(p, (size_t)(*comment_end - p)); } } return NONE_TEXT; |
