search for: vslength

Displaying 15 results from an estimated 15 matches for "vslength".

Did you mean: tslength
2019 Jan 25
0
[klibc:update-dash] [EXPAND] Do not split quoted VSLENGTH and VSTRIM
...git;a=commit;h=baa2d8dd94e0d59450fc8bc96c27c2dd891c014c Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Wed, 8 Oct 2014 15:42:08 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [EXPAND] Do not split quoted VSLENGTH and VSTRIM Currently VSLENGTH and VSTRIM* are field-split even within quotes. This is obviously wrong. This patch fixes that. 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 | 32 +++++++++++++---...
2020 Mar 28
0
[klibc:update-dash] dash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM
...commit;h=2474db119d9240db258134f8532ebcb096e539a4 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Wed, 8 Oct 2014 15:42:08 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM [ dash commit 8ecad23eae02bbdf36fe5dc8e53deb67fb894357 ] Currently VSLENGTH and VSTRIM* are field-split even within quotes. This is obviously wrong. This patch fixes that. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decaden...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Eat closing brace for length parameter expansion
...u> AuthorDate: Mon, 19 Nov 2018 18:41:20 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [klibc] dash: expand: Eat closing brace for length parameter expansion [ dash commit 878514712c5d21f675c45d99d2f8a04098ea4a19 ] When we are doing VSLENGTH expansion, the closing brace is currently not removed in evalvar. This causes the caller argstr to terminate prematurely as it would interpret the closing brace as one that belongs to a parameter expansion at the outer level. This patch fixes it. Reported-by: Martijn Dekker <martijn at inlv.o...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Do not reprocess data when expanding words
...~QUOTES_ESC); + + if (flag & EXP_DISCARD) + return p; + varflags &= ~VSNUL; - /* - * Remove any recorded regions beyond - * start of variable - */ - removerecordregions(startloc); goto again; } @@ -759,20 +744,14 @@ vsplus: varunset(p, var, 0, 0); if (subtype == VSLENGTH) { + if (flag & EXP_DISCARD) + return p; cvtnum(varlen > 0 ? varlen : 0); goto record; } - if (subtype == VSNORMAL) { -record: - if (quoted) { - quoted = *var == '@' && shellparam.nparam; - if (!quoted) - goto end; - } - recordregion(startloc, expdest -...
2019 Jan 25
0
[klibc:update-dash] [PARSER] Catch variable length expansions on non-existant specials
...ash/parser.c @@ -1229,8 +1229,7 @@ varname: STPUTC(c, out); c = pgetc_eatbnl(); } while (is_digit(c)); - } - else if (is_special(c)) { + } else { int cc = c; c = pgetc_eatbnl(); @@ -1251,10 +1250,14 @@ varname: } } + if (!is_special(cc)) { + if (subtype == VSLENGTH) + subtype = 0; + goto badsub; + } + USTPUTC(cc, out); } - else - goto badsub; if (subtype == 0) { switch (c) {
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Catch variable length expansions on non-existant specials
...ash/parser.c @@ -1229,8 +1229,7 @@ varname: STPUTC(c, out); c = pgetc_eatbnl(); } while (is_digit(c)); - } - else if (is_special(c)) { + } else { int cc = c; c = pgetc_eatbnl(); @@ -1251,10 +1250,14 @@ varname: } } + if (!is_special(cc)) { + if (subtype == VSLENGTH) + subtype = 0; + goto badsub; + } + USTPUTC(cc, out); } - else - goto badsub; if (subtype == 0) { switch (c) {
2019 Jan 25
0
[klibc:update-dash] [EXPAND] Optimise nulonly away and just use quoted as before
...nt 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;...
2020 Mar 28
0
[klibc:update-dash] dash: [EXPAND] Optimise nulonly away and just use quoted as before
...nt 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;...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Fix multiple issues with EXP_DISCARD in evalvar
...ag & EXP_DISCARD) - return p; + if ((flag | ~discard) & EXP_DISCARD) + goto record; varflags &= ~VSNUL; + subtype = VSNORMAL; goto again; } - if (varlen < 0 && uflag) + if ((discard & ~flag) && uflag) varunset(p, var, 0, 0); if (subtype == VSLENGTH) { if (flag & EXP_DISCARD) return p; cvtnum(varlen > 0 ? varlen : 0, flag); - goto record; + goto really_record; } if (subtype == VSNORMAL) @@ -765,7 +766,7 @@ again: } #endif - flag |= varlen < 0 ? EXP_DISCARD : 0; + flag |= discard; if (!(flag & EXP_DISCARD)...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Ensure result is escaped in cvtnum
...); @@ -463,7 +463,7 @@ static 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 m...
2019 Jan 25
0
[klibc:update-dash] [PARSER] Handle backslash newlines properly after dollar sign
...n_name(c)); } else if (is_digit(c)) { do { STPUTC(c, out); - c = pgetc(); + c = pgetc_eatbnl(); } while (is_digit(c)); } else if (is_special(c)) { int cc = c; - c = pgetc(); + c = pgetc_eatbnl(); if (!subtype && cc == '#') { subtype = VSLENGTH; @@ -1227,7 +1245,7 @@ varname: goto varname; cc = c; - c = pgetc(); + c = pgetc_eatbnl(); if (cc == '}' || c != '}') { pungetc(); subtype = 0; @@ -1245,7 +1263,7 @@ varname: switch (c) { case ':': subtype = VSNUL; - c = pg...
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Handle backslash newlines properly after dollar sign
...n_name(c)); } else if (is_digit(c)) { do { STPUTC(c, out); - c = pgetc(); + c = pgetc_eatbnl(); } while (is_digit(c)); } else if (is_special(c)) { int cc = c; - c = pgetc(); + c = pgetc_eatbnl(); if (!subtype && cc == '#') { subtype = VSLENGTH; @@ -1227,7 +1245,7 @@ varname: goto varname; cc = c; - c = pgetc(); + c = pgetc_eatbnl(); if (cc == '}' || c != '}') { pungetc(); subtype = 0; @@ -1245,7 +1263,7 @@ varname: switch (c) { case ':': subtype = VSNUL; - c = pg...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Merge syntax/quotes in memtodest with flags
...t(p, len, syntax, quotes); + memtodest(p, len, flags); return len; } @@ -886,15 +879,14 @@ varvalue(char *name, int varflags, int flags, int quoted) int sep; char sepc; char **ap; - char const *syntax; int subtype = varflags & VSTYPE; int discard = subtype == VSPLUS || subtype == VSLENGTH; - int quotes = (discard ? 0 : (flags & QUOTES_ESC)) | QUOTES_KEEPNUL; ssize_t len = 0; char c; + flags |= EXP_KEEPNUL; + flags &= discard ? ~QUOTES_ESC : ~0; sep = (flags & EXP_FULL) << CHAR_BIT; - syntax = quoted ? DQSYNTAX : BASESYNTAX; switch (*name) { case '...
2019 Jan 25
0
[klibc:update-dash] expand: Fix ghost fields with unquoted $@/$*
...varflags, int flags, int quoted) { int num; char *p; @@ -887,11 +888,11 @@ varvalue(char *name, int varflags, int flags, int *quotedp) char sepc; char **ap; char const *syntax; - 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; + char c; sep = (flags & EXP_FULL) << CHAR_BIT; syntax = quoted ? DQSYNTAX : BASESYNTAX; @@ -928,12 +929,25 @@ numvar: goto param; /* fall through */ case '*': - if (quote...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Fix ghost fields with unquoted $@/$*
...varflags, int flags, int quoted) { int num; char *p; @@ -887,11 +888,11 @@ varvalue(char *name, int varflags, int flags, int *quotedp) char sepc; char **ap; char const *syntax; - 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; + char c; sep = (flags & EXP_FULL) << CHAR_BIT; syntax = quoted ? DQSYNTAX : BASESYNTAX; @@ -928,12 +929,25 @@ numvar: goto param; /* fall through */ case '*': - if (quote...