[klibc] [klibc:update-dash] dash: [EXPAND] Optimise nulonly away and just use quoted as before
klibc-bot for Herbert Xu
herbert at gondor.apana.org.au
Sat Mar 28 14:48:25 PDT 2020
Commit-ID: f253b53e6b2b89b31085e7d1e50f0eb6edf891dd
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=f253b53e6b2b89b31085e7d1e50f0eb6edf891dd
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Wed, 8 Oct 2014 20:09:56 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:54 +0000
[klibc] dash: [EXPAND] Optimise nulonly away and just use quoted as before
[ dash commit ab657e36b68f4a7e9ddb0f36c455c98d1c069a2c ]
This patch makes a small optimisation by using the same value for
quoted between evalvar and varvalue by eliminating nulonly and
passing along quoted instead.
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
usr/dash/expand.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/usr/dash/expand.c b/usr/dash/expand.c
index 9bbd19da..a2f99f14 100644
--- a/usr/dash/expand.c
+++ b/usr/dash/expand.c
@@ -722,7 +722,6 @@ evalvar(char *p, int flag)
ssize_t varlen;
int easy;
int quoted;
- int nulonly;
varflags = *p++;
subtype = varflags & VSTYPE;
@@ -733,12 +732,11 @@ evalvar(char *p, int flag)
quoted = flag & EXP_QUOTED;
var = p;
easy = (!quoted || (*var == '@' && shellparam.nparam));
- nulonly = easy;
startloc = expdest - (char *)stackblock();
p = strchr(p, '=') + 1;
again:
- varlen = varvalue(var, varflags, flag, &nulonly);
+ varlen = varvalue(var, varflags, flag, "ed);
if (varflags & VSNUL)
varlen--;
@@ -783,7 +781,7 @@ vsplus:
record:
if (!easy)
goto end;
- recordregion(startloc, expdest - (char *)stackblock(), nulonly);
+ recordregion(startloc, expdest - (char *)stackblock(), quoted);
goto end;
}
@@ -888,7 +886,7 @@ strtodest(p, syntax, quotes)
*/
STATIC ssize_t
-varvalue(char *name, int varflags, int flags, int *nulonly)
+varvalue(char *name, int varflags, int flags, int *quotedp)
{
int num;
char *p;
@@ -897,14 +895,12 @@ varvalue(char *name, int varflags, int flags, int *nulonly)
char sepc;
char **ap;
char const *syntax;
- int quoted = flags & EXP_QUOTED;
+ int quoted = *quotedp;
int subtype = varflags & VSTYPE;
int discard = subtype == VSPLUS || subtype == VSLENGTH;
int quotes = (discard ? 0 : (flags & QUOTES_ESC)) | QUOTES_KEEPNUL;
ssize_t len = 0;
- sep = *nulonly ? (flags & EXP_FULL) << CHAR_BIT : 0;
- *nulonly = 0;
syntax = quoted ? DQSYNTAX : BASESYNTAX;
switch (*name) {
@@ -935,16 +931,20 @@ numvar:
expdest = p;
break;
case '@':
+ sep = 0;
if (quoted)
goto param;
/* fall through */
case '*':
- sep |= ifsset() ? ifsval()[0] : ' ';
+ sep = ifsset() ? ifsval()[0] : ' ';
+ if (!quoted) {
param:
+ sep |= (flags & EXP_FULL) << CHAR_BIT;
+ }
+ sepc = sep;
+ *quotedp = !sepc;
if (!(ap = shellparam.p))
return -1;
- sepc = sep;
- *nulonly = !sepc;
while ((p = *ap++)) {
len += strtodest(p, syntax, quotes);
More information about the klibc
mailing list