From 5c2430e6896de2139bf8e5e467dd3a6ba527f46a Mon Sep 17 00:00:00 2001 From: Stef Date: Wed, 31 Mar 2004 22:25:56 +0000 Subject: Changes for FreeBSD compatibility --- src/Makefile.am | 39 +-------------------------------------- src/rtfparser.h | 5 ++--- src/usuals.h | 12 ++++++++++++ src/xmlcomposehelpers.h | 5 +---- src/xmlcomposer.cpp | 15 +++++++-------- 5 files changed, 23 insertions(+), 53 deletions(-) (limited to 'src') 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 -# -# 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 +#include "usuals.h" #include -using std::string; -using std::wstring; +#include 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 #include +#include +#include +using std::string; + +#if HAVE_WSTRING +using std::wstring; +#else +typedef std::basic_string 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 -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; } -- cgit v1.2.3