mac: fix build #10780

min and max macros conflict with C++ functions, so rename them to _min
and _max.
This commit is contained in:
Peter Bui 2018-01-13 17:07:32 -05:00 committed by Leаh Neukirchen
parent 7561ffc040
commit 59e6aa9bf8
2 changed files with 181 additions and 1 deletions

View File

@ -0,0 +1,180 @@
--- ./src/Shared/NoWindows.h
+++ ./src/Shared/NoWindows.h
@@ -39,8 +39,8 @@
typedef const wchar_t * LPCWSTR;
#define ZeroMemory(POINTER, BYTES) memset(POINTER, 0, BYTES);
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define _max(a,b) (((a) > (b)) ? (a) : (b))
+#define _min(a,b) (((a) < (b)) ? (a) : (b))
#define __stdcall
#define CALLBACK
--- ./src/Shared/CircleBuffer.cpp
+++ ./src/Shared/CircleBuffer.cpp
@@ -45,7 +46,7 @@
if (pBuffer != NULL && nBytes > 0)
{
- int nHeadBytes = min(m_nEndCap - m_nHead, nBytes);
+ int nHeadBytes = _min(m_nEndCap - m_nHead, nBytes);
int nFrontBytes = nBytes - nHeadBytes;
memcpy(&pBuffer[0], &m_pBuffer[m_nHead], nHeadBytes);
@@ -72,7 +73,7 @@
int CCircleBuffer::RemoveHead(int nBytes)
{
- nBytes = min(MaxGet(), nBytes);
+ nBytes = _min(MaxGet(), nBytes);
m_nHead += nBytes;
if (m_nHead >= m_nEndCap)
m_nHead -= m_nEndCap;
@@ -81,7 +82,7 @@
int CCircleBuffer::RemoveTail(int nBytes)
{
- nBytes = min(MaxGet(), nBytes);
+ nBytes = _min(MaxGet(), nBytes);
m_nTail -= nBytes;
if (m_nTail < 0)
m_nTail += m_nEndCap;
--- ./src/MACLib/APESimple.cpp
+++ ./src/MACLib/APESimple.cpp
@@ -193,7 +194,7 @@
nBytesRead = 1;
while ((nBytesLeft > 0) && (nBytesRead > 0))
{
- int nBytesToRead = min(16384, nBytesLeft);
+ int nBytesToRead = _min(16384, nBytesLeft);
if (pIO->Read(spBuffer, nBytesToRead, &nBytesRead) != ERROR_SUCCESS)
return ERROR_IO_READ;
--- ./src/MACLib/APEDecompress.cpp
+++ ./src/MACLib/APEDecompress.cpp
@@ -35,8 +36,8 @@
m_bErrorDecodingCurrentFrame = FALSE;
// set the "real" start and finish blocks
- m_nStartBlock = (nStartBlock < 0) ? 0 : min(nStartBlock, GetInfo(APE_INFO_TOTAL_BLOCKS));
- m_nFinishBlock = (nFinishBlock < 0) ? GetInfo(APE_INFO_TOTAL_BLOCKS) : min(nFinishBlock, GetInfo(APE_INFO_TOTAL_BLOCKS));
+ m_nStartBlock = (nStartBlock < 0) ? 0 : _min(nStartBlock, GetInfo(APE_INFO_TOTAL_BLOCKS));
+ m_nFinishBlock = (nFinishBlock < 0) ? GetInfo(APE_INFO_TOTAL_BLOCKS) : _min(nFinishBlock, GetInfo(APE_INFO_TOTAL_BLOCKS));
m_bIsRanged = (m_nStartBlock != 0) || (m_nFinishBlock != GetInfo(APE_INFO_TOTAL_BLOCKS));
}
@@ -85,7 +86,7 @@
// cap
int nBlocksUntilFinish = m_nFinishBlock - m_nCurrentBlock;
- const int nBlocksToRetrieve = min(nBlocks, nBlocksUntilFinish);
+ const int nBlocksToRetrieve = _min(nBlocks, nBlocksUntilFinish);
// get the data
unsigned char * pOutputBuffer = (unsigned char *) pBuffer;
@@ -99,7 +100,7 @@
// analyze how much to remove from the buffer
const int nFrameBufferBlocks = m_nFrameBufferFinishedBlocks;
- nBlocksThisPass = min(nBlocksLeft, nFrameBufferBlocks);
+ nBlocksThisPass = _min(nBlocksLeft, nFrameBufferBlocks);
// remove as much as possible
if (nBlocksThisPass > 0)
@@ -182,7 +183,7 @@
int nFrameOffsetBlocks = m_nCurrentFrameBufferBlock % GetInfo(APE_INFO_BLOCKS_PER_FRAME);
int nFrameBlocksLeft = nFrameBlocks - nFrameOffsetBlocks;
- int nBlocksThisPass = min(nFrameBlocksLeft, nBlocksLeft);
+ int nBlocksThisPass = _min(nFrameBlocksLeft, nBlocksLeft);
// start the frame if we need to
if (nFrameOffsetBlocks == 0)
--- ./src/MACLib/BitArray.cpp
+++ ./src/MACLib/BitArray.cpp
@@ -113,7 +114,7 @@
m_nCurrentBitIndex = (m_nCurrentBitIndex & 31);
// zero the rest of the memory (may not need the +1 because of frame byte alignment)
- memset(&m_pBitArray[1], 0, min(nBytesToWrite + 1, BIT_ARRAY_BYTES - 1));
+ memset(&m_pBitArray[1], 0, _min(nBytesToWrite + 1, BIT_ARRAY_BYTES - 1));
}
// return a success
@@ -247,7 +247,7 @@
BitArrayState.k++;
// figure the pivot value
- int nPivotValue = max(nOriginalKSum / 32, 1);
+ int nPivotValue = _max(nOriginalKSum / 32, 1);
int nOverflow = nEncode / nPivotValue;
int nBase = nEncode - (nOverflow * nPivotValue);
--- ./src/MACLib/APECompress.cpp
+++ ./src/MACLib/APECompress.cpp
@@ -117,7 +118,7 @@
return ERROR_UNDEFINED;
// calculate how many bytes to copy and add that much to the buffer
- int nBytesToProcess = min(nBytesAvailable, nBytes - nBytesDone);
+ int nBytesToProcess = _min(nBytesAvailable, nBytes - nBytesDone);
memcpy(pBuffer, &pData[nBytesDone], nBytesToProcess);
// unlock the buffer (fail if not successful)
@@ -162,7 +163,7 @@
while ((m_nBufferTail - m_nBufferHead) >= nThreshold)
{
- int nFrameBytes = min(m_spAPECompressCreate->GetFullFrameBytes(), m_nBufferTail - m_nBufferHead);
+ int nFrameBytes = _min(m_spAPECompressCreate->GetFullFrameBytes(), m_nBufferTail - m_nBufferHead);
if (nFrameBytes == 0)
break;
--- src/MACLib/Prepare.cpp
+++ src/MACLib/Prepare.cpp
@@ -177,9 +177,9 @@
if (LPeak == 0) { *pSpecialCodes |= SPECIAL_FRAME_LEFT_SILENCE; }
if (RPeak == 0) { *pSpecialCodes |= SPECIAL_FRAME_RIGHT_SILENCE; }
- if (max(LPeak, RPeak) > *pPeakLevel)
+ if (_max(LPeak, RPeak) > *pPeakLevel)
{
- *pPeakLevel = max(LPeak, RPeak);
+ *pPeakLevel = _max(LPeak, RPeak);
}
// check for pseudo-stereo files
--- src/MACLib/UnBitArray.cpp
+++ src/MACLib/UnBitArray.cpp
@@ -110,7 +110,7 @@
if (m_nVersion >= 3990)
{
// figure the pivot value
- int nPivotValue = max(BitArrayState.nKSum / 32, 1);
+ int nPivotValue = _max(BitArrayState.nKSum / 32, 1);
// get the overflow
int nOverflow = 0;
--- src/MACLib/APETag.cpp
+++ src/MACLib/APETag.cpp
@@ -16,7 +16,7 @@
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 = 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)
--- src/MACLib/MACProgressHelper.cpp
+++ src/MACLib/MACProgressHelper.cpp
@@ -35,7 +35,7 @@
m_nCurrentStep = nCurrentStep;
// figure the percentage done
- float fPercentageDone = float(m_nCurrentStep) / float(max(m_nTotalSteps, 1));
+ float fPercentageDone = float(m_nCurrentStep) / float(_max(m_nTotalSteps, 1));
int nPercentageDone = (int) (fPercentageDone * 1000 * 100);
if (nPercentageDone > 100000) nPercentageDone = 100000;

View File

@ -1,7 +1,7 @@
# Template file for 'mac'
pkgname=mac
version=3.99u4b5s7
revision=1
revision=2
_version=$(echo $version | sed 's/\([a-z]\)/-\1/g')
short_desc="APE (Monkey's Audio) codec and decompressor"
homepage="http://www.etree.org/shnutils/shntool/"