mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
Fix compilation failures with Visual C++ 2012 (issue #375)
This commit is contained in:
parent
66c309557d
commit
148fd1f275
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -30,3 +30,9 @@ version.txt
|
|||
.DS_Store
|
||||
Info.plist
|
||||
GoldenDict.xcodeproj/
|
||||
|
||||
# visual studio files
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.suo
|
||||
*.vcxproj.user
|
||||
|
|
12
about.cc
12
about.cc
|
@ -19,9 +19,19 @@ About::About( QWidget * parent ): QDialog( parent )
|
|||
version = QString::fromLatin1( versionFile.readAll() ).trimmed();
|
||||
|
||||
ui.version->setText( version );
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
QString compilerVersion = QString( "Visual C++ %1.%2.%3" )
|
||||
.arg( GD_CXX_MSVC_MAJOR )
|
||||
.arg( GD_CXX_MSVC_MINOR )
|
||||
.arg( GD_CXX_MSVC_BUILD );
|
||||
#else
|
||||
QString compilerVersion = QLatin1String( "GCC " ) + QLatin1String( __VERSION__ );
|
||||
#endif
|
||||
|
||||
ui.qtVersion->setText( tr( "Based on Qt %1 (%2, %3 bit)" ).arg(
|
||||
QLatin1String( qVersion() ),
|
||||
QLatin1String( "GCC " ) + QLatin1String( __VERSION__ ),
|
||||
compilerVersion,
|
||||
QString::number( QSysInfo::WordSize ) ) );
|
||||
|
||||
QFile creditsFile( ":/CREDITS.txt" );
|
||||
|
|
16
about.hh
16
about.hh
|
@ -4,8 +4,22 @@
|
|||
#ifndef ABOUT_HH
|
||||
#define ABOUT_HH
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_about.h"
|
||||
#include <QDialog>
|
||||
|
||||
// Microsoft Visual C++ version
|
||||
#if defined (_MSC_VER)
|
||||
// how many digits does the build number have?
|
||||
# if _MSC_FULL_VER / 10000 == _MSC_VER
|
||||
# define GD_CXX_MSVC_BUILD (_MSC_FULL_VER % 10000) // four digits
|
||||
# elif _MSC_FULL_VER / 100000 == _MSC_VER
|
||||
# define GD_CXX_MSVC_BUILD (_MSC_FULL_VER % 100000) // five digits
|
||||
# else
|
||||
# define GD_CXX_MSVC_BUILD 0
|
||||
# endif
|
||||
# define GD_CXX_MSVC_MAJOR (_MSC_VER/100-6)
|
||||
# define GD_CXX_MSVC_MINOR (_MSC_VER%100)
|
||||
#endif
|
||||
|
||||
class About: public QDialog
|
||||
{
|
||||
|
|
|
@ -446,13 +446,7 @@ void ArticleRequest::altSearchFinished()
|
|||
|
||||
for( unsigned x = 0; x < altsVector.size(); ++x )
|
||||
{
|
||||
DPRINTF( "Alt: %ls\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( altsVector[ x ] ).toStdWString().c_str()
|
||||
#else
|
||||
altsVector[ x ].c_str()
|
||||
#endif
|
||||
);
|
||||
qDebug() << "Alt:" << gd::toQString( altsVector[ x ] );
|
||||
}
|
||||
|
||||
wstring wordStd = gd::toWString( word );
|
||||
|
|
|
@ -301,6 +301,11 @@ qint64 ArticleResourceReply::bytesAvailable() const
|
|||
|
||||
qint64 ArticleResourceReply::readData( char * out, qint64 maxSize )
|
||||
{
|
||||
// From the doc: "This function might be called with a maxSize of 0,
|
||||
// which can be used to perform post-reading operations".
|
||||
if ( maxSize == 0 )
|
||||
return 0;
|
||||
|
||||
DPRINTF( "====reading %d bytes\n", (int)maxSize );
|
||||
|
||||
bool finished = req->isFinished();
|
||||
|
|
|
@ -125,7 +125,10 @@ Reader::Reader( File::Class & f, uint32_t offset ): file( f )
|
|||
{
|
||||
file.seek( offset );
|
||||
|
||||
offsets.resize( file.read< uint32_t >() );
|
||||
uint32_t size = file.read< uint32_t >();
|
||||
if ( size == 0 )
|
||||
return;
|
||||
offsets.resize( size );
|
||||
file.read( &offsets.front(), offsets.size() * sizeof( uint32_t ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,9 @@ long DataRequest::dataSize()
|
|||
void DataRequest::getDataSlice( size_t offset, size_t size, void * buffer )
|
||||
throw( exSliceOutOfRange )
|
||||
{
|
||||
if ( size == 0 )
|
||||
return;
|
||||
|
||||
Mutex::Lock _( dataMutex );
|
||||
|
||||
if ( offset + size > data.size() || !hasAnyData )
|
||||
|
|
19
dictzip.c
19
dictzip.c
|
@ -460,6 +460,9 @@ dictData *dict_data_open( const char *filename, int computeCRC )
|
|||
|
||||
for(;;)
|
||||
{
|
||||
#ifdef __WIN32
|
||||
wchar_t wname[16384];
|
||||
#endif
|
||||
if (dict_read_header( filename, h, computeCRC )) {
|
||||
break; /*
|
||||
err_fatal( __func__,
|
||||
|
@ -467,7 +470,6 @@ dictData *dict_data_open( const char *filename, int computeCRC )
|
|||
}
|
||||
|
||||
#ifdef __WIN32
|
||||
wchar_t wname[16384];
|
||||
if( MultiByteToWideChar( CP_UTF8, 0, filename, -1, wname, 16384 ) == 0 )
|
||||
break;
|
||||
|
||||
|
@ -543,9 +545,8 @@ char *dict_data_read_ (
|
|||
dictData *h, unsigned long start, unsigned long size,
|
||||
const char *preFilter, const char *postFilter )
|
||||
{
|
||||
(void) preFilter;
|
||||
(void) postFilter;
|
||||
char *buffer, *pt;
|
||||
char * buffer;
|
||||
char * pt;
|
||||
unsigned long end;
|
||||
int count;
|
||||
char *inBuffer;
|
||||
|
@ -554,6 +555,8 @@ char *dict_data_read_ (
|
|||
int firstOffset, lastOffset;
|
||||
int i, j;
|
||||
int found, target, lastStamp;
|
||||
(void) preFilter;
|
||||
(void) postFilter;
|
||||
|
||||
end = start + size;
|
||||
|
||||
|
@ -670,6 +673,10 @@ char *dict_data_read_ (
|
|||
count = h->cache[target].count;
|
||||
inBuffer = h->cache[target].inBuffer;
|
||||
} else {
|
||||
#ifdef __WIN32
|
||||
DWORD pos ;
|
||||
DWORD readed;
|
||||
#endif
|
||||
h->cache[target].chunk = -1;
|
||||
if (!h->cache[target].inBuffer)
|
||||
h->cache[target].inBuffer = xmalloc( h->chunkLength );
|
||||
|
@ -688,8 +695,8 @@ char *dict_data_read_ (
|
|||
}
|
||||
|
||||
#ifdef __WIN32
|
||||
DWORD pos = SetFilePointer( h->fd, h->offsets[ i ], 0, FILE_BEGIN );
|
||||
DWORD readed = 0;
|
||||
pos = SetFilePointer( h->fd, h->offsets[ i ], 0, FILE_BEGIN );
|
||||
readed = 0;
|
||||
if( pos != INVALID_SET_FILE_POINTER || GetLastError() != NO_ERROR )
|
||||
ReadFile( h->fd, outBuffer, h->chunks[ i ], &readed, 0 );
|
||||
if( h->chunks[ i ] != readed )
|
||||
|
|
19
dsl.cc
19
dsl.cc
|
@ -346,7 +346,7 @@ void DslDictionary::doDeferredInit()
|
|||
|
||||
chunks = new ChunkedStorage::Reader( idx, idxHeader.chunksOffset );
|
||||
|
||||
// Open the .dict file
|
||||
// Open the .dsl file
|
||||
|
||||
dz = dict_data_open( getDictionaryFilenames()[ 0 ].c_str(), 0 );
|
||||
|
||||
|
@ -1607,13 +1607,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
// Building the index
|
||||
initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) );
|
||||
|
||||
DPRINTF( "Dictionary name: %ls\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( scanner.getDictionaryName() ).toStdWString().c_str()
|
||||
#else
|
||||
scanner.getDictionaryName().c_str()
|
||||
#endif
|
||||
);
|
||||
qDebug() << "Building the index for dictionary:"
|
||||
<< gd::toQString( scanner.getDictionaryName() );
|
||||
|
||||
File::Class idx( indexFile, "wb" );
|
||||
|
||||
|
@ -1795,13 +1790,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
if ( isDslWs( curString[ 0 ] ) )
|
||||
break; // No more headwords
|
||||
|
||||
DPRINTF( "Alt headword: %ls\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( curString ).toStdWString().c_str()
|
||||
#else
|
||||
curString.c_str()
|
||||
#endif
|
||||
);
|
||||
qDebug() << "Alt headword" << gd::toQString( curString );
|
||||
|
||||
processUnsortedParts( curString, true );
|
||||
expandTildes( curString, allEntryWords.front() );
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "dsl_details.hh"
|
||||
|
||||
#include "folding.hh"
|
||||
#include "langcoder.hh"
|
||||
#include <wctype.h>
|
||||
#include <stdio.h>
|
||||
#include "dprintf.hh"
|
||||
#include "ufile.hh"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "wstring_qt.hh"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <wctype.h>
|
||||
|
||||
namespace Dsl {
|
||||
namespace Details {
|
||||
|
@ -545,13 +544,8 @@ void ArticleDom::closeTag( wstring const & name,
|
|||
else
|
||||
if ( warn )
|
||||
{
|
||||
FDPRINTF( stderr, "Warning: no corresponding opening tag for closing tag \"/%ls\" found.\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( name ).toStdWString().c_str()
|
||||
#else
|
||||
name.c_str()
|
||||
#endif
|
||||
);
|
||||
qWarning() << "Warning: no corresponding opening tag for closing tag" <<
|
||||
gd::toQString( name ) << "found.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,7 +586,7 @@ void ArticleDom::nextChar() throw( eot )
|
|||
|
||||
DslScanner::DslScanner( string const & fileName ) throw( Ex, Iconv::Ex ):
|
||||
encoding( Windows1252 ), iconv( encoding ), readBufferPtr( readBuffer ),
|
||||
readBufferLeft( 0 ), linesRead( 0 )
|
||||
readBufferLeft( 0 ), wcharBuffer( 64 ), linesRead( 0 )
|
||||
{
|
||||
// Since .dz is backwards-compatible with .gz, we use gz- functions to
|
||||
// read it -- they are much nicer than the dict_data- ones.
|
||||
|
|
|
@ -171,12 +171,12 @@ void expandOptionalParts( wstring & str, list< wstring > * result,
|
|||
/// them.
|
||||
void expandTildes( wstring & str, wstring const & tildeReplacement );
|
||||
|
||||
// Unescapes any escaped chars. Be sure to handle all their special meanings
|
||||
// before unescaping them.
|
||||
/// Unescapes any escaped chars. Be sure to handle all their special meanings
|
||||
/// before unescaping them.
|
||||
void unescapeDsl( wstring & str );
|
||||
|
||||
// Normalizes the headword. Currently turns any sequences of consecutive spaces
|
||||
// into a single space.
|
||||
/// Normalizes the headword. Currently turns any sequences of consecutive spaces
|
||||
/// into a single space.
|
||||
void normalizeHeadword( wstring & );
|
||||
|
||||
/// Strip DSL {{...}} comments
|
||||
|
|
4
file.cc
4
file.cc
|
@ -9,7 +9,9 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32
|
||||
#include <windows.h>
|
||||
|
@ -248,7 +250,7 @@ bool Class::eof() throw( exWriteError )
|
|||
if ( writeBuffer )
|
||||
flushWriteBuffer();
|
||||
|
||||
return feof( f );
|
||||
return feof( f ) != 0;
|
||||
}
|
||||
|
||||
FILE * Class::file() throw( exWriteError )
|
||||
|
|
8
forvo.cc
8
forvo.cc
|
@ -153,13 +153,7 @@ ForvoArticleRequest::ForvoArticleRequest( wstring const & str,
|
|||
void ForvoArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
||||
wstring const & str )
|
||||
{
|
||||
DPRINTF( "Requesting article %ls\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( str ).toStdWString().c_str()
|
||||
#else
|
||||
str.c_str()
|
||||
#endif
|
||||
);
|
||||
qDebug() << "Requesting article" << gd::toQString( str );
|
||||
|
||||
QString key;
|
||||
|
||||
|
|
|
@ -495,13 +495,7 @@ QVector< wstring > HunspellHeadwordsRequest::suggest( wstring & word )
|
|||
|
||||
if ( Folding::applySimpleCaseOnly( alt ) != lowercasedWord ) // No point in providing same word
|
||||
{
|
||||
DPRINTF( ">>>>>Alt: %ls\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( alt ).toStdWString().c_str()
|
||||
#else
|
||||
alt.c_str()
|
||||
#endif
|
||||
);
|
||||
qDebug() << ">>>>>Alt:" << gd::toQString( alt );
|
||||
result.append( alt );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
/* This file is (c) 2008-2013 Konstantin Isakov <ikm@goldendict.org>
|
||||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
||||
|
||||
#include "langcoder.hh"
|
||||
#include "folding.hh"
|
||||
#include "wstring_qt.hh"
|
||||
#include "language.hh"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <cctype>
|
||||
#include <QLocale>
|
||||
|
||||
|
|
10
mediawiki.cc
10
mediawiki.cc
|
@ -254,13 +254,7 @@ MediaWikiArticleRequest::MediaWikiArticleRequest( wstring const & str,
|
|||
void MediaWikiArticleRequest::addQuery( QNetworkAccessManager & mgr,
|
||||
wstring const & str )
|
||||
{
|
||||
DPRINTF( "Requesting article %ls\n",
|
||||
#ifdef Q_OS_WIN
|
||||
gd::toQString( str ).toStdWString().c_str()
|
||||
#else
|
||||
str.c_str()
|
||||
#endif
|
||||
);
|
||||
qDebug() << "Requesting article" << gd::toQString( str );
|
||||
|
||||
QUrl reqUrl( url + "/api.php?action=parse&prop=text|revid&format=xml&redirects" );
|
||||
|
||||
|
@ -367,8 +361,6 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
|
||||
QByteArray articleBody = articleString.toUtf8();
|
||||
|
||||
DPRINTF( "Article body after: %s\n", articleBody.data() );
|
||||
|
||||
articleBody.prepend( dictPtr->isToLanguageRTL() ? "<div class=\"mwiki\" dir=\"rtl\">" :
|
||||
"<div class=\"mwiki\">" );
|
||||
articleBody.append( "</div>" );
|
||||
|
|
|
@ -25,16 +25,16 @@ MouseOver & MouseOver::instance()
|
|||
#ifdef Q_OS_WIN32
|
||||
const UINT WM_MY_SHOW_TRANSLATION = WM_USER + 301;
|
||||
static wchar_t className[] = L"GoldenDictMouseover";
|
||||
typedef BOOL WINAPI ( *ChangeWindowMessageFilterFunc )( UINT, DWORD );
|
||||
typedef BOOL ( WINAPI *ChangeWindowMessageFilterFunc )( UINT, DWORD );
|
||||
|
||||
#ifndef CHANGEFILTERSTRUCT
|
||||
#ifndef WINAPI_FAMILY
|
||||
typedef struct tagCHANGEFILTERSTRUCT {
|
||||
DWORD cbSize;
|
||||
DWORD ExtStatus;
|
||||
} CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT;
|
||||
#endif
|
||||
|
||||
typedef BOOL WINAPI ( *ChangeWindowMessageFilterExFunc )( HWND, UINT, DWORD, PCHANGEFILTERSTRUCT );
|
||||
typedef BOOL ( WINAPI *ChangeWindowMessageFilterExFunc )( HWND, UINT, DWORD, PCHANGEFILTERSTRUCT );
|
||||
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
#include "termination.hh"
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef __WIN32
|
||||
|
@ -28,13 +32,24 @@ static void termHandler()
|
|||
char * function = 0;
|
||||
size_t functionLength = 0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
std::type_info * ti = 0;
|
||||
#else
|
||||
std::type_info * ti = __cxxabiv1::__cxa_current_exception_type();
|
||||
#endif
|
||||
|
||||
if ( ti )
|
||||
{
|
||||
char const * name = ti->name();
|
||||
|
||||
#ifdef _MSC_VER
|
||||
char * ret = 0;
|
||||
// avoid 'unused' warnings
|
||||
(void) status;
|
||||
(void) functionLength;
|
||||
#else
|
||||
char * ret = abi::__cxa_demangle( name, function, &functionLength, &status );
|
||||
#endif
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
|
|
1
ufile.cc
1
ufile.cc
|
@ -1,6 +1,7 @@
|
|||
#ifdef __WIN32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
|
5
ufile.hh
5
ufile.hh
|
@ -5,6 +5,11 @@
|
|||
|
||||
#include "zlib.h"
|
||||
|
||||
// eliminate some VC++ warnings
|
||||
#ifdef _MSC_VER
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
4
utf8.cc
4
utf8.cc
|
@ -141,6 +141,10 @@ string encode( wstring const & in ) throw()
|
|||
|
||||
wstring decode( string const & in ) throw( exCantDecode )
|
||||
{
|
||||
|
||||
if ( in.size() == 0 )
|
||||
return wstring();
|
||||
|
||||
std::vector< wchar > buffer( in.size() );
|
||||
|
||||
long result = decode( in.data(), in.size(), &buffer.front() );
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <windows.h>
|
||||
#include <servprov.h>
|
||||
#include <winable.h>
|
||||
#include "wordbyauto.hh"
|
||||
#include "uiauto.hh"
|
||||
|
||||
|
@ -12,7 +11,7 @@ public:
|
|||
GDAutomationClient();
|
||||
~GDAutomationClient();
|
||||
bool getWordAtPoint( POINT pt );
|
||||
WCHAR *getText() { return buffer; };
|
||||
WCHAR *getText() { return buffer; }
|
||||
private:
|
||||
WCHAR buffer[256];
|
||||
IUIAutomation *pGDAutomation;
|
||||
|
|
10
xdxf.cc
10
xdxf.cc
|
@ -25,6 +25,10 @@
|
|||
#include "indexedzip.hh"
|
||||
#include "filetype.hh"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <stub_msvc.h>
|
||||
#endif
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QTextDocument>
|
||||
|
@ -94,7 +98,11 @@ struct IdxHeader
|
|||
// resource index.
|
||||
uint32_t zipIndexRootOffset;
|
||||
uint32_t revisionNumber; // Format revision
|
||||
} __attribute__((packed));
|
||||
}
|
||||
#ifndef _MSC_VER
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
bool indexIsOldOrBad( string const & indexFile )
|
||||
{
|
||||
|
|
18
zipfile.cc
18
zipfile.cc
|
@ -16,7 +16,11 @@ struct EndOfCdirRecord
|
|||
quint16 numDisk, numDiskCd, totalEntriesDisk, totalEntries;
|
||||
quint32 size, offset;
|
||||
quint16 commentLength;
|
||||
} __attribute__((packed));
|
||||
}
|
||||
#ifndef _MSC_VER
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
struct CentralFileHeaderRecord
|
||||
{
|
||||
|
@ -26,7 +30,11 @@ struct CentralFileHeaderRecord
|
|||
quint16 fileNameLength, extraFieldLength, fileCommentLength, diskNumberStart,
|
||||
intFileAttrs;
|
||||
quint32 externalFileAttrs, offsetOfLocalHeader;
|
||||
} __attribute__((packed));
|
||||
}
|
||||
#ifndef _MSC_VER
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
struct LocalFileHeaderRecord
|
||||
{
|
||||
|
@ -34,7 +42,11 @@ struct LocalFileHeaderRecord
|
|||
quint16 verNeeded, gpBits, compressionMethod, fileTime, fileDate;
|
||||
quint32 crc32, compressedSize, uncompressedSize;
|
||||
quint16 fileNameLength, extraFieldLength;
|
||||
} __attribute__((packed));
|
||||
}
|
||||
#ifndef _MSC_VER
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
|
|
Loading…
Reference in a new issue