aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Henty <onepoint@starurchin.org>2009-11-02 12:15:34 -0300
committerJeremy Henty <onepoint@starurchin.org>2009-11-02 12:15:34 -0300
commit3215c44d44b6aa35a9437d50e30d484f98cb3e1d (patch)
treea1e4ec1e256cae4b5f1ab1dcdba6aee29be4f8c7 /src
parente0f858edd0f8e54a436cffeb8114f575fdbafd09 (diff)
Refactor Html_tag_cleanup_at_close()
Diffstat (limited to 'src')
-rw-r--r--src/html.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/html.cc b/src/html.cc
index dcc2363e..ddc22249 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1273,6 +1273,20 @@ static void Html_real_pop_tag(DilloHtml *html)
Html_eventually_pop_dw(html, hand_over_break);
}
+static void Html_tag_cleanup_to_idx(DilloHtml *html, int idx)
+{
+ while (html->stack->size() > idx) {
+ int toptag_idx = S_TOP(html)->tag_idx;
+ if (html->stack->size() > idx + 1 &&
+ Tags[toptag_idx].EndTag != 'O')
+ BUG_MSG(" - forcing close of open tag: <%s>\n",
+ Tags[toptag_idx].name);
+ _MSG("Close: %*s%s\n", html->stack->size()," ",Tags[toptag_idx].name);
+ Tags[toptag_idx].close (html, toptag_idx);
+ Html_real_pop_tag(html);
+ }
+}
+
/*
* Default close function for tags.
* (conditional cleanup of the stack)
@@ -1307,21 +1321,7 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int TagIdx)
/* clean, up to the matching tag */
if (cmp == 0 && stack_idx > 0) {
- /* There's a valid matching tag in the stack */
- while (html->stack->size() > stack_idx) {
- int toptag_idx = S_TOP(html)->tag_idx;
- /* Warn when we decide to close an open tag (for !w3c_mode) */
- if (html->stack->size() > stack_idx + 1 &&
- Tags[toptag_idx].EndTag != 'O')
- BUG_MSG(" - forcing close of open tag: <%s>\n",
- Tags[toptag_idx].name);
-
- /* Close this and only this tag */
- _MSG("Close: %*s%s\n", html->stack->size()," ",Tags[toptag_idx].name);
- Tags[toptag_idx].close (html, toptag_idx);
- Html_real_pop_tag(html);
- }
-
+ Html_tag_cleanup_to_idx(html, stack_idx);
} else {
if (stack_idx == 0) {
BUG_MSG("unexpected closing tag: </%s>.\n", Tags[new_idx].name);