Skip to content

Commit

Permalink
clean up headers, boost is really optional to avoid dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlonemeth committed May 2, 2018
1 parent 24b378d commit 908a306
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 36 deletions.
24 changes: 9 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
m4_define([numbertext_version_major],[1])
m4_define([numbertext_version_minor],[0])
m4_define([numbertext_version_micro],[1])
m4_define([numbertext_version],[numbertext_version_major.numbertext_version_minor.numbertext_version_micro])
m4_define([numbertext_version],[numbertext_version_major.numbertext_version_minor.numbertext_version_micro-3])

AC_PREREQ([2.68])

AC_INIT([libnumbertext],[numbertext_version])
AC_CONFIG_MACRO_DIR([m4])
AC_LANG([C])

AM_INIT_AUTOMAKE([1.11 foreign dist-xz dist-bzip2])
AM_MAINTAINER_MODE
Expand All @@ -21,29 +20,24 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL

dnl Checks for headers
AC_HEADER_STDC
AC_CHECK_HEADERS([inttypes.h stdint.h string.h])


dnl Checks for typedefs, structures, and compiler characteristics.
AC_LANG([C++])
CXXFLAGS='-Wall -std=c++11'

AC_CHECK_HEADERS([codecvt regex])

AS_IF([test "x$with_boost" != x], [
AC_DEFINE([BOOST_ALL_NO_LIB], [], [Disable boost autolink.])
BOOST_REQUIRE
BOOST_LOCALE
BOOST_REGEX
])
#AS_IF([test "x$with_boost" != x], [
# AC_DEFINE([BOOST_ALL_NO_LIB], [], [Disable boost autolink.])
# BOOST_REQUIRE
# BOOST_LOCALE
# BOOST_REGEX
#])

AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
[
AS_IF([test "x$with_boost" == x], [
# AS_IF([test "x$with_boost" == x], [
AC_MSG_ERROR([Missing std::codecvt or std::regex support, use GCC 4.9 (or greater) or --with-boost.])
])
# ])
])

dnl Checks for functions
Expand Down
9 changes: 3 additions & 6 deletions src/Numbertext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@

#include <sstream>
#include <fstream>
#include "config.h"

#include "Numbertext.hxx"

#ifdef HAVE_BOOST_REGEX_HPP
#include <boost/locale/encoding_utf.hpp>
#include <boost/regex.hpp>
using namespace boost;
#else
#include <codecvt>
#include <regex>
#include <locale>
using namespace std;
#endif

#include <locale>
#include "Numbertext.hxx"

#define MODULE_DIR ""
#define SOROS_EXT ".sor"

Expand Down
6 changes: 6 additions & 0 deletions src/Soros.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

#include "Soros.hxx"

#ifdef HAVE_BOOST_REGEX_HPP
using namespace boost;
#else
using namespace std;
#endif

#define ITERATION_LIMIT 250
#define SEP L"\uE00A"

Expand Down
13 changes: 9 additions & 4 deletions src/Soros.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include <iterator>
#include <string>

#ifndef _MSC_VER
#include "config.h"
#endif

#ifdef HAVE_BOOST_REGEX_HPP
#include <boost/regex.hpp>
using namespace boost;
#else
#include <regex>
using namespace std;
#endif

class Soros {
Expand All @@ -31,13 +31,18 @@ private:
static void replace(std::wstring& s, const std::wstring& search,
const std::wstring& replace);

std::vector<wregex> patterns;
#ifdef HAVE_BOOST_REGEX_HPP
std::vector<boost::wregex> patterns;
static const boost::wregex func;
#else
std::vector<std::wregex> patterns;
static const std::wregex func;
#endif
std::vector<std::wstring> values;
std::vector<bool> begins;
std::vector<bool> ends;

static const std::wstring m, m2, c, c2, slash, pipe;
static const wregex func;
};

#endif
13 changes: 2 additions & 11 deletions src/spellout.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@
#include "numbertext-version.h"
#include <cstring>

#ifdef _MSC_VER
#define HAVE_CODECVT

#else
#include "config.h"
#endif

#ifdef HAVE_BOOST_REGEX_HPP
#include <boost/regex.hpp>
using namespace boost;
using namespace boost;
#else
#include <regex>
using namespace std;
using namespace std;
#endif

#define LANG "LANG"
Expand Down

0 comments on commit 908a306

Please sign in to comment.