commit b66a970c9137e83266bc2a7fb000491cdee21528 Author: Daniel Swanson Date: Thu Jul 29 11:24:05 2021 -0500 drop apertium_config.h and use string_view wrapper from lttoolbox diff --git a/apertium/apertium-multiple-translations.cc b/apertium/apertium-multiple-translations.cc index f7a6443..0c602dd 100644 --- a/apertium/apertium-multiple-translations.cc +++ b/apertium/apertium-multiple-translations.cc @@ -16,7 +16,6 @@ */ #include #include -#include #include #include diff --git a/apertium/apertium-postlatex-raw.l b/apertium/apertium-postlatex-raw.l index 05a4094..277d541 100644 --- a/apertium/apertium-postlatex-raw.l +++ b/apertium/apertium-postlatex-raw.l @@ -16,9 +16,6 @@ extern "C" { } #include -#ifndef GENFORMAT -#include "apertium_config.h" -#endif #include using namespace std; diff --git a/apertium/apertium-postlatex.l b/apertium/apertium-postlatex.l index 4bf1457..63be03d 100644 --- a/apertium/apertium-postlatex.l +++ b/apertium/apertium-postlatex.l @@ -19,9 +19,6 @@ extern "C" { } #include -#ifndef GENFORMAT -#include "apertium_config.h" -#endif #include #include #ifdef _WIN32 diff --git a/apertium/apertium-prelatex.l b/apertium/apertium-prelatex.l index 13faec1..b06deb3 100644 --- a/apertium/apertium-prelatex.l +++ b/apertium/apertium-prelatex.l @@ -21,9 +21,6 @@ extern "C" { } #include -#ifndef GENFORMAT -#include "apertium_config.h" -#endif #include #ifdef _WIN32 #include diff --git a/apertium/apertium_config.h.cmake_in b/apertium/apertium_config.h.cmake_in deleted file mode 100644 index 2d14f63..0000000 --- a/apertium/apertium_config.h.cmake_in +++ /dev/null @@ -1,57 +0,0 @@ -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "${PACKAGE_NAME}" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "${PACKAGE_STRING}" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "${PACKAGE_TARNAME}" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "${PACKAGE_VERSION}" - -#define HAVE_DECL_FPUTS_UNLOCKED ${HAVE_DECL_FPUTS_UNLOCKED} -#define HAVE_DECL_FGETC_UNLOCKED ${HAVE_DECL_FGETC_UNLOCKED} -#define HAVE_DECL_FPUTC_UNLOCKED ${HAVE_DECL_FPUTC_UNLOCKED} -#define HAVE_DECL_FWRITE_UNLOCKED ${HAVE_DECL_FWRITE_UNLOCKED} -#define HAVE_DECL_FREAD_UNLOCKED ${HAVE_DECL_FREAD_UNLOCKED} -#define HAVE_DECL_FGETWC_UNLOCKED ${HAVE_DECL_FGETWC_UNLOCKED} -#define HAVE_DECL_FPUTWC_UNLOCKED ${HAVE_DECL_FPUTWC_UNLOCKED} -#define HAVE_DECL_FPUTWS_UNLOCKED ${HAVE_DECL_FPUTWS_UNLOCKED} - -#define HAVE_DECL_FPUTS_NOLOCK ${HAVE_DECL_FPUTS_NOLOCK} -#define HAVE_DECL_FGETC_NOLOCK ${HAVE_DECL_FGETC_NOLOCK} -#define HAVE_DECL_FPUTC_NOLOCK ${HAVE_DECL_FPUTC_NOLOCK} -#define HAVE_DECL_FWRITE_NOLOCK ${HAVE_DECL_FWRITE_NOLOCK} -#define HAVE_DECL_FREAD_NOLOCK ${HAVE_DECL_FREAD_NOLOCK} -#define HAVE_DECL_FGETWC_NOLOCK ${HAVE_DECL_FGETWC_NOLOCK} -#define HAVE_DECL_FPUTWC_NOLOCK ${HAVE_DECL_FPUTWC_NOLOCK} -#define HAVE_DECL_FPUTWS_NOLOCK ${HAVE_DECL_FPUTWS_NOLOCK} - -#if !defined(HAVE_DECL_FPUTS_UNLOCKED) && defined (HAVE_DECL_FPUTS_NOLOCK) -#define fputs_unlocked _fputs_nolock -#endif -#if !defined(HAVE_DECL_FGETC_UNLOCKED) && defined (HAVE_DECL_FGETC_NOLOCK) -#define fgetc_unlocked _fgetc_nolock -#endif -#if !defined(HAVE_DECL_FPUTC_UNLOCKED) && defined (HAVE_DECL_FPUTC_NOLOCK) -#define fputc_unlocked _fputc_nolock -#endif -#if !defined(HAVE_DECL_FWRITE_UNLOCKED) && defined (HAVE_DECL_FWRITE_NOLOCK) -#define fwrite_unlocked _fwrite_nolock -#endif -#if !defined(HAVE_DECL_FREAD_UNLOCKED) && defined (HAVE_DECL_FREAD_NOLOCK) -#define fread_unlocked _fread_nolock -#endif -#if !defined(HAVE_DECL_FPUTWS_UNLOCKED) && defined (HAVE_DECL_FPUTWS_NOLOCK) -#define fputws_unlocked _fputws_nolock -#endif -#if !defined(HAVE_DECL_FGETWC_UNLOCKED) && defined (HAVE_DECL_FGETWC_NOLOCK) -#define fgetwc_unlocked _fgetwc_nolock -#endif -#if !defined(HAVE_DECL_FPUTWC_UNLOCKED) && defined (HAVE_DECL_FPUTWC_NOLOCK) -#define fputwc_unlocked _fputwc_nolock -#endif diff --git a/apertium/apertium_tmxbuild.cc b/apertium/apertium_tmxbuild.cc index a1c475f..81675e5 100644 --- a/apertium/apertium_tmxbuild.cc +++ b/apertium/apertium_tmxbuild.cc @@ -22,10 +22,8 @@ #include #include -#include #include #include -#include "apertium_config.h" #include using namespace std; diff --git a/apertium/deformat.xsl b/apertium/deformat.xsl index 9bf2e28..70e7626 100644 --- a/apertium/deformat.xsl +++ b/apertium/deformat.xsl @@ -162,9 +162,6 @@ extern "C" { #include <lttoolbox/lt_locale.h> #include <lttoolbox/ustring.h> -#ifndef GENFORMAT -#include "apertium_config.h" -#endif #include <utf8.h> #include <apertium/unlocked_cstdio.h> diff --git a/apertium/deserialiser.h b/apertium/deserialiser.h index e0a4136..62b8f26 100644 --- a/apertium/deserialiser.h +++ b/apertium/deserialiser.h @@ -21,7 +21,6 @@ #include "i.h" #include "lemma.h" #include "morpheme.h" -#include "apertium_config.h" #include #include diff --git a/apertium/endian_double_util.cc b/apertium/endian_double_util.cc index 61dc8b8..5da42ea 100644 --- a/apertium/endian_double_util.cc +++ b/apertium/endian_double_util.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include using namespace std; diff --git a/apertium/file_morpho_stream.cc b/apertium/file_morpho_stream.cc index 82d264f..4cb8a76 100644 --- a/apertium/file_morpho_stream.cc +++ b/apertium/file_morpho_stream.cc @@ -22,14 +22,10 @@ #include #include -#include "apertium_config.h" #include FileMorphoStream::FileMorphoStream(const char* ftxt, bool d, TaggerData *t) : - ms() { - foundEOF = false; - debug=d; - td = t; + ms(), debug(d), td(t) { me = td->getPatternList().newMatchExe(); alphabet = td->getPatternList().getAlphabet(); input.open(ftxt); @@ -48,9 +44,6 @@ FileMorphoStream::FileMorphoStream(const char* ftxt, bool d, TaggerData *t) : map &tag_index = td->getTagIndex(); ca_tag_keof = tag_index["TAG_kEOF"_u]; ca_tag_kundef = tag_index["TAG_kUNDEF"_u]; - - end_of_file = false; - null_flush = false; } FileMorphoStream::~FileMorphoStream() diff --git a/apertium/file_morpho_stream.h b/apertium/file_morpho_stream.h index fdf8871..208648d 100644 --- a/apertium/file_morpho_stream.h +++ b/apertium/file_morpho_stream.h @@ -47,7 +47,7 @@ using namespace std; */ class FileMorphoStream : public MorphoStream { private: - bool foundEOF; + bool foundEOF = false; UString last_string_tag; bool debug; InputFile input; @@ -71,8 +71,8 @@ private: Alphabet alphabet; MatchState ms; - bool null_flush; - bool end_of_file; + bool null_flush = false; + bool end_of_file = false; void readRestOfWord(int &ivwords); void lrlmClassify(UString const &str, int &ivwords); diff --git a/apertium/filesystem.h b/apertium/filesystem.h index 822fd7f..f116377 100644 --- a/apertium/filesystem.h +++ b/apertium/filesystem.h @@ -19,8 +19,7 @@ #ifndef APERTIUM_FILESYSTEM_HPP_ #define APERTIUM_FILESYSTEM_HPP_ -#include "apertium_config.h" -#include "string_view.h" +#include #ifdef HAVE_FILESYSTEM #include diff --git a/apertium/getopt_long.c b/apertium/getopt_long.c index a78208c..51c71a3 100644 --- a/apertium/getopt_long.c +++ b/apertium/getopt_long.c @@ -34,8 +34,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "apertium_config.h" #ifndef HAVE_GETOPT_LONG /* We shouldn't be compiling this module in this case, but we clearly diff --git a/apertium/getopt_long.h b/apertium/getopt_long.h index 6fc2842..c5bca0b 100644 --- a/apertium/getopt_long.h +++ b/apertium/getopt_long.h @@ -23,8 +23,6 @@ #ifndef _GETOPT_LONG_H #define _GETOPT_LONG_H 1 -#include "apertium_config.h" - #if HAVE_UNISTD_H /* Declares getopt, if present */ #include diff --git a/apertium/hmm.cc b/apertium/hmm.cc index 3dd9414..e5b7960 100644 --- a/apertium/hmm.cc +++ b/apertium/hmm.cc @@ -22,7 +22,6 @@ */ #include -#include "apertium_config.h" #include #include diff --git a/apertium/lswpost.cc b/apertium/lswpost.cc index d93c9bd..a8cf10f 100644 --- a/apertium/lswpost.cc +++ b/apertium/lswpost.cc @@ -23,7 +23,6 @@ #include #include -#include "apertium_config.h" #include #include diff --git a/apertium/pretransfer.cc b/apertium/pretransfer.cc index 6c8c778..41b5cbd 100644 --- a/apertium/pretransfer.cc +++ b/apertium/pretransfer.cc @@ -1,7 +1,6 @@ #include #include -#include #include #include diff --git a/apertium/reformat.xsl b/apertium/reformat.xsl index f471823..375243b 100644 --- a/apertium/reformat.xsl +++ b/apertium/reformat.xsl @@ -23,9 +23,6 @@ %{ -#ifndef GENFORMAT -#include "apertium_config.h" -#endif #include <apertium/unlocked_cstdio.h> #include <cstdlib> diff --git a/apertium/serialiser.h b/apertium/serialiser.h index 4c586b6..1ca7063 100644 --- a/apertium/serialiser.h +++ b/apertium/serialiser.h @@ -21,7 +21,6 @@ #include "i.h" #include "lemma.h" #include "morpheme.h" -#include "apertium_config.h" #include #include diff --git a/apertium/string_view.h b/apertium/string_view.h deleted file mode 100644 index 0275d40..0000000 --- a/apertium/string_view.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright (C) 2021 Apertium -* -* 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, either version 2 of the License, or -* (at your option) any later version. -* -* 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. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -#pragma once -#ifndef APERTIUM_STRING_VIEW_HPP__ -#define APERTIUM_STRING_VIEW_HPP__ - -#include "apertium_config.h" - -#ifdef HAVE_STRING_VIEW - #include -#else - #include - #include - - namespace std { - using string_view = ::std::experimental::string_view; - template - using basic_string_view = ::std::experimental::basic_string_view; - - inline ::std::string& operator+=(::std::string& str, ::std::string_view sv) { - str.append(sv.begin(), sv.end()); - return str; - } - } -#endif - -#endif diff --git a/apertium/tagger.cc b/apertium/tagger.cc index f068586..e56672f 100644 --- a/apertium/tagger.cc +++ b/apertium/tagger.cc @@ -15,8 +15,6 @@ #include -#include "apertium_config.h" - #include "align.h" #include "exception.h" #include "linebreak.h" diff --git a/apertium/tagger.h b/apertium/tagger.h index cf3017b..bfe918b 100644 --- a/apertium/tagger.h +++ b/apertium/tagger.h @@ -16,8 +16,6 @@ #ifndef TAGGER_H #define TAGGER_H -#include "apertium_config.h" - #include "tagger_flags.h" #include "stream_tagger.h" #include "file_tagger.h" diff --git a/apertium/tagger_word.cc b/apertium/tagger_word.cc index ff44de4..16ec8a6 100644 --- a/apertium/tagger_word.cc +++ b/apertium/tagger_word.cc @@ -16,7 +16,6 @@ */ #include #include -#include "apertium_config.h" #include bool TaggerWord::generate_marks=false; diff --git a/apertium/tmx_builder.cc b/apertium/tmx_builder.cc index c62204d..0dafda5 100644 --- a/apertium/tmx_builder.cc +++ b/apertium/tmx_builder.cc @@ -27,7 +27,6 @@ #include #include #include -#include "apertium_config.h" #include #ifdef _MSC_VER diff --git a/apertium/unigram_tagger.cc b/apertium/unigram_tagger.cc index 8fb543b..228d828 100644 --- a/apertium/unigram_tagger.cc +++ b/apertium/unigram_tagger.cc @@ -15,8 +15,6 @@ #include "unigram_tagger.h" -#include "apertium_config.h" - #include "deserialiser.h" #include "serialiser.h" #include "lexical_unit.h" diff --git a/apertium/wblank-mode.cc b/apertium/wblank-mode.cc index b854a7d..932b6dc 100644 --- a/apertium/wblank-mode.cc +++ b/apertium/wblank-mode.cc @@ -22,7 +22,6 @@ #include #include #include -#include "apertium_config.h" void trim(std::string& str) { while (!str.empty() && isspace(str.back())) { diff --git a/configure.ac b/configure.ac index b6c1d2c..45f2eb5 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,6 @@ m4_define([PKG_VERSION_MINOR], [8]) m4_define([PKG_VERSION_PATCH], [0]) AC_INIT([apertium], [PKG_VERSION_MAJOR.PKG_VERSION_MINOR.PKG_VERSION_PATCH], [apertium-stuff@lists.sourceforge.net], [apertium], [https://wiki.apertium.org/]) -AC_CONFIG_HEADER([apertium/apertium_config.h]) VERSION=$PACKAGE_VERSION VERSION_MAJOR=PKG_VERSION_MAJOR diff --git a/python/setup.py.in b/python/setup.py.in index 6c8a2e6..f73bf6b 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -3,56 +3,25 @@ ''' Setup for SWIG Python bindings for apertium ''' -from os import path from distutils.core import Extension, setup -from distutils.command.build import build - - -class CustomBuild(build): - sub_commands = [ - ('build_ext', build.has_ext_modules), - ('build_py', build.has_pure_modules), - ('build_clib', build.has_c_libraries), - ('build_scripts', build.has_scripts), - ] - - -def get_sources(): - sources = ['apertium_core.i'] - cc_sources = [ - # interchunk.cc postchunk.cc transfer.cc - 'apertium_re.cc', 'interchunk.cc', 'interchunk_word.cc', 'postchunk.cc', 'transfer.cc', - 'transfer_data.cc', 'transfer_instr.cc', 'transfer_mult.cc', 'transfer_token.cc', 'transfer_word.cc', - 'trx_reader.cc', 'xml_reader.cc', - # 'pretransfer.cc' - 'pretransfer.cc', - # tagger.cc - 'a.cc', 'align.cc', 'analysis.cc', 'collection.cc', - 'constant_manager.cc', 'endian_double_util.cc', 'exception_type.cc', 'feature_vec.cc', - 'feature_vec_averager.cc', 'file_morpho_stream.cc', 'file_tagger.cc', 'hmm.cc', 'i.cc', 'lemma.cc', - 'linebreak.cc', 'lswpost.cc', 'morpheme.cc', 'morpho_stream.cc', 'mtx_reader.cc', 'perceptron_spec.cc', - 'perceptron_tagger.cc', 'sentence_stream.cc', 'shell_utils.cc', 'stream.cc', 'stream_tagger.cc', - 'tagger.cc', 'tagger_data.cc', 'tagger_data_hmm.cc', 'tagger_data_lsw.cc', - 'tagger_data_percep_coarse_tags.cc', 'tagger_flags.cc','tagger_utils.cc', 'tagger_word.cc', - 'tsx_reader.cc', 'unigram_tagger.cc'] - rel_path = '@top_srcdir@/apertium' - sources.extend(path.join(rel_path, f) for f in cc_sources) - return sources - -def get_include_dirs(): - # Remove '-I' from Flags, as python add '-I' on its own - dirs = '@APERTIUM_CFLAGS@'.replace('-I', '').split() - return dirs + ['..'] +from sys import platform +compile_args = '@CXXFLAGS@'.split() + '@LTTOOLBOX_CFLAGS@'.split() + '@ICU_CFLAGS@'.split() +link_args = [] +if platform == 'darwin': + compile_args += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] + link_args.append('-mmacosx-version-min=10.7') apertium_core_module = Extension( name='_apertium_core', - sources=get_sources(), - swig_opts=['-c++', '-I..', '-I@top_srcdir@/apertium', '-Wall']+'@APERTIUM_CFLAGS@'.split(), - include_dirs=get_include_dirs(), - library_dirs=['/usr/include/libxml2', '/usr/local/lib'], - extra_compile_args='@CPPFLAGS@'.split()+'@CXXFLAGS@'.split(), - extra_link_args='@LIBS@'.split(), + language = 'c++', + sources = ['apertium_core.i'], + swig_opts=['-c++', '-I..', '-I@top_srcdir@/apertium', '-Wall'], + include_dirs= ['@top_srcdir@', '@top_srcdir@/apertium'], + library_dirs=['@top_srcdir@/apertium/.libs'], + libraries = ['apertium@VERSION_MAJOR@'], + extra_compile_args=compile_args, + extra_link_args=link_args, ) setup( @@ -64,7 +33,7 @@ setup( author_email='@PACKAGE_BUGREPORT@', license='GPL-3.0+', maintainer_email='@PACKAGE_BUGREPORT@', - cmdclass={'build': CustomBuild}, ext_modules=[apertium_core_module], py_modules=['apertium_core'], + data_files=[] )