diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2012-10-03 13:09:15 +0000 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-10-03 16:13:34 -0700 |
commit | bb64d1c92fbbc2441772f2eb9b4527499955c04e (patch) | |
tree | e0e6c9db0ce729c2996c9e63ecaedfa5b830e687 | |
parent | da83bcd7b33d9e4dca3913cb5c0827dce0f8672a (diff) | |
download | u-boot-imx-bb64d1c92fbbc2441772f2eb9b4527499955c04e.zip u-boot-imx-bb64d1c92fbbc2441772f2eb9b4527499955c04e.tar.gz u-boot-imx-bb64d1c92fbbc2441772f2eb9b4527499955c04e.tar.bz2 |
Output strings from echo with puts where easy
Change echo to puts characters together where it knows about them
together. This improves netconsole performance by greatly reducing
the number of packets that are sent.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
-rw-r--r-- | common/cmd_echo.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/common/cmd_echo.c b/common/cmd_echo.c index 43a6da5..1e499fb 100644 --- a/common/cmd_echo.c +++ b/common/cmd_echo.c @@ -30,17 +30,31 @@ int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int putnl = 1; for (i = 1; i < argc; i++) { - char *p = argv[i], c; + char *p = argv[i]; + char *nls; /* new-line suppression */ if (i > 1) putc(' '); - while ((c = *p++) != '\0') { - if (c == '\\' && *p == 'c') { - putnl = 0; - p++; - } else { - putc(c); + + nls = strstr(p, "\\c"); + if (nls) { + char *prenls = p; + + putnl = 0; + /* + * be paranoid and guess that someone might + * say \c more than once + */ + while (nls) { + *nls = '\0'; + puts(prenls); + *nls = '\\'; + prenls = nls + 2; + nls = strstr(prenls, "\\c"); } + puts(prenls); + } else { + puts(p); } } |