diff --git a/src/common/utils.cc b/src/common/utils.cc index ca119af0..4a80f155 100644 --- a/src/common/utils.cc +++ b/src/common/utils.cc @@ -4,9 +4,7 @@ #include #include #include -#ifdef _MSC_VER - #include -#endif + #include #include @@ -31,10 +29,9 @@ std::string c_string( const QString & str ) return std::string( str.toUtf8().constData() ); } -bool endsWithIgnoreCase( const string & str1, string str2 ) -{ - return ( str1.size() >= (unsigned)str2.size() ) - && ( strcasecmp( str1.c_str() + ( str1.size() - str2.size() ), str2.data() ) == 0 ); +bool endsWithIgnoreCase( QByteArrayView str, QByteArrayView extension ) +{ + return str.endsWith( extension ); } QString escapeAmps( QString const & str ) diff --git a/src/common/utils.hh b/src/common/utils.hh index 78087314..dfa7301e 100644 --- a/src/common/utils.hh +++ b/src/common/utils.hh @@ -40,7 +40,7 @@ inline QString rstrip( const QString & str ) } std::string c_string( const QString & str ); -bool endsWithIgnoreCase( const string & str1, string str2 ); +bool endsWithIgnoreCase( QByteArrayView str, QByteArrayView extension ); /** * remove punctuation , space, symbol * diff --git a/src/dict/aard.cc b/src/dict/aard.cc index bcf982d2..1e76e27d 100644 --- a/src/dict/aard.cc +++ b/src/dict/aard.cc @@ -16,9 +16,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif #include #include diff --git a/src/dict/bgl.cc b/src/dict/bgl.cc index 3632d9df..4fda7d37 100644 --- a/src/dict/bgl.cc +++ b/src/dict/bgl.cc @@ -22,9 +22,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif #include #include diff --git a/src/dict/dictdfiles.cc b/src/dict/dictdfiles.cc index 8a52fc63..094feca3 100644 --- a/src/dict/dictdfiles.cc +++ b/src/dict/dictdfiles.cc @@ -23,10 +23,6 @@ #include -#ifdef _MSC_VER - #include -#endif - namespace DictdFiles { using std::map; diff --git a/src/dict/dsl.cc b/src/dict/dsl.cc index 3eedafa7..3dff84e7 100644 --- a/src/dict/dsl.cc +++ b/src/dict/dsl.cc @@ -27,10 +27,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif - #include #include #include @@ -1740,12 +1736,16 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f // Make sure it's not an abbreviation file int extSize = ( uncompressedDsl ? 4 : 7 ); - if ( fileName.size() - extSize >= 5 - && strncasecmp( fileName.c_str() + fileName.size() - extSize - 5, "_abrv", 5 ) == 0 ) { - // It is, skip it - continue; + + if ( fileName.size() - extSize >= 5){ + auto fileName_without_extension = QByteArrayView( fileName ).chopped(extSize); + if ( fileName_without_extension.endsWith( "_abrv" ) ) { + // It is, skip it + continue; + } } + unsigned atLine = 0; // Indicates current line in .dsl, for debug purposes try { diff --git a/src/dict/epwing_book.hh b/src/dict/epwing_book.hh index 25655455..41ea1af5 100644 --- a/src/dict/epwing_book.hh +++ b/src/dict/epwing_book.hh @@ -1,5 +1,8 @@ #pragma once + + + #include "dict/dictionary.hh" #include "ex.hh" @@ -18,8 +21,12 @@ #include #include -#ifdef _MSC_VER - #include +// POSIX symbol unavailable on Windows needed for eb headers +#ifdef Q_OS_WIN + #ifndef _SSIZE_T + #define _SSIZE_T + #define ssize_t long + #endif #endif #include diff --git a/src/dict/gls.cc b/src/dict/gls.cc index 3bf734b1..9be2fea0 100644 --- a/src/dict/gls.cc +++ b/src/dict/gls.cc @@ -39,9 +39,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif namespace Gls { diff --git a/src/dict/lsa.cc b/src/dict/lsa.cc index 18e13c66..94f3416b 100644 --- a/src/dict/lsa.cc +++ b/src/dict/lsa.cc @@ -14,10 +14,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif - #define OV_EXCLUDE_STATIC_CALLBACKS #include #include diff --git a/src/dict/mdx.cc b/src/dict/mdx.cc index c849f7ae..e81aab94 100644 --- a/src/dict/mdx.cc +++ b/src/dict/mdx.cc @@ -23,9 +23,6 @@ #include #include #include -#ifdef _MSC_VER - #include -#endif #include "globalregex.hh" #include "tiff.hh" diff --git a/src/dict/sdict.cc b/src/dict/sdict.cc index 837c85ae..5b9bd669 100644 --- a/src/dict/sdict.cc +++ b/src/dict/sdict.cc @@ -19,13 +19,8 @@ #include #include -#include "utils.hh" -#ifdef _MSC_VER - #include -#endif - namespace Sdict { using std::map; diff --git a/src/dict/slob.cc b/src/dict/slob.cc index e88b1331..0a530131 100644 --- a/src/dict/slob.cc +++ b/src/dict/slob.cc @@ -17,10 +17,6 @@ #include "tiff.hh" #include "utils.hh" -#ifdef _MSC_VER - #include -#endif - #include "iconv.hh" #include diff --git a/src/dict/stardict.cc b/src/dict/stardict.cc index c50a1491..e04b3d35 100644 --- a/src/dict/stardict.cc +++ b/src/dict/stardict.cc @@ -30,9 +30,6 @@ #endif #include -#ifdef _MSC_VER - #include -#endif #include #include diff --git a/src/dict/xdxf.cc b/src/dict/xdxf.cc index a5f20ff7..b68f25e3 100644 --- a/src/dict/xdxf.cc +++ b/src/dict/xdxf.cc @@ -27,9 +27,6 @@ #include "tiff.hh" #include "ftshelpers.hh" -#ifdef _MSC_VER - #include -#endif #include #include diff --git a/src/dict/zim.cc b/src/dict/zim.cc index d91bee11..01d7da1b 100644 --- a/src/dict/zim.cc +++ b/src/dict/zim.cc @@ -17,10 +17,6 @@ #include "ftshelpers.hh" #include "htmlescape.hh" - #ifdef _MSC_VER - #include - #endif - #include #include #include diff --git a/src/dict/zipsounds.cc b/src/dict/zipsounds.cc index 274ea38e..9a5085c2 100644 --- a/src/dict/zipsounds.cc +++ b/src/dict/zipsounds.cc @@ -19,9 +19,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif #include "utils.hh" diff --git a/src/langcoder.cc b/src/langcoder.cc index dea04b73..fb070d76 100644 --- a/src/langcoder.cc +++ b/src/langcoder.cc @@ -9,9 +9,7 @@ #include #include -#ifdef _MSC_VER - #include -#endif + // Language codes QMap< QString, GDLangCode > LangCoder::LANG_CODE_MAP = { @@ -231,10 +229,11 @@ QString LangCoder::intToCode2( quint32 val ) quint32 LangCoder::findIdForLanguage( gd::wstring const & lang ) { - const auto langFolded = Utf8::encode( lang ); + const auto langFolded = QByteArrayView( Utf8::encode( lang ) ); for ( auto const & lc : LANG_CODE_MAP ) { - if ( strcasecmp( langFolded.c_str(), lc.lang.c_str() ) == 0 ) { + if ( langFolded.compare( lc.lang, Qt::CaseInsensitive ) ) + { return code2toInt( lc.code2.toStdString().c_str() ); } } diff --git a/src/windows/stub_msvc.h b/src/windows/stub_msvc.h deleted file mode 100644 index b3a7ebd7..00000000 --- a/src/windows/stub_msvc.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#ifdef _MSC_VER -#if !defined(strcasecmp) -# define strcasecmp _strcmpi -#endif -#if !defined(strncasecmp) -# define strncasecmp _strnicmp -#endif - -#ifndef _SSIZE_T -#define _SSIZE_T -#define ssize_t long -#endif -#endif -