From 010f5aa422c13b9f3d9a1f33926edf594dbfe339 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 12 Apr 2009 12:45:12 +0000 Subject: [PATCH] Possibly less than ideal, but gets ape_reader building on both gcc2 and 4. (The previous gcc4 fixes broke it again on gcc2). I'm uncertain as to why the include order of seems to matter though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30138 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../ape_reader/MAClib/APEDecompress.cpp | 20 +++++++++++-------- .../plugins/ape_reader/MAClib/APEDecompress.h | 2 -- .../plugins/ape_reader/MAClib/APESimple.cpp | 12 +++++++---- .../plugins/ape_reader/MAClib/APETag.cpp | 12 +++++++---- .../plugins/ape_reader/MAClib/UnBitArray.cpp | 11 +++++++--- 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.cpp b/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.cpp index f6f4731e25..3aeb27ebc5 100644 --- a/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.cpp +++ b/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.cpp @@ -1,8 +1,7 @@ -#include "All.h" -#include "APEDecompress.h" - #include +#include "All.h" +#include "APEDecompress.h" #include "APEInfo.h" #include "Prepare.h" #include "UnBitArray.h" @@ -10,6 +9,11 @@ #define DECODE_BLOCK_SIZE 4096 +#if __GNUC__ != 2 +using std::min; +using std::max; +#endif + CAPEDecompress::CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStartBlock, int nFinishBlock) { *pErrorCode = ERROR_SUCCESS; @@ -38,10 +42,10 @@ CAPEDecompress::CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStart // set the "real" start and finish blocks m_nStartBlock = (nStartBlock < 0) - ? 0 : std::min(nStartBlock, GetInfo(APE_INFO_TOTAL_BLOCKS)); + ? 0 : min(nStartBlock, GetInfo(APE_INFO_TOTAL_BLOCKS)); m_nFinishBlock = (nFinishBlock < 0) ? GetInfo(APE_INFO_TOTAL_BLOCKS) - : std::min(nFinishBlock, GetInfo(APE_INFO_TOTAL_BLOCKS)); + : min(nFinishBlock, GetInfo(APE_INFO_TOTAL_BLOCKS)); m_bIsRanged = (m_nStartBlock != 0) || (m_nFinishBlock != GetInfo(APE_INFO_TOTAL_BLOCKS)); } @@ -90,7 +94,7 @@ int CAPEDecompress::GetData(char * pBuffer, int nBlocks, int * pBlocksRetrieved) // cap int nBlocksUntilFinish = m_nFinishBlock - m_nCurrentBlock; - const int nBlocksToRetrieve = std::min(nBlocks, nBlocksUntilFinish); + const int nBlocksToRetrieve = min(nBlocks, nBlocksUntilFinish); // get the data unsigned char * pOutputBuffer = (unsigned char *) pBuffer; @@ -104,7 +108,7 @@ int CAPEDecompress::GetData(char * pBuffer, int nBlocks, int * pBlocksRetrieved) // analyze how much to remove from the buffer const int nFrameBufferBlocks = m_nFrameBufferFinishedBlocks; - nBlocksThisPass = std::min(nBlocksLeft, nFrameBufferBlocks); + nBlocksThisPass = min(nBlocksLeft, nFrameBufferBlocks); // remove as much as possible if (nBlocksThisPass > 0) @@ -187,7 +191,7 @@ int CAPEDecompress::FillFrameBuffer() int nFrameOffsetBlocks = m_nCurrentFrameBufferBlock % GetInfo(APE_INFO_BLOCKS_PER_FRAME); int nFrameBlocksLeft = nFrameBlocks - nFrameOffsetBlocks; - int nBlocksThisPass = std::min(nFrameBlocksLeft, nBlocksLeft); + int nBlocksThisPass = min(nFrameBlocksLeft, nBlocksLeft); // start the frame if we need to if (nFrameOffsetBlocks == 0) diff --git a/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.h b/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.h index 1a7f7344b9..fa66a0aca8 100644 --- a/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.h +++ b/src/add-ons/media/plugins/ape_reader/MAClib/APEDecompress.h @@ -1,8 +1,6 @@ #ifndef APE_APEDECOMPRESS_H #define APE_APEDECOMPRESS_H -#include "APEDecompress.h" - class CUnBitArray; class CPrepare; class CAPEInfo; diff --git a/src/add-ons/media/plugins/ape_reader/MAClib/APESimple.cpp b/src/add-ons/media/plugins/ape_reader/MAClib/APESimple.cpp index 16074fccec..5dd590bd9d 100644 --- a/src/add-ons/media/plugins/ape_reader/MAClib/APESimple.cpp +++ b/src/add-ons/media/plugins/ape_reader/MAClib/APESimple.cpp @@ -1,3 +1,5 @@ +#include + #include "All.h" #include "APEInfo.h" #include "APECompress.h" @@ -9,15 +11,17 @@ #include "MD5.h" #include "CharacterHelper.h" -#include - - #define UNMAC_DECODER_OUTPUT_NONE 0 #define UNMAC_DECODER_OUTPUT_WAV 1 #define UNMAC_DECODER_OUTPUT_APE 2 #define BLOCKS_PER_DECODE 9216 +#if __GNUC__ != 2 +using std::min; +using std::max; +#endif + int DecompressCore(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nOutputMode, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag); /***************************************************************************************** @@ -207,7 +211,7 @@ int __stdcall VerifyFileW(const str_utf16 * pInputFilename, int * pPercentageDon nBytesRead = 1; while ((nBytesLeft > 0) && (nBytesRead > 0)) { - int nBytesToRead = std::min(16384, nBytesLeft); + int nBytesToRead = min(16384, nBytesLeft); if (pIO->Read(spBuffer, nBytesToRead, &nBytesRead) != ERROR_SUCCESS) throw(ERROR_IO_READ); diff --git a/src/add-ons/media/plugins/ape_reader/MAClib/APETag.cpp b/src/add-ons/media/plugins/ape_reader/MAClib/APETag.cpp index 0fb185998a..3777ba89f9 100644 --- a/src/add-ons/media/plugins/ape_reader/MAClib/APETag.cpp +++ b/src/add-ons/media/plugins/ape_reader/MAClib/APETag.cpp @@ -1,13 +1,17 @@ -#include "All.h" -#include "APETag.h" - #include +#include "All.h" +#include "APETag.h" #include "ID3Genres.h" #include "CharacterHelper.h" #include "IO.h" #include IO_HEADER_FILE +#if __GNUC__ != 2 +using std::min; +using std::max; +#endif + /***************************************************************************************** CAPETagField *****************************************************************************************/ @@ -19,7 +23,7 @@ CAPETagField::CAPETagField(const str_utf16 * pFieldName, const void * pFieldValu memcpy(m_spFieldNameUTF16, pFieldName, (wcslen(pFieldName) + 1) * sizeof(str_utf16)); // data (we'll always allocate two extra bytes and memset to 0 so we're safely NULL terminated) - m_nFieldValueBytes = std::max(nFieldBytes, 0); + m_nFieldValueBytes = max(nFieldBytes, 0); m_spFieldValue.Assign(new char [m_nFieldValueBytes + 2], TRUE); memset(m_spFieldValue, 0, m_nFieldValueBytes + 2); if (m_nFieldValueBytes > 0) diff --git a/src/add-ons/media/plugins/ape_reader/MAClib/UnBitArray.cpp b/src/add-ons/media/plugins/ape_reader/MAClib/UnBitArray.cpp index ceb43a9c28..41d9aa62d0 100644 --- a/src/add-ons/media/plugins/ape_reader/MAClib/UnBitArray.cpp +++ b/src/add-ons/media/plugins/ape_reader/MAClib/UnBitArray.cpp @@ -1,10 +1,10 @@ +#include + #include "All.h" #include "APEInfo.h" #include "UnBitArray.h" #include "BitArray.h" -#include - const uint32 POWERS_OF_TWO_MINUS_ONE_REVERSED[33] = {4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0}; @@ -27,6 +27,11 @@ const uint32 RANGE_WIDTH_2[64] = {19578,16582,12257,7906,4576,2366,1170,536,261, #define MODEL_ELEMENTS 64 +#if __GNUC__ != 2 +using std::min; +using std::max; +#endif + /*********************************************************************************** Construction ***********************************************************************************/ @@ -111,7 +116,7 @@ int CUnBitArray::DecodeValueRange(UNBIT_ARRAY_STATE & BitArrayState) if (m_nVersion >= 3990) { // figure the pivot value - int nPivotValue = std::max(BitArrayState.nKSum / 32, 1UL); + int nPivotValue = max(BitArrayState.nKSum / 32, 1UL); // get the overflow int nOverflow = 0;