Added argument checks to forbid negative input
This commit is contained in:
parent
4629c59b45
commit
dde62454ea
@ -63,21 +63,25 @@ int main(int argc, char* argv[]) {
|
|||||||
case 'u':
|
case 'u':
|
||||||
valid += upper;
|
valid += upper;
|
||||||
min_upper = std::atoi(optarg);
|
min_upper = std::atoi(optarg);
|
||||||
|
if (min_upper < 0) throw std::runtime_error("minimum amout of upper case must be zero or more");
|
||||||
noflags = false;
|
noflags = false;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
valid += lower;
|
valid += lower;
|
||||||
min_lower = std::atoi(optarg);
|
min_lower = std::atoi(optarg);
|
||||||
|
if (min_upper < 0) throw std::runtime_error("minimum amout of lower case must be zero or more");
|
||||||
noflags = false;
|
noflags = false;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
valid += digits;
|
valid += digits;
|
||||||
min_digits = std::atoi(optarg);
|
min_digits = std::atoi(optarg);
|
||||||
|
if (min_upper < 0) throw std::runtime_error("minimum amout of digits must be zero or more");
|
||||||
noflags = false;
|
noflags = false;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
valid += symbols;
|
valid += symbols;
|
||||||
min_symbols = std::atoi(optarg);
|
min_symbols = std::atoi(optarg);
|
||||||
|
if (min_upper < 0) throw std::runtime_error("minimum amout of symbols must be zero or more");
|
||||||
noflags = false;
|
noflags = false;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user