]> Git Repo - J-u-boot.git/blobdiff - common/cli_simple.c
Convert CONFIG_ID_EEPROM to Kconfig
[J-u-boot.git] / common / cli_simple.c
index 358e9b7fe11f28ccc473744bbc6fac932757f8bf..e80ba488a5eb0f4234a920a404465471e353c558 100644 (file)
@@ -14,6 +14,7 @@
 #include <command.h>
 #include <console.h>
 #include <env.h>
+#include <log.h>
 #include <linux/ctype.h>
 
 #define DEBUG_PARSER   0       /* set to 1 to debug */
@@ -59,13 +60,14 @@ int cli_simple_parse_line(char *line, char *argv[])
        return nargs;
 }
 
-void cli_simple_process_macros(const char *input, char *output)
+int cli_simple_process_macros(const char *input, char *output, int max_size)
 {
        char c, prev;
        const char *varname_start = NULL;
        int inputcnt = strlen(input);
-       int outputcnt = CONFIG_SYS_CBSIZE;
+       int outputcnt = max_size;
        int state = 0;          /* 0 = waiting for '$'  */
+       int ret;
 
        /* 1 = waiting for '(' or '{' */
        /* 2 = waiting for ')' or '}' */
@@ -156,13 +158,18 @@ void cli_simple_process_macros(const char *input, char *output)
                prev = c;
        }
 
-       if (outputcnt)
+       ret = inputcnt ? -ENOSPC : 0;
+       if (outputcnt) {
                *output = 0;
-       else
+       } else {
                *(output - 1) = 0;
+               ret = -ENOSPC;
+       }
 
        debug_parser("[PROCESS_MACROS] OUTPUT len %zd: \"%s\"\n",
                     strlen(output_start), output_start);
+
+       return ret;
 }
 
  /*
@@ -238,7 +245,8 @@ int cli_simple_run_command(const char *cmd, int flag)
                debug_parser("token: \"%s\"\n", token);
 
                /* find macros in this token and replace them */
-               cli_simple_process_macros(token, finaltoken);
+               cli_simple_process_macros(token, finaltoken,
+                                         sizeof(finaltoken));
 
                /* Extract arguments */
                argc = cli_simple_parse_line(finaltoken, argv);
This page took 0.022791 seconds and 4 git commands to generate.