Mercurial > octave
changeset 25232:8a92b651838b
primes.m: Improve input validation (bug #53472).
* primes.m: Accept only a numeric scalar for input N.
Add BIST test.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 12 Apr 2018 13:19:25 -0700 |
parents | b68abed2db20 |
children | c64f7a95b464 |
files | scripts/specfun/primes.m |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/specfun/primes.m Thu Apr 12 12:11:34 2018 -0700 +++ b/scripts/specfun/primes.m Thu Apr 12 13:19:25 2018 -0700 @@ -48,8 +48,8 @@ print_usage (); endif - if (! isscalar (n)) - error ("primes: N must be a scalar"); + if (! (isnumeric (n) && isscalar (n))) + error ("primes: N must be a numeric scalar"); endif if (n > 100e3) @@ -107,4 +107,5 @@ %!error primes () %!error primes (1, 2) -%!error <N must be a scalar> primes (ones (2,2)) +%!error <N must be a numeric scalar> primes ("1") +%!error <N must be a numeric scalar> primes (ones (2,2))