summary refs log tree commit diff
path: root/src/bltin
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2014-10-27 16:23:33 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2014-10-27 16:23:33 +0800
commit7a784244625d5489c0fc779201c349555dc5f8bc (patch)
tree28950eb39fa8a2760db318713c6350064c945309 /src/bltin
parent[BUILTIN] Optimise handling of backslash octals in printf (diff)
downloaddash-7a784244625d5489c0fc779201c349555dc5f8bc.tar.gz
dash-7a784244625d5489c0fc779201c349555dc5f8bc.zip
[BUILTIN] Simplify echo command
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'src/bltin')
-rw-r--r--src/bltin/printf.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/bltin/printf.c b/src/bltin/printf.c
index 6f39526..9673e10 100644
--- a/src/bltin/printf.c
+++ b/src/bltin/printf.c
@@ -442,33 +442,21 @@ check_conversion(const char *s, const char *ep)
 int
 echocmd(int argc, char **argv)
 {
-	int nonl = 0;
-	struct output *outs = out1;
-
-	if (!*++argv)
-		goto end;
-	if (equal(*argv, "-n")) {
-		nonl = ~nonl;
-		if (!*++argv)
-			goto end;
-	}
+	int nonl;
+
+	nonl = *++argv ? equal(*argv, "-n") : 0;
+	argv += nonl;
 
 	do {
 		int c;
 
-		nonl += print_escape_str("%s", NULL, NULL, *argv);
+		if (likely(*argv))
+			nonl += print_escape_str("%s", NULL, NULL, *argv++);
 		if (nonl > 0)
 			break;
 
-		c = ' ';
-		if (!*++argv) {
-end:
-			if (nonl) {
-				break;
-			}
-			c = '\n';
-		}
-		outc(c, outs);
+		c = *argv ? ' ' : '\n';
+		out1c(c);
 	} while (*argv);
 	return 0;
 }
23:31:24 +0000'>2020-11-24Update pounce to 2.1June McEnroe 2020-11-24Update libretls to 3.3.0June McEnroe 2020-11-17Update catgirl to 1.3June McEnroe 2020-11-17Update libretls to 3.2.2June McEnroe 2020-09-29Update libretls to 3.2.1June McEnroe 2020-09-10Update catgirl to 1.2June McEnroe 2020-09-09Add pounce-palaver portJune McEnroe 2020-09-09Update pounce to 2.0June McEnroe 2020-09-09Update litterbox to 1.6June McEnroe 2020-08-23Add scooper portJune McEnroe 2020-08-23Add catsit portJune McEnroe 2020-08-13Update pounce to 1.4p2June McEnroe 2020-08-11Update pounce to 1.4p1June McEnroe 2020-08-10Add litterbox portJune McEnroe 2020-08-10Add missing USES=pkgconfig to pounceJune McEnroe