summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStef <stef@ws.local>2004-03-31 04:04:16 +0000
committerStef <stef@ws.local>2004-03-31 04:04:16 +0000
commita4c0a06821a6f77ee1d7aebeb2eee02bb7aa913d (patch)
tree3de5c30f7fd9239c8db38fb1a5a8518064fa38b4 /src
parent4d38570e69b996d6d119808c66460ceb4fe940b0 (diff)
Unix porting
Unix porting
Diffstat (limited to 'src')
-rw-r--r--src/basehandler.cpp1
-rw-r--r--src/rtfparser.cpp12
-rw-r--r--src/rtfx.cpp3
-rw-r--r--src/sablo.h2
-rw-r--r--src/sablotr.cpp12
-rw-r--r--src/usuals.h2
-rw-r--r--src/xmlcomposehelpers.cpp1
-rw-r--r--src/xmlcomposehelpers.h2
-rw-r--r--src/xmlcomposer.cpp58
-rw-r--r--src/xmlcomposer.h2
10 files changed, 51 insertions, 44 deletions
diff --git a/src/basehandler.cpp b/src/basehandler.cpp
index d561cef..8be9c25 100644
--- a/src/basehandler.cpp
+++ b/src/basehandler.cpp
@@ -49,4 +49,3 @@ void BaseHandler::charData(wstring data)
{
}
-
diff --git a/src/rtfparser.cpp b/src/rtfparser.cpp
index 336847f..589ef71 100644
--- a/src/rtfparser.cpp
+++ b/src/rtfparser.cpp
@@ -60,7 +60,10 @@ void RtfReader::sendData(RtfContext& cx, wstring data)
{
if(m_uniEat > 0)
{
- int len = __min(data.size(), m_uniEat);
+ int len = data.size();
+ if(len > m_uniEat)
+ len = m_uniEat;
+
cx.data.append(data.substr(len));
m_uniEat -= len;
}
@@ -134,11 +137,11 @@ bool RtfReader::parseControlWord(RtfContext& cx)
// NOTE: Although the RTF specification prohibits upercase
// control words, MS Word uses them :-/
if(ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z')
- controlword.append(1, ch);
+ controlword.append(1, (char)ch);
// Part of the parameter of a control word
else if(ch >= '0' && ch <= '9')
- param.append(1, ch);
+ param.append(1, (char)ch);
// Now handle escapes and other special types of
// control words. These are all only valid at beginning
@@ -199,7 +202,7 @@ bool RtfReader::parseControlWord(RtfContext& cx)
// a hyphen right after control word is part of number
else if(!empty && param.empty() && ch == '-')
{
- param.append(1, ch);
+ param.append(1, (char)ch);
}
// TODO: This looks real hokey and acts that
@@ -399,4 +402,3 @@ done:
return m_parseErrors.empty();
}
-
diff --git a/src/rtfx.cpp b/src/rtfx.cpp
index e3ceb61..4d1bbd6 100644
--- a/src/rtfx.cpp
+++ b/src/rtfx.cpp
@@ -2,13 +2,14 @@
#include "usuals.h"
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include "rtfreader.h"
#include "rtfanalyser.h"
int usage()
{
- fprintf(stderr, "usage: rtfm inrtf outxml\n");
+ fprintf(stderr, "usage: rtfm <inrtf> <outxml>\n");
return 2;
}
diff --git a/src/sablo.h b/src/sablo.h
index 99cfc40..7b2b04d 100644
--- a/src/sablo.h
+++ b/src/sablo.h
@@ -2136,4 +2136,4 @@ namespace DOM
}; // namespace DOM
-#endif //__SABLO_H__ \ No newline at end of file
+#endif //__SABLO_H__
diff --git a/src/sablotr.cpp b/src/sablotr.cpp
index 3b62cd6..218f0b8 100644
--- a/src/sablotr.cpp
+++ b/src/sablotr.cpp
@@ -80,10 +80,10 @@ bool DOM::transcode8to16(const std::basic_string<char>& data,
(c[2] & 0xC0) == 0x80 &&
(c[3] & 0xC0) == 0x80)
{
- ret.append(1, ((wchar_t)c[0] & 7) << 18 |
+ ret.append(1, (wchar_t)(((wchar_t)c[0] & 7) << 18 |
((wchar_t)c[1] & 63) << 12 |
((wchar_t)c[2] & 63) << 6 |
- ((wchar_t)c[3] & 63));
+ ((wchar_t)c[3] & 63)));
c += 3;
}
@@ -92,9 +92,9 @@ bool DOM::transcode8to16(const std::basic_string<char>& data,
(c[1] & 0xC0) == 0x80 &&
(c[2] & 0xC0) == 0x80)
{
- ret.append(1, ((wchar_t)c[0] & 15) << 12 |
+ ret.append(1, (wchar_t)(((wchar_t)c[0] & 15) << 12 |
((wchar_t)c[1] & 63) << 6 |
- ((wchar_t)c[2] & 63));
+ ((wchar_t)c[2] & 63)));
c += 2;
}
@@ -102,8 +102,8 @@ bool DOM::transcode8to16(const std::basic_string<char>& data,
else if((c[0] & 0xE0) == 0xC0 &&
(c[1] & 0xC0) == 0x80)
{
- ret.append(1, ((wchar_t)c[0] & 31) << 6 |
- ((wchar_t)c[1] & 63));
+ ret.append(1, (wchar_t)(((wchar_t)c[0] & 31) << 6 |
+ ((wchar_t)c[1] & 63)));
c += 1;
}
diff --git a/src/usuals.h b/src/usuals.h
index ea4384c..5d74f0e 100644
--- a/src/usuals.h
+++ b/src/usuals.h
@@ -8,4 +8,4 @@
#include <stdlib.h>
#include <assert.h>
-#endif // __USUALS_H__ \ No newline at end of file
+#endif // __USUALS_H__
diff --git a/src/xmlcomposehelpers.cpp b/src/xmlcomposehelpers.cpp
index 3f457b4..240c0a4 100644
--- a/src/xmlcomposehelpers.cpp
+++ b/src/xmlcomposehelpers.cpp
@@ -100,4 +100,3 @@ void Level::setTextProperties(RtfFormatting& formatting)
{
m_text.copy(formatting);
}
-
diff --git a/src/xmlcomposehelpers.h b/src/xmlcomposehelpers.h
index 05abb8b..a73e9b9 100644
--- a/src/xmlcomposehelpers.h
+++ b/src/xmlcomposehelpers.h
@@ -84,4 +84,4 @@ protected:
};
-#endif //__RTFPARSEHELPERS_H__ \ No newline at end of file
+#endif //__RTFPARSEHELPERS_H__
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp
index 9795fe2..36a705a 100644
--- a/src/xmlcomposer.cpp
+++ b/src/xmlcomposer.cpp
@@ -726,10 +726,10 @@ ON_CONTROLWORD(ListOverrideTable)
// the list node for overriding, using the 'listid' and 'ls' we gathered
if(curList != NULL && lsId != -1)
{
- DOM::Element parent = (DOM::Element&)curList.getParentNode();
+ DOM::Element parent = (const DOM::Element&)curList.getParentNode();
if(parent != NULL)
{
- curList = (DOM::Element&)curList.cloneNode(true);
+ curList = (const DOM::Element&)curList.cloneNode(true);
if(curList != NULL)
{
parent.appendChild(curList);
@@ -990,11 +990,11 @@ bool RtfParser::isEqualElement(const DOM::Element& el1, const DOM::Element& el2)
for(int i = 0; i < at1->getLength(); i++)
{
- DOM::Attr attr1 = (DOM::Attr&)at1->item(0);
+ DOM::Attr attr1 = (const DOM::Attr&)at1->item(0);
if(attr1 != NULL)
return false;
- DOM::Attr attr2 = (DOM::Attr&)at2->getNamedItem(attr1.getNodeName());
+ DOM::Attr attr2 = (const DOM::Attr&)at2->getNamedItem(attr1.getNodeName());
if(attr2 != NULL)
return false;
@@ -1008,7 +1008,13 @@ bool RtfParser::isEqualElement(const DOM::Element& el1, const DOM::Element& el2)
wstring RtfParser::formatInt(int num)
{
wchar_t buff[12];
+
+ // The Win32 version isn't secure
+#ifdef _WIN32
swprintf(buff, L"%d", num);
+#else
+ swprintf(buff, 12, L"%d", num);
+#endif
wstring n(buff);
return n;
@@ -1110,7 +1116,7 @@ void RtfParser::breakBreak(DOM::Document& doc, const string& contain,
{
for(int i = 0; i < els->getLength(); i++)
{
- DOM::Element el = (DOM::Element&)els->item(i);
+ DOM::Element el = (const DOM::Element&)els->item(i);
#if 0
// See if parent node only has this break tag
// in it. If so then replace parent with this
@@ -1154,11 +1160,11 @@ void RtfParser::breakBreak(DOM::Document& doc, const string& contain,
* <b>test of </b> your concentration.
* </dest>
*/
-bool RtfParser::breakElement(DOM::Element& el, const string& contain)
+bool RtfParser::breakElement(const DOM::Element& el, const string& contain)
{
ASSERT(el != NULL);
- DOM::Element parent = (DOM::Element&)el.getParentNode();
+ DOM::Element parent = (const DOM::Element&)el.getParentNode();
DOM::Element grandparent;
string s = el.getNodeName();
@@ -1166,7 +1172,7 @@ bool RtfParser::breakElement(DOM::Element& el, const string& contain)
// Get the parent node
if(parent != NULL)
- grandparent = (DOM::Element&)parent.getParentNode();
+ grandparent = (const DOM::Element&)parent.getParentNode();
// Make sure we have something to work with before continuing
if(grandparent == NULL || parent == NULL ||
@@ -1200,7 +1206,7 @@ bool RtfParser::breakElement(DOM::Element& el, const string& contain)
else
{
// Clone it but not deep
- DOM::Element parent2 = (DOM::Element&)parent.cloneNode(false);
+ DOM::Element parent2 = (const DOM::Element&)parent.cloneNode(false);
if(parent2 == NULL)
return false;
@@ -1254,7 +1260,7 @@ void RtfParser::breakBlocks(DOM::Document& document)
{
for(int i = 0; i < blocks->getLength(); i++)
{
- DOM::Element block = (DOM::Element&)blocks->item(i);
+ DOM::Element block = (const DOM::Element&)blocks->item(i);
// If it's the single closed style para then break it
if(block != NULL && !block.hasChildNodes())
@@ -1269,7 +1275,7 @@ void RtfParser::breakBlocks(DOM::Document& document)
{
for(int i = 0; i < destinations->getLength(); i++)
{
- DOM::Element dest = (DOM::Element&)destinations->item(i);
+ DOM::Element dest = (const DOM::Element&)destinations->item(i);
// Sanity Check
if(dest == NULL || !dest.hasChildNodes())
@@ -1321,7 +1327,7 @@ void RtfParser::wrapTags(DOM::Document& doc, const string& tagName,
{
for(int i = 0; i < tags->getLength(); i++)
{
- DOM::Element tag = (DOM::Element&)tags->item(i);
+ DOM::Element tag = (const DOM::Element&)tags->item(i);
DOM::Element wrap = doc.createElement(wrapName);
while(tag.hasChildNodes())
@@ -1340,7 +1346,7 @@ void RtfParser::breakTags(DOM::Document& doc, const string& parentName,
{
for(int i = 0; i < parents->getLength(); i++)
{
- DOM::Element parent = (DOM::Element&)parents->item(i);
+ DOM::Element parent = (const DOM::Element&)parents->item(i);
if(!parent.hasChildNodes())
continue;
@@ -1349,7 +1355,7 @@ void RtfParser::breakTags(DOM::Document& doc, const string& parentName,
if(tags != NULL)
{
for(int i = 0; i < tags->getLength(); i++)
- breakElement((DOM::Element&)tags->item(i), parentName);
+ breakElement((const DOM::Element&)tags->item(i), parentName);
}
DOM::Node tag = doc.createElement(tagName);
@@ -1406,7 +1412,7 @@ void RtfParser::breakTags(DOM::Document& doc, const string& parentName,
{
for(int i = 0; i < tags->getLength(); i++)
{
- DOM::Element tag = (DOM::Element&)tags->item(i);
+ DOM::Element tag = (const DOM::Element&)tags->item(i);
DOM::Node parent = tag.getParentNode();
if(parent != NULL && !isElement(parent, parentName))
@@ -1438,7 +1444,7 @@ void RtfParser::breakLists(DOM::Document& doc)
{
for(int i = 0; i < destinations->getLength(); i++)
{
- DOM::Element dest = (DOM::Element&)destinations->item(i);
+ DOM::Element dest = (const DOM::Element&)destinations->item(i);
// Sanity Check
if(dest == NULL)
@@ -1503,14 +1509,14 @@ void RtfParser::fixStyles(const DOM::Document doc)
{
for(int i = 0; i < blocks->getLength(); i++)
{
- DOM::Element block = (DOM::Element&)blocks->item(i);
+ DOM::Element block = (const DOM::Element&)blocks->item(i);
if(block == NULL || !block.hasAttribute(kElStyle))
continue;
for(int j = 0; j < styles->getLength(); j++)
{
- DOM::Element style = (DOM::Element&)styles->item(j);
+ DOM::Element style = (const DOM::Element&)styles->item(j);
if(style != NULL)
{
if(style.getAttribute(kAtId) == block.getAttribute(kElStyle))
@@ -1526,7 +1532,7 @@ void RtfParser::fixStyles(const DOM::Document doc)
for(int i = 0; i < styles->getLength(); i++)
{
- DOM::Element style = (DOM::Element&)styles->item(i);
+ DOM::Element style = (const DOM::Element&)styles->item(i);
if(style != NULL)
style.removeAttribute(kAtId);
}
@@ -1543,7 +1549,7 @@ void RtfParser::breakTables(DOM::Document& doc)
{
for(int i = 0; i < rows->getLength(); i++)
{
- DOM::Element row = (DOM::Element&)rows->item(i);
+ DOM::Element row = (const DOM::Element&)rows->item(i);
DOM::Node parent = row.getParentNode();
if(parent == NULL)
@@ -1574,7 +1580,7 @@ void RtfParser::breakTables(DOM::Document& doc)
{
for(int i = 0; i < destinations->getLength(); i++)
{
- DOM::Element dest = (DOM::Element&)destinations->item(i);
+ DOM::Element dest = (const DOM::Element&)destinations->item(i);
// Sanity Check
if(dest == NULL)
@@ -1643,7 +1649,7 @@ void RtfParser::removeTags(const DOM::Document& doc)
{
for(int j = 0; j < elements->getLength(); j++)
{
- DOM::Element el = (DOM::Element&)elements->item(j);
+ DOM::Element el = (const DOM::Element&)elements->item(j);
DOM::Node parent = el->getParentNode();
if(parent == NULL)
@@ -1668,14 +1674,14 @@ void RtfParser::fixLists(const DOM::Document doc)
{
for(int i = 0; i < listdefs->getLength(); i++)
{
- DOM::Element listdef = (DOM::Element&)listdefs->item(i);
+ DOM::Element listdef = (const DOM::Element&)listdefs->item(i);
if(listdef == NULL || !listdef.hasAttribute(kAtList))
continue;
for(int j = 0; j < lists->getLength(); j++)
{
- DOM::Element list = (DOM::Element&)lists->item(j);
+ DOM::Element list = (const DOM::Element&)lists->item(j);
if(list != NULL)
{
if(list.getAttribute(kAtList) == listdef.getAttribute(kAtList))
@@ -1701,7 +1707,7 @@ void RtfParser::fixBlocks(const DOM::Document doc)
for(int i = 0; i < blocks->getLength(); i++)
{
- DOM::Element block = (DOM::Element&)blocks->item(i);
+ DOM::Element block = (const DOM::Element&)blocks->item(i);
DOM::Node parent = block.getParentNode();
if(parent == NULL)
@@ -1756,7 +1762,7 @@ void RtfParser::removeDuplicates(const DOM::Document& doc)
{
// Make sure it's a valid element
- DOM::Element element = (DOM::Element&)elements->item(j);
+ DOM::Element element = (const DOM::Element&)elements->item(j);
if(element == NULL)
continue;
diff --git a/src/xmlcomposer.h b/src/xmlcomposer.h
index 24dd649..a91304a 100644
--- a/src/xmlcomposer.h
+++ b/src/xmlcomposer.h
@@ -61,7 +61,7 @@ protected:
void fixBlocks(DOM::Document doc);
void fixLists(const DOM::Document doc);
void fixStyles(const DOM::Document doc);
- bool breakElement(DOM::Element& el, const string& contain);
+ bool breakElement(const DOM::Element& el, const string& contain);
void breakBreak(DOM::Document& doc, const string& contain,
const string& tag);