Displaying 4 results from an estimated 4 matches for "exp_discard".
2020 Mar 28
0
[klibc:update-dash] dash: expand: Fix multiple issues with EXP_DISCARD in evalvar
...t;h=1285f79afbd9686c78c7815203ecbf3e87a81ff8
Author: Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Wed, 12 Sep 2018 14:27:16 +0800
Committer: Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:55 +0000
[klibc] dash: expand: Fix multiple issues with EXP_DISCARD in evalvar
[ dash commit a29e9a1738a4e7040211842f3f3d90e172fa58ce ]
The commit 3cd538634f71538370f5af239f342aec48b7470b broke parameter
expansion in multiple ways because the EXP_DISCARD flag wasn't set
or tested for various cases:
$ src/dash -c 'var=; echo ${var:+nonempty}'
nonemp...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Do not reprocess data when expanding words
...the various expansion functions such as expari
and subevalvar to return the next character to be expanded.
This is inspired by similar code from FreeBSD. However, we take
things one step further and completely remove the manual word
skipping in evalvar. This is accomplished by introducing a new
EXP_DISCARD flag that tells argstr to only parse and not produce
any actual expansions.
Incidentally, argstr will now always NUL-terminate the expansion
unless the EXP_WORD flag is set. This is because all but one
caller of argstr wants the result to be NUL-termianted.
Signed-off-by: Herbert Xu <herbert...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Eat closing brace for length parameter expansion
...usr/dash/expand.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/usr/dash/expand.c b/usr/dash/expand.c
index 25236c09..20362cef 100644
--- a/usr/dash/expand.c
+++ b/usr/dash/expand.c
@@ -745,6 +745,7 @@ again:
varunset(p, var, 0, 0);
if (subtype == VSLENGTH) {
+ p++;
if (flag & EXP_DISCARD)
return p;
cvtnum(varlen > 0 ? varlen : 0, flag);
2020 Mar 28
0
[klibc:update-dash] dash: expand: Ensure result is escaped in cvtnum
...char *expari(char *start, int flag)
result = arith(start);
popstackmark(&sm);
- len = cvtnum(result);
+ len = cvtnum(result, flag);
if (likely(!(flag & EXP_QUOTED)))
recordregion(begoff, begoff + len, 0);
@@ -746,7 +746,7 @@ again:
if (subtype == VSLENGTH) {
if (flag & EXP_DISCARD)
return p;
- cvtnum(varlen > 0 ? varlen : 0);
+ cvtnum(varlen > 0 ? varlen : 0, flag);
goto record;
}
@@ -795,15 +795,17 @@ record:
* Put a string on the stack.
*/
-static void memtodest(const char *p, size_t len, int flags)
+static size_t memtodest(const char *p, size_t le...