Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thau <danthau@bedrocklinux.org>2021-09-02 14:41:08 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2021-09-05 04:42:51 +0300
commit7d06d6e18651cb183a3723fa21ef62935ea08647 (patch)
tree29a36fb92c34c697ca6e0c21d5cdc4edf26484d3 /editors
parentf4ba69d47698c5357c32e21eb9122a5031b9b080 (diff)
awk: fix printf %%
A refactor of the awk printf code in e2e3802987266c98df0efdf40ad5da4b07df0113 appears to have broken the printf interpretation of two percent signs, which normally outputs only one percent sign. The patch below brings busybox awk printf behavior back into alignment with the pre-e2e380 behavior, the busybox printf util, and other common (awk and non-awk) printf implementations. function old new delta awk_printf 626 672 +46 Signed-off-by: Daniel Thau <danthau at bedrocklinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 3adbca7aa..f7b8ef0d3 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2346,8 +2346,15 @@ static char *awk_printf(node *n, size_t *len)
size_t slen;
s = f;
- while (*f && (*f != '%' || *++f == '%'))
+ while (*f && *f != '%')
f++;
+ c = *++f;
+ if (c == '%') { /* double % */
+ slen = f - s;
+ s = xstrndup(s, slen);
+ f++;
+ goto tail;
+ }
while (*f && !isalpha(*f)) {
if (*f == '*')
syntax_error("%*x formats are not supported");