From 310df91d23ab9680b67a29d82564cc25e8765ce7 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Fri, 26 Mar 2021 19:45:56 +0100 Subject: Refactoring: replace QMIN/QMAX by std::min/std::max --- src/commentcnv.l | 3 ++- src/configimpl.l | 2 +- src/diagram.cpp | 21 +++++++++++---------- src/docparser.cpp | 26 +++++++++++++------------- src/dot.cpp | 3 ++- src/dotclassgraph.cpp | 8 +++++--- src/dotfilepatcher.cpp | 2 +- src/doxygen.cpp | 4 ++-- src/fortranscanner.l | 2 +- src/latexdocvisitor.cpp | 5 ++++- src/pre.l | 3 ++- src/qcstring.h | 6 ++---- src/rtfdocvisitor.cpp | 6 ++++-- src/util.cpp | 4 ++-- src/vhdldocgen.cpp | 4 ++-- 15 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/commentcnv.l b/src/commentcnv.l index 09583d3..2d0a4aa 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -28,6 +28,7 @@ #include #include #include +#include #include "bufstr.h" #include "debug.h" @@ -1114,7 +1115,7 @@ static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size) { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; yy_size_t bytesInBuf = yyextra->inBuf->curPos()-yyextra->inBufPos; - yy_size_t bytesToCopy = QMIN(max_size,bytesInBuf); + yy_size_t bytesToCopy = std::min(max_size,bytesInBuf); memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy); yyextra->inBufPos+=bytesToCopy; return bytesToCopy; diff --git a/src/configimpl.l b/src/configimpl.l index 4443f9c..a4c6c5d 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -1737,7 +1737,7 @@ void Config::checkAndCorrect() } else if (dotNumThreads<=0) { - dotNumThreads=QMAX(2,std::thread::hardware_concurrency()+1); + dotNumThreads=std::max(2u,std::thread::hardware_concurrency()+1); } Config_updateInt(DOT_NUM_THREADS,dotNumThreads); diff --git a/src/diagram.cpp b/src/diagram.cpp index 5054756..365dd46 100644 --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "diagram.h" #include "image.h" @@ -519,8 +520,8 @@ void TreeDiagram::computeExtremes(uint *maxLabelLen,uint *maxXPos) for (const auto &di : *dr) // for each item in a row { if (di->isInList()) done=TRUE; - if (maxXPos) mx=QMAX(mx,(uint)di->xPos()); - if (maxLabelLen) ml=QMAX(ml,Image::stringLength(di->label())); + if (maxXPos) mx=std::max(mx,(uint)di->xPos()); + if (maxLabelLen) ml=std::max(ml,Image::stringLength(di->label())); } if (done) break; } @@ -1051,12 +1052,12 @@ void ClassDiagram::writeFigure(std::ostream &output,const char *path, p->base.computeExtremes(&baseMaxLabelWidth,&baseMaxX); p->super.computeExtremes(&superMaxLabelWidth,&superMaxX); - uint rows=QMAX(1,baseRows+superRows-1); - uint cols=(QMAX(baseMaxX,superMaxX)+gridWidth*2-1)/gridWidth; + uint rows=std::max(1u,baseRows+superRows-1); + uint cols=(std::max(baseMaxX,superMaxX)+gridWidth*2-1)/gridWidth; // Estimate the image aspect width and height in pixels. uint estHeight = rows*40; - uint estWidth = cols*(20+QMAX(baseMaxLabelWidth,superMaxLabelWidth)); + uint estWidth = cols*(20+std::max(baseMaxLabelWidth,superMaxLabelWidth)); //printf("Estimated size %d x %d\n",estWidth,estHeight); const float pageWidth = 14.0f; // estimated page width in cm. @@ -1064,8 +1065,8 @@ void ClassDiagram::writeFigure(std::ostream &output,const char *path, // errors. // compute the image height in centimeters based on the estimates - float realHeight = QMIN(rows,12); // real height in cm - float realWidth = realHeight * estWidth/(float)estHeight; + float realHeight = static_cast(std::min(rows,12u)); // real height in cm + float realWidth = realHeight * estWidth/static_cast(estHeight); if (realWidth>pageWidth) // assume that the page width is about 15 cm { realHeight*=pageWidth/realWidth; @@ -1345,9 +1346,9 @@ void ClassDiagram::writeImage(std::ostream &t,const char *path, p->base.computeExtremes(&lb,&xb); p->super.computeExtremes(&ls,&xs); - uint cellWidth = QMAX(lb,ls)+labelHorMargin*2; - uint maxXPos = QMAX(xb,xs); - uint labelVertMargin = 6; //QMAX(6,(cellWidth-fontHeight)/6); // aspect at least 1:3 + uint cellWidth = std::max(lb,ls)+labelHorMargin*2; + uint maxXPos = std::max(xb,xs); + uint labelVertMargin = 6; //std::max(6,(cellWidth-fontHeight)/6); // aspect at least 1:3 uint cellHeight = labelVertMargin*2+fontHeight; uint imageWidth = (maxXPos+gridWidth)*cellWidth/gridWidth+ (maxXPos*labelHorSpacing)/gridWidth; diff --git a/src/docparser.cpp b/src/docparser.cpp index 4965953..b1cce37 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -2049,7 +2049,7 @@ void DocIncOperator::parse() m_text = g_includeFileText.mid(so,o-so); DBG(("DocIncOperator::parse() Line: %s\n",qPrint(m_text))); } - g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + g_includeFileOffset = std::min(l,o+1); // set pointer to start of new line m_showLineNo = g_includeFileShowLineNo; break; case SkipLine: @@ -2080,7 +2080,7 @@ void DocIncOperator::parse() } o++; // skip new line } - g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + g_includeFileOffset = std::min(l,o+1); // set pointer to start of new line m_showLineNo = g_includeFileShowLineNo; break; case Skip: @@ -2140,7 +2140,7 @@ void DocIncOperator::parse() } o++; // skip new line } - g_includeFileOffset = QMIN(l,o+1); // set pointer to start of new line + g_includeFileOffset = std::min(l,o+1); // set pointer to start of new line m_showLineNo = g_includeFileShowLineNo; break; } @@ -3070,7 +3070,7 @@ int DocInternal::parse(int level) ) { DocSection *s=new DocSection(this, - QMIN(level+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(level+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } @@ -3341,7 +3341,7 @@ uint DocHtmlCell::colSpan() const { if (attr.name.lower()=="colspan") { - return QMAX(1,attr.value.toUInt()); + return std::max(1u,attr.value.toUInt()); } } return 1; @@ -6794,7 +6794,7 @@ int DocSection::parse() while (retval==RetVal_Subsection) // more sections follow { DocSection *s=new DocSection(this, - QMIN(2+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(2+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } @@ -6808,13 +6808,13 @@ int DocSection::parse() while (retval==RetVal_Subsubsection) // more sections follow { DocSection *s=new DocSection(this, - QMIN(3+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(3+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } if (!(m_levelsectionId.startsWith("autotoc_md")) warn_doc_error(g_fileName,getDoctokinizerLineNr(),"Unexpected paragraph command found inside %s!",sectionLevelToName[m_level]); @@ -6822,7 +6822,7 @@ int DocSection::parse() while (retval==RetVal_Paragraph) // more sections follow { DocSection *s=new DocSection(this, - QMIN(4+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(4+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } @@ -6995,7 +6995,7 @@ void DocRoot::parse() if (sec) { DocSection *s=new DocSection(this, - QMIN(4+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(4+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } @@ -7024,7 +7024,7 @@ void DocRoot::parse() if (sec) { DocSection *s=new DocSection(this, - QMIN(3+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(3+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } @@ -7055,7 +7055,7 @@ void DocRoot::parse() if (sec) { DocSection *s=new DocSection(this, - QMIN(2+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(2+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } @@ -7095,7 +7095,7 @@ void DocRoot::parse() if (sec) { DocSection *s=new DocSection(this, - QMIN(1+Doxygen::subpageNestingLevel,5),g_token->sectionId); + std::min(1+Doxygen::subpageNestingLevel,5),g_token->sectionId); m_children.push_back(std::unique_ptr(s)); retval = s->parse(); } diff --git a/src/dot.cpp b/src/dot.cpp index 6a38a6e..2ffe9c2 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "config.h" #include "dot.h" @@ -163,7 +164,7 @@ bool DotManager::run() const } else { - msg("Generating dot graphs using %zu parallel threads...\n",QMIN(numDotRuns+numFilePatchers,m_workers.size())); + msg("Generating dot graphs using %zu parallel threads...\n",std::min(numDotRuns+numFilePatchers,m_workers.size())); } } size_t i=1; diff --git a/src/dotclassgraph.cpp b/src/dotclassgraph.cpp index c4f5b48..fe36bc9 100644 --- a/src/dotclassgraph.cpp +++ b/src/dotclassgraph.cpp @@ -13,6 +13,8 @@ * */ +#include + #include "containers.h" #include "dotclassgraph.h" #include "dotnode.h" @@ -164,7 +166,7 @@ bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, int oldSize=(int)childTreeWidth.size(); if (distance>oldSize) { - childTreeWidth.resize(QMAX(childTreeWidth.size(),(uint)distance)); + childTreeWidth.resize(std::max(childTreeWidth.size(),(size_t)distance)); int i; for (i=oldSize;ilabel().length(); @@ -191,7 +193,7 @@ bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, int oldSize = (int)parentTreeWidth.size(); if (distance>oldSize) { - parentTreeWidth.resize(QMAX(parentTreeWidth.size(),(uint)distance)); + parentTreeWidth.resize(std::max(parentTreeWidth.size(),(size_t)distance)); int i; for (i=oldSize;ilabel().length(); @@ -208,7 +210,7 @@ bool DotClassGraph::determineVisibleNodes(DotNode *rootNode, } if (Config_getBool(UML_LOOK)) return FALSE; // UML graph are always top to bottom int maxWidth=0; - int maxHeight=(int)QMAX(childTreeWidth.size(),parentTreeWidth.size()); + int maxHeight=(int)std::max(childTreeWidth.size(),parentTreeWidth.size()); uint i; for (i=0;i=0 && mapId<(int)m_maps.size()) { - int e = QMAX(line.find("--]"),line.find("-->")); + int e = std::max(line.find("--]"),line.find("-->")); const Map &map = m_maps.at(mapId); //printf("DotFilePatcher::writeSVGFigure: file=%s zoomable=%d\n", // m_patchFile.data(),map.zoomable); diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 658bbe5..34cea10 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -2761,7 +2761,7 @@ static void addVariable(const Entry *root,int isFuncPtr=-1) { QCString pScope; ClassDefMutable *pcd=0; - pScope = scope.left(QMAX(si-2,0)); // scope without tag less parts + pScope = scope.left(std::max(si-2,0)); // scope without tag less parts if (!pScope.isEmpty()) pScope.prepend(annScopePrefix); else if (annScopePrefix.length()>2) @@ -10150,7 +10150,7 @@ static int computeIdealCacheParam(uint v) // r = log2(v) // convert to a valid cache size value - return QMAX(0,QMIN(r-16,9)); + return std::max(0,std::min(r-16,9)); } void readConfiguration(int argc, char **argv) diff --git a/src/fortranscanner.l b/src/fortranscanner.l index 0cf49ee..bfab8c2 100755 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -2338,7 +2338,7 @@ static void addModule(yyscan_t yyscanner,const char *name, bool isModule) else { QCString fname = yyextra->fileName; - int index = QMAX(fname.findRev('/'), fname.findRev('\\')); + int index = std::max(fname.findRev('/'), fname.findRev('\\')); fname = fname.right(fname.length()-index-1); fname = fname.prepend("__").append("__"); yyextra->current->name = fname; diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 9ead3fc..ddaa97b 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -15,6 +15,9 @@ * input used in their production; they are not affected by this license. * */ + +#include + #include "htmlattrib.h" #include "latexdocvisitor.h" #include "latexgen.h" @@ -46,7 +49,7 @@ static const char *getSectionName(int level) int l = level; if (compactLatex) l++; if (Doxygen::insideMainPage) l--; - return secLabels[QMIN(maxLevels-1,l)]; + return secLabels[std::min(maxLevels-1,l)]; } static void visitPreStart(std::ostream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage = FALSE) diff --git a/src/pre.l b/src/pre.l index b7797eb..b3758bc 100644 --- a/src/pre.l +++ b/src/pre.l @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -1664,7 +1665,7 @@ static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size) { YY_EXTRA_TYPE state = preYYget_extra(yyscanner); yy_size_t bytesInBuf = state->inputBuf->curPos()-state->inputBufPos; - yy_size_t bytesToCopy = QMIN(max_size,bytesInBuf); + yy_size_t bytesToCopy = std::min(max_size,bytesInBuf); memcpy(buf,state->inputBuf->data()+state->inputBufPos,bytesToCopy); state->inputBufPos+=bytesToCopy; return bytesToCopy; diff --git a/src/qcstring.h b/src/qcstring.h index 7cf6dd3..c5cae37 100644 --- a/src/qcstring.h +++ b/src/qcstring.h @@ -27,16 +27,14 @@ #include #include -const bool FALSE = false; -const bool TRUE = true; +#define FALSE false +#define TRUE true typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned uint; typedef unsigned long ulong; typedef int64_t int64; typedef uint64_t uint64; -#define QMAX(a,b) ((a) > (b) ? (a) : (b)) -#define QMIN(a,b) ((a) < (b) ? (a) : (b)) #define ASSERT(x) if ( !(x) )\ fprintf(stderr,"ASSERT: \"%s\" in %s (%d)",#x,__FILE__,__LINE__) diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index de3d869..5a19fc0 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -16,6 +16,8 @@ * */ +#include + #include "rtfdocvisitor.h" #include "docparser.h" #include "language.h" @@ -862,7 +864,7 @@ void RTFDocVisitor::visitPre(DocSection *s) m_t << "{{" // start section << rtf_Style_Reset; QCString heading; - int level = QMIN(s->level()+1,4); + int level = std::min(s->level()+1,4); heading.sprintf("Heading%d",level); // set style m_t << rtf_Style[heading.str()].reference() << "\n"; @@ -1153,7 +1155,7 @@ void RTFDocVisitor::visitPre(DocHtmlHeader *header) m_t << "{" // start section << rtf_Style_Reset; QCString heading; - int level = QMIN(header->level(),5); + int level = std::min(header->level(),5); heading.sprintf("Heading%d",level); // set style m_t << rtf_Style[heading.str()].reference(); diff --git a/src/util.cpp b/src/util.cpp index c5bc40e..0e73bd3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3311,7 +3311,7 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig) int slashPos; const FileName *fn; if (name.isEmpty()) goto exit; - slashPos=QMAX(name.findRev('/'),name.findRev('\\')); + slashPos=std::max(name.findRev('/'),name.findRev('\\')); if (slashPos!=-1) { path=name.left(slashPos+1); @@ -3371,7 +3371,7 @@ QCString showFileDefMatches(const FileNameLinkedMap *fnMap,const char *n) QCString result; QCString name=n; QCString path; - int slashPos=QMAX(name.findRev('/'),name.findRev('\\')); + int slashPos=std::max(name.findRev('/'),name.findRev('\\')); if (slashPos!=-1) { path=name.left(slashPos+1); diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp index 07ee7ad..f8d2cc3 100644 --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -1769,7 +1769,7 @@ void VhdlDocGen::writeVHDLDeclaration(const MemberDefMutable* mdef,OutputList &o // start a new member declaration uint isAnonymous = (bool)(annoClassDef); // || m_impl->annMemb || m_impl->annEnumType; ///printf("startMemberItem for %s\n",name().data()); - int mm=mdef->getMemberSpecifiers(); + uint64_t mm=mdef->getMemberSpecifiers(); if (mm==VhdlDocGen::MISCELLANEOUS) isAnonymous=3; @@ -2046,7 +2046,7 @@ void VhdlDocGen::writePlainVHDLDeclarations( MemberDefMutable *md = toMemberDefMutable(imd); if (md) { - int mems=md->getMemberSpecifiers(); + uint64_t mems=md->getMemberSpecifiers(); if (md->isBriefSectionVisible() && (mems==specifier) && (mems!=VhdlDocGen::LIBRARY) ) { if (first) { ol.startMemberList();first=FALSE; } -- cgit v0.12