add check for matching numbers of left/right brackets of div-text
This commit is contained in:
parent
d931ebb61c
commit
682e92c14d
@ -631,7 +631,7 @@ namespace nana
|
|||||||
|
|
||||||
static division * search_div_name(division* start, const std::string&) noexcept;
|
static division * search_div_name(division* start, const std::string&) noexcept;
|
||||||
|
|
||||||
std::unique_ptr<division> scan_div(place_parts::tokenizer&, const std::string& ignore_duplicate = {});
|
std::unique_ptr<division> scan_div(place_parts::tokenizer&, bool implicitly_started, const std::string& ignore_duplicate = {});
|
||||||
void check_unique(const division*) const;
|
void check_unique(const division*) const;
|
||||||
|
|
||||||
//connect the field/dock with div object
|
//connect the field/dock with div object
|
||||||
@ -1988,7 +1988,7 @@ namespace nana
|
|||||||
|
|
||||||
std::string::size_type tag_pos{ left ? div.find('<', bound.second + 2) : div.rfind('>', bound.first - 2) };
|
std::string::size_type tag_pos{ left ? div.find('<', bound.second + 2) : div.rfind('>', bound.first - 2) };
|
||||||
if (div.npos == tag_pos)
|
if (div.npos == tag_pos)
|
||||||
throw std::runtime_error("place report an issue if it throws");
|
throw std::invalid_argument("please report an issue if it throws");
|
||||||
|
|
||||||
auto other_bound = get_field_boundary(div, tag_pos);
|
auto other_bound = get_field_boundary(div, tag_pos);
|
||||||
|
|
||||||
@ -2707,8 +2707,9 @@ namespace nana
|
|||||||
throw std::invalid_argument("nana.place: the type of the " + std::string{pos_strs[pos]} +"th parameter for collapse should be integer.");
|
throw std::invalid_argument("nana.place: the type of the " + std::string{pos_strs[pos]} +"th parameter for collapse should be integer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//implicitly_started indicates whether the field in div-text starts without < mark.
|
||||||
//ignore_duplicate A field is allowed to have same name if its has an ancestor which name is same with ignore_duplicate.
|
//ignore_duplicate A field is allowed to have same name if its has an ancestor which name is same with ignore_duplicate.
|
||||||
auto place::implement::scan_div(place_parts::tokenizer& tknizer, const std::string& ignore_duplicate) -> std::unique_ptr<division>
|
auto place::implement::scan_div(place_parts::tokenizer& tknizer, bool implicitly_started, const std::string& ignore_duplicate) -> std::unique_ptr<division>
|
||||||
{
|
{
|
||||||
using token = place_parts::tokenizer::token ;
|
using token = place_parts::tokenizer::token ;
|
||||||
|
|
||||||
@ -2730,7 +2731,8 @@ namespace nana
|
|||||||
bool undisplayed = false;
|
bool undisplayed = false;
|
||||||
bool invisible = false;
|
bool invisible = false;
|
||||||
|
|
||||||
for (token tk = tknizer.read(); (tk != token::eof && tk != token::div_end); tk = tknizer.read())
|
token tk = token::eof;
|
||||||
|
for (tk = tknizer.read(); (tk != token::eof && tk != token::div_end); tk = tknizer.read())
|
||||||
{
|
{
|
||||||
switch (tk)
|
switch (tk)
|
||||||
{
|
{
|
||||||
@ -2759,7 +2761,7 @@ namespace nana
|
|||||||
break;
|
break;
|
||||||
case token::div_start:
|
case token::div_start:
|
||||||
{
|
{
|
||||||
auto div = scan_div(tknizer, ignore_duplicate);
|
auto div = scan_div(tknizer, false, ignore_duplicate);
|
||||||
if (!children.empty())
|
if (!children.empty())
|
||||||
children.back()->div_next = div.get();
|
children.back()->div_next = div.get();
|
||||||
|
|
||||||
@ -2889,6 +2891,9 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (implicitly_started && (tk == token::div_end))
|
||||||
|
throw std::invalid_argument("nana.place: the div-text ends prematurely at " + std::to_string(tknizer.pos()));
|
||||||
|
|
||||||
field_gather * attached_field = nullptr;
|
field_gather * attached_field = nullptr;
|
||||||
|
|
||||||
//find the field with specified name.
|
//find the field with specified name.
|
||||||
@ -3228,7 +3233,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
place_parts::tokenizer tknizer(div_text.c_str());
|
place_parts::tokenizer tknizer(div_text.c_str());
|
||||||
impl_->disconnect();
|
impl_->disconnect();
|
||||||
auto div = impl_->scan_div(tknizer);
|
auto div = impl_->scan_div(tknizer, true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
impl_->connect(div.get()); //throws if there is a redefined name of field.
|
impl_->connect(div.get()); //throws if there is a redefined name of field.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user