Another dString retired.
This commit is contained in:
22
src/form.cc
22
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());
|
||||
}
|
||||
}
|
||||
|
28
src/html.cc
28
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: <title></title> */
|
||||
char *title = html->Stash->str;
|
||||
const char *title = html->Stash.c_str();
|
||||
if (!title || title[0] == '\0')
|
||||
return;
|
||||
a_UIcmd_set_page_title(html->bw, title);
|
||||
@ -1730,8 +1727,8 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize)
|
||||
static void Html_tag_close_style(DilloHtml *html)
|
||||
{
|
||||
if (prefs.parse_embedded_css && html->loadCssFromStash)
|
||||
html->styleEngine->parse(html, html->base_url.get(), html->Stash->str,
|
||||
html->Stash->len, CSS_ORIGIN_AUTHOR);
|
||||
html->styleEngine->parse(html, html->base_url.get(), html->Stash.c_str(),
|
||||
html->Stash.size(), CSS_ORIGIN_AUTHOR);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4262,9 +4259,8 @@ static int Html_write_raw(DilloHtml *html, char *buf, int bufsize, int Eof)
|
||||
} else if (strncmp(buf + buf_index, "</", 2) == 0 &&
|
||||
Html_match_tag(tag, buf+buf_index+2, strlen(tag)+1)) {
|
||||
/* copy VERBATIM text into the stash buffer */
|
||||
text = dStrndup(buf + token_start, buf_index - token_start);
|
||||
dStr_append(html->Stash, text);
|
||||
dFree(text);
|
||||
const std::string text{ buf + token_start, buf + buf_index };
|
||||
html->Stash+= text.c_str();
|
||||
token_start = buf_index;
|
||||
break;
|
||||
} else
|
||||
|
@ -196,7 +196,7 @@ public: //BUG: for now everything is public
|
||||
|
||||
int InFlags; /**< tracks which elements we are in */
|
||||
|
||||
Dstr *Stash;
|
||||
std::string Stash;
|
||||
bool StashSpace;
|
||||
|
||||
int pre_column; /**< current column, used in PRE tags with tabs */
|
||||
|
Reference in New Issue
Block a user