diff --git a/src/form.cc b/src/form.cc index aaadaea..6a60247 100644 --- a/src/form.cc +++ b/src/form.cc @@ -678,24 +678,24 @@ void Html_tag_close_textarea(DilloHtml *html) if (html->InFlags & IN_TEXTAREA && !S_TOP(html)->display_none) { /* Remove the line ending that follows the opening tag */ - if (html->Stash->str[0] == '\r') - dStr_erase(html->Stash, 0, 1); - if (html->Stash->str[0] == '\n') - dStr_erase(html->Stash, 0, 1); + if (html->Stash[0] == '\r') + html->Stash.erase( 0, 1 ); + if (html->Stash[0] == '\n') + html->Stash.erase( 0, 1 ); /* As the spec recommends to canonicalize line endings, it is safe * to replace '\r' with '\n'. It will be canonicalized anyway! */ - for (i = 0; i < html->Stash->len; ++i) { - if (html->Stash->str[i] == '\r') { - if (html->Stash->str[i + 1] == '\n') - dStr_erase(html->Stash, i, 1); + for (i = 0; i < html->Stash.size(); ++i) { + if (html->Stash[i] == '\r') { + if (html->Stash[i + 1] == '\n') + html->Stash.erase( i, 1 ); else - html->Stash->str[i] = '\n'; + html->Stash[i] = '\n'; } } /* The HTML3.2 spec says it can have "text and character entities". */ - auto str = a_Html_parse_entities(html, html->Stash->str, html->Stash->len); + auto str = a_Html_parse_entities(html, html->Stash.c_str(), html->Stash.size()); auto input = Html_get_current_input(*html); if (input) { input->init_str = str; @@ -1973,6 +1973,6 @@ static void Html_option_finish(DilloHtml *html) (input->type == DILLO_HTML_INPUT_SELECT || input->type == DILLO_HTML_INPUT_SEL_LIST)) { DilloHtmlOptbase *opt = input->select->getCurrentOpt (); - opt->setContent (html->Stash->str, html->Stash->len); + opt->setContent (html->Stash.c_str(), html->Stash.size()); } } diff --git a/src/html.cc b/src/html.cc index 2f96140..ec17d0f 100644 --- a/src/html.cc +++ b/src/html.cc @@ -491,7 +491,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, InFlags = IN_NONE; - Stash = dStr_new(""); StashSpace = false; pre_column = 0; @@ -603,7 +602,6 @@ int DilloHtml::getCurrLineNumber() */ void DilloHtml::freeParseData() { - dStr_free(Stash, TRUE); dStr_free(attr_data, TRUE); } @@ -814,7 +812,7 @@ void a_Html_stash_init(DilloHtml *html) { S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_STASH; html->StashSpace = false; - dStr_truncate(html->Stash, 0); + html->Stash.clear(); } /** @@ -1104,10 +1102,10 @@ static void Html_process_space(DilloHtml *html, const char *space, if (S_TOP(html)->display_none) { /* do nothing */ } else if (parse_mode == DILLO_HTML_PARSE_MODE_STASH) { - html->StashSpace = (html->Stash->len > 0); + html->StashSpace = not html->Stash.empty(); } else if (parse_mode == DILLO_HTML_PARSE_MODE_VERBATIM) { - dStr_append_l(html->Stash, space, spacesize); + html->Stash+= std::string_view{ space, space + spacesize }; } else if (parse_mode == DILLO_HTML_PARSE_MODE_PRE) { int spaceCnt = 0; @@ -1168,7 +1166,7 @@ static void Html_process_space(DilloHtml *html, const char *space, } if (parse_mode == DILLO_HTML_PARSE_MODE_STASH_AND_BODY) - html->StashSpace = (html->Stash->len > 0); + html->StashSpace = not html->Stash.empty(); } } @@ -1195,15 +1193,14 @@ static void Html_process_word(DilloHtml *html, const char *word, int size) if (parse_mode == DILLO_HTML_PARSE_MODE_STASH || parse_mode == DILLO_HTML_PARSE_MODE_STASH_AND_BODY) { if (html->StashSpace) { - dStr_append_c(html->Stash, ' '); + html->Stash+= ' '; html->StashSpace = false; } - const std::string Pword= a_Html_parse_entities(html, word, size); - dStr_append(html->Stash, Pword.c_str()); + html->Stash+= a_Html_parse_entities(html, word, size); } else if (parse_mode == DILLO_HTML_PARSE_MODE_VERBATIM) { /* word goes in untouched, it is not processed here. */ - dStr_append_l(html->Stash, word, size); + html->Stash+= std::string_view{ word, word + size }; } if (parse_mode == DILLO_HTML_PARSE_MODE_STASH || @@ -1667,7 +1664,7 @@ static void Html_tag_close_title(DilloHtml *html) /* title is only valid inside HEAD */ if (html->InFlags & IN_HEAD && html->Num_TITLE == 1) { /* Ignore empty titles: