Skip to content

Commit

Permalink
Fix trailing whitespaces, moved the edge case check to reduce null check
Browse files Browse the repository at this point in the history
  • Loading branch information
xdufour committed Jan 30, 2025
1 parent cce0332 commit 4cdaa5c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,14 +1789,14 @@ bool comp_switch(ast node) {

node = get_child(node, 1);

if (node == 0 || (get_op(node) != '{' && get_op(node) != CASE_KW)) fatal_error("comp_statement: switch without body");

if(get_op(node) == CASE_KW) {
// This is for the edge case where the entire 'statement' part of < switch ( expression ) statement >
// This is for the edge case where the entire 'statement' part of < switch ( expression ) statement >
// is a single < case constant-expression : statement >
// therefore we wrap the case statement with a block statement to simplify down to the typical syntax
node = new_ast2('{', node, 0);
}

if (node == 0 || get_op(node) != '{') fatal_error("comp_statement: switch without body");
while (get_op(node) == '{') {
statement = get_child(node, 0);
node = get_child(node, 1);
Expand Down

0 comments on commit 4cdaa5c

Please sign in to comment.