diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-30 15:59:57 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-30 15:59:57 -0400 |
| commit | 9090a2a09f119510f40c5385f3790cc6b6539abc (patch) | |
| tree | 06616ba7f497a1d14003413816b98c2e0e81bda3 /src/formatter/args.c | |
| parent | f38fa3389c881ef8341011c05d7b2435686068e7 (diff) | |
Arg formatting tweaks
Diffstat (limited to 'src/formatter/args.c')
| -rw-r--r-- | src/formatter/args.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/formatter/args.c b/src/formatter/args.c index 9809645f..997a1e39 100644 --- a/src/formatter/args.c +++ b/src/formatter/args.c @@ -29,14 +29,14 @@ 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 code = EMPTY_TEXT; - for (; args; args = args->next) { - if (args->name && args->next && args->type == args->next->type && args->value == args->next->value) { - code = Texts(code, Text$from_str(args->name), ","); + for (arg_ast_t *arg = args; arg; arg = arg->next) { + if (arg->name && arg->next && arg->type == arg->next->type && arg->value == arg->next->value) { + code = Texts(code, Text$from_str(arg->name), ","); } else { - code = Texts(code, must(format_inline_arg(args, comments))); - if (args->next) code = Texts(code, ", "); + code = Texts(code, must(format_inline_arg(arg, comments))); + if (arg->next) code = Texts(code, ", "); } - if (args->next && range_has_comment(args->end, args->next->start, comments)) return NONE_TEXT; + if (arg->next && range_has_comment(arg->end, arg->next->start, comments)) return NONE_TEXT; } return code; } @@ -45,12 +45,12 @@ Text_t format_args(arg_ast_t *args, Table_t comments, Text_t indent) { OptionalText_t inline_args = format_inline_args(args, comments); if (inline_args.length >= 0 && inline_args.length <= MAX_WIDTH) return inline_args; Text_t code = EMPTY_TEXT; - for (; args; args = args->next) { - if (args->name && args->next && args->type == args->next->type && args->value == args->next->value) { - code = Texts(code, Text$from_str(args->name), ","); + for (arg_ast_t *arg = args; arg; arg = arg->next) { + if (arg->name && arg->next && arg->type == arg->next->type && arg->value == arg->next->value) { + code = Texts(code, Text$from_str(arg->name), ","); } else { - code = - Texts(code, "\n", indent, single_indent, format_arg(args, comments, Texts(indent, single_indent)), ","); + code = Texts(code, "\n", indent, single_indent, format_arg(arg, comments, Texts(indent, single_indent))); + if (args->next) code = Texts(code, ","); } } return code; |
