Kaydet (Commit) 7d8e9444 authored tarafından Noel Grandin's avatar Noel Grandin

convert a<b?a:b to std::min(a,b)

with something like

    git grep -nP '(.*)\s*<\s*(.*)\s*\?\s*\g1\s*:\s*\g2' -- *.?xx

Change-Id: Id5078b35961847feb78a66204fdb7598ee63fd23
Note: we also convert a>b?b:a
Reviewed-on: https://gerrit.libreoffice.org/47736Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 80fb8d40
......@@ -351,7 +351,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth,
nDig = nExp + 1;
// round number
if( (nNum += roundArray [( nDig > 16 ) ? 16 : nDig] ) >= 10.0 )
if( (nNum += roundArray [std::min<short>( nDig, 16 )] ) >= 10.0 )
{
nNum = 1.0;
++nExp;
......
......@@ -278,7 +278,7 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut,
// Ensure we have enough space for the amount of data we can actually read.
const sal_Int64 nBytesAvailable = m_nBlobLength - m_nBlobPosition;
const sal_Int32 nBytesToRead = nBytes < nBytesAvailable ? nBytes : nBytesAvailable;
const sal_Int32 nBytesToRead = std::min<sal_Int64>(nBytes, nBytesAvailable);
if (rDataOut.getLength() < nBytesToRead)
rDataOut.realloc(nBytesToRead);
......@@ -289,7 +289,7 @@ sal_Int32 SAL_CALL Blob::readBytes(uno::Sequence< sal_Int8 >& rDataOut,
{
sal_uInt16 nBytesRead = 0;
sal_uInt64 nDataRemaining = nBytesToRead - nTotalBytesRead;
sal_uInt16 nReadSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining;
sal_uInt16 nReadSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16);
aErr = isc_get_segment(m_statusVector,
&m_blobHandle,
&nBytesRead,
......
......@@ -552,7 +552,7 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 nParameterIndex, const Refer
{
sal_Int64 nCharRemain = nLen - nCharWritten;
constexpr sal_uInt16 MAX_SIZE = SAL_MAX_UINT16 / 4;
sal_uInt16 nWriteSize = (nCharRemain > MAX_SIZE) ? MAX_SIZE : nCharRemain;
sal_uInt16 nWriteSize = std::min<sal_Int64>(nCharRemain, MAX_SIZE);
OString sData = OUStringToOString(
xClob->getSubString(nCharWritten, nWriteSize),
RTL_TEXTENCODING_UTF8);
......@@ -642,7 +642,7 @@ void SAL_CALL OPreparedStatement::setBlob(sal_Int32 nParameterIndex,
while (xBlob->length() - nDataWritten > 0)
{
sal_uInt64 nDataRemaining = xBlob->length() - nDataWritten;
sal_uInt16 nWriteSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining;
sal_uInt16 nWriteSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16);
aErr = isc_put_segment(m_statusVector,
&aBlobHandle,
nWriteSize,
......@@ -802,7 +802,7 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex,
while (xBytes.getLength() - nDataWritten > 0)
{
sal_uInt64 nDataRemaining = xBytes.getLength() - nDataWritten;
sal_uInt16 nWriteSize = (nDataRemaining > SAL_MAX_UINT16) ? SAL_MAX_UINT16 : nDataRemaining;
sal_uInt16 nWriteSize = std::min<sal_uInt64>(nDataRemaining, SAL_MAX_UINT16);
aErr = isc_put_segment(m_statusVector,
&aBlobHandle,
nWriteSize,
......
......@@ -257,7 +257,7 @@ sal_Int32 ResultSet::guessDataType( sal_Int32 column )
// we don't look into more than 100 rows ...
sal_Int32 ret = css::sdbc::DataType::INTEGER;
int maxRows = ( m_rowCount > 100 ? 100 : m_rowCount );
int maxRows = std::min<sal_Int32>( m_rowCount, 100 );
for( int i = 0 ; i < maxRows ; i ++ )
{
if( ! PQgetisnull( m_result, i , column-1 ) )
......
......@@ -1664,7 +1664,7 @@ extern "C" sal_Int32 typelib_typedescription_getAlignedUnoSize(
#ifdef __m68k__
// Anything that is at least 16 bits wide is aligned on a 16-bit
// boundary on the m68k default abi
sal_Int32 nMaxAlign = (rMaxIntegralTypeSize > 2) ? 2 : rMaxIntegralTypeSize;
sal_Int32 nMaxAlign = std::min(rMaxIntegralTypeSize, 2);
nStructSize = (nStructSize + nMaxAlign -1) / nMaxAlign * nMaxAlign;
#else
// Example: A { double; int; } structure has a size of 16 instead of 10. The
......
......@@ -200,7 +200,7 @@ SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(vcl::Window* pParent,
xDefNum->getDefaultContinuousNumberingLevels( rLocale );
sal_Int32 nLength = aNumberings.getLength() > NUM_VALUSET_COUNT ? NUM_VALUSET_COUNT :aNumberings.getLength();
sal_Int32 nLength = std::min<sal_Int32>(aNumberings.getLength(), NUM_VALUSET_COUNT);
const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
for(sal_Int32 i = 0; i < nLength; i++)
......
......@@ -165,7 +165,7 @@ bool SvxEditSourceHelper::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nE
nClosestEndIndex_s = nCurrIndex;
}
}
sal_Int32 nClosestEndIndex = nClosestEndIndex_s < nClosestEndIndex_e ? nClosestEndIndex_s : nClosestEndIndex_e;
sal_Int32 nClosestEndIndex = std::min(nClosestEndIndex_s, nClosestEndIndex_e);
nStartIndex = nClosestStartIndex;
nEndIndex = nClosestEndIndex;
......
......@@ -58,7 +58,7 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase
if( currentPara == maSelection.nStartPara )
nStartPos = std::max(nStartPos, maSelection.nStartPos);
if( currentPara == maSelection.nEndPara )
nEndPos = nEndPos<maSelection.nEndPos ? nEndPos : maSelection.nEndPos;
nEndPos = std::min(nEndPos, maSelection.nEndPos);
ESelection aCurrentParaSel = ESelection( currentPara, nStartPos, currentPara, nEndPos );
for( auto aIter = rRanges.begin(); (aIter != rRanges.end()) && (pContent == nullptr); ++aIter )
{
......@@ -400,7 +400,7 @@ SvxUnoTextRangeEnumeration::SvxUnoTextRangeEnumeration(const SvxUnoTextBase& rTe
continue;
nStartPos = std::max<int>(nStartPos, mnSel.nStartPos);
nEndPos = nEndPos<mnSel.nEndPos ? nEndPos : mnSel.nEndPos;
nEndPos = std::min<sal_uInt16>(nEndPos, mnSel.nEndPos);
ESelection aSel( mnParagraph, nStartPos, mnParagraph, nEndPos );
const SvxUnoTextRangeBaseList& rRanges( mpEditSource->getRanges() );
......
......@@ -65,8 +65,8 @@ awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt
sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
sal_Int32 nRight2 = aRect2.X + aRect2.Width;
sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
aResult.Width = ( nRight1 < nRight2 ? nRight1 : nRight2 ) - aResult.X;
aResult.Height = ( nBottom1 < nBottom2 ? nBottom1 : nBottom2 ) - aResult.Y;
aResult.Width = std::min( nRight1, nRight2 ) - aResult.X;
aResult.Height = std::min( nBottom1, nBottom2 ) - aResult.Y;
return aResult;
}
......
......@@ -330,7 +330,7 @@ bool OwnView_Impl::ReadContentsAndGenerateTempFile( const uno::Reference< io::XI
sal_uInt32 nRead = 0;
while ( nRead < nDataSize )
{
sal_uInt32 nToRead = ( nDataSize - nRead > 32000 ) ? 32000 : nDataSize - nRead;
sal_uInt32 nToRead = std::min<sal_uInt32>( nDataSize - nRead, 32000 );
sal_uInt32 nLocalRead = xInStream->readBytes( aReadSeq, nToRead );
......
......@@ -4121,7 +4121,7 @@ void EscherGraphicProvider::WriteBlibStoreContainer( SvStream& rSt, SvStream* pM
// record
while ( nBlipSize )
{
sal_uInt32 nBytes = ( nBlipSize > nBuf ? nBuf : nBlipSize );
sal_uInt32 nBytes = std::min( nBlipSize, nBuf );
pMergePicStreamBSE->ReadBytes(pBuf.get(), nBytes);
rSt.WriteBytes(pBuf.get(), nBytes);
nBlipSize -= nBytes;
......
......@@ -5425,7 +5425,7 @@ PPTPortionObj::PPTPortionObj( const PPTStyleSheet& rStyleSheet, TSS_Type nInstan
PPTCharPropSet ( 0 ),
mrStyleSheet ( rStyleSheet ),
mnInstance ( nInstance ),
mnDepth ( ( nDepth > 4 ) ? 4 : nDepth )
mnDepth ( std::min<sal_uInt32>( nDepth, 4 ) )
{
}
......@@ -5433,7 +5433,7 @@ PPTPortionObj::PPTPortionObj( const PPTCharPropSet& rCharPropSet, const PPTStyle
PPTCharPropSet ( rCharPropSet ),
mrStyleSheet ( rStyleSheet ),
mnInstance ( nInstance ),
mnDepth ( ( nDepth > 4 ) ? 4 : nDepth )
mnDepth ( std::min<sal_uInt32>( nDepth, 4 ) )
{
}
......@@ -7299,8 +7299,8 @@ void GetLinePositions( const SdrObject* pObj, const std::set< sal_Int32 >& rRows
else
nPosition |= aPt1.Y() < aPt2.Y() ? LinePositionBLTR : LinePositionTLBR;
std::set< sal_Int32 >::const_iterator aRow( rRows.find( aPt1.Y() < aPt2.Y() ? aPt1.Y() : aPt2.Y() ) );
std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( aPt1.X() < aPt2.X() ? aPt1.X() : aPt2.X() ) );
std::set< sal_Int32 >::const_iterator aRow( rRows.find( std::min(aPt1.Y(), aPt2.Y() ) ) );
std::set< sal_Int32 >::const_iterator aColumn( rColumns.find( std::min(aPt1.X(), aPt2.X() ) ) );
if ( ( aRow != rRows.end() ) && ( aColumn != rColumns.end() ) )
{
nPosition |= ( std::distance( rRows.begin(), aRow ) * rColumns.size() ) + std::distance( rColumns.begin(), aColumn );
......
......@@ -129,7 +129,7 @@ void ParaWin::UpdateArgDesc( sal_uInt16 nArg )
else if ( nArgs < PAIRED_VAR_ARGS )
{
sal_uInt16 nFix = nArgs - VAR_ARGS;
sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix );
sal_uInt16 nPos = std::min( nArg, nFix );
sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
aArgDesc = pFuncDesc->getParameterDescription(nRealArg);
......@@ -182,7 +182,7 @@ void ParaWin::UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i )
else if ( nArgs < PAIRED_VAR_ARGS)
{
sal_uInt16 nFix = nArgs - VAR_ARGS;
sal_uInt16 nPos = ( nArg < nFix ? nArg : nFix );
sal_uInt16 nPos = std::min( nArg, nFix );
sal_uInt16 nRealArg = (nPos < aVisibleArgMapping.size() ?
aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
SetArgNameFont( i,
......
......@@ -130,7 +130,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
{
Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( ePICKLIST );
int nPickListMenuItems = ( aHistoryList.getLength() > MAX_MENU_ITEMS ) ? MAX_MENU_ITEMS : aHistoryList.getLength();
int nPickListMenuItems = std::min<sal_Int32>( aHistoryList.getLength(), MAX_MENU_ITEMS );
m_aRecentFilesItems.clear();
if (( nPickListMenuItems > 0 ) && !m_bDisabled )
{
......
......@@ -80,9 +80,9 @@ bool FieldCode::Read(HWPFile & hwpf)
hwpf.Read4b(&len3, 1);
hwpf.Read4b(&binlen, 1);
uint const len1_ = ((len1 > 1024) ? 1024 : len1) / sizeof(hchar);
uint const len2_ = ((len2 > 1024) ? 1024 : len2) / sizeof(hchar);
uint const len3_ = ((len3 > 1024) ? 1024 : len3) / sizeof(hchar);
uint const len1_ = std::min<uint>(len1, 1024) / sizeof(hchar);
uint const len2_ = std::min<uint>(len2, 1024) / sizeof(hchar);
uint const len3_ = std::min<uint>(len3, 1024) / sizeof(hchar);
str1.reset( new hchar[len1_ ? len1_ : 1] );
str2.reset( new hchar[len2_ ? len2_ : 1] );
......
......@@ -71,7 +71,7 @@ sal_Int32 SAL_CALL BreakIterator_CTL::previousCharacters( const OUString& Text,
} else
nStartPos = 0;
} else { // for BS to delete one char.
nDone = (nStartPos > nCount) ? nCount : nStartPos;
nDone = std::min(nStartPos, nCount);
nStartPos -= nDone;
}
......@@ -98,7 +98,7 @@ sal_Int32 SAL_CALL BreakIterator_CTL::nextCharacters(const OUString& Text,
} else
nStartPos = len;
} else {
nDone = (len - nStartPos > nCount) ? nCount : len - nStartPos;
nDone = std::min(len - nStartPos, nCount);
nStartPos += nDone;
}
......
......@@ -459,7 +459,7 @@ Boundary const & xdictionary::getWordBoundary(const OUString& rText, sal_Int32 a
} else {
boundary.startPos = anyPos;
if (anyPos < len) rText.iterateCodePoints(&anyPos);
boundary.endPos = anyPos < len ? anyPos : len;
boundary.endPos = std::min(anyPos, len);
}
if (wordType == WordType::WORD_COUNT) {
// skip punctuation for word count.
......
......@@ -316,9 +316,9 @@ int WLevDistance::LCM( int a, int b )
inline int WLevDistance::Min3( int x, int y, int z )
{
if ( x < y )
return( x < z ? x : z );
return std::min(x, z);
else
return( y < z ? y : z );
return std::min(y, z);
}
// The value in the middle
......@@ -326,11 +326,11 @@ int WLevDistance::Mid3( int x, int y, int z )
{
int min = Min3(x,y,z);
if ( x == min )
return( y < z ? y : z);
return std::min(y, z);
else if ( y == min )
return( x < z ? x : z);
return std::min(x, z);
else // z == min
return( x < y ? x : y);
return std::min(x, y);
}
// Maximum of three values
......
......@@ -1062,7 +1062,7 @@ SearchResult TextSearch::ApproxSrchFrwrd( const OUString& searchStr,
if( aWBnd.startPos >= endPos )
break;
nStt = aWBnd.startPos < startPos ? startPos : aWBnd.startPos;
nEnd = aWBnd.endPos > endPos ? endPos : aWBnd.endPos;
nEnd = std::min(aWBnd.endPos, endPos);
if( nStt < nEnd &&
pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
......@@ -1106,7 +1106,7 @@ SearchResult TextSearch::ApproxSrchBkwrd( const OUString& searchStr,
if( aWBnd.endPos <= endPos )
break;
nStt = aWBnd.startPos < endPos ? endPos : aWBnd.startPos;
nEnd = aWBnd.endPos > startPos ? startPos : aWBnd.endPos;
nEnd = std::min(aWBnd.endPos, startPos);
if( nStt < nEnd &&
pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
......
......@@ -103,7 +103,7 @@ TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCo
if (nCount2 + pos2 > str2.getLength())
nCount2 = str2.getLength() - pos2;
realCount = ((nCount1 > nCount2) ? nCount2 : nCount1);
realCount = std::min(nCount1, nCount2);
s1 = str1.getStr() + pos1;
s2 = str2.getStr() + pos2;
......
......@@ -24,8 +24,6 @@ using namespace com::sun::star::uno;
namespace i18npool {
inline sal_Int32 Min( sal_Int32 a, sal_Int32 b ) { return a > b ? b : a; }
sal_Bool SAL_CALL
transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32& nMatch1,
const OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 )
......@@ -39,7 +37,7 @@ transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 n
const sal_Unicode * p1 = s1.getStr();
const sal_Unicode * p2 = s2.getStr();
sal_Int32 length = Min(s1.getLength(), s2.getLength());
sal_Int32 length = std::min(s1.getLength(), s2.getLength());
sal_Int32 nmatch;
for ( nmatch = 0; nmatch < length; nmatch++)
......
......@@ -100,7 +100,7 @@ namespace basegfx
// (::std::max(fVal,0.00001));
if(fVal < 0.0)
return (fVal < -0.00001 ? fVal : -0.00001);
return std::min(fVal, -0.00001);
else
return std::max(fVal, 0.00001);
}
......
......@@ -3426,7 +3426,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
// Clamp the input value in [MIN_ZOOM, MAX_ZOOM]
fZoom = fZoom < MIN_ZOOM ? MIN_ZOOM : fZoom;
fZoom = fZoom > MAX_ZOOM ? MAX_ZOOM : fZoom;
fZoom = std::min(fZoom, MAX_ZOOM);
if (lok_approxEqual(fZoom, priv->m_fZoom))
return;
......
......@@ -111,8 +111,7 @@ bool LinguIsUnspecified( const OUString & rBcp47 )
static inline sal_Int32 Minimum( sal_Int32 n1, sal_Int32 n2, sal_Int32 n3 )
{
sal_Int32 nMin = n1 < n2 ? n1 : n2;
return nMin < n3 ? nMin : n3;
return std::min(std::min(n1, n2), n3);
}
class IntArray2D
......
......@@ -311,7 +311,7 @@ sal_Int32 Decompression::explode()
// point back to copy position and read bytes
m_pOutStream->SeekRel(-static_cast<long>(distance));
sal_uInt8 sTemp[MAXWIN];
sal_uInt32 nRead = distance > Length? Length:distance;
sal_uInt32 nRead = std::min(distance, Length);
m_pOutStream->ReadBytes(sTemp, nRead);
if (nRead != Length)
{
......
......@@ -205,7 +205,7 @@ void LwpGlossary::Read()
{
if (NumIndexRows)
{
sal_uInt16 EntriesRead = (FiledEntries > NumIndexRows)? NumIndexRows:FiledEntries;
sal_uInt16 EntriesRead = std::min(FiledEntries, NumIndexRows);
for (sal_uInt16 EntryCount = 1; EntryCount <= EntriesRead; EntryCount++)
m_pObjStrm->QuickReaduInt16();
......
......@@ -104,7 +104,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
unsigned char *wb = buf;
while (r)
{
const size_t count = (r > SSIZE_MAX) ? SSIZE_MAX : r;
const size_t count = std::min(r, SSIZE_MAX);
size_t c = fread(wb, 1, count, patchFile);
if (c != count)
{
......
......@@ -179,7 +179,7 @@ bool AgileEngine::decrypt(BinaryXInputStream& aInputStream,
Decrypt aDecryptor(mKey, iv, AgileEngine::cryptoType(mInfo));
outputLength = aDecryptor.update(outputBuffer, inputBuffer, inputLength);
sal_uInt32 writeLength = outputLength > remaining ? remaining : outputLength;
sal_uInt32 writeLength = std::min(outputLength, remaining);
aOutputStream.writeMemory(outputBuffer.data(), writeLength);
remaining -= outputLength;
......
......@@ -359,7 +359,7 @@ void VBACompression::write()
std::size_t nRemainingSize = nSize;
while(bStreamNotEnded)
{
std::size_t nChunkSize = nRemainingSize > 4096 ? 4096 : nRemainingSize;
std::size_t nChunkSize = std::min<size_t>(nRemainingSize, 4096);
VBACompressionChunk aChunk(mrCompressedStream, &pData[nSize - nRemainingSize], nChunkSize);
aChunk.write();
......
......@@ -13,6 +13,7 @@
#include <sstream>
#include <memory>
#include <vector>
#include <algorithm>
#include <comphelper/random.hxx>
#include <opencl/openclconfig.hxx>
......@@ -285,7 +286,7 @@ ds_status evaluateScoreForDevice(ds_device& rDevice, std::unique_ptr<LibreOffice
for (unsigned long i = 0; i < testData->inputSize; i++)
{
fAverage += testData->input0[i];
fMin = ((fMin < testData->input1[i]) ? fMin : testData->input1[i]);
fMin = std::min(fMin, testData->input1[i]);
fSoP += testData->input2[i] * testData->input3[i];
}
fAverage /= testData->inputSize;
......
......@@ -210,7 +210,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
nRead = mxZipStream->readBytes (
aData,
static_cast < sal_Int32 > ( nDiff < nRequestedBytes ? nDiff : nRequestedBytes ) );
std::min<sal_Int32>(nDiff, nRequestedBytes) );
mnZipCurrent += nRead;
......
......@@ -20,6 +20,7 @@
#include <new>
#include <memory>
#include <algorithm>
#include <sal/types.h>
#include <sal/macros.h>
#include <osl/endian.h>
......@@ -570,7 +571,7 @@ void MethodEntry::reallocParams(sal_uInt16 size)
if (m_paramCount)
{
sal_uInt16 i;
sal_uInt16 mn = size < m_paramCount ? size : m_paramCount;
sal_uInt16 mn = std::min(size, m_paramCount);
for (i = 0; i < mn; i++)
{
......@@ -594,7 +595,7 @@ void MethodEntry::reallocExcs(sal_uInt16 size)
newExcNames = nullptr;
sal_uInt16 i;
sal_uInt16 mn = size < m_excCount ? size : m_excCount;
sal_uInt16 mn = std::min(size, m_excCount);
for (i = 0; i < mn; i++)
{
......
......@@ -1252,7 +1252,7 @@ static sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Line, sa
}
}
LineNo = LineNo > pProfile->m_NoLines ? pProfile->m_NoLines : LineNo;
LineNo = std::min(LineNo, pProfile->m_NoLines);
if (LineNo < pProfile->m_NoLines)
{
......
......@@ -263,7 +263,7 @@ static bool osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszDirectory, sal
OUSTRING_TO_OSTRING_CVTFLAGS);
if (pStrValue && pStrValue->length > 0)
{
sal_Int32 nCopy = (sal_Int32)(nMax-1) < pStrValue->length ? (sal_Int32)(nMax-1) : pStrValue->length ;
sal_Int32 nCopy = (sal_Int32)std::min(nMax-1, pStrValue->length) ;
strncpy (pszDirectory, pStrValue->buffer, nCopy);
pszDirectory[nCopy] = '\0';
bRet = (std::size_t)pStrValue->length < nMax;
......
......@@ -1374,7 +1374,7 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li
}
}
LineNo = LineNo > pProfile->m_NoLines ? pProfile->m_NoLines : LineNo;
LineNo = std::min(LineNo, pProfile->m_NoLines);
if (LineNo < pProfile->m_NoLines)
{
......
......@@ -31,6 +31,7 @@
#if defined(SAL_UNX)
#include <sys/time.h>
#endif
#include <algorithm>
/**
* @internal
......@@ -1283,7 +1284,7 @@ static void rtl_cache_depot_wsupdate(
depot->m_prev_min = depot->m_curr_min;
depot->m_curr_min = depot->m_mag_count;
npurge = depot->m_curr_min < depot->m_prev_min ? depot->m_curr_min : depot->m_prev_min;
npurge = std::min(depot->m_curr_min, depot->m_prev_min);
for (; npurge > 0; npurge--)
{
rtl_cache_magazine_type * mag = rtl_cache_depot_dequeue (depot);
......
......@@ -137,7 +137,7 @@ void * rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXTERN_C()
p = rtl_allocateMemory (n);
if (p)
{
memcpy (p, p_old, (n < n_old) ? n : n_old);
memcpy (p, p_old, std::min(n, n_old));
rtl_freeMemory (p_old);
}
}
......
......@@ -22,6 +22,7 @@
#include <sal/types.h>
#include <rtl/alloc.h>
#include <rtl/cipher.h>
#include <algorithm>
#define RTL_CIPHER_NTOHL(c, l) \
((l) = (static_cast<sal_uInt32>(*((c)++))) << 24, \
......@@ -660,7 +661,7 @@ static rtlCipherError BF_init(
if (pArgData && nArgLen)
{
nArgLen = ((nArgLen < 8) ? nArgLen : 8);
nArgLen = std::min<sal_Size>(nArgLen, 8);
if (eMode == rtl_Cipher_ModeStream)
{
memcpy(ctx->m_iv.m_byte, pArgData, nArgLen);
......
......@@ -443,7 +443,7 @@ inline void doubleToString(typename T::String ** pResult,
// Round the number
if(nDigits >= 0)
{
if ((fValue += nRoundVal[nDigits > 15 ? 15 : nDigits] ) >= 10)
if ((fValue += nRoundVal[std::min<sal_Int32>(nDigits, 15)] ) >= 10)
{
fValue = 1.0;
nExp++;
......
......@@ -436,7 +436,7 @@ sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
{
assert(firstLen >= 0 && secondLen >= 0);
sal_Int32 i;
sal_Int32 len = firstLen < secondLen ? firstLen : secondLen;
sal_Int32 len = std::min(firstLen, secondLen);
for (i = 0; i < len; ++i) {
/* Check ASCII range */
SAL_WARN_IF( (static_cast<unsigned char>(*second)) > 127, "rtl.string",
......
......@@ -121,17 +121,17 @@ SAL_WARN_UNUSED_RESULT inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB
SAL_WARN_UNUSED_RESULT inline SCCOL SanitizeCol( SCCOL nCol )
{
return nCol < 0 ? 0 : (nCol > MAXCOL ? MAXCOL : nCol);
return nCol < 0 ? 0 : std::min(nCol, MAXCOL);
}
SAL_WARN_UNUSED_RESULT inline SCROW SanitizeRow( SCROW nRow )
{
return nRow < 0 ? 0 : (nRow > MAXROW ? MAXROW : nRow);
return nRow < 0 ? 0 : std::min(nRow, MAXROW);
}
SAL_WARN_UNUSED_RESULT inline SCTAB SanitizeTab( SCTAB nTab )
{
return nTab < 0 ? 0 : (nTab > MAXTAB ? MAXTAB : nTab);
return nTab < 0 ? 0 : std::min(nTab, MAXTAB);
}
// The result of ConvertRef() is a bit group of the following:
......
......@@ -235,7 +235,7 @@ bool ScDPFilteredCache::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
if (pLastRow)
{
// Return the last row of current segment.
*pLastRow = nLastRowFilter < nLastRowPage ? nLastRowFilter : nLastRowPage;
*pLastRow = std::min(nLastRowFilter, nLastRowPage);
*pLastRow -= 1; // End position is not inclusive. Move back one.
}
......
......@@ -949,7 +949,7 @@ bool ScTable::SearchRangeForEmptyCell(
{
// row direction.
SCROW nLastNonFilteredRow = MAXROW + 1;
SCROW nBeginRow = rRange.aEnd.Row() > rRow ? rRow : rRange.aEnd.Row();
SCROW nBeginRow = std::min(rRange.aEnd.Row(), rRow);
for (SCROW nRow = nBeginRow; nRow >= rRange.aStart.Row(); --nRow)
{
if (bSkipFiltered)
......@@ -972,7 +972,7 @@ bool ScTable::SearchRangeForEmptyCell(
else
{
// column direction.
SCCOL nBeginCol = rRange.aEnd.Col() > rCol ? rCol : rRange.aEnd.Col();
SCCOL nBeginCol = std::min(rRange.aEnd.Col(), rCol);
for (SCCOL nCol = nBeginCol; nCol >= rRange.aStart.Col(); --nCol)
{
SCROW nLastNonFilteredRow = MAXROW + 1;
......
......@@ -98,7 +98,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
{
tmpCur = vSubArguments[1]->GetFormulaToken();
pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
size_t nCurWindowSize = pCurDVR->GetArrayLength() < pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength() : pCurDVR->GetRefRowSize() ;
size_t nCurWindowSize = std::min(pCurDVR->GetArrayLength(), pCurDVR->GetRefRowSize());
int unrollSize = 8;
ss << " int loop;\n";
if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
......
......@@ -4111,7 +4111,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
{
ScRawToken aToken;
aToken.SetOpCode( ocSpaces );
aToken.sbyte.cByte = static_cast<sal_uInt8>( nSpaces > 255 ? 255 : nSpaces );
aToken.sbyte.cByte = static_cast<sal_uInt8>( std::min<sal_Int32>(nSpaces, 255) );
if( !static_cast<ScTokenArray*>(pArr)->AddRawToken( aToken ) )
{
SetError(FormulaError::CodeOverflow);
......
......@@ -678,7 +678,7 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx,
// nCol1 is the first column of the block that gets shifted, determine
// the head and tail elements that are to be copied for deletion or
// insertion.
size_t nHead = static_cast<size_t>(::std::max( nCol1 + (nDx < 0 ? nDx : 0) - nOldCol1, 0));
size_t nHead = static_cast<size_t>(::std