From: <man...@us...> - 2015-02-21 21:34:45
|
Revision: 4785 http://sourceforge.net/p/modplug/code/4785 Author: manxorist Date: 2015-02-21 21:34:40 +0000 (Sat, 21 Feb 2015) Log Message: ----------- [Fix] Unarchiver: Doh, and now fix unzip for 32bit again. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/unarchiver/unzip.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-02-21 19:00:26 UTC (rev 4784) +++ trunk/OpenMPT/common/misc_util.h 2015-02-21 21:34:40 UTC (rev 4785) @@ -268,6 +268,20 @@ } // namespace mpt +namespace Util +{ + +// Returns true iff Tdst can represent the value val. +// Use as if(Util::TypeCanHold<uin8>(-1)). +template <typename Tdst, typename Tsrc> +inline bool TypeCanHoldValue(Tsrc val) +{ + return (static_cast<Tsrc>(mpt::saturate_cast<Tdst>(val)) == val); +} + +} //namespace Util + + // Limits 'val' to given range. If 'val' is less than 'lowerLimit', 'val' is set to value 'lowerLimit'. // Similarly if 'val' is greater than 'upperLimit', 'val' is set to value 'upperLimit'. // If 'lowerLimit' > 'upperLimit', 'val' won't be modified. Modified: trunk/OpenMPT/unarchiver/unzip.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unzip.cpp 2015-02-21 19:00:26 UTC (rev 4784) +++ trunk/OpenMPT/unarchiver/unzip.cpp 2015-02-21 21:34:40 UTC (rev 4785) @@ -65,7 +65,7 @@ static long ZCALLBACK fseek64_mem(voidpf opaque, voidpf, ZPOS64_T offset, int origin) { FileReader &file = *static_cast<FileReader *>(opaque); - FileReader::off_t destination = 0; + ZPOS64_T destination = 0; switch(origin) { case ZLIB_FILEFUNC_SEEK_CUR: @@ -80,7 +80,11 @@ default: return -1; } - return (file.Seek(destination) ? 0 : 1); + if(!Util::TypeCanHoldValue<FileReader::off_t>(destination)) + { + return 1; + } + return (file.Seek(static_cast<FileReader::off_t>(destination)) ? 0 : 1); } static int ZCALLBACK fclose_mem(voidpf, voidpf) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |