sh: Allow arbitrarily large numbers in break and continue.
The argument is capped to loopnest, so strtol()'s [ERANGE] can be ignored.
This commit is contained in:
parent
120d6dd50d
commit
4d34663be3
@ -1250,8 +1250,16 @@ bltincmd(int argc, char **argv)
|
||||
int
|
||||
breakcmd(int argc, char **argv)
|
||||
{
|
||||
int n = argc > 1 ? number(argv[1]) : 1;
|
||||
long n;
|
||||
char *end;
|
||||
|
||||
if (argc > 1) {
|
||||
/* Allow arbitrarily large numbers. */
|
||||
n = strtol(argv[1], &end, 10);
|
||||
if (!is_digit(argv[1][0]) || *end != '\0')
|
||||
error("Illegal number: %s", argv[1]);
|
||||
} else
|
||||
n = 1;
|
||||
if (n > loopnest)
|
||||
n = loopnest;
|
||||
if (n > 0) {
|
||||
|
@ -14,6 +14,7 @@ FILES+= break2.0 break2.0.stdout
|
||||
FILES+= break3.0
|
||||
FILES+= break4.4
|
||||
FILES+= break5.4
|
||||
FILES+= break6.0
|
||||
FILES+= builtin1.0
|
||||
FILES+= case1.0
|
||||
FILES+= case2.0
|
||||
|
8
bin/sh/tests/builtins/break6.0
Normal file
8
bin/sh/tests/builtins/break6.0
Normal file
@ -0,0 +1,8 @@
|
||||
# $FreeBSD$
|
||||
# Per POSIX, this need only work if LONG_MAX > 4294967295.
|
||||
|
||||
while :; do
|
||||
break 4294967296
|
||||
echo bad
|
||||
exit 3
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user