Smashed another SimpleVector.
This commit is contained in:
39
src/html.cc
39
src/html.cc
@ -2307,20 +2307,19 @@ static void Html_tag_close_map(DilloHtml *html)
|
|||||||
/**
|
/**
|
||||||
* Read coords in a string, returning a vector of ints.
|
* Read coords in a string, returning a vector of ints.
|
||||||
*/
|
*/
|
||||||
static
|
static std::vector< int >
|
||||||
misc::SimpleVector<int> *Html_read_coords(DilloHtml *html, const char *str)
|
Html_read_coords(DilloHtml *html, const char *str)
|
||||||
{
|
{
|
||||||
int coord;
|
int coord;
|
||||||
const char *tail = str;
|
const char *tail = str;
|
||||||
char *newtail = NULL;
|
char *newtail = NULL;
|
||||||
misc::SimpleVector<int> *coords = new misc::SimpleVector<int> (4);
|
std::vector< int > coords;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
coord = strtol(tail, &newtail, 10);
|
coord = strtol(tail, &newtail, 10);
|
||||||
if (coord == 0 && newtail == tail)
|
if (coord == 0 && newtail == tail)
|
||||||
break;
|
break;
|
||||||
coords->increase();
|
coords.push_back( coord );
|
||||||
coords->set(coords->size() - 1, coord);
|
|
||||||
while (isspace(*newtail))
|
while (isspace(*newtail))
|
||||||
newtail++;
|
newtail++;
|
||||||
if (!*newtail)
|
if (!*newtail)
|
||||||
@ -2342,7 +2341,6 @@ static void
|
|||||||
{
|
{
|
||||||
enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
|
enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND};
|
||||||
types type;
|
types type;
|
||||||
misc::SimpleVector<int> *coords = NULL;
|
|
||||||
DilloUrl* url;
|
DilloUrl* url;
|
||||||
const char *attrbuf;
|
const char *attrbuf;
|
||||||
int link = -1;
|
int link = -1;
|
||||||
@ -2370,33 +2368,32 @@ static void
|
|||||||
}
|
}
|
||||||
if (type == RECTANGLE || type == CIRCLE || type == POLYGON) {
|
if (type == RECTANGLE || type == CIRCLE || type == POLYGON) {
|
||||||
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "coords"))) {
|
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "coords"))) {
|
||||||
coords = Html_read_coords(html, attrbuf);
|
auto coords= Html_read_coords(html, attrbuf);
|
||||||
|
|
||||||
if (type == RECTANGLE) {
|
if (type == RECTANGLE) {
|
||||||
if (coords->size() != 4)
|
if (coords.size() != 4)
|
||||||
BUG_MSG("<area> rectangle must have four coordinate values.");
|
BUG_MSG("<area> rectangle must have four coordinate values.");
|
||||||
if (coords->size() >= 4)
|
if (coords.size() >= 4)
|
||||||
shape = std::make_unique< Rectangle >(coords->get(0),
|
shape = std::make_unique< Rectangle >(coords.at(0),
|
||||||
coords->get(1),
|
coords.at(1),
|
||||||
coords->get(2) - coords->get(0),
|
coords.at(2) - coords.at(0),
|
||||||
coords->get(3) - coords->get(1));
|
coords.at(3) - coords.at(1));
|
||||||
} else if (type == CIRCLE) {
|
} else if (type == CIRCLE) {
|
||||||
if (coords->size() != 3)
|
if (coords.size() != 3)
|
||||||
BUG_MSG("<area> circle must have three coordinate values.");
|
BUG_MSG("<area> circle must have three coordinate values.");
|
||||||
if (coords->size() >= 3)
|
if (coords.size() >= 3)
|
||||||
shape = std::make_unique< Circle >(coords->get(0), coords->get(1),
|
shape = std::make_unique< Circle >(coords.at(0), coords.at(1),
|
||||||
coords->get(2));
|
coords.at(2));
|
||||||
} else if (type == POLYGON) {
|
} else if (type == POLYGON) {
|
||||||
std::unique_ptr< Polygon > poly;
|
std::unique_ptr< Polygon > poly;
|
||||||
int i;
|
int i;
|
||||||
if (coords->size() % 2)
|
if (coords.size() % 2)
|
||||||
BUG_MSG("<area> polygon with odd number of coordinates.");
|
BUG_MSG("<area> polygon with odd number of coordinates.");
|
||||||
poly = std::make_unique< Polygon >();
|
poly = std::make_unique< Polygon >();
|
||||||
for (i = 0; i < (coords->size() / 2); i++)
|
for (i = 0; i < (coords.size() / 2); i++)
|
||||||
poly->addPoint(coords->get(2*i), coords->get(2*i + 1));
|
poly->addPoint(coords.at(2*i), coords.at(2*i + 1));
|
||||||
shape= std::move( poly );
|
shape= std::move( poly );
|
||||||
}
|
}
|
||||||
delete(coords);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shape != nullptr || type == BACKGROUND) {
|
if (shape != nullptr || type == BACKGROUND) {
|
||||||
|
|||||||
Reference in New Issue
Block a user