From b033314bf1901d436dc71d41d5e1f37dda47e511 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Thu, 12 Dec 2024 16:03:08 +0100 Subject: formatting: Use clang-format on all projects This commit also add braces to all `if` statements. --- userland/minibox/utilities/sh/lexer.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'userland/minibox/utilities/sh/lexer.c') diff --git a/userland/minibox/utilities/sh/lexer.c b/userland/minibox/utilities/sh/lexer.c index d7f00c7..09fc2ff 100644 --- a/userland/minibox/utilities/sh/lexer.c +++ b/userland/minibox/utilities/sh/lexer.c @@ -15,19 +15,23 @@ void free_tokens(struct TOKEN *token) { } int is_special_char(char c) { - if (!isprint(c)) + if (!isprint(c)) { return 1; - if (isspace(c)) + } + if (isspace(c)) { return 1; - if (isalnum(c)) + } + if (isalnum(c)) { return 0; + } return !(('>' != c && '|' != c && '&' != c)); } int parse_chars(struct sv *code_ptr, struct TOKEN *cur) { struct sv code = *code_ptr; - if (is_special_char(sv_peek(code))) + if (is_special_char(sv_peek(code))) { return 0; + } cur->type = TOKEN_CHARS; cur->string_rep = sv_split_function(code, &code, is_special_char); *code_ptr = code; @@ -83,16 +87,18 @@ struct TOKEN *lex(struct sv code) { struct TOKEN *cur = malloc(sizeof(struct TOKEN)); cur->next = NULL; - if (prev) + if (prev) { prev->next = cur; + } if (parse_chars(&code, cur)) { } else if (parse_operand(&code, cur)) { } else { free(cur); assert(0 && "Unknown token"); } - if (!head) + if (!head) { head = cur; + } prev = cur; } return head; -- cgit v1.2.3