changeset 147:77ad934fb3a2

- Removed tag_name from the navigation stack (Tags[tag_idx] server the same).
author jcid
date Sun, 16 Mar 2008 14:55:08 +0100
parents 2168ad66d209
children 029012f3f10c
files src/html.cc
diffstat 1 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Sun Mar 16 13:43:56 2008 +0100
+++ b/src/html.cc	Sun Mar 16 14:55:08 2008 +0100
@@ -194,7 +194,6 @@
 };
 
 struct _DilloHtmlState {
-   char *tag_name;
    dw::core::style::Style *style, *table_cell_style;
    DilloHtmlParseMode parse_mode;
    DilloHtmlTableMode table_mode;
@@ -818,7 +817,6 @@
 
    stack = new misc::SimpleVector <DilloHtmlState> (16);
    stack->increase();
-   stack->getRef(0)->tag_name = dStrdup("none");
    stack->getRef(0)->style = NULL;
    stack->getRef(0)->table_cell_style = NULL;
    stack->getRef(0)->parse_mode = DILLO_HTML_PARSE_MODE_INIT;
@@ -1017,7 +1015,6 @@
          Html_tag_cleanup_at_close(this, stack->getRef(si)->tag_idx);
       }
    }
-   dFree(stack->getRef(0)->tag_name);    /* "none" */
    (stack->getRef(0)->style)->unref ();  /* template style */
 
    delete (stack);
@@ -1599,18 +1596,13 @@
  */
 static void Html_push_tag(DilloHtml *html, int tag_idx)
 {
-   char *tagstr;
    int n_items;
 
-   /* Save the element's name (no parameters) into tagstr. */
-   tagstr = dStrdup(Tags[tag_idx].name);
-
    n_items = html->stack->size ();
    html->stack->increase ();
    /* We'll copy the former stack item and just change the tag and its index
     * instead of copying all fields except for tag.  --Jcid */
    *html->stack->getRef(n_items) = *html->stack->getRef(n_items - 1);
-   html->stack->getRef(n_items)->tag_name = tagstr;
    html->stack->getRef(n_items)->tag_idx = tag_idx;
    /* proper memory management, may be unref'd later */
    (S_TOP(html)->style)->ref ();
@@ -1638,7 +1630,6 @@
    (S_TOP(html)->style)->unref ();
    if (S_TOP(html)->table_cell_style)
       (S_TOP(html)->table_cell_style)->unref ();
-   dFree(S_TOP(html)->tag_name);
    hand_over_break = S_TOP(html)->hand_over_break;
    html->stack->setSize (html->stack->size() - 1);
    Html_eventually_pop_dw(html, hand_over_break);
@@ -1701,8 +1692,13 @@
       }
 
    } else {
-      MSG_HTML("unexpected closing tag: </%s>. -- expected </%s>\n",
-               Tags[new_idx].name, html->stack->getRef(stack_idx)->tag_name);
+      if (stack_idx == 0) {
+         MSG_HTML("unexpected closing tag: </%s>.\n", Tags[new_idx].name);
+      } else {
+         MSG_HTML("unexpected closing tag: </%s>. -- expected </%s>\n",
+                  Tags[new_idx].name,
+                  Tags[html->stack->getRef(stack_idx)->tag_idx].name);
+      }
    }
 }
 
@@ -5585,7 +5581,7 @@
           DILLO_HTML_PARSE_MODE_VERBATIM) {
          /* Non HTML code here, let's skip until closing tag */
          do {
-            char *tag = S_TOP(html)->tag_name;
+            const char *tag = Tags[S_TOP(html)->tag_idx].name;
             buf_index += strcspn(buf + buf_index, "<");
             if (buf_index + (int)strlen(tag) + 3 > bufsize) {
                buf_index = bufsize;