aboutsummaryrefslogtreecommitdiffstats
path: root/braces.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-21 20:51:19 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-21 20:51:19 -0500
commit0001803f0b9523c94fa2ede48eaecb047fef4524 (patch)
treef334332811e033ff966d94f6268f0629a94304b3 /braces.c
parent89a92869e56aba4e4cab2d639c00a86f0545c862 (diff)
downloadandroid_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.tar.gz
android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.tar.bz2
android_external_bash-0001803f0b9523c94fa2ede48eaecb047fef4524.zip
Bash-4.1 distribution source
Diffstat (limited to 'braces.c')
-rw-r--r--braces.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/braces.c b/braces.c
index 4e0c08a..45abe45 100644
--- a/braces.c
+++ b/braces.c
@@ -364,7 +364,7 @@ expand_seqterm (text, tlen)
char *t, *lhs, *rhs;
int i, lhs_t, rhs_t, lhs_v, rhs_v, incr, lhs_l, rhs_l, width;
intmax_t tl, tr;
- char **result, *ep;
+ char **result, *ep, *oep;
t = strstr (text, BRACE_SEQ_SPECIFIER);
if (t == 0)
@@ -410,10 +410,12 @@ expand_seqterm (text, tlen)
incr = 1;
if (rhs_t != ST_BAD)
{
+ oep = ep;
if (ep && *ep == '.' && ep[1] == '.' && ep[2])
incr = strtoimax (ep + 2, &ep, 10);
if (*ep != 0)
rhs_t = ST_BAD; /* invalid incr */
+ tlen -= ep - oep;
}
if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)
@@ -449,6 +451,11 @@ expand_seqterm (text, tlen)
width = rhs_l, lhs_t = ST_ZINT;
if (rhs_l > 2 && rhs[0] == '-' && rhs[1] == '0' && width < rhs_l)
width = rhs_l, lhs_t = ST_ZINT;
+
+ if (width < lhs_l && lhs_t == ST_ZINT)
+ width = lhs_l;
+ if (width < rhs_l && lhs_t == ST_ZINT)
+ width = rhs_l;
}
result = mkseq (lhs_v, rhs_v, incr, lhs_t, width);