[git commit] awk: code shrink

Denys Vlasenko vda.linux at googlemail.com
Thu Sep 9 17:13:32 UTC 2021


commit: https://git.busybox.net/busybox/commit/?id=e60c56932ed95eb1c72b12d7404d42798da61bca
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
awk_printf                                           652     651      -1

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 editors/awk.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/editors/awk.c b/editors/awk.c
index 46bda93b2..6644d7d6f 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2351,16 +2351,15 @@ static char *awk_printf(node *n, size_t *len)
 			c = *f;
 			if (!c) /* no percent chars found at all */
 				goto nul;
-			if (c == '%') {
-				c = *++f;
-				if (!c) /* we are past % in "....%" */
-					goto nul;
-				break;
-			}
 			f++;
+			if (c == '%')
+				break;
 		}
-		/* we are past % in "....%...", c == char after % */
-		if (c == '%') { /* double % */
+		/* we are past % in "....%..." */
+		c = *f;
+		if (!c) /* "....%" */
+			goto nul;
+		if (c == '%') { /* "....%%...." */
 			slen = f - s;
 			s = xstrndup(s, slen);
 			f++;


More information about the busybox-cvs mailing list