diff --git a/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.cpp b/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.cpp index 3eac38a..9606ec0 100644 --- a/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.cpp +++ b/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.cpp @@ -422,6 +422,14 @@ XHTMLTagAction *XHTMLReader::addAction(const std::string &tag, XHTMLTagAction *a return old; } +void XHTMLReader::clearTagTable() { + ActionMap::iterator it = ourTagActions.begin(); + while (it != ourTagActions.end()) { + delete it->second; + ourTagActions.erase(it++); + } +} + void XHTMLReader::fillTagTable() { if (ourTagActions.empty()) { //addAction("html", new XHTMLTagAction()); @@ -480,7 +488,6 @@ void XHTMLReader::fillTagTable() { addAction("br", new XHTMLTagLineBreakAction()); //addAction("center", new XHTMLTagAction()); addAction("div", new XHTMLTagParagraphAction()); - addAction("dt", new XHTMLTagParagraphAction()); //addAction("head", new XHTMLTagAction()); //addAction("hr", new XHTMLTagAction()); addAction("link", new XHTMLTagLinkAction()); diff --git a/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.h b/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.h index 50d6ebf..e3522d6 100644 --- a/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.h +++ b/fbreader/fbreader/fbreader/src/formats/xhtml/XHTMLReader.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2004-2010 Geometer Plus + * Copyright (C) 2016-2018 Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,9 +57,11 @@ class XHTMLReader : public ZLXMLReader { public: static XHTMLTagAction *addAction(const std::string &tag, XHTMLTagAction *action); static void fillTagTable(); + static void clearTagTable(); private: - static std::map ourTagActions; + typedef std::map ActionMap; + static ActionMap ourTagActions; public: XHTMLReader(BookReader &modelReader); diff --git a/fbreader/fbreader/fbreader/src/library/Tag.cpp b/fbreader/fbreader/fbreader/src/library/Tag.cpp index c5f0937..fb453dc 100644 --- a/fbreader/fbreader/fbreader/src/library/Tag.cpp +++ b/fbreader/fbreader/fbreader/src/library/Tag.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2010 Geometer Plus + * Copyright (C) 2016-2018 Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -137,3 +138,9 @@ void Tag::setTagId(shared_ptr tag, int tagId) { tag->myTagId = tagId; ourTagsById[tagId] = tag; } + +void Tag::clearTags() +{ + ourRootTags.clear(); + ourTagsById.clear(); +} diff --git a/fbreader/fbreader/fbreader/src/library/Tag.h b/fbreader/fbreader/fbreader/src/library/Tag.h index eb19b30..1133660 100644 --- a/fbreader/fbreader/fbreader/src/library/Tag.h +++ b/fbreader/fbreader/fbreader/src/library/Tag.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2010 Geometer Plus + * Copyright (C) 2016-2018 Slava Monich * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +38,7 @@ public: static shared_ptr getTag(const std::string &name, shared_ptr parent = 0, int tagId = 0); static shared_ptr getTagByFullName(const std::string &fullName); static shared_ptr getTagById(int tagId); + static void clearTags(); static void setTagId(shared_ptr, int tagId); diff --git a/fbreader/fbreader/zlibrary/core/src/encoding/MyEncodingConverter.cpp b/fbreader/fbreader/zlibrary/core/src/encoding/MyEncodingConverter.cpp index 71aa32f..bc9d29f 100644 --- a/fbreader/fbreader/zlibrary/core/src/encoding/MyEncodingConverter.cpp +++ b/fbreader/fbreader/zlibrary/core/src/encoding/MyEncodingConverter.cpp @@ -143,15 +143,14 @@ MyOneByteEncodingConverter::MyOneByteEncodingConverter(const std::string &encodi myEncodingMap = new char[1024]; memset(myEncodingMap, '\0', 1024); for (int i = 0; i < 256; ++i) { - ZLUnicodeUtil::ucs4ToUtf8(myEncodingMap + 4 * i, i); - } - if (encodingMap != 0) { - for (int i = 0; i < 256; ++i) { - if (encodingMap[i] != 0) { - strcpy(myEncodingMap + 4 * i, encodingMap[i]); - } + if (encodingMap[i]) { + strcpy(myEncodingMap + 4 * i, encodingMap[i]); + delete[] encodingMap[i]; + } else { + ZLUnicodeUtil::ucs4ToUtf8(myEncodingMap + 4 * i, i); } } + delete[] encodingMap; } MyOneByteEncodingConverter::~MyOneByteEncodingConverter() {