]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_source.c
Prepare v2013.01.01
[u-boot] / common / cmd_source.c
index 43e131592933346b0a36f53c014583b2ea526862..02a862cc5a353b4c5788de13137c26f40d26b345 100644 (file)
@@ -39,9 +39,6 @@
 #if defined(CONFIG_8xx)
 #include <mpc8xx.h>
 #endif
-#ifdef CONFIG_SYS_HUSH_PARSER
-#include <hush.h>
-#endif
 
 int
 source (ulong addr, const char *fit_uname)
@@ -49,8 +46,6 @@ source (ulong addr, const char *fit_uname)
        ulong           len;
        image_header_t  *hdr;
        ulong           *data;
-       char            *cmd;
-       int             rcode = 0;
        int             verify;
 #if defined(CONFIG_FIT)
        const void*     fit_hdr;
@@ -151,55 +146,13 @@ source (ulong addr, const char *fit_uname)
        }
 
        debug ("** Script length: %ld\n", len);
-
-       if ((cmd = malloc (len + 1)) == NULL) {
-               return 1;
-       }
-
-       /* make sure cmd is null terminated */
-       memmove (cmd, (char *)data, len);
-       *(cmd + len) = 0;
-
-#ifdef CONFIG_SYS_HUSH_PARSER /*?? */
-       rcode = parse_string_outer (cmd, FLAG_PARSE_SEMICOLON);
-#else
-       {
-               char *line = cmd;
-               char *next = cmd;
-
-               /*
-                * break into individual lines,
-                * and execute each line;
-                * terminate on error.
-                */
-               while (*next) {
-                       if (*next == '\n') {
-                               *next = '\0';
-                               /* run only non-empty commands */
-                               if (*line) {
-                                       debug ("** exec: \"%s\"\n",
-                                               line);
-                                       if (run_command (line, 0) < 0) {
-                                               rcode = 1;
-                                               break;
-                                       }
-                               }
-                               line = next + 1;
-                       }
-                       ++next;
-               }
-               if (rcode == 0 && *line)
-                       rcode = (run_command(line, 0) >= 0);
-       }
-#endif
-       free (cmd);
-       return rcode;
+       return run_command_list((char *)data, len, 0);
 }
 
 /**************************************************/
 #if defined(CONFIG_CMD_SOURCE)
 int
-do_source (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong addr;
        int rcode;
@@ -224,33 +177,21 @@ do_source (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        return rcode;
 }
 
-U_BOOT_CMD(
-       source, 2, 0,   do_source,
-       "run script from memory",
+#ifdef CONFIG_SYS_LONGHELP
+static char source_help_text[] =
        "[addr]\n"
        "\t- run script starting at addr\n"
-       "\t- A valid image header must be present\n"
+       "\t- A valid image header must be present"
 #if defined(CONFIG_FIT)
+       "\n"
        "For FIT format uImage addr must include subimage\n"
-       "unit name in the form of addr:<subimg_uname>\n"
+       "unit name in the form of addr:<subimg_uname>"
+#endif
+       "";
 #endif
-);
-
-/*
- * Keep for now for backward compatibility;
- * remove later when support for "autoscr" goes away.
- */
-static int
-do_autoscr (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-       printf ("\n### WARNING ### "
-               "\"autoscr\" is deprecated, use \"source\" instead ###\n\n");
-       return do_source (cmdtp, flag, argc, argv);
-}
 
 U_BOOT_CMD(
-       autoscr, 2, 0,  do_autoscr,
-       "DEPRECATED - use \"source\" command instead",
-       "DEPRECATED - use \"source\" command instead\n"
+       source, 2, 0,   do_source,
+       "run script from memory", source_help_text
 );
 #endif