From dc969f30d5321f249eef7929d020e4543f8d8a81 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sat, 28 Nov 2015 15:14:53 +0100 Subject: [PATCH 1/2] Issue #311 - small changes for MinGW32 build --- include/tidyplatform.h | 2 +- src/mappedio.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/tidyplatform.h b/include/tidyplatform.h index a40e0a0..ea999c5 100644 --- a/include/tidyplatform.h +++ b/include/tidyplatform.h @@ -469,7 +469,7 @@ extern "C" { */ #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__) -#ifndef __WATCOMC__ +#if !(defined(__WATCOMC__) || defined(__MINGW32__)) #define fileno _fileno #define setmode _setmode #endif diff --git a/src/mappedio.c b/src/mappedio.c index 61cf748..f80c978 100644 --- a/src/mappedio.c +++ b/src/mappedio.c @@ -191,7 +191,21 @@ static int initMappedFileSource( TidyAllocator *allocator, TidyInputSource* inp, fin = (MappedFileSource*) TidyAlloc( allocator, sizeof(MappedFileSource) ); if ( !fin ) return -1; - + +#if defined(__MINGW32__) + { + DWORD lowVal, highVal; + lowVal = GetFileSize(fp, &highVal); + if ((lowVal == INVALID_FILE_SIZE) && (GetLastError() != NO_ERROR)) + { + TidyFree(allocator, fin); + return -1; + } + fin->size = highVal; + fin->size = (fin->size << 32); + fin->size += lowVal; + } +#else /* NOT a MinGW build */ #if defined(_MSC_VER) && (_MSC_VER < 1300) /* less than msvc++ 7.0 */ { LARGE_INTEGER* pli = (LARGE_INTEGER *)&fin->size; @@ -210,6 +224,7 @@ static int initMappedFileSource( TidyAllocator *allocator, TidyInputSource* inp, return -1; } #endif +#endif /* MinGW y/n */ fin->map = CreateFileMapping( fp, NULL, PAGE_READONLY, 0, 0, NULL ); From 77e053d582e5ea6cba64fe959f70e4c0ab3d612c Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sat, 28 Nov 2015 15:25:24 +0100 Subject: [PATCH 2/2] Issue #311 - Add MinGW to the version --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb22e03..873d3a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,9 @@ add_definitions ( -DSUPPORT_ASIAN_ENCODINGS=1 ) add_definitions ( -DSUPPORT_ACCESSIBILITY_CHECKS=1 ) add_definitions ( -DLIBTIDY_VERSION="${LIBTIDY_VERSION}" ) add_definitions ( -DRELEASE_DATE="${tidy_YEAR}/${tidy_MONTH}/${tidy_DAY}" ) -### add_definitions ( -DRC_NUMBER="EXP3" ) +if (MINGW) +add_definitions ( -DRC_NUMBER="MinGW" ) +endif () # Issue #188 - Support user items in platform.h if (TIDY_CONFIG_FILE)