aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-23 20:30:38 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-23 20:30:38 +0200
commitde21170afbb37e7de1d0504de8768e9a38fd5b24 (patch)
treec121f243ac5ff34ebea15be09564cda7e37e237a
parent85f1ef95dd6e46909f034184bc095a577b79970d (diff)
strdup() id and style strings
-rw-r--r--src/css.cc11
-rw-r--r--src/html.cc24
2 files changed, 32 insertions, 3 deletions
diff --git a/src/css.cc b/src/css.cc
index af961738..5712390d 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -9,6 +9,7 @@
* (at your option) any later version.
*/
+#include <stdio.h>
#include "css.hh"
StyleEngine::StyleEngine () {
@@ -16,3 +17,13 @@ StyleEngine::StyleEngine () {
StyleEngine::~StyleEngine () {
}
+
+void
+StyleEngine::startElement (int tag, const char *id, const char *style) {
+ fprintf(stderr, "===> START %d %s %s\n", tag, id, style);
+}
+
+void
+StyleEngine::endElement (int tag) {
+ fprintf(stderr, "===> END %d\n", tag);
+}
diff --git a/src/html.cc b/src/html.cc
index e79c7160..7fd53227 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -3445,6 +3445,7 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
{
int ci, ni; /* current and new tag indexes */
const char *attrbuf;
+ char *id = NULL, *style = NULL;
char *start = tag + 1; /* discard the '<' */
int IsCloseTag = (*start == '/');
@@ -3497,12 +3498,14 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
* spec states in Sec. 7.5.2 that anchor ids are case-sensitive.
* So we don't do it and hope for better specs in the future ...
*/
- Html_check_name_val(html, attrbuf, "id");
+ if (attrbuf)
+ id = strdup (attrbuf);
+ Html_check_name_val(html, id, "id");
/* We compare the "id" value with the url-decoded "name" value */
- if (!html->NameVal || strcmp(html->NameVal, attrbuf)) {
+ if (!html->NameVal || strcmp(html->NameVal, id)) {
if (html->NameVal)
BUG_MSG("'id' and 'name' attribute of <a> tag differ\n");
- Html_add_anchor(html, attrbuf);
+ Html_add_anchor(html, id);
}
}
@@ -3512,6 +3515,20 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
html->NameVal = NULL;
}
+ if (tagsize >= 11) { /* length of "<t style=i>" */
+ attrbuf = Html_get_attr2(html, tag, tagsize, "style",
+ HTML_LeftTrim | HTML_RightTrim);
+ if (attrbuf)
+ style = strdup (attrbuf);
+ }
+
+ html->styleEngine->startElement (ni, id, style);
+
+ if (id)
+ free (id);
+ if (style)
+ free (style);
+
/* let the parser know this was an open tag */
html->PrevWasOpenTag = true;
@@ -3534,6 +3551,7 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
(size_t)tagsize == strlen(Tags[ni].name) + 3))) { /* <x/> */
Tags[ni].close (html, ni);
+ html->styleEngine->endElement (ni);
/* This was a close tag */
html->PrevWasOpenTag = false;
html->ReqTagClose = false;