diff --git a/src/html.cc b/src/html.cc
index 18e755b..1e6f3f6 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -505,8 +505,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
Num_HTML = Num_HEAD = Num_BODY = Num_TITLE = 0;
- attr_data = dStr_sized_new(1024);
-
non_css_link_color = -1;
non_css_visited_color = -1;
visited_color = -1;
@@ -542,8 +540,6 @@ DilloHtml::~DilloHtml()
{
_MSG("::~DilloHtml(this=%p)\n", this);
- freeParseData();
-
a_Bw_remove_doc(bw, this);
}
@@ -592,14 +588,6 @@ int DilloHtml::getCurrLineNumber()
return line;
}
-/**
- * Free parsing data.
- */
-void DilloHtml::freeParseData()
-{
- dStr_free(attr_data, TRUE);
-}
-
/**
* Finish parsing a HTML page. Close the parser and close the client.
* The class is not deleted here, it remains until the widget is destroyed.
@@ -2577,20 +2565,20 @@ static const char* Html_get_javascript_link(DilloHtml *html)
{
size_t i;
char ch, *p1, *p2;
- Dstr *Buf = html->attr_data;
+ std::string &Buf = html->attr_data;
- if (dStrnAsciiCasecmp("javascript", Buf->str, 10) == 0) {
- i = strcspn(Buf->str, "'\"");
- ch = Buf->str[i];
+ if (dStrnAsciiCasecmp("javascript", Buf.c_str(), 10) == 0) {
+ i = strcspn(Buf.c_str(), "'\"");
+ ch = Buf.at( i );
if ((ch == '"' || ch == '\'') &&
- (p2 = strchr(Buf->str + i + 1 , ch))) {
- p1 = Buf->str + i;
+ (p2 = strchr(Buf.data() + i + 1 , ch))) {
+ p1 = Buf.data() + i;
BUG_MSG("Link depends on javascript().");
- dStr_truncate(Buf, p2 - Buf->str);
- dStr_erase(Buf, 0, p1 - Buf->str + 1);
+ while( Buf.size() > ( p2 - Buf.c_str() ) ) Buf.pop_back();
+ Buf.erase( 0, p1 - Buf.c_str() + 1 );
}
}
- return Buf->str;
+ return Buf.c_str();
}
/**
@@ -4085,12 +4073,12 @@ static const char *Html_get_attr2(DilloHtml *html,
int tag_parsing_flags)
{
int i, entsize, Found = 0, delimiter = 0, attr_pos = 0;
- Dstr *Buf = html->attr_data;
+ std::string &Buf = html->attr_data;
DilloHtmlTagParsingState state = SEEK_ATTR_START;
dReturn_val_if_fail(*attrname, NULL);
- dStr_truncate(Buf, 0);
+ Buf.clear();
for (i = 1; i < tagsize; ++i) {
switch (state) {
@@ -4148,17 +4136,17 @@ static const char *Html_get_attr2(DilloHtml *html,
if ((entstr = Html_parse_entity(html, tag+i, tagsize-i, &entsize,
is_attr))) {
- dStr_append(Buf, entstr);
+ Buf+= entstr;
i += entsize-1;
} else {
- dStr_append_c(Buf, tag[i]);
+ Buf+= tag[i];
}
} else if (tag[i] == '\r' || tag[i] == '\t') {
- dStr_append_c(Buf, ' ');
+ Buf+= ' ';
} else if (tag[i] == '\n') {
/* ignore */
} else {
- dStr_append_c(Buf, tag[i]);
+ Buf+= tag[i];
}
break;
@@ -4169,13 +4157,13 @@ static const char *Html_get_attr2(DilloHtml *html,
}
if (tag_parsing_flags & HTML_LeftTrim)
- while (isspace(Buf->str[0]))
- dStr_erase(Buf, 0, 1);
+ while (isspace(Buf.front()))
+ Buf.erase( 0, 1 );
if (tag_parsing_flags & HTML_RightTrim)
- while (Buf->len && isspace(Buf->str[Buf->len - 1]))
- dStr_truncate(Buf, Buf->len - 1);
+ while (Buf.size() && isspace( Buf.back() ))
+ Buf.pop_back();
- return (Found) ? Buf->str : NULL;
+ return (Found) ? Buf.c_str() : NULL;
}
/**
diff --git a/src/html_common.hh b/src/html_common.hh
index f62685f..cc8e7cd 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -214,7 +214,7 @@ public: //BUG: for now everything is public
* ATM they're used as three state flags {0,1,>1} */
uchar_t Num_HTML, Num_HEAD, Num_BODY, Num_TITLE;
- Dstr *attr_data; /**< Buffer for attribute value */
+ std::string attr_data; /**< Buffer for attribute value */
int32_t non_css_link_color; /**< as provided by link attribute in BODY */
int32_t non_css_visited_color; /**< as provided by vlink attribute in BODY */
@@ -230,7 +230,6 @@ public: //BUG: for now everything is public
dw::ImageMapsList maps;
private:
- void freeParseData();
void initDw(); /* Used by the constructor */
public: