From d8a29a35c7912d2b0fb0aa32d9b58a82acd91d86 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 16 Jul 2014 22:03:27 +0900 Subject: [PATCH] Fixed FTBFS on Jessie caused by new version of libsword-dev. --- src/Makefile.am | 4 +-- src/plainhtml.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++++++ src/plainhtml.h | 38 ++++++++++++++++++++ 3 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 src/plainhtml.cpp create mode 100644 src/plainhtml.h diff --git a/src/Makefile.am b/src/Makefile.am index 6a1baf9..2906721 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ CXXFLAGS += $(USE_EXCEPTIONS) kde_module_LTLIBRARIES = tdeio_sword.la tdeio_sword_la_SOURCES = tdeio_sword.cpp renderer.cpp ks_osishtml.cpp ks_gbfhtml.cpp \ - ks_thmlhtml.cpp utils.cpp swordutils.cpp swordoptions.cpp filter.cpp template.cpp + ks_thmlhtml.cpp utils.cpp swordutils.cpp swordoptions.cpp filter.cpp template.cpp plainhtml.cpp tdeio_sword_la_LIBADD = $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEIO) $(LIB_SWORD) @@ -20,4 +20,4 @@ messages: rc.cpp $(XGETTEXT) *.cpp -o $(podir)/tdeio_sword.pot noinst_HEADERS = tdeio_sword.h renderer.h swordoptions.h ks_osishtml.h \ - ks_gbfhtml.h ks_thmlhtml.h utils.h swordutils.h option.h filter.h template.h + ks_gbfhtml.h ks_thmlhtml.h utils.h swordutils.h option.h filter.h template.h plainhtml.h diff --git a/src/plainhtml.cpp b/src/plainhtml.cpp new file mode 100644 index 0000000..3f989fa --- /dev/null +++ b/src/plainhtml.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * plainhtml.cpp - description + * ------------------- + * begin : Thu Jun 24 1999 + * copyright : (C) 1999 by Torsten Uhlmann + * email : TUhlmann@gmx.de + * + * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org) + * CrossWire Bible Society + * P. O. Box 2528 + * Tempe, AZ 85280-2528 + * + * 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 the + * Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#include +#include + +SWORD_NAMESPACE_START + +PLAINHTML::PLAINHTML() +{ +} + + +char PLAINHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module) +{ + int count = 0; + + SWBuf orig = text; + const char *from = orig.c_str(); + for (text = ""; *from; from++) + { + if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph + { + text += "

"; + from++; + continue; + } else { + if ((*from == '\n')) // && (from[1] != '\n')) // only one new line + { + text += "
"; + continue; + } + } + + if (*from == '{') { //footnote start + text += " ("; + continue; + } + else if (*from == '}') //footnote end + { + text += ") "; + continue; + } + else if (*from == '<') { + text += "<"; + continue; + } + else if (*from == '>') { + text += ">"; + continue; + } + else if (*from == '&') { + text += "&"; + continue; + } + else if ((*from == ' ') && (count > 5000)) + { + text += ""; + count = 0; + continue; + } + + text += *from; + count++; + } + return 0; +} + +SWORD_NAMESPACE_END diff --git a/src/plainhtml.h b/src/plainhtml.h new file mode 100644 index 0000000..e09821a --- /dev/null +++ b/src/plainhtml.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * + * $Id: plainhtml.h 1688 2005-01-01 04:42:26Z scribe $ + * + * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) + * CrossWire Bible Society + * P. O. Box 2528 + * Tempe, AZ 85280-2528 + * + * 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 the + * Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#ifndef PLAINHTML_H +#define PLAINHTML_H + +#include + +SWORD_NAMESPACE_START + +/** this filter converts plain text to HTML text + * @author Torsten Uhlmann, begin : Tue Jun 15 15:34:26 CEST 1999 + */ +class SWDLLEXPORT PLAINHTML : public SWFilter { +public: + PLAINHTML(); + virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0); +}; + +SWORD_NAMESPACE_END +#endif