diff options
author | Stef <stef@ws.local> | 2004-03-31 04:04:16 +0000 |
---|---|---|
committer | Stef <stef@ws.local> | 2004-03-31 04:04:16 +0000 |
commit | a4c0a06821a6f77ee1d7aebeb2eee02bb7aa913d (patch) | |
tree | 3de5c30f7fd9239c8db38fb1a5a8518064fa38b4 | |
parent | 4d38570e69b996d6d119808c66460ceb4fe940b0 (diff) |
Unix porting
Unix porting
-rw-r--r-- | .cvsignore | 22 | ||||
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | BUGS | 3 | ||||
-rw-r--r-- | COPYING | 14 | ||||
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | INSTALL | 8 | ||||
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | config.h.in | 126 | ||||
-rw-r--r-- | configure.in | 43 | ||||
-rw-r--r-- | src/basehandler.cpp | 1 | ||||
-rw-r--r-- | src/rtfparser.cpp | 12 | ||||
-rw-r--r-- | src/rtfx.cpp | 3 | ||||
-rw-r--r-- | src/sablo.h | 2 | ||||
-rw-r--r-- | src/sablotr.cpp | 12 | ||||
-rw-r--r-- | src/usuals.h | 2 | ||||
-rw-r--r-- | src/xmlcomposehelpers.cpp | 1 | ||||
-rw-r--r-- | src/xmlcomposehelpers.h | 2 | ||||
-rw-r--r-- | src/xmlcomposer.cpp | 58 | ||||
-rw-r--r-- | src/xmlcomposer.h | 2 |
21 files changed, 272 insertions, 50 deletions
@@ -1,6 +1,16 @@ -*.plg -*.opt -*.ncb -Debug -Release -test-files
\ No newline at end of file +test-files +config.h +autom4te.cache +Makefile +Makefile.in +aclocal.m4 +config.h +config.log +config.status +configure +depcomp +install-sh +missing +mkinstalldirs +stamp-* +*~ @@ -0,0 +1 @@ +nielsen@memberwebs.com @@ -0,0 +1,3 @@ +RTFM TODOS AND BUGS +- No font support +- Doesn't handle crummy RTF files nicely. @@ -0,0 +1,14 @@ +LICENSE +This software is in the public domain. + +The software is provided "as is", without warranty of any kind, +express or implied, including but not limited to the warranties +of merchantability, fitness for a particular purpose, and +noninfringement. In no event shall the author(s) be liable for any +claim, damages, or other liability, whether in an action of +contract, tort, or otherwise, arising from, out of, or in connection +with the software or the use or other dealings in the software. + +SUPPORT +Send bug reports to: <nielsen@memberwebs.com> + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..40246ca --- /dev/null +++ b/ChangeLog @@ -0,0 +1,3 @@ +Version 1.0 + - Initial working release + @@ -0,0 +1,8 @@ +====================================================================== + RTFM 1.0 INSTALL + +QUICK INSTALLATION: + # tar -zxvf rtfm-1.0.tar.gz + # ./configure + # make && make install + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..5e729c5 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = BUGS config.win32.h +SUBDIRS = src win32 + @@ -0,0 +1 @@ +See ChangeLog
\ No newline at end of file @@ -0,0 +1,3 @@ +================================================================= + RTFM 1.0 README + diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..0c4c8b5 --- /dev/null +++ b/config.h.in @@ -0,0 +1,126 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the <assert.h> header file. */ +#undef HAVE_ASSERT_H + +/* Define to 1 if you have the <errno.h> header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the <exception> header file. */ +#undef HAVE_EXCEPTION + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `sablot' library (-lsablot). */ +#undef HAVE_LIBSABLOT + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the <sablot.h> header file. */ +#undef HAVE_SABLOT_H + +/* Define to 1 if you have the <sdom.h> header file. */ +#undef HAVE_SDOM_H + +/* Define to 1 if you have the <stack> header file. */ +#undef HAVE_STACK + +/* Define to 1 if you have the <stddef.h> header file. */ +#undef HAVE_STDDEF_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdio.h> header file. */ +#undef HAVE_STDIO_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the <string> header file. */ +#undef HAVE_STRING + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `swprintf' function. */ +#undef HAVE_SWPRINTF + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the <wchar.h> header file. */ +#undef HAVE_WCHAR_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `unsigned' if <sys/types.h> does not define. */ +#undef size_t diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..f033a0c --- /dev/null +++ b/configure.in @@ -0,0 +1,43 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT(rtfm, 1.0, nielsen@memberwebs.com) +AM_INIT_AUTOMAKE(rtfm, 1.0) + +LDFLAGS="$LDFLAGS -L/usr/local/lib" + +AC_LANG_CPLUSPLUS + +AC_CONFIG_SRCDIR([src/rtfm.cpp]) +AM_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET + +# Check for libraries +AC_CHECK_LIB(sablot, SDOM_createElement, , + [echo "ERROR: Must install sablotron libraries."; exit 1]) + +# Checks for header files. +AC_FUNC_ALLOCA +AC_HEADER_STDC +AC_CHECK_HEADERS([stddef.h stdlib.h wchar.h assert.h stdio.h errno.h], , + [echo "ERROR: Required C header missing"; exit 1]) +AC_CHECK_HEADERS([string exception stack], , + [echo "ERROR: Required STL header missing"; exit 1]) +AC_CHECK_HEADERS([sablot.h sdom.h], , + [echo "ERROR: Required Sablotron header missing"; exit 1]) + + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +# Required Functions +AC_CHECK_FUNCS([memset strchr strerror swprintf], , + [echo "ERROR: Required function missing"; exit 1]) + +AC_CONFIG_FILES([Makefile src/Makefile win32/Makefile]) +AC_OUTPUT 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); |