From 8f6ef372bef30cdfa63799d6ecfa8a71468df7a0 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Wed, 20 Nov 2024 04:36:02 -0500 Subject: [PATCH] clean: delete stub_msvc.h --- src/common/utils.cc | 8 ++------ src/common/utils.hh | 2 +- src/dict/aard.cc | 3 --- src/dict/bgl.cc | 3 --- src/dict/dictdfiles.cc | 4 ---- src/dict/dsl.cc | 6 +----- src/dict/epwing_book.hh | 8 ++++++-- src/dict/gls.cc | 3 --- src/dict/lsa.cc | 4 ---- src/dict/mdx.cc | 3 --- src/dict/sdict.cc | 6 ------ src/dict/slob.cc | 4 ---- src/dict/stardict.cc | 3 --- src/dict/xdxf.cc | 3 --- src/dict/zim.cc | 4 ---- src/dict/zipsounds.cc | 3 --- src/langcoder.cc | 7 ++----- src/windows/stub_msvc.h | 17 ----------------- 18 files changed, 12 insertions(+), 79 deletions(-) delete mode 100644 src/windows/stub_msvc.h diff --git a/src/common/utils.cc b/src/common/utils.cc index ca119af0..c052c17a 100644 --- a/src/common/utils.cc +++ b/src/common/utils.cc @@ -4,9 +4,6 @@ #include #include #include -#ifdef _MSC_VER - #include -#endif #include #include @@ -31,10 +28,9 @@ std::string c_string( const QString & str ) return std::string( str.toUtf8().constData() ); } -bool endsWithIgnoreCase( const string & str1, string str2 ) +bool endsWithIgnoreCase( QByteArrayView str, QByteArrayView extension ) { - return ( str1.size() >= (unsigned)str2.size() ) - && ( strcasecmp( str1.c_str() + ( str1.size() - str2.size() ), str2.data() ) == 0 ); + return ( str.size() >= extension.size() ) && str.last( extension.size() ).compare( extension, Qt::CaseInsensitive ); } 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..d02c3614 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 @@ -1741,7 +1737,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f int extSize = ( uncompressedDsl ? 4 : 7 ); if ( fileName.size() - extSize >= 5 - && strncasecmp( fileName.c_str() + fileName.size() - extSize - 5, "_abrv", 5 ) == 0 ) { + && qstrnicmp( fileName.c_str() + fileName.size() - extSize - 5, "_abrv", 5 ) == 0 ) { // It is, skip it continue; } diff --git a/src/dict/epwing_book.hh b/src/dict/epwing_book.hh index 25655455..9a02413d 100644 --- a/src/dict/epwing_book.hh +++ b/src/dict/epwing_book.hh @@ -18,8 +18,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..389c17ec 100644 --- a/src/dict/sdict.cc +++ b/src/dict/sdict.cc @@ -19,12 +19,6 @@ #include #include -#include "utils.hh" - - -#ifdef _MSC_VER - #include -#endif namespace Sdict { 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..5f2029c3 100644 --- a/src/langcoder.cc +++ b/src/langcoder.cc @@ -9,9 +9,6 @@ #include #include -#ifdef _MSC_VER - #include -#endif // Language codes QMap< QString, GDLangCode > LangCoder::LANG_CODE_MAP = { @@ -231,10 +228,10 @@ 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 -