X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcommands_parser.c;h=05d39cff53790ef42ed61ab1e896a137f19a3984;hb=cacc199a6837868a67c4f546df5bd32972d6cc5c;hp=1720fd6f0418d84fced2026d992f8049bca8fc89;hpb=71ccb4bef2850bd5beab8a4ef4669bf53b5a9781;p=i3%2Fi3 diff --git a/src/commands_parser.c b/src/commands_parser.c index 1720fd6f..05d39cff 100644 --- a/src/commands_parser.c +++ b/src/commands_parser.c @@ -13,7 +13,7 @@ * We use a hand-written parser instead of lex/yacc because our commands are * easy for humans, not for computers. Thus, it’s quite hard to specify a * context-free grammar for the commands. A PEG grammar would be easier, but - * there’s downsides to every PEG parser generator I have come accross so far. + * there’s downsides to every PEG parser generator I have come across so far. * * This parser is basically a state machine which looks for literals or strings * and can push either on a stack. After identifying a literal or string, it @@ -190,6 +190,7 @@ static void next_state(const cmdp_token *token) { subcommand_output.json_gen = command_output.json_gen; subcommand_output.needs_tree_render = false; GENERATED_call(token->extra.call_identifier, &subcommand_output); + state = subcommand_output.next_state; /* If any subcommand requires a tree_render(), we need to make the * whole parser result request a tree_render(). */ if (subcommand_output.needs_tree_render) @@ -231,7 +232,7 @@ struct CommandResult *parse_command(const char *input) { /* The "<=" operator is intentional: We also handle the terminating 0-byte * explicitly by looking for an 'end' token. */ - while ((walk - input) <= len) { + while ((size_t)(walk - input) <= len) { /* skip whitespace and newlines before every token */ while ((*walk == ' ' || *walk == '\t' || *walk == '\r' || *walk == '\n') && *walk != '\0')