Pushing null values into a sequence is legitimate
This commit is contained in:
parent
2aef4f8884
commit
c26daee2cf
2 changed files with 26 additions and 30 deletions
|
|
@ -62,6 +62,8 @@ void interactive_t::verify_arguments() const
|
||||||
for (; ! wrong_arg && ! exit_loop && *p && next_arg; p++) {
|
for (; ! wrong_arg && ! exit_loop && *p && next_arg; p++) {
|
||||||
DEBUG("interactive.verify",
|
DEBUG("interactive.verify",
|
||||||
"Want " << *p << " got: " << next_arg->label());
|
"Want " << *p << " got: " << next_arg->label());
|
||||||
|
|
||||||
|
wrong_arg = false;
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case 'a':
|
case 'a':
|
||||||
label = _("an amount");
|
label = _("an amount");
|
||||||
|
|
@ -86,24 +88,24 @@ void interactive_t::verify_arguments() const
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'l':
|
case 'l':
|
||||||
label = _("an integer");
|
label = _("an integer");
|
||||||
if (next_arg->is_long() ||
|
if (next_arg->is_long() ||
|
||||||
(next_arg->is_amount() &&
|
(next_arg->is_amount() &&
|
||||||
! next_arg->as_amount().has_commodity())) {
|
! next_arg->as_amount().has_commodity())) {
|
||||||
wrong_arg = false;
|
wrong_arg = false;
|
||||||
}
|
}
|
||||||
else if (next_arg->is_string()) {
|
else if (next_arg->is_string()) {
|
||||||
wrong_arg = false;
|
wrong_arg = false;
|
||||||
for (const char * q = next_arg->as_string().c_str(); *q; q++) {
|
for (const char * q = next_arg->as_string().c_str(); *q; q++) {
|
||||||
if (! std::isdigit(*q) && *q != '-') {
|
if (! std::isdigit(*q) && *q != '-') {
|
||||||
wrong_arg = true;
|
wrong_arg = true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
wrong_arg = true;
|
else {
|
||||||
}
|
wrong_arg = true;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
label = _("a regex");
|
label = _("a regex");
|
||||||
wrong_arg = ! next_arg->is_mask();
|
wrong_arg = ! next_arg->is_mask();
|
||||||
|
|
@ -134,6 +136,8 @@ void interactive_t::verify_arguments() const
|
||||||
dont_skip = true;
|
dont_skip = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (wrong_arg && optional && next_arg->is_null())
|
||||||
|
wrong_arg = false;
|
||||||
|
|
||||||
if (wrong_arg)
|
if (wrong_arg)
|
||||||
vlabel = next_arg->label();
|
vlabel = next_arg->label();
|
||||||
|
|
|
||||||
20
src/value.h
20
src/value.h
|
|
@ -818,13 +818,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(const value_t& val) {
|
void push_back(const value_t& val) {
|
||||||
if (! val.is_null()) {
|
if (is_null())
|
||||||
if (is_null())
|
*this = sequence_t();
|
||||||
*this = sequence_t();
|
if (! is_sequence())
|
||||||
if (! is_sequence())
|
in_place_cast(SEQUENCE);
|
||||||
in_place_cast(SEQUENCE);
|
as_sequence_lval().push_back(val);
|
||||||
as_sequence_lval().push_back(val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop_back() {
|
void pop_back() {
|
||||||
|
|
@ -855,24 +853,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence_t::iterator begin() {
|
sequence_t::iterator begin() {
|
||||||
VERIFY(is_sequence());
|
|
||||||
return as_sequence_lval().begin();
|
return as_sequence_lval().begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence_t::iterator end() {
|
sequence_t::iterator end() {
|
||||||
VERIFY(is_sequence());
|
return as_sequence_lval().end();
|
||||||
// This special hack is because we never used end() in a context which
|
|
||||||
// needs us to call _dup().
|
|
||||||
return boost::get<sequence_t *>(storage->data)->end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence_t::const_iterator begin() const {
|
sequence_t::const_iterator begin() const {
|
||||||
VERIFY(is_sequence());
|
|
||||||
return as_sequence().begin();
|
return as_sequence().begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence_t::const_iterator end() const {
|
sequence_t::const_iterator end() const {
|
||||||
VERIFY(is_sequence());
|
|
||||||
return as_sequence().end();
|
return as_sequence().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue