summaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorJinWang An <jinwang.an@samsung.com>2022-12-27 12:33:07 +0900
committerJinWang An <jinwang.an@samsung.com>2022-12-27 12:33:07 +0900
commit9cf4982ab5fc6d964e1a024ff91a72d1fee5dc00 (patch)
treea19f0c024ea91acd7177f41fb5f066023f49027b /src/util.cpp
parent15e5c5601a13a41757e2a5e1a9105d1714d40215 (diff)
downloaddoxygen-9cf4982ab5fc6d964e1a024ff91a72d1fee5dc00.tar.gz
doxygen-9cf4982ab5fc6d964e1a024ff91a72d1fee5dc00.tar.bz2
doxygen-9cf4982ab5fc6d964e1a024ff91a72d1fee5dc00.zip
Imported Upstream version 1.9.4upstream/1.9.4
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp431
1 files changed, 222 insertions, 209 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 9d9cc41..f957181 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -96,7 +96,7 @@ static const char *hex = "0123456789ABCDEF";
// TextGeneratorOLImpl implementation
//------------------------------------------------------------------------
-TextGeneratorOLImpl::TextGeneratorOLImpl(OutputDocInterface &od) : m_od(od)
+TextGeneratorOLImpl::TextGeneratorOLImpl(BaseOutputDocInterface &od) : m_od(od)
{
}
@@ -182,7 +182,7 @@ QCString removeAnonymousScopes(const QCString &str)
// helper to check if the found delimiter ends with a colon
auto endsWithColon = [](const std::string &del)
{
- for (int i=(int)del.size()-1;i>=0;i--)
+ for (int i=static_cast<int>(del.size())-1;i>=0;i--)
{
if (del[i]=='@') return false;
else if (del[i]==':') return true;
@@ -261,20 +261,20 @@ done:
return newScope;
}
-void writePageRef(OutputDocInterface &od,const QCString &cn,const QCString &mn)
+void writePageRef(OutputList &ol,const QCString &cn,const QCString &mn)
{
- od.pushGeneratorState();
+ ol.pushGeneratorState();
- od.disable(OutputGenerator::Html);
- od.disable(OutputGenerator::Man);
- od.disable(OutputGenerator::Docbook);
- if (Config_getBool(PDF_HYPERLINKS)) od.disable(OutputGenerator::Latex);
- if (Config_getBool(RTF_HYPERLINKS)) od.disable(OutputGenerator::RTF);
- od.startPageRef();
- od.docify(theTranslator->trPageAbbreviation());
- od.endPageRef(cn,mn);
+ ol.disable(OutputGenerator::Html);
+ ol.disable(OutputGenerator::Man);
+ ol.disable(OutputGenerator::Docbook);
+ if (Config_getBool(PDF_HYPERLINKS)) ol.disable(OutputGenerator::Latex);
+ if (Config_getBool(RTF_HYPERLINKS)) ol.disable(OutputGenerator::RTF);
+ ol.startPageRef();
+ ol.docify(theTranslator->trPageAbbreviation());
+ ol.endPageRef(cn,mn);
- od.popGeneratorState();
+ ol.popGeneratorState();
}
/*! Generate a place holder for a position in a list. Used for
@@ -377,6 +377,11 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
if (typedefContext) *typedefContext=context;
// see if the qualified name has a scope part
+ if (qualifiedName.find('<')!=-1)
+ {
+ //printf(" templates cannot be typedefs!\n");
+ return result;
+ }
int scopeIndex = qualifiedName.findRev("::");
QCString resName=qualifiedName;
if (scopeIndex!=-1) // strip scope part for the name
@@ -460,7 +465,7 @@ QCString resolveTypeDef(const Definition *context,const QCString &qualifiedName,
if (md)
{
//printf(">>resolveTypeDef: Found typedef name '%s' in scope '%s' value='%s' args='%s'\n",
- // qPrint(qualifiedName),qPrint(context->name()),md->typeString(),md->argsString()
+ // qPrint(qualifiedName),qPrint(context->name()),qPrint(md->typeString()),qPrint(md->argsString())
// );
result=md->typeString();
QCString args = md->argsString();
@@ -552,11 +557,11 @@ QCString removeRedundantWhiteSpace(const QCString &s)
// improve the performance of this function
// and thread_local is needed to make it multi-thread safe
static THREAD_LOCAL char *growBuf = 0;
- static THREAD_LOCAL int growBufLen = 0;
- if ((int)s.length()*3>growBufLen) // For input character we produce at most 3 output characters,
+ static THREAD_LOCAL size_t growBufLen = 0;
+ if (s.length()*3>growBufLen) // For input character we produce at most 3 output characters,
{
growBufLen = s.length()*3;
- growBuf = (char *)realloc(growBuf,growBufLen+1); // add 1 for 0-terminator
+ growBuf = static_cast<char *>(realloc(growBuf,growBufLen+1)); // add 1 for 0-terminator
}
if (growBuf==0) return s; // should not happen, only we run out of memory
@@ -572,7 +577,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
char c;
char pc=0;
// skip leading whitespace
- while (i<l && isspace((uchar)src[i]))
+ while (i<l && isspace(static_cast<uchar>(src[i])))
{
i++;
}
@@ -629,7 +634,6 @@ QCString removeRedundantWhiteSpace(const QCString &s)
case '"': // quoted string
{
*dst++=c;
- pc = c;
i++;
for (;i<l;i++) // find end of string
{
@@ -637,7 +641,6 @@ QCString removeRedundantWhiteSpace(const QCString &s)
*dst++=c;
if (c=='\\' && i+1<l)
{
- pc = c;
i++;
c = src[i];
*dst++=c;
@@ -646,7 +649,6 @@ QCString removeRedundantWhiteSpace(const QCString &s)
{
break;
}
- pc = c;
}
}
break;
@@ -661,7 +663,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
}
break;
case '>': // current char is a >
- if (i>0 && !isspace((uchar)pc) &&
+ if (i>0 && !isspace(static_cast<uchar>(pc)) &&
(isId(pc) || pc=='*' || pc=='&' || pc=='.' || pc=='>') && // prev char is an id char or space or *&.
(osp<8 || (osp==8 && pc!='-')) // string in front is not "operator>" or "operator->"
)
@@ -676,7 +678,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
break;
case ',': // current char is a ,
*dst++=c;
- if (i>0 && !isspace((uchar)pc) &&
+ if (i>0 && !isspace(static_cast<uchar>(pc)) &&
((i<l-1 && (isId(nc) || nc=='[')) || // the [ is for attributes (see bug702170)
(i<l-2 && nc=='$' && isId(src[i+2])) || // for PHP: ',$name' -> ', $name'
(i<l-3 && nc=='&' && src[i+2]=='$' && isId(src[i+3])) // for PHP: ',&$name' -> ', &$name'
@@ -733,7 +735,7 @@ QCString removeRedundantWhiteSpace(const QCString &s)
// else fallthrough
case '@': // '@name' -> ' @name'
case '\'': // ''name' -> '' name'
- if (i>0 && i<l-1 && pc!='=' && pc!=':' && !isspace((uchar)pc) &&
+ if (i>0 && i<l-1 && pc!='=' && pc!=':' && !isspace(static_cast<uchar>(pc)) &&
isId(nc) && osp<8) // ")id" -> ") id"
{
*dst++=' ';
@@ -762,8 +764,8 @@ QCString removeRedundantWhiteSpace(const QCString &s)
case '\n': // fallthrough
case '\t':
{
- if (g_charAroundSpace.charMap[(uchar)pc].before &&
- g_charAroundSpace.charMap[(uchar)nc].after &&
+ if (g_charAroundSpace.charMap[static_cast<uchar>(pc)].before &&
+ g_charAroundSpace.charMap[static_cast<uchar>(nc)].after &&
!(pc==',' && nc=='.') &&
(osp<8 || (osp>=8 && isId(pc) && isId(nc)))
// e.g. 'operator >>' -> 'operator>>',
@@ -782,21 +784,21 @@ QCString removeRedundantWhiteSpace(const QCString &s)
default:
*dst++=c;
if (c=='t' && csp==5 && i<l-1 && // found 't' in 'const'
- !(isId(nc) || nc==')' || nc==',' || isspace((uchar)nc))
+ !(isId(nc) || nc==')' || nc==',' || isspace(static_cast<uchar>(nc)))
) // prevent const ::A from being converted to const::A
{
*dst++=' ';
csp=0;
}
else if (c=='e' && vosp==8 && i<l-1 && // found 'e' in 'volatile'
- !(isId(nc) || nc==')' || nc==',' || isspace((uchar)nc))
+ !(isId(nc) || nc==')' || nc==',' || isspace(static_cast<uchar>(nc)))
) // prevent volatile ::A from being converted to volatile::A
{
*dst++=' ';
vosp=0;
}
else if (c=='l' && vsp==7 && i<l-1 && // found 'l' in 'virtual'
- !(isId(nc) || nc==')' || nc==',' || isspace((uchar)nc))
+ !(isId(nc) || nc==')' || nc==',' || isspace(static_cast<uchar>(nc)))
) // prevent virtual ::A from being converted to virtual::A
{
*dst++=' ';
@@ -1108,7 +1110,7 @@ void writeMarkerList(OutputList &ol,const std::string &markerText,size_t numMark
size_t matchLen = match.length();
ol.parseText(markerText.substr(index,newIndex-index));
unsigned long entryIndex = std::stoul(match[1].str());
- if (entryIndex<(unsigned long)numMarkers)
+ if (entryIndex<static_cast<unsigned long>(numMarkers))
{
replaceFunc(entryIndex);
}
@@ -1140,7 +1142,7 @@ void writeExamples(OutputList &ol,const ExampleList &list)
ol.popGeneratorState();
};
- writeMarkerList(ol, theTranslator->trWriteList((int)list.size()).str(), list.size(), replaceFunc);
+ writeMarkerList(ol, theTranslator->trWriteList(static_cast<int>(list.size())).str(), list.size(), replaceFunc);
ol.writeString(".");
}
@@ -1247,10 +1249,10 @@ QCString tempArgListToString(const ArgumentList &al,SrcLangExt lang,bool include
* converted content (i.e. the same as \a len (Unix, MAC) or
* smaller (DOS).
*/
-static int filterCRLF(char *buf,int len)
+static size_t filterCRLF(char *buf,size_t len)
{
- int src = 0; // source index
- int dest = 0; // destination index
+ size_t src = 0; // source index
+ size_t dest = 0; // destination index
char c; // current character
while (src<len)
@@ -1350,14 +1352,14 @@ QCString getFileFilter(const QCString &name,bool isSourceCode)
QCString transcodeCharacterStringToUTF8(const QCString &input)
{
bool error=FALSE;
- static QCString inputEncoding = Config_getString(INPUT_ENCODING);
+ QCString inputEncoding = Config_getString(INPUT_ENCODING);
const char *outputEncoding = "UTF-8";
if (inputEncoding.isEmpty() || qstricmp(inputEncoding,outputEncoding)==0) return input;
int inputSize=input.length();
int outputSize=inputSize*4+1;
QCString output(outputSize);
void *cd = portable_iconv_open(outputEncoding,inputEncoding.data());
- if (cd==(void *)(-1))
+ if (cd==reinterpret_cast<void *>(-1))
{
err("unsupported character conversion: '%s'->'%s'\n",
qPrint(inputEncoding),outputEncoding);
@@ -1371,7 +1373,7 @@ QCString transcodeCharacterStringToUTF8(const QCString &input)
char *outputPtr = output.rawData();
if (!portable_iconv(cd, &inputPtr, &iLeft, &outputPtr, &oLeft))
{
- outputSize-=(int)oLeft;
+ outputSize-=static_cast<int>(oLeft);
output.resize(outputSize+1);
output.at(outputSize)='\0';
//printf("iconv: input size=%d output size=%d\n[%s]\n",size,newSize,qPrint(srcBuf));
@@ -1397,7 +1399,6 @@ QCString fileToString(const QCString &name,bool filter,bool isSourceCode)
bool fileOpened=false;
if (name[0]=='-' && name[1]==0) // read from stdin
{
- fileOpened=true;
std::string contents;
std::string line;
while (getline(std::cin,line))
@@ -1414,11 +1415,11 @@ QCString fileToString(const QCString &name,bool filter,bool isSourceCode)
err("file '%s' not found\n",qPrint(name));
return "";
}
- BufStr buf((uint)fi.size());
+ BufStr buf(fi.size());
fileOpened=readInputFile(name,buf,filter,isSourceCode);
if (fileOpened)
{
- int s = buf.size();
+ size_t s = buf.size();
if (s>1 && buf.at(s-2)!='\n')
{
buf.at(s-1)='\n';
@@ -1517,7 +1518,7 @@ static void stripIrrelevantString(QCString &target,const QCString &str)
while ((i=target.find(str,p))!=-1)
{
bool isMatch = (i==0 || !isId(target.at(i-1))) && // not a character before str
- (i+l==(int)target.length() || !isId(target.at(i+l))); // not a character after str
+ (i+l==static_cast<int>(target.length()) || !isId(target.at(i+l))); // not a character after str
if (isMatch)
{
int i1=target.find('*',i+l);
@@ -1589,9 +1590,9 @@ static QCString stripDeclKeywords(const QCString &s)
}
// forward decl for circular dependencies
-static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCString type);
+static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCString type,SrcLangExt lang);
-QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QCString& spec)
+static QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QCString& spec,SrcLangExt lang)
{
QCString templSpec = spec.stripWhiteSpace();
@@ -1599,9 +1600,9 @@ QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QC
// std::list<std::string> against list<string> so it is now back again!
if (!templSpec.isEmpty() && templSpec.at(0) == '<')
{
- templSpec = "< " + extractCanonicalType(d,fs,templSpec.right(templSpec.length()-1).stripWhiteSpace());
+ templSpec = "< " + extractCanonicalType(d,fs,templSpec.right(templSpec.length()-1).stripWhiteSpace(),lang);
}
- QCString resolvedType = resolveTypeDef(d,templSpec);
+ QCString resolvedType = lang==SrcLangExt_Java ? templSpec : resolveTypeDef(d,templSpec);
if (!resolvedType.isEmpty()) // not known as a typedef either
{
templSpec = resolvedType;
@@ -1612,14 +1613,14 @@ QCString getCanonicalTemplateSpec(const Definition *d,const FileDef *fs,const QC
static QCString getCanonicalTypeForIdentifier(
- const Definition *d,const FileDef *fs,const QCString &word,
+ const Definition *d,const FileDef *fs,const QCString &word,SrcLangExt lang,
QCString *tSpec,int count=0)
{
if (count>10) return word; // oops recursion
QCString symName,result,templSpec,tmpName;
if (tSpec && !tSpec->isEmpty())
- templSpec = stripDeclKeywords(getCanonicalTemplateSpec(d,fs,*tSpec));
+ templSpec = stripDeclKeywords(getCanonicalTemplateSpec(d,fs,*tSpec,lang));
if (word.findRev("::")!=-1 && !(tmpName=stripScope(word)).isEmpty())
{
@@ -1691,7 +1692,7 @@ static QCString getCanonicalTypeForIdentifier(
else if (!ts.isEmpty() && templSpec.isEmpty())
{
// use formal template args for spec
- templSpec = stripDeclKeywords(getCanonicalTemplateSpec(d,fs,ts));
+ templSpec = stripDeclKeywords(getCanonicalTemplateSpec(d,fs,ts,lang));
}
result = removeRedundantWhiteSpace(cd->qualifiedName() + templSpec);
@@ -1734,7 +1735,7 @@ static QCString getCanonicalTypeForIdentifier(
type.stripPrefix("typename ");
type = stripTemplateSpecifiersFromScope(type,FALSE);
}
- result = getCanonicalTypeForIdentifier(d,fs,type,tSpec,count+1);
+ result = getCanonicalTypeForIdentifier(d,fs,type,mType->getLanguage(),tSpec,count+1);
}
else
{
@@ -1743,7 +1744,7 @@ static QCString getCanonicalTypeForIdentifier(
}
else // fallback
{
- resolvedType = resolveTypeDef(d,word);
+ resolvedType = lang==SrcLangExt_Java ? word : resolveTypeDef(d,word);
//printf("typedef [%s]->[%s]\n",qPrint(word),qPrint(resolvedType));
if (resolvedType.isEmpty()) // not known as a typedef either
{
@@ -1758,7 +1759,7 @@ static QCString getCanonicalTypeForIdentifier(
return result;
}
-static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCString type)
+static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCString type,SrcLangExt lang)
{
type = type.stripWhiteSpace();
@@ -1785,7 +1786,7 @@ static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCStr
//printf(" i=%d p=%d\n",i,p);
if (i>pp) canType += type.mid(pp,i-pp);
- QCString ct = getCanonicalTypeForIdentifier(d,fs,word,&templSpec);
+ QCString ct = getCanonicalTypeForIdentifier(d,fs,word,lang,&templSpec);
// in case the ct is empty it means that "word" represents scope "d"
// and this does not need to be added to the canonical
@@ -1819,7 +1820,7 @@ static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCStr
size_t tl = match.length();
std::string matchStr = match.str();
canType += ts.substr(tp,ti-tp);
- canType += getCanonicalTypeForIdentifier(d,fs,matchStr.c_str(),0);
+ canType += getCanonicalTypeForIdentifier(d,fs,matchStr.c_str(),lang,0);
tp=ti+tl;
}
canType+=ts.substr(tp);
@@ -1833,7 +1834,7 @@ static QCString extractCanonicalType(const Definition *d,const FileDef *fs,QCStr
return removeRedundantWhiteSpace(canType);
}
-static QCString extractCanonicalArgType(const Definition *d,const FileDef *fs,const Argument &arg)
+static QCString extractCanonicalArgType(const Definition *d,const FileDef *fs,const Argument &arg,SrcLangExt lang)
{
QCString type = arg.type.stripWhiteSpace();
QCString name = arg.name;
@@ -1853,12 +1854,13 @@ static QCString extractCanonicalArgType(const Definition *d,const FileDef *fs,co
type+=arg.array;
}
- return extractCanonicalType(d,fs,type);
+ return extractCanonicalType(d,fs,type,lang);
}
static bool matchArgument2(
const Definition *srcScope,const FileDef *srcFileScope,Argument &srcA,
- const Definition *dstScope,const FileDef *dstFileScope,Argument &dstA
+ const Definition *dstScope,const FileDef *dstFileScope,Argument &dstA,
+ SrcLangExt lang
)
{
//printf(">> match argument: %s::'%s|%s' (%s) <-> %s::'%s|%s' (%s)\n",
@@ -1896,8 +1898,8 @@ static bool matchArgument2(
if (srcA.canType.isEmpty() || dstA.canType.isEmpty())
{
// need to re-evaluate both see issue #8370
- srcA.canType = extractCanonicalArgType(srcScope,srcFileScope,srcA);
- dstA.canType = extractCanonicalArgType(dstScope,dstFileScope,dstA);
+ srcA.canType = extractCanonicalArgType(srcScope,srcFileScope,srcA,lang);
+ dstA.canType = extractCanonicalArgType(dstScope,dstFileScope,dstA,lang);
}
if (srcA.canType==dstA.canType)
@@ -1917,8 +1919,8 @@ static bool matchArgument2(
// new algorithm for argument matching
bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,const ArgumentList *srcAl,
- const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList *dstAl,
- bool checkCV)
+ const Definition *dstScope,const FileDef *dstFileScope,const ArgumentList *dstAl,
+ bool checkCV,SrcLangExt lang)
{
ASSERT(srcScope!=0 && dstScope!=0);
@@ -1990,7 +1992,8 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons
Argument &srcA = const_cast<Argument&>(*srcIt);
Argument &dstA = const_cast<Argument&>(*dstIt);
if (!matchArgument2(srcScope,srcFileScope,srcA,
- dstScope,dstFileScope,dstA)
+ dstScope,dstFileScope,dstA,
+ lang)
)
{
NOMATCH
@@ -2002,7 +2005,6 @@ bool matchArguments2(const Definition *srcScope,const FileDef *srcFileScope,cons
}
-
// merges the initializer of two argument lists
// pre: the types of the arguments in the list should match.
void mergeArguments(ArgumentList &srcAl,ArgumentList &dstAl,bool forceNameOverwrite)
@@ -2172,7 +2174,7 @@ static void findMembersWithSpecificName(const MemberName *mn,
match=matchArguments2(
md->getOuterScope(),fd,&mdAl,
Doxygen::globalScope,fd,argList_p.get(),
- checkCV);
+ checkCV,md->getLanguage());
}
if (match)
{
@@ -2246,7 +2248,7 @@ bool getDefs(const QCString &scName,
if (memberName.left(9)!="operator " && // treat operator conversion methods
// as a special case
(im=memberName.findRev("::"))!=-1 &&
- im<(int)memberName.length()-2 // not A::
+ im<static_cast<int>(memberName.length())-2 // not A::
)
{
mScope=memberName.left(im);
@@ -2310,7 +2312,7 @@ bool getDefs(const QCString &scName,
bool match = args.isEmpty() ||
matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),&mmdAl,
fcd, fcd->getFileDef(),argList.get(),
- checkCV);
+ checkCV,mmd->getLanguage());
//printf("match=%d\n",match);
if (match)
{
@@ -2433,9 +2435,8 @@ bool getDefs(const QCString &scName,
const ArgumentList &mmdAl = mmd->argumentList();
if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),&mmdAl,
- Doxygen::globalScope,mmd->getFileDef(),argList.get(),
- checkCV
- )
+ Doxygen::globalScope,mmd->getFileDef(),argList.get(),
+ checkCV,mmd->getLanguage())
)
{
fuzzy_mmd = mmd;
@@ -2520,7 +2521,7 @@ bool getDefs(const QCString &scName,
match=matchArguments2(
mmd->getOuterScope(),mmd->getFileDef(),&mmdAl,
fnd,mmd->getFileDef(),argList_p.get(),
- checkCV);
+ checkCV,mmd->getLanguage());
}
if (match)
{
@@ -2696,7 +2697,7 @@ static bool getScopeDefs(const QCString &docScope,const QCString &scope,
cd=0;nd=0;
QCString scopeName=scope;
- //printf("getScopeDefs: docScope='%s' scope='%s'\n",docScope,scope);
+ //printf("getScopeDefs: docScope='%s' scope='%s'\n",qPrint(docScope),qPrint(scope));
if (scopeName.isEmpty()) return FALSE;
bool explicitGlobalScope=FALSE;
@@ -2719,8 +2720,7 @@ static bool getScopeDefs(const QCString &docScope,const QCString &scope,
if (scopeOffset>0) fullName.prepend(docScopeName.left(scopeOffset)+"::");
if (((cd=getClass(fullName)) || // normal class
- (cd=getClass(fullName+"-p")) //|| // ObjC protocol
- //(cd=getClass(fullName+"-g")) // C# generic
+ (cd=getClass(fullName+"-p")) // ObjC protocol
) && cd->isLinkable())
{
return TRUE; // class link written => quit
@@ -2745,9 +2745,9 @@ static bool getScopeDefs(const QCString &docScope,const QCString &scope,
static bool isLowerCase(QCString &s)
{
if (s.isEmpty()) return true;
- uchar *p=(uchar*)s.data();
+ const char *p=s.data();
int c;
- while ((c=*p++)) if (!islower(c)) return false;
+ while ((c=static_cast<uchar>(*p++))) if (!islower(c)) return false;
return true;
}
@@ -2802,11 +2802,12 @@ bool resolveRef(/* in */ const QCString &scName,
return FALSE;
}
- //printf("scName=%s fullName=%s\n",scName,qPrint(fullName));
+ //printf("scName=%s fullName=%s\n",qPrint(scName),qPrint(fullName));
// check if this is a class or namespace reference
if (scName!=fullName && getScopeDefs(scName,fullName,cd,nd))
{
+ //printf("found scopeDef\n");
if (cd) // scope matches that of a class
{
*resContext = cd;
@@ -2823,7 +2824,7 @@ bool resolveRef(/* in */ const QCString &scName,
{
//printf("found scName=%s fullName=%s scName==fullName=%d "
// "inSeeBlock=%d scopePos=%d!\n",
- // scName,qPrint(fullName),scName==fullName,inSeeBlock,scopePos);
+ // qPrint(scName),qPrint(fullName),scName==fullName,inSeeBlock,scopePos);
return FALSE;
}
// continue search...
@@ -2942,7 +2943,7 @@ bool resolveRef(/* in */ const QCString &scName,
QCString linkToText(SrcLangExt lang,const QCString &link,bool isFileName)
{
- //static bool optimizeOutputJava = Config_getBool(OPTIMIZE_OUTPUT_JAVA);
+ //bool optimizeOutputJava = Config_getBool(OPTIMIZE_OUTPUT_JAVA);
QCString result=link;
if (!result.isEmpty())
{
@@ -2984,7 +2985,7 @@ QCString linkToText(SrcLangExt lang,const QCString &link,bool isFileName)
* instead of :: the \# symbol may also be used.
*/
-bool generateRef(OutputDocInterface &od,const char *scName,
+bool generateRef(BaseOutputDocInterface &od,const char *scName,
const char *name,bool inSeeBlock,const char *rt)
{
//printf("generateRef(scName=%s,name=%s,inSee=%d,rt=%s)\n",scName,name,inSeeBlock,rt);
@@ -3148,7 +3149,7 @@ bool resolveLink(/* in */ const QCString &scName,
// basis for the link's text.
// returns TRUE if a link could be generated.
-bool generateLink(OutputDocInterface &od,const QCString &clName,
+bool generateLink(OutputList &ol,const QCString &clName,
const QCString &lr,bool inSeeBlock,const QCString &lt)
{
//printf("generateLink(clName=%s,lr=%s,lr=%s)\n",clName,lr,lt);
@@ -3170,11 +3171,11 @@ bool generateLink(OutputDocInterface &od,const QCString &clName,
{
linkText=linkToText(compound->getLanguage(),lt,TRUE);
}
- od.writeObjectLink(compound->getReference(),
+ ol.writeObjectLink(compound->getReference(),
compound->getOutputFileBase(),anchor,linkText);
if (!compound->isReference())
{
- writePageRef(od,compound->getOutputFileBase(),anchor);
+ writePageRef(ol,compound->getOutputFileBase(),anchor);
}
}
else
@@ -3185,12 +3186,12 @@ bool generateLink(OutputDocInterface &od,const QCString &clName,
}
else // link could not be found
{
- od.docify(linkText);
+ ol.docify(linkText);
return FALSE;
}
}
-void generateFileRef(OutputDocInterface &od,const QCString &name,const QCString &text)
+void generateFileRef(OutputList &ol,const QCString &name,const QCString &text)
{
//printf("generateFileRef(%s,%s)\n",name,text);
QCString linkText = text.isEmpty() ? text : name;
@@ -3200,9 +3201,9 @@ void generateFileRef(OutputDocInterface &od,const QCString &name,const QCString
if ((fd=findFileDef(Doxygen::inputNameLinkedMap,name,ambig)) &&
fd->isLinkable())
// link to documented input file
- od.writeObjectLink(fd->getReference(),fd->getOutputFileBase(),QCString(),linkText);
+ ol.writeObjectLink(fd->getReference(),fd->getOutputFileBase(),QCString(),linkText);
else
- od.docify(linkText);
+ ol.docify(linkText);
}
//----------------------------------------------------------------------
@@ -3228,7 +3229,7 @@ FileDef *findFileDef(const FileNameLinkedMap *fnMap,const QCString &n,bool &ambi
const int maxAddrSize = 20;
char addr[maxAddrSize];
- qsnprintf(addr,maxAddrSize,"%p:",(void*)fnMap);
+ qsnprintf(addr,maxAddrSize,"%p:",reinterpret_cast<const void*>(fnMap));
QCString key = addr;
key+=n;
@@ -3496,7 +3497,7 @@ QCString escapeCharsInString(const QCString &name,bool allowDots,bool allowUnder
if (doEscape) // not a valid unicode char or escaping needed
{
char ids[5];
- unsigned char id = (unsigned char)c;
+ unsigned char id = static_cast<unsigned char>(c);
ids[0]='_';
ids[1]='x';
ids[2]=hex[id>>4];
@@ -3512,7 +3513,7 @@ QCString escapeCharsInString(const QCString &name,bool allowDots,bool allowUnder
else
{
growBuf.addChar('_');
- growBuf.addChar((char)tolower(c));
+ growBuf.addChar(static_cast<char>(tolower(c)));
}
break;
}
@@ -3574,7 +3575,7 @@ QCString unescapeCharsInString(const QCString &s)
default:
if (!caseSenseNames && c>='a' && c<='z') // lower to upper case escape, _a -> 'A'
{
- result+=(char)toupper(*p);
+ result+=static_cast<char>(toupper(*p));
p++;
}
else // unknown escape, pass underscore character as-is
@@ -3597,6 +3598,8 @@ static std::unordered_map<std::string,int> g_usedNames;
static std::mutex g_usedNamesMutex;
static int g_usedNamesCount=1;
+
+
/*! This function determines the file name on disk of an item
* given its name, which could be a class name with template
* arguments, so special characters need to be escaped.
@@ -3604,8 +3607,8 @@ static int g_usedNamesCount=1;
QCString convertNameToFile(const QCString &name,bool allowDots,bool allowUnderscore)
{
if (name.isEmpty()) return name;
- static bool shortNames = Config_getBool(SHORT_NAMES);
- static bool createSubdirs = Config_getBool(CREATE_SUBDIRS);
+ bool shortNames = Config_getBool(SHORT_NAMES);
+ bool createSubdirs = Config_getBool(CREATE_SUBDIRS);
QCString result;
if (shortNames) // use short names only
{
@@ -3632,7 +3635,7 @@ QCString convertNameToFile(const QCString &name,bool allowDots,bool allowUndersc
// third algorithm based on MD5 hash
uchar md5_sig[16];
char sigStr[33];
- MD5Buffer((const unsigned char *)result.data(),resultLen,md5_sig);
+ MD5Buffer(result.data(),resultLen,md5_sig);
MD5SigToString(md5_sig,sigStr);
result=result.left(128-32)+sigStr;
}
@@ -3640,12 +3643,14 @@ QCString convertNameToFile(const QCString &name,bool allowDots,bool allowUndersc
if (createSubdirs)
{
int l1Dir=0,l2Dir=0;
+ int createSubdirsLevel = Config_getInt(CREATE_SUBDIRS_LEVEL);
+ int createSubdirsBitmaskL2 = (1<<createSubdirsLevel)-1;
// compute md5 hash to determine sub directory to use
uchar md5_sig[16];
- MD5Buffer((const unsigned char *)result.data(),result.length(),md5_sig);
- l1Dir = md5_sig[14]&0xf;
- l2Dir = md5_sig[15];
+ MD5Buffer(result.data(),result.length(),md5_sig);
+ l1Dir = md5_sig[14] & 0xf;
+ l2Dir = md5_sig[15] & createSubdirsBitmaskL2;
result.prepend(QCString().sprintf("d%x/d%02x/",l1Dir,l2Dir));
}
@@ -3678,7 +3683,8 @@ void createSubDirs(const Dir &d)
{
if (Config_getBool(CREATE_SUBDIRS))
{
- // create 4096 subdirectories
+ // create up to 4096 subdirectories
+ int createSubdirsLevelPow2 = 1 << Config_getInt(CREATE_SUBDIRS_LEVEL);
int l1,l2;
for (l1=0;l1<16;l1++)
{
@@ -3688,7 +3694,7 @@ void createSubDirs(const Dir &d)
{
term("Failed to create output directory '%s'\n",qPrint(subdir));
}
- for (l2=0;l2<256;l2++)
+ for (l2=0; l2 < createSubdirsLevelPow2; l2++)
{
QCString subsubdir;
subsubdir.sprintf("d%x/d%02x",l1,l2);
@@ -3706,11 +3712,12 @@ void clearSubDirs(const Dir &d)
if (Config_getBool(CREATE_SUBDIRS))
{
// remove empty subdirectories
+ int createSubdirsLevelPow2 = 1 << Config_getInt(CREATE_SUBDIRS_LEVEL);
for (int l1=0;l1<16;l1++)
{
QCString subdir;
subdir.sprintf("d%x",l1);
- for (int l2=0;l2<256;l2++)
+ for (int l2=0; l2 < createSubdirsLevelPow2; l2++)
{
QCString subsubdir;
subsubdir.sprintf("d%x/d%02x",l1,l2);
@@ -3923,8 +3930,8 @@ QCString convertToId(const QCString &s)
else
{
encChar[0]='_';
- encChar[1]=hex[((unsigned char)c)>>4];
- encChar[2]=hex[((unsigned char)c)&0xF];
+ encChar[1]=hex[static_cast<unsigned char>(c)>>4];
+ encChar[2]=hex[static_cast<unsigned char>(c)&0xF];
encChar[3]=0;
growBuf.addStr(encChar);
}
@@ -4000,9 +4007,9 @@ QCString convertToDocBook(const QCString &s, const bool retainNewline)
{
if (s.isEmpty()) return s;
GrowBuf growBuf;
- const unsigned char *q;
+ const char *q;
int cnt;
- const unsigned char *p=(const unsigned char *)s.data();
+ const char *p=s.data();
char c;
while ((c=*p++))
{
@@ -4022,8 +4029,8 @@ QCString convertToDocBook(const QCString &s, const bool retainNewline)
if (*q == ';')
{
--p; // we need & as well
- DocSymbol::SymType res = HtmlEntityMapper::instance()->name2sym(QCString((char *)p).left(cnt));
- if (res == DocSymbol::Sym_Unknown)
+ HtmlEntityMapper::SymType res = HtmlEntityMapper::instance()->name2sym(QCString(p).left(cnt));
+ if (res == HtmlEntityMapper::Sym_Unknown)
{
p++;
growBuf.addStr("&amp;");
@@ -4189,9 +4196,9 @@ QCString convertCharEntitiesToUTF8(const QCString &str)
growBuf.addStr(s.substr(i,p-i));
}
QCString entity(match.str());
- DocSymbol::SymType symType = HtmlEntityMapper::instance()->name2sym(entity);
+ HtmlEntityMapper::SymType symType = HtmlEntityMapper::instance()->name2sym(entity);
const char *code=0;
- if (symType!=DocSymbol::Sym_Unknown && (code=HtmlEntityMapper::instance()->utf8(symType)))
+ if (symType!=HtmlEntityMapper::Sym_Unknown && (code=HtmlEntityMapper::instance()->utf8(symType)))
{
growBuf.addStr(code);
}
@@ -4338,14 +4345,14 @@ void addMembersToMemberGroup(MemberList *ml,
*/
int extractClassNameFromType(const QCString &type,int &pos,QCString &name,QCString &templSpec,SrcLangExt lang)
{
- static reg::Ex re_norm(R"(\a[\w:]*)");
- static reg::Ex re_fortran(R"(\a[\w:()=]*)");
+ static const reg::Ex re_norm(R"(\a[\w:]*)");
+ static const reg::Ex re_fortran(R"(\a[\w:()=]*)");
static const reg::Ex *re = &re_norm;
name.resize(0);
templSpec.resize(0);
if (type.isEmpty()) return -1;
- int typeLen=(int)type.length();
+ size_t typeLen=type.length();
if (typeLen>0)
{
if (lang == SrcLangExt_Fortran)
@@ -4357,33 +4364,33 @@ int extractClassNameFromType(const QCString &type,int &pos,QCString &name,QCStri
}
}
std::string s = type.str();
- reg::Iterator it(s,*re,(int)pos);
+ reg::Iterator it(s,*re,static_cast<int>(pos));
reg::Iterator end;
if (it!=end)
{
const auto &match = *it;
- int i = (int)match.position();
- int l = (int)match.length();
- int ts = i+l;
- int te = ts;
- int tl = 0;
+ size_t i = match.position();
+ size_t l = match.length();
+ size_t ts = i+l;
+ size_t te = ts;
+ size_t tl = 0;
- while (ts<typeLen && type[ts]==' ') ts++,tl++; // skip any whitespace
- if (ts<typeLen && type[ts]=='<') // assume template instance
+ while (ts<typeLen && type[static_cast<uint>(ts)]==' ') ts++,tl++; // skip any whitespace
+ if (ts<typeLen && type[static_cast<uint>(ts)]=='<') // assume template instance
{
// locate end of template
te=ts+1;
int brCount=1;
while (te<typeLen && brCount!=0)
{
- if (type[te]=='<')
+ if (type[static_cast<uint>(te)]=='<')
{
- if (te<typeLen-1 && type[te+1]=='<') te++; else brCount++;
+ if (te<typeLen-1 && type[static_cast<uint>(te)+1]=='<') te++; else brCount++;
}
- if (type[te]=='>')
+ if (type[static_cast<uint>(te)]=='>')
{
- if (te<typeLen-1 && type[te+1]=='>') te++; else brCount--;
+ if (te<typeLen-1 && type[static_cast<uint>(te)+1]=='>') te++; else brCount--;
}
te++;
}
@@ -4393,18 +4400,18 @@ int extractClassNameFromType(const QCString &type,int &pos,QCString &name,QCStri
{
templSpec = QCString(type).mid(ts,te-ts);
tl+=te-ts;
- pos=i+l+tl;
+ pos=static_cast<int>(i+l+tl);
}
else // no template part
{
- pos=i+l;
+ pos=static_cast<int>(i+l);
}
//printf("extractClassNameFromType([in] type=%s,[out] pos=%d,[out] name=%s,[out] templ=%s)=TRUE i=%d\n",
// qPrint(type),pos,qPrint(name),qPrint(templSpec),i);
- return i;
+ return static_cast<int>(i);
}
}
- pos = typeLen;
+ pos = static_cast<int>(typeLen);
//printf("extractClassNameFromType([in] type=%s,[out] pos=%d,[out] name=%s,[out] templ=%s)=FALSE\n",
// qPrint(type),pos,qPrint(name),qPrint(templSpec));
return -1;
@@ -4937,14 +4944,14 @@ void filterLatexString(TextStream &t,const QCString &str,
{
if (str.isEmpty()) return;
//if (strlen(str)<2) stackTrace();
- const unsigned char *p=(const unsigned char *)str.data();
- const unsigned char *q;
+ const char *p=str.data();
+ const char *q;
int cnt;
unsigned char c;
unsigned char pc='\0';
while (*p)
{
- c=*p++;
+ c=static_cast<unsigned char>(*p++);
if (insidePre)
{
@@ -4952,13 +4959,13 @@ void filterLatexString(TextStream &t,const QCString &str,
{
case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd
// the LaTeX command \ucr has been defined in doxygen.sty
- if ((unsigned char)*(p) == 0xbf && (unsigned char)*(p+1) == 0xbd)
+ if (static_cast<unsigned char>(*(p)) == 0xbf && static_cast<unsigned char>(*(p+1)) == 0xbd)
{
t << "{\\ucr}";
p += 2;
}
else
- t << (char)c;
+ t << static_cast<char>(c);
break;
case '\\': t << "\\(\\backslash\\)"; break;
case '{': t << "\\{"; break;
@@ -4970,7 +4977,7 @@ void filterLatexString(TextStream &t,const QCString &str,
case '$': t << "\\$"; break;
case '"': t << "\"{}"; break;
case '-': t << "-\\/"; break;
- case '^': insideTable ? t << "\\string^" : t << (char)c; break;
+ case '^': insideTable ? t << "\\string^" : t << static_cast<char>(c); break;
case '~': t << "\\string~"; break;
case '\n': if (retainNewline) t << "\\newline"; else t << ' ';
break;
@@ -4978,7 +4985,7 @@ void filterLatexString(TextStream &t,const QCString &str,
break;
default:
if (c<32) t << ' '; // non printable control character
- else t << (char)c;
+ else t << static_cast<char>(c);
break;
}
}
@@ -4988,13 +4995,13 @@ void filterLatexString(TextStream &t,const QCString &str,
{
case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd
// the LaTeX command \ucr has been defined in doxygen.sty
- if ((unsigned char)*(p) == 0xbf && (unsigned char)*(p+1) == 0xbd)
+ if (static_cast<unsigned char>(*(p)) == 0xbf && static_cast<unsigned char>(*(p+1)) == 0xbd)
{
t << "{\\ucr}";
p += 2;
}
else
- t << (char)c;
+ t << static_cast<char>(c);
break;
case '#': t << "\\#"; break;
case '$': t << "\\$"; break;
@@ -5011,8 +5018,8 @@ void filterLatexString(TextStream &t,const QCString &str,
if (*q == ';')
{
--p; // we need & as well
- DocSymbol::SymType res = HtmlEntityMapper::instance()->name2sym(QCString((char *)p).left(cnt));
- if (res == DocSymbol::Sym_Unknown)
+ HtmlEntityMapper::SymType res = HtmlEntityMapper::instance()->name2sym(QCString(p).left(cnt));
+ if (res == HtmlEntityMapper::Sym_Unknown)
{
p++;
t << "\\&";
@@ -5080,7 +5087,7 @@ void filterLatexString(TextStream &t,const QCString &str,
}
else
{
- t << (char)c;
+ t << static_cast<char>(c);
}
}
}
@@ -5203,7 +5210,7 @@ QCString latexFilterURL(const QCString &s)
{
if (s.isEmpty()) return s;
TextStream t;
- const signed char *p=(const signed char*)s.data();
+ const char *p=s.data();
char c;
while ((c=*p++))
{
@@ -5215,7 +5222,7 @@ QCString latexFilterURL(const QCString &s)
default:
if (c<0)
{
- unsigned char id = (unsigned char)c;
+ unsigned char id = static_cast<unsigned char>(c);
t << "\\%" << hex[id>>4] << hex[id&0xF];
}
else
@@ -5280,7 +5287,7 @@ bool checkExtension(const QCString &fName, const QCString &ext)
QCString addHtmlExtensionIfMissing(const QCString &fName)
{
if (fName.isEmpty()) return fName;
- if (fName.find('.')==-1) // no extension
+ if (stripPath(fName).find('.')==-1) // no extension
{
return QCString(fName)+Doxygen::htmlFileExtension;
}
@@ -5468,7 +5475,7 @@ g_lang2extMap[] =
{ "sql", "sql", SrcLangExt_SQL, ".sql" },
{ "md", "md", SrcLangExt_Markdown, ".md" },
{ "lex", "lex", SrcLangExt_Lex, ".l" },
- { 0, 0, (SrcLangExt)0, 0 }
+ { 0, 0, static_cast<SrcLangExt>(0),0}
};
bool updateLanguageMapping(const QCString &extension,const QCString &language)
@@ -5587,7 +5594,7 @@ SrcLangExt getLanguageFromFileName(const QCString& fileName, SrcLangExt defLang)
if (it!=g_extLookup.end()) // listed extension
{
//printf("getLanguageFromFileName(%s)=%x\n",qPrint(fi.extension()),*pVal);
- return (SrcLangExt)it->second;
+ return static_cast<SrcLangExt>(it->second);
}
//printf("getLanguageFromFileName(%s) not found!\n",qPrint(fileName));
return defLang; // not listed => assume C-ish language.
@@ -5699,17 +5706,17 @@ bool checkIfTypedef(const Definition *scope,const FileDef *fileScope,const QCStr
static int nextUTF8CharPosition(const QCString &utf8Str,uint len,uint startPos)
{
if (startPos>=len) return len;
- uchar c = (uchar)utf8Str[startPos];
+ uchar c = static_cast<uchar>(utf8Str[startPos]);
int bytes=getUTF8CharNumBytes(c);
if (c=='&') // skip over character entities
{
bytes=1;
int (*matcher)(int) = 0;
- c = (uchar)utf8Str[startPos+bytes];
+ c = static_cast<uchar>(utf8Str[startPos+bytes]);
if (c=='#') // numerical entity?
{
bytes++;
- c = (uchar)utf8Str[startPos+bytes];
+ c = static_cast<uchar>(utf8Str[startPos+bytes]);
if (c=='x') // hexadecimal entity?
{
bytes++;
@@ -5727,7 +5734,7 @@ static int nextUTF8CharPosition(const QCString &utf8Str,uint len,uint startPos)
}
if (matcher)
{
- while ((c = (uchar)utf8Str[startPos+bytes])!=0 && matcher(c))
+ while ((c = static_cast<uchar>(utf8Str[startPos+bytes]))!=0 && matcher(c))
{
bytes++;
}
@@ -5746,13 +5753,17 @@ QCString parseCommentAsText(const Definition *scope,const MemberDef *md,
if (doc.isEmpty()) return "";
//printf("parseCommentAsText(%s)\n",qPrint(doc));
TextStream t;
- std::unique_ptr<IDocParser> parser { createDocParser() };
- std::unique_ptr<DocRoot> root { validatingParseDoc(*parser.get(),
- fileName,lineNr,
- (Definition*)scope,(MemberDef*)md,doc,FALSE,FALSE,
- QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)) };
- auto visitor = std::make_unique<TextDocVisitor>(t);
- root->accept(visitor.get());
+ auto parser { createDocParser() };
+ auto ast { validatingParseDoc(*parser.get(),
+ fileName,lineNr,
+ const_cast<Definition*>(scope),const_cast<MemberDef*>(md),doc,FALSE,FALSE,
+ QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)) };
+ auto astImpl = dynamic_cast<const DocNodeAST*>(ast.get());
+ if (astImpl)
+ {
+ TextDocVisitor visitor(t);
+ std::visit(visitor,astImpl->root);
+ }
QCString result = convertCharEntitiesToUTF8(t.str().c_str()).stripWhiteSpace();
int i=0;
int charCnt=0;
@@ -5788,10 +5799,10 @@ static QCString expandAliasRec(StringUnorderedSet &aliasesProcessed,
struct Marker
{
- Marker(int p, int n,int s) : pos(p),number(n),size(s) {}
- int pos; // position in the string
+ Marker(size_t p, int n,size_t s) : pos(p),number(n),size(s) {}
+ size_t pos; // position in the string
int number; // argument number
- int size; // size of the marker
+ size_t size; // size of the marker
};
/** For a string \a s that starts with a command name, returns the character
@@ -5817,7 +5828,7 @@ static int findEndOfCommand(const char *s)
QCString args = extractAliasArgs(p,0);
i+=args.length();
}
- i+=(int)(p-s);
+ i+=static_cast<int>(p-s);
}
return i;
}
@@ -5833,8 +5844,8 @@ static QCString replaceAliasArguments(StringUnorderedSet &aliasesProcessed,
// first make a list of arguments from the comma separated argument list
std::vector<QCString> args;
- int i,l=(int)argList.length();
- int s=0;
+ size_t i,l=argList.length();
+ size_t s=0;
for (i=0;i<l;i++)
{
char c = argList.at(i);
@@ -5857,7 +5868,7 @@ static QCString replaceAliasArguments(StringUnorderedSet &aliasesProcessed,
l = aliasValue.length();
char pc='\0';
bool insideMarkerId=false;
- int markerStart=0;
+ size_t markerStart=0;
auto isDigit = [](char c) { return c>='0' && c<='9'; };
for (i=0;i<=l;i++)
{
@@ -5865,7 +5876,7 @@ static QCString replaceAliasArguments(StringUnorderedSet &aliasesProcessed,
if (insideMarkerId && !isDigit(c)) // found end of a markerId
{
insideMarkerId = false;
- int markerLen = i-markerStart;
+ size_t markerLen = i-markerStart;
markerList.push_back(Marker(markerStart-1,
aliasValue.mid(markerStart,markerLen).toInt(),
markerLen+1));
@@ -5888,13 +5899,13 @@ static QCString replaceAliasArguments(StringUnorderedSet &aliasesProcessed,
// then we replace the markers with the corresponding arguments in one pass
QCString result;
- int p=0;
- for (i=0;i<(int)markerList.size();i++)
+ size_t p=0;
+ for (i=0;i<markerList.size();i++)
{
const Marker &m = markerList.at(i);
result+=aliasValue.mid(p,m.pos-p);
//printf("part before marker %d: '%s'\n",i,qPrint(aliasValue.mid(p,m->pos-p)));
- if (m.number>0 && m.number<=(int)args.size()) // valid number
+ if (m.number>0 && m.number<=static_cast<int>(args.size())) // valid number
{
result+=expandAliasRec(aliasesProcessed,args.at(m.number-1),TRUE);
//printf("marker index=%d pos=%d number=%d size=%d replacement %s\n",i,m->pos,m->number,m->size,
@@ -6124,28 +6135,28 @@ void stackTrace()
#endif
}
-static int transcodeCharacterBuffer(const QCString &fileName,BufStr &srcBuf,int size,
+static size_t transcodeCharacterBuffer(const QCString &fileName,BufStr &srcBuf,size_t size,
const QCString &inputEncoding,const QCString &outputEncoding)
{
if (inputEncoding.isEmpty() || outputEncoding.isEmpty()) return size;
if (qstricmp(inputEncoding,outputEncoding)==0) return size;
void *cd = portable_iconv_open(outputEncoding.data(),inputEncoding.data());
- if (cd==(void *)(-1))
+ if (cd==reinterpret_cast<void *>(-1))
{
term("unsupported character conversion: '%s'->'%s': %s\n"
"Check the INPUT_ENCODING setting in the config file!\n",
qPrint(inputEncoding),qPrint(outputEncoding),strerror(errno));
}
- int tmpBufSize=size*4+1;
+ size_t tmpBufSize=size*4+1;
BufStr tmpBuf(tmpBufSize);
size_t iLeft=size;
size_t oLeft=tmpBufSize;
const char *srcPtr = srcBuf.data();
char *dstPtr = tmpBuf.data();
- uint newSize=0;
+ size_t newSize=0;
if (!portable_iconv(cd, &srcPtr, &iLeft, &dstPtr, &oLeft))
{
- newSize = tmpBufSize-(int)oLeft;
+ newSize = tmpBufSize-oLeft;
srcBuf.shrink(newSize);
strncpy(srcBuf.data(),tmpBuf.data(),newSize);
//printf("iconv: input size=%d output size=%d\n[%s]\n",size,newSize,qPrint(srcBuf));
@@ -6163,7 +6174,7 @@ static int transcodeCharacterBuffer(const QCString &fileName,BufStr &srcBuf,int
bool readInputFile(const QCString &fileName,BufStr &inBuf,bool filter,bool isSourceCode)
{
// try to open file
- int size=0;
+ size_t size=0;
FileInfo fi(fileName.str());
if (!fi.exists()) return FALSE;
@@ -6176,7 +6187,7 @@ bool readInputFile(const QCString &fileName,BufStr &inBuf,bool filter,bool isSou
err("could not open file %s\n",qPrint(fileName));
return FALSE;
}
- size=(int)fi.size();
+ size=fi.size();
// read the file
inBuf.skip(size);
f.read(inBuf.data(),size);
@@ -6199,7 +6210,7 @@ bool readInputFile(const QCString &fileName,BufStr &inBuf,bool filter,bool isSou
const int bufSize=1024;
char buf[bufSize];
int numRead;
- while ((numRead=(int)fread(buf,1,bufSize,f))>0)
+ while ((numRead=static_cast<int>(fread(buf,1,bufSize,f)))>0)
{
//printf(">>>>>>>>Reading %d bytes\n",numRead);
inBuf.addArray(buf,numRead),size+=numRead;
@@ -6212,23 +6223,25 @@ bool readInputFile(const QCString &fileName,BufStr &inBuf,bool filter,bool isSou
int start=0;
if (size>=2 &&
- ((uchar)inBuf.at(0)==0xFF && (uchar)inBuf.at(1)==0xFE) // Little endian BOM
+ static_cast<uchar>(inBuf.at(0))==0xFF &&
+ static_cast<uchar>(inBuf.at(1))==0xFE // Little endian BOM
) // UCS-2LE encoded file
{
transcodeCharacterBuffer(fileName,inBuf,inBuf.curPos(),
"UCS-2LE","UTF-8");
}
else if (size>=2 &&
- ((uchar)inBuf.at(0)==0xFE && (uchar)inBuf.at(1)==0xFF) // big endian BOM
+ static_cast<uchar>(inBuf.at(0))==0xFE &&
+ static_cast<uchar>(inBuf.at(1))==0xFF // big endian BOM
) // UCS-2BE encoded file
{
transcodeCharacterBuffer(fileName,inBuf,inBuf.curPos(),
"UCS-2BE","UTF-8");
}
else if (size>=3 &&
- (uchar)inBuf.at(0)==0xEF &&
- (uchar)inBuf.at(1)==0xBB &&
- (uchar)inBuf.at(2)==0xBF
+ static_cast<uchar>(inBuf.at(0))==0xEF &&
+ static_cast<uchar>(inBuf.at(1))==0xBB &&
+ static_cast<uchar>(inBuf.at(2))==0xBF
) // UTF-8 encoded file
{
inBuf.dropFromStart(3); // remove UTF-8 BOM: no translation needed
@@ -6244,7 +6257,7 @@ bool readInputFile(const QCString &fileName,BufStr &inBuf,bool filter,bool isSou
// and translate CR's
size=inBuf.curPos()-start;
- int newSize=filterCRLF(inBuf.data()+start,size);
+ size_t newSize=filterCRLF(inBuf.data()+start,size);
//printf("filter char at %p size=%d newSize=%d\n",qPrint(dest)+oldPos,size,newSize);
if (newSize!=size) // we removed chars
{
@@ -6327,7 +6340,7 @@ bool patternMatch(const FileInfo &fi,const StringVector &patList)
QCString externalLinkTarget(const bool parent)
{
- static bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW);
+ bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW);
if (extLinksInWindow)
return "target=\"_blank\" ";
else if (parent)
@@ -6367,9 +6380,9 @@ QCString externalRef(const QCString &relPath,const QCString &ref,bool href)
*/
void writeColoredImgData(const QCString &dir,ColoredImgDataItem data[])
{
- static int hue = Config_getInt(HTML_COLORSTYLE_HUE);
- static int sat = Config_getInt(HTML_COLORSTYLE_SAT);
- static int gamma = Config_getInt(HTML_COLORSTYLE_GAMMA);
+ int hue = Config_getInt(HTML_COLORSTYLE_HUE);
+ int sat = Config_getInt(HTML_COLORSTYLE_SAT);
+ int gamma = Config_getInt(HTML_COLORSTYLE_GAMMA);
while (data->name)
{
QCString fileName = dir+"/"+data->name;
@@ -6397,9 +6410,9 @@ QCString replaceColorMarkers(const QCString &str)
static const reg::Ex re(R"(##[0-9A-Fa-f][0-9A-Fa-f])");
reg::Iterator it(s,re);
reg::Iterator end;
- static int hue = Config_getInt(HTML_COLORSTYLE_HUE);
- static int sat = Config_getInt(HTML_COLORSTYLE_SAT);
- static int gamma = Config_getInt(HTML_COLORSTYLE_GAMMA);
+ int hue = Config_getInt(HTML_COLORSTYLE_HUE);
+ int sat = Config_getInt(HTML_COLORSTYLE_SAT);
+ int gamma = Config_getInt(HTML_COLORSTYLE_GAMMA);
size_t sl=s.length();
size_t p=0;
for (; it!=end ; ++it)
@@ -6418,9 +6431,9 @@ QCString replaceColorMarkers(const QCString &str)
int level = HEXTONUM(lumStr[0])*16+HEXTONUM(lumStr[1]);
ColoredImage::hsl2rgb(hue/360.0,sat/255.0,
pow(level/255.0,gamma/100.0),&r,&g,&b);
- red = (int)(r*255.0);
- green = (int)(g*255.0);
- blue = (int)(b*255.0);
+ red = static_cast<int>(r*255.0);
+ green = static_cast<int>(g*255.0);
+ blue = static_cast<int>(b*255.0);
char colStr[8];
colStr[0]='#';
colStr[1]=hex[red>>4];
@@ -6589,8 +6602,8 @@ QCString correctURL(const QCString &url,const QCString &relPath)
bool protectionLevelVisible(Protection prot)
{
- static bool extractPrivate = Config_getBool(EXTRACT_PRIVATE);
- static bool extractPackage = Config_getBool(EXTRACT_PACKAGE);
+ bool extractPrivate = Config_getBool(EXTRACT_PRIVATE);
+ bool extractPackage = Config_getBool(EXTRACT_PACKAGE);
return (prot!=Private && prot!=Package) ||
(prot==Private && extractPrivate) ||
@@ -6610,7 +6623,7 @@ QCString stripIndentation(const QCString &s)
int indent=0;
int minIndent=1000000; // "infinite"
bool searchIndent=TRUE;
- static int tabSize=Config_getInt(TAB_SIZE);
+ int tabSize=Config_getInt(TAB_SIZE);
while ((c=*p++))
{
if (c=='\t') indent+=tabSize - (indent%tabSize);
@@ -6716,7 +6729,7 @@ void stripIndentation(QCString &doc,const int indentationLevel)
bool fileVisibleInIndex(const FileDef *fd,bool &genSourceFile)
{
- static bool allExternals = Config_getBool(ALLEXTERNALS);
+ bool allExternals = Config_getBool(ALLEXTERNALS);
bool isDocFile = fd->isDocumentationFile();
genSourceFile = !isDocFile && fd->generateSourceFile();
return ( ((allExternals && fd->isLinkable()) ||
@@ -6860,7 +6873,7 @@ void convertProtectionLevel(
int *outListType2
)
{
- static bool extractPrivate = Config_getBool(EXTRACT_PRIVATE);
+ bool extractPrivate = Config_getBool(EXTRACT_PRIVATE);
// default representing 1-1 mapping
*outListType1=inListType;
*outListType2=-1;
@@ -7089,11 +7102,8 @@ void writeExtraLatexPackages(TextStream &t)
void writeLatexSpecialFormulaChars(TextStream &t)
{
unsigned char minus[4]; // Superscript minus
- char *pminus = (char *)minus;
unsigned char sup2[3]; // Superscript two
- char *psup2 = (char *)sup2;
unsigned char sup3[3];
- char *psup3 = (char *)sup3; // Superscript three
minus[0]= 0xE2;
minus[1]= 0x81;
minus[2]= 0xBB;
@@ -7106,9 +7116,9 @@ void writeLatexSpecialFormulaChars(TextStream &t)
sup3[2]= 0;
t << "\\usepackage{newunicodechar}\n"
- " \\newunicodechar{" << pminus << "}{${}^{-}$}% Superscript minus\n"
- " \\newunicodechar{" << psup2 << "}{${}^{2}$}% Superscript two\n"
- " \\newunicodechar{" << psup3 << "}{${}^{3}$}% Superscript three\n"
+ " \\newunicodechar{" << minus << "}{${}^{-}$}% Superscript minus\n"
+ " \\newunicodechar{" << sup2 << "}{${}^{2}$}% Superscript two\n"
+ " \\newunicodechar{" << sup3 << "}{${}^{3}$}% Superscript three\n"
"\n";
}
@@ -7121,6 +7131,7 @@ bool recognizeFixedForm(const QCString &contents, FortranFormat format)
if (format == FortranFormat_Fixed) return TRUE;
if (format == FortranFormat_Free) return FALSE;
+ int tabSize=Config_getInt(TAB_SIZE);
for (int i=0;;i++)
{
@@ -7132,6 +7143,9 @@ bool recognizeFixedForm(const QCString &contents, FortranFormat format)
column=0;
skipLine=FALSE;
break;
+ case '\t':
+ column += tabSize-1;
+ break;
case ' ':
break;
case '\000':
@@ -7146,8 +7160,7 @@ bool recognizeFixedForm(const QCString &contents, FortranFormat format)
if (skipLine) break;
return FALSE;
case '!':
- if (column>1 && column<7) return FALSE;
- skipLine=TRUE;
+ if (column!=6) skipLine=TRUE;
break;
default:
if (skipLine) break;
@@ -7175,13 +7188,13 @@ QCString clearBlock(const QCString &s,const QCString &begin,const QCString &end)
{
if (s.isEmpty() || begin.isEmpty() || end.isEmpty()) return s;
const char *p, *q;
- int beginLen = (int)begin.length();
- int endLen = (int)end.length();
- int resLen = 0;
+ size_t beginLen = begin.length();
+ size_t endLen = end.length();
+ size_t resLen = 0;
for (p=s.data(); (q=strstr(p,begin.data()))!=0; p=q+endLen)
{
- resLen+=(int)(q-p);
- p=q+beginLen;
+ resLen += q-p;
+ p = q+beginLen;
if ((q=strstr(p,end.data()))==0)
{
resLen+=beginLen;
@@ -7195,7 +7208,7 @@ QCString clearBlock(const QCString &s,const QCString &begin,const QCString &end)
char *r;
for (r=result.rawData(), p=s.data(); (q=strstr(p,begin.data()))!=0; p=q+endLen)
{
- int l = (int)(q-p);
+ size_t l = q-p;
memcpy(r,p,l);
r+=l;
p=q+beginLen;
@@ -7324,7 +7337,7 @@ StringVector split(const std::string &s,const reg::Ex &delimiter)
int findIndex(const StringVector &sv,const std::string &s)
{
auto it = std::find(sv.begin(),sv.end(),s);
- return it!=sv.end() ? (int)(it-sv.begin()) : -1;
+ return it!=sv.end() ? static_cast<int>(it-sv.begin()) : -1;
}
/// find the index of the first occurrence of pattern \a re in a string \a s
@@ -7332,7 +7345,7 @@ int findIndex(const StringVector &sv,const std::string &s)
int findIndex(const std::string &s,const reg::Ex &re)
{
reg::Match match;
- return reg::search(s,match,re) ? (int)match.position() : -1;
+ return reg::search(s,match,re) ? static_cast<int>(match.position()) : -1;
}
/// create a string where the string in the vector are joined by the given delimiter