]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/cli.c
Add makefiles (replace Tup)
[z180-stamp.git] / avr / cli.c
index f11e932666a4b1d7d10f20061f8e933faef99c41..7c452511d0642b732c94befd0c0f61a1cbaf11d8 100644 (file)
--- a/avr/cli.c
+++ b/avr/cli.c
  */
 
 #include "cli.h"
-#include "common.h"
-
-#include <string.h>
+#include "command.h"
 #include <ctype.h>
-#include <stdlib.h>
-#include <stdio.h>
 
 #include "config.h"
-#include "command.h"
 #include "debug.h"
 #include "env.h"
 #include "cli_readline.h"
@@ -242,7 +237,7 @@ char *process_macros(char *input)
  * @returns
  *
  */
-static int cli_run_command(const char *cmd, int flag)
+static int cli_run_command(const char *cmd, uint_fast8_t flag)
 {
        char cmdbuf[strlen(cmd) + 1];                   /* working copy of cmd          */
        char *token;                    /* start of token in cmdbuf     */
@@ -314,6 +309,10 @@ static int cli_run_command(const char *cmd, int flag)
                } else {
                        str = sep;                      /* no more commands for next pass */
                }
+               while (isblank(*token))
+                       ++token;
+               if (*token == '\0')             /* empty (comment only) */
+                       continue;
                debug_parser("token: \"%s\"\n", token);
 
                /* find macros in this token and replace them */
@@ -369,7 +368,7 @@ static int cli_run_command_list(const char *cmd)
  * @param flag Execution flags (CMD_FLAG_...)
  * @return 0 on success, or != 0 on error.
  */
-int run_command(const char *cmd, int flag)
+int run_command(const char *cmd, uint_fast8_t flag)
 {
        /*
         * cli_run_command can return 0 or 1 for success, so clean up
@@ -388,7 +387,7 @@ int run_command(const char *cmd, int flag)
  * @param flag Execution flags (CMD_FLAG_...)
  * @return 0 (not repeatable) or 1 (repeatable) on success, -1 on error.
  */
-static int run_command_repeatable(const char *cmd, int flag)
+static int run_command_repeatable(const char *cmd, uint_fast8_t flag)
 {
        return cli_run_command(cmd, flag);
 }
@@ -407,7 +406,7 @@ void cli_loop(void)
 {
        char *lastcommand = NULL;
        int len;
-       int flag;
+       uint_fast8_t flag;
        int rc = 1;
 
        for (;;) {