diff options
| -rw-r--r-- | Makefile.am | 38 | ||||
| -rw-r--r-- | config.h.in | 12 | ||||
| -rw-r--r-- | configure.in | 89 | ||||
| -rw-r--r-- | src/Makefile.am | 39 | ||||
| -rw-r--r-- | src/rtfparser.h | 5 | ||||
| -rw-r--r-- | src/usuals.h | 12 | ||||
| -rw-r--r-- | src/xmlcomposehelpers.h | 5 | ||||
| -rw-r--r-- | src/xmlcomposer.cpp | 15 | 
8 files changed, 84 insertions, 131 deletions
| diff --git a/Makefile.am b/Makefile.am index 95ee595..514f7a0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,43 +1,7 @@ -# -# Copyright (c) 2004, Nate Nielsen -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -#     * Redistributions of source code must retain the above -#       copyright notice, this list of conditions and the -#       following disclaimer. -#     * Redistributions in binary form must reproduce the -#       above copyright notice, this list of conditions and -#       the following disclaimer in the documentation and/or -#       other materials provided with the distribution. -#     * The names of contributors to this software may not be -#       used to endorse or promote products derived from this -#       software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGE. -# -# -# CONTRIBUTORS -#  Nate Nielsen <nielsen@memberwebs.com> -# -#  EXTRA_DIST = BUGS test-files  SUBDIRS = src win32  dist-hook:  	rm -rf `find $(distdir)/ -name CVS` + diff --git a/config.h.in b/config.h.in index 0c4c8b5..36b5094 100644 --- a/config.h.in +++ b/config.h.in @@ -27,6 +27,9 @@  /* Define to 1 if you have the <inttypes.h> header file. */  #undef HAVE_INTTYPES_H +/* Define to 1 if you have the `expat' library (-lexpat). */ +#undef HAVE_LIBEXPAT +  /* Define to 1 if you have the `sablot' library (-lsablot). */  #undef HAVE_LIBSABLOT @@ -42,6 +45,9 @@  /* Define to 1 if you have the <sdom.h> header file. */  #undef HAVE_SDOM_H +/* Define to 1 if you have the `sprintf' function. */ +#undef HAVE_SPRINTF +  /* Define to 1 if you have the <stack> header file. */  #undef HAVE_STACK @@ -72,9 +78,6 @@  /* 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 @@ -87,6 +90,9 @@  /* Define to 1 if you have the <wchar.h> header file. */  #undef HAVE_WCHAR_H +/* Define to 1 if the system has the type `wstring'. */ +#undef HAVE_WSTRING +  /* Name of package */  #undef PACKAGE diff --git a/configure.in b/configure.in index 28636c3..95b4440 100644 --- a/configure.in +++ b/configure.in @@ -1,45 +1,47 @@ -# -# Copyright (c) 2004, Nate Nielsen -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -#     * Redistributions of source code must retain the above -#       copyright notice, this list of conditions and the -#       following disclaimer. -#     * Redistributions in binary form must reproduce the -#       above copyright notice, this list of conditions and -#       the following disclaimer in the documentation and/or -#       other materials provided with the distribution. -#     * The names of contributors to this software may not be -#       used to endorse or promote products derived from this -#       software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGE. -# -# -# CONTRIBUTORS -#  Nate Nielsen <nielsen@memberwebs.com> -# +dnl +dnl Copyright (c) 2004, Nate Nielsen +dnl All rights reserved. +dnl +dnl Redistribution and use in source and binary forms, with or without +dnl modification, are permitted provided that the following conditions +dnl are met: +dnl +dnl     * Redistributions of source code must retain the above +dnl       copyright notice, this list of conditions and the +dnl       following disclaimer. +dnl     * Redistributions in binary form must reproduce the +dnl       above copyright notice, this list of conditions and +dnl       the following disclaimer in the documentation and/or +dnl       other materials provided with the distribution. +dnl     * The names of contributors to this software may not be +dnl       used to endorse or promote products derived from this +dnl       software without specific prior written permission. +dnl +dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +dnl FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +dnl COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +dnl INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +dnl BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +dnl OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +dnl AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +dnl THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +dnl DAMAGE. +dnl +dnl +dnl CONTRIBUTORS +dnl  Nate Nielsen <nielsen@memberwebs.com> +dnl -# Process this file with autoconf to produce a configure script. +dnl Process this file with autoconf to produce a configure script.  AC_INIT(rtfm, 0.9, nielsen@memberwebs.com)  AM_INIT_AUTOMAKE(rtfm, 0.9)  LDFLAGS="$LDFLAGS -L/usr/local/lib" +CPPFLAGS="$CPPFLAGS -I/usr/local/include" +CFLAGS="$CFLAGS -I/usr/local/include"  AC_LANG_CPLUSPLUS @@ -54,6 +56,12 @@ AC_PROG_LN_S  AC_PROG_MAKE_SET  # Check for libraries +AC_CHECK_LIB(c, iconv, [ LIB_ICONV=""; ], +    [ AC_CHECK_LIB(iconv, iconv, [ LIB_ICONV="-liconv"; LIBS="-liconv $LIBS" ], +         [echo "ERROR: Must have iconv routines."; exit 1]) +    ]) +AC_CHECK_LIB(expat, XML_Parse, , +	     [echo "ERROR: Must install sablotron libraries."; exit 1])  AC_CHECK_LIB(sablot, SDOM_createElement, ,  	     [echo "ERROR: Must install sablotron libraries."; exit 1]) @@ -71,9 +79,14 @@ AC_CHECK_HEADERS([sablot.h sdom.h], ,  # Checks for typedefs, structures, and compiler characteristics.  AC_C_CONST  AC_TYPE_SIZE_T +AC_CHECK_TYPES(wstring, , , [ +    #include <wchar.h> +    #include <string> +    using std::wstring; +])  # Required Functions -AC_CHECK_FUNCS([memset strchr strerror swprintf], , +AC_CHECK_FUNCS([memset strchr strerror sprintf], ,  	       [echo "ERROR: Required function missing"; exit 1])  AC_CONFIG_FILES([Makefile src/Makefile win32/Makefile]) diff --git a/src/Makefile.am b/src/Makefile.am index 81120ec..9a7efde 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,47 +1,10 @@ -# -# Copyright (c) 2004, Nate Nielsen -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -#     * Redistributions of source code must retain the above -#       copyright notice, this list of conditions and the -#       following disclaimer. -#     * Redistributions in binary form must reproduce the -#       above copyright notice, this list of conditions and -#       the following disclaimer in the documentation and/or -#       other materials provided with the distribution. -#     * The names of contributors to this software may not be -#       used to endorse or promote products derived from this -#       software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGE. -# -# -# CONTRIBUTORS -#  Nate Nielsen <nielsen@memberwebs.com> -# -#  bin_PROGRAMS = rtfm  rtfm_SOURCES = rtfm.cpp basehandler.cpp basehandler.h levelhandler.cpp levelhandler.h \                reference.h rtfanalyser.cpp rtfanalyser.h rtfparsehelpers.cpp rtfformatting.h \                rtfparsehelpers.h rtfreader.cpp rtfreader.h sablo.h sablotr.cpp usuals.h -rtfm_LDADD = -lsablot +rtfm_LDADD = -lsablot -lexpat $(LIB_ICONV)  rtfm_CFLAGS = -O0 -I${top_srcdir} -I/usr/local/include  rtfm_LDFLAGS = -L/usr/local/lib  man_MANS = rtfm.1 diff --git a/src/rtfparser.h b/src/rtfparser.h index f5983e5..bfa2e59 100644 --- a/src/rtfparser.h +++ b/src/rtfparser.h @@ -39,10 +39,9 @@  #ifndef __RTFREADER_H__  #define __RTFREADER_H__ -#include <string> +#include "usuals.h"  #include <stack> -using std::string; -using std::wstring; +#include <stdio.h>  class RtfReader; diff --git a/src/usuals.h b/src/usuals.h index fcc696d..8a58660 100644 --- a/src/usuals.h +++ b/src/usuals.h @@ -42,7 +42,19 @@  #define NULL 0  #endif +#include "config.h" +  #include <stdlib.h>  #include <assert.h> +#include <wchar.h> +#include <string> +using std::string; + +#if HAVE_WSTRING +using std::wstring; +#else +typedef std::basic_string<wchar_t> wstring; +#endif +  #endif // __USUALS_H__ diff --git a/src/xmlcomposehelpers.h b/src/xmlcomposehelpers.h index 7769d91..b901039 100644 --- a/src/xmlcomposehelpers.h +++ b/src/xmlcomposehelpers.h @@ -39,14 +39,11 @@  #ifndef __RTFPARSEHELPERS_H__  #define __RTFPARSEHELPERS_H__ +#include "usuals.h"  #include "reference.h"  #include "sablo.h"  #include "rtfformatting.h" -#include <string> -using std::wstring; -using std::string; -  class RtfParser;  class Destination : diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index b0643e2..80d45af 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -1044,16 +1044,15 @@ bool RtfParser::isEqualElement(const DOM::Element& el1, const DOM::Element& el2)  wstring RtfParser::formatInt(int num)  { -  wchar_t buff[12]; +  char buff[16]; -	// The Win32 version isn't secure -#ifdef _WIN32 -  swprintf(buff, L"%d", num); -#else -	swprintf(buff, 12, L"%d", num); -#endif +  // Certain OSs don't support swprintf :( +  sprintf(buff, "%d", num); + +  wstring n; +  for(char* s = buff; *s; s++) +    n.append(1, *s); -  wstring n(buff);    return n;  } | 
