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:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-05-27 17:16:58 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-27 17:17:38 +0300
commit84ff1825dd82e8de45020e3def34d1430d8e5a99 (patch)
tree3fc6b7037c6e3a1fc1e43878efb0f7e6c5eb64da /editors
parent9225f9684fedd5c997fc729fee29f8ac402b8db9 (diff)
awk: fix splitting with default FS
function old new delta awk_split 543 544 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 2af823808..b3748b502 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2049,13 +2049,17 @@ static int awk_split(const char *s, node *spl, char **slist)
}
return n;
}
- /* space split */
+ /* space split: "In the special case that FS is a single space,
+ * fields are separated by runs of spaces and/or tabs and/or newlines"
+ */
while (*s) {
- s = skip_whitespace(s);
+ /* s = skip_whitespace(s); -- WRONG (also skips \v \f \r) */
+ while (*s == ' ' || *s == '\t' || *s == '\n')
+ s++;
if (!*s)
break;
n++;
- while (*s && !isspace(*s))
+ while (*s && !(*s == ' ' || *s == '\t' || *s == '\n'))
*s1++ = *s++;
*s1++ = '\0';
}
@@ -2304,7 +2308,6 @@ static int awk_getline(rstream *rsm, var *v)
setvar_i(intvar[ERRNO], errno);
}
b[p] = '\0';
-
} while (p > pp);
if (p == 0) {
@@ -3145,7 +3148,7 @@ static var *evaluate(node *op, var *res)
/* make sure that we never return a temp var */
if (L.v == TMPVAR0)
L.v = res;
- /* if source is a temporary string, jusk relink it to dest */
+ /* if source is a temporary string, just relink it to dest */
if (R.v == TMPVAR1
&& !(R.v->type & VF_NUMBER)
/* Why check !NUMBER? if R.v is a number but has cached R.v->string,