summaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-15 10:46:26 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-15 10:46:26 +0900
commitb7b8bd24feb1363d7d84d030b9ea688fe2f149de (patch)
tree83a30b06a24a934bb4120199cd0c180ece6fc1ed /src/util.cpp
parent046aece77e373b5280b56bf871fa6e974d06e85d (diff)
downloaddoxygen-b7b8bd24feb1363d7d84d030b9ea688fe2f149de.tar.gz
doxygen-b7b8bd24feb1363d7d84d030b9ea688fe2f149de.tar.bz2
doxygen-b7b8bd24feb1363d7d84d030b9ea688fe2f149de.zip
Imported Upstream version 1.8.4upstream/1.8.4
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp248
1 files changed, 195 insertions, 53 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 0d48f96..0d70d43 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -2,7 +2,7 @@
*
*
*
- * Copyright (C) 1997-2012 by Dimitri van Heesch.
+ * Copyright (C) 1997-2013 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
@@ -278,7 +278,7 @@ static QCString stripFromPath(const QCString &path,QStrList &l)
{
QCString prefix = s;
if (prefix.length() > length &&
- stricmp(path.left(prefix.length()),prefix)==0) // case insensitive compare
+ qstricmp(path.left(prefix.length()),prefix)==0) // case insensitive compare
{
length = prefix.length();
potential = path.right(path.length()-prefix.length());
@@ -498,7 +498,7 @@ NamespaceDef *getResolvedNamespace(const char *name)
}
if (count==10)
{
- err("warning: possible recursive namespace alias detected for %s!\n",name);
+ warn_uncond("possible recursive namespace alias detected for %s!\n",name);
}
return Doxygen::namespaceSDict->find(subst->data());
}
@@ -1567,6 +1567,7 @@ ClassDef *getResolvedClass(Definition *scope,
QCString *pResolvedType
)
{
+ static bool optimizeOutputVhdl = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
g_resolvedTypedefs.clear();
if (scope==0 ||
(scope->definitionType()!=Definition::TypeClass &&
@@ -1583,7 +1584,15 @@ ClassDef *getResolvedClass(Definition *scope,
// n,
// mayBeUnlinkable
// );
- ClassDef *result = getResolvedClassRec(scope,fileScope,n,pTypeDef,pTemplSpec,pResolvedType);
+ ClassDef *result;
+ if (optimizeOutputVhdl)
+ {
+ result = getClass(n);
+ }
+ else
+ {
+ result = getResolvedClassRec(scope,fileScope,n,pTypeDef,pTemplSpec,pResolvedType);
+ }
if (!mayBeUnlinkable && result && !result->isLinkable())
{
if (!mayBeHidden || !result->isHidden())
@@ -1815,6 +1824,49 @@ nextChar:
return growBuf.get();
}
+/**
+ * Returns the position in the string where a function parameter list
+ * begins, or -1 if one is not found.
+ */
+int findParameterList(const QString &name)
+{
+ int pos=-1;
+ int templateDepth=0;
+ do
+ {
+ if (templateDepth > 0)
+ {
+ int nextOpenPos=name.findRev('>', pos);
+ int nextClosePos=name.findRev('<', pos);
+ if (nextOpenPos!=-1 && nextOpenPos>nextClosePos)
+ {
+ ++templateDepth;
+ pos=nextOpenPos-1;
+ }
+ else
+ {
+ --templateDepth;
+ pos=nextClosePos-1;
+ }
+ }
+ else
+ {
+ int lastAnglePos=name.findRev('>', pos);
+ int bracePos=name.findRev('(', pos);
+ if (lastAnglePos!=-1 && lastAnglePos>bracePos)
+ {
+ ++templateDepth;
+ pos=lastAnglePos-1;
+ }
+ else
+ {
+ return bracePos;
+ }
+ }
+ } while (pos!=-1);
+ return -1;
+}
+
bool rightScopeMatch(const QCString &scope, const QCString &name)
{
return (name==scope || // equal
@@ -2287,7 +2339,7 @@ QCString transcodeCharacterStringToUTF8(const QCString &input)
void *cd = portable_iconv_open(outputEncoding,inputEncoding);
if (cd==(void *)(-1))
{
- err("error: unsupported character conversion: '%s'->'%s'\n",
+ err("unsupported character conversion: '%s'->'%s'\n",
inputEncoding.data(),outputEncoding);
error=TRUE;
}
@@ -2306,7 +2358,7 @@ QCString transcodeCharacterStringToUTF8(const QCString &input)
}
else
{
- err("error: failed to translate characters from %s to %s: check INPUT_ENCODING\ninput=[%s]\n",
+ err("failed to translate characters from %s to %s: check INPUT_ENCODING\ninput=[%s]\n",
inputEncoding.data(),outputEncoding,input.data());
error=TRUE;
}
@@ -2351,7 +2403,7 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode)
QFileInfo fi(name);
if (!fi.exists() || !fi.isFile())
{
- err("error: file `%s' not found\n",name);
+ err("file `%s' not found\n",name);
return "";
}
QCString filterName = getFileFilter(name,isSourceCode);
@@ -2385,7 +2437,7 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode)
FILE *f=portable_popen(cmd,"r");
if (!f)
{
- err("error: could not execute filter %s\n",filterName.data());
+ err("could not execute filter %s\n",filterName.data());
return "";
}
const int bSize=4096;
@@ -2409,7 +2461,7 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode)
}
if (!fileOpened)
{
- err("error: cannot open file `%s' for reading\n",name);
+ err("cannot open file `%s' for reading\n",name);
}
return "";
}
@@ -2449,8 +2501,8 @@ int minClassDistance(const ClassDef *cd,const ClassDef *bcd,int level)
if (cd==bcd) return level;
if (level==256)
{
- err("error: Internal inconsistency: found class %s seem to have a recursive "
- "inheritance relation! Please send a bug report to dimitri@stack.nl\n",cd->name().data());
+ warn_uncond("class %s seem to have a recursive "
+ "inheritance relation!\n",cd->name().data());
return -1;
}
int m=maxInheritanceDepth;
@@ -2481,7 +2533,7 @@ Protection classInheritedProtectionLevel(ClassDef *cd,ClassDef *bcd,Protection p
}
if (level==256)
{
- err("error: Internal inconsistency: found class %s seem to have a recursive "
+ err("Internal inconsistency: found class %s seem to have a recursive "
"inheritance relation! Please send a bug report to dimitri@stack.nl\n",cd->name().data());
}
else if (cd->baseClasses())
@@ -2889,11 +2941,11 @@ static bool matchArgument(const Argument *srcA,const Argument *dstA,
stripIrrelevantConstVolatile(dstAType);
// strip typename keyword
- if (strncmp(srcAType,"typename ",9)==0)
+ if (qstrncmp(srcAType,"typename ",9)==0)
{
srcAType = srcAType.right(srcAType.length()-9);
}
- if (strncmp(dstAType,"typename ",9)==0)
+ if (qstrncmp(dstAType,"typename ",9)==0)
{
dstAType = dstAType.right(dstAType.length()-9);
}
@@ -3802,13 +3854,13 @@ static void findMembersWithSpecificName(MemberName *mn,
{
bool match=TRUE;
ArgumentList *argList=0;
- if (args && !md->isDefine() && strcmp(args,"()")!=0)
+ if (args && !md->isDefine() && qstrcmp(args,"()")!=0)
{
argList=new ArgumentList;
- LockingPtr<ArgumentList> mdAl = md->argumentList();
+ ArgumentList *mdAl = md->argumentList();
stringToArgumentList(args,argList);
match=matchArguments2(
- md->getOuterScope(),fd,mdAl.pointer(),
+ md->getOuterScope(),fd,mdAl,
Doxygen::globalScope,fd,argList,
checkCV);
delete argList; argList=0;
@@ -3937,9 +3989,9 @@ bool getDefs(const QCString &scName,
{
//if (mmd->isLinkable())
//{
- LockingPtr<ArgumentList> mmdAl = mmd->argumentList();
+ ArgumentList *mmdAl = mmd->argumentList();
bool match=args==0 ||
- matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl.pointer(),
+ matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl,
fcd,fcd->getFileDef(),argList,
checkCV
);
@@ -3964,7 +4016,7 @@ bool getDefs(const QCString &scName,
{
delete argList; argList=0;
}
- if (mdist==maxInheritanceDepth && args && strcmp(args,"()")==0)
+ if (mdist==maxInheritanceDepth && args && qstrcmp(args,"()")==0)
// no exact match found, but if args="()" an arbitrary member will do
{
//printf(" >Searching for arbitrary member\n");
@@ -4022,7 +4074,7 @@ bool getDefs(const QCString &scName,
MemberListIterator mmli(*mn);
MemberDef *mmd, *fuzzy_mmd = 0;
ArgumentList *argList = 0;
- bool hasEmptyArgs = args && strcmp(args, "()") == 0;
+ bool hasEmptyArgs = args && qstrcmp(args, "()") == 0;
if (args)
stringToArgumentList(args, argList = new ArgumentList);
@@ -4037,8 +4089,8 @@ bool getDefs(const QCString &scName,
QCString className = mmd->getClassDef()->name();
- LockingPtr<ArgumentList> mmdAl = mmd->argumentList();
- if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl.pointer(),
+ ArgumentList *mmdAl = mmd->argumentList();
+ if (matchArguments2(mmd->getOuterScope(),mmd->getFileDef(),mmdAl,
Doxygen::globalScope,mmd->getFileDef(),argList,
checkCV
)
@@ -4098,13 +4150,13 @@ bool getDefs(const QCString &scName,
{ // namespace is found
bool match=TRUE;
ArgumentList *argList=0;
- if (args && strcmp(args,"()")!=0)
+ if (args && qstrcmp(args,"()")!=0)
{
argList=new ArgumentList;
- LockingPtr<ArgumentList> mmdAl = mmd->argumentList();
+ ArgumentList *mmdAl = mmd->argumentList();
stringToArgumentList(args,argList);
match=matchArguments2(
- mmd->getOuterScope(),mmd->getFileDef(),mmdAl.pointer(),
+ mmd->getOuterScope(),mmd->getFileDef(),mmdAl,
fnd,mmd->getFileDef(),argList,
checkCV);
}
@@ -4120,7 +4172,7 @@ bool getDefs(const QCString &scName,
}
}
}
- if (!found && args && !strcmp(args,"()"))
+ if (!found && args && !qstrcmp(args,"()"))
// no exact match found, but if args="()" an arbitrary
// member will do
{
@@ -4171,7 +4223,7 @@ bool getDefs(const QCString &scName,
findMembersWithSpecificName(mn,args,FALSE,currentFile,checkCV,forceTagFile,members);
}
//printf("found %d members\n",members.count());
- if (members.count()!=1 && args && !strcmp(args,"()"))
+ if (members.count()!=1 && args && !qstrcmp(args,"()"))
{
// no exact match found, but if args="()" an arbitrary
// member will do
@@ -4295,12 +4347,20 @@ bool resolveRef(/* in */ const char *scName,
bool checkScope
)
{
+ //printf("resolveRef(scope=%s,name=%s,inSeeBlock=%d)\n",scName,name,inSeeBlock);
QCString tsName = name;
//bool memberScopeFirst = tsName.find('#')!=-1;
QCString fullName = substitute(tsName,"#","::");
- fullName = removeRedundantWhiteSpace(substitute(fullName,".","::"));
+ if (fullName.find("anonymous_namespace{")==-1 && fullName.find('<')==-1)
+ {
+ fullName = removeRedundantWhiteSpace(substitute(fullName,".","::"));
+ }
+ else
+ {
+ fullName = removeRedundantWhiteSpace(fullName);
+ }
- int bracePos=fullName.findRev('('); // reverse is needed for operator()(...)
+ int bracePos=findParameterList(fullName);
int endNamePos=bracePos!=-1 ? bracePos : fullName.length();
int scopePos=fullName.findRev("::",endNamePos);
bool explicitScope = fullName.left(2)=="::" && // ::scope or #scope
@@ -4457,7 +4517,7 @@ QCString linkToText(SrcLangExt lang,const char *link,bool isFileName)
// replace # by ::
result=substitute(result,"#","::");
// replace . by ::
- if (!isFileName) result=substitute(result,".","::");
+ if (!isFileName && result.find('<')==-1) result=substitute(result,".","::");
// strip leading :: prefix if present
if (result.at(0)==':' && result.at(1)==':')
{
@@ -4559,6 +4619,7 @@ bool resolveLink(/* in */ const char *scName,
ClassDef *cd;
DirDef *dir;
NamespaceDef *nd;
+ SectionInfo *si=0;
bool ambig;
if (linkRef.isEmpty()) // no reference name!
{
@@ -4569,7 +4630,6 @@ bool resolveLink(/* in */ const char *scName,
GroupDef *gd = pd->getGroupDef();
if (gd)
{
- SectionInfo *si=0;
if (!pd->name().isEmpty()) si=Doxygen::sectionDict->find(pd->name());
*resContext=gd;
if (si) resAnchor = si->label;
@@ -4580,6 +4640,12 @@ bool resolveLink(/* in */ const char *scName,
}
return TRUE;
}
+ else if ((si=Doxygen::sectionDict->find(linkRef)))
+ {
+ *resContext=si->definition;
+ resAnchor = si->label;
+ return TRUE;
+ }
else if ((pd=Doxygen::exampleSDict->find(linkRef))) // link to an example
{
*resContext=pd;
@@ -5440,7 +5506,7 @@ QCString convertToJSString(const char *s)
}
}
growBuf.addChar(0);
- return growBuf.get();
+ return convertCharEntitiesToUTF8(growBuf.get());
}
@@ -5587,25 +5653,32 @@ QCString convertCharEntitiesToUTF8(const QCString &s)
init=FALSE;
}
- if (s==0) return result;
+ if (s.length()==0) return result;
+ static GrowBuf growBuf;
+ growBuf.clear();
int p,i=0,l;
while ((p=entityPat.match(s,i,&l))!=-1)
{
- if (p>i) result+=s.mid(i,p-i);
+ if (p>i)
+ {
+ growBuf.addStr(s.mid(i,p-i));
+ }
QCString entity = s.mid(p+1,l-2);
char *code = entityMap.find(entity);
if (code)
{
- result+=code;
+ growBuf.addStr(code);
}
else
{
- result+=s.mid(p,l);
+ growBuf.addStr(s.mid(p,l));
}
i=p+l;
}
- result+=s.mid(i,s.length()-i);
- return result;
+ growBuf.addStr(s.mid(i,s.length()-i));
+ growBuf.addChar(0);
+ //printf("convertCharEntitiesToUTF8(%s)->%s\n",s.data(),growBuf.get());
+ return growBuf.get();
}
/*! Returns the standard string that is generated when the \\overload
@@ -5633,7 +5706,7 @@ void addMembersToMemberGroup(MemberList *ml,
{
if (md->isEnumerate()) // insert enum value of this enum into groups
{
- LockingPtr<MemberList> fmdl=md->enumFieldList();
+ MemberList *fmdl=md->enumFieldList();
if (fmdl!=0)
{
MemberDef *fmd=fmdl->first();
@@ -6152,9 +6225,12 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle,
if (tagInfo)
{
pd->setReference(tagInfo->tagName);
+ pd->setFileName(tagInfo->fileName);
+ }
+ else
+ {
+ pd->setFileName(convertNameToFile(pd->name(),FALSE,TRUE));
}
-
- pd->setFileName(convertNameToFile(pd->name(),FALSE,TRUE));
//printf("Appending page `%s'\n",baseName.data());
Doxygen::pageSDict->append(baseName,pd);
@@ -6195,7 +6271,7 @@ void addRefItem(const QList<ListItemInfo> *sli,
const char *prefix, const char *name,const char *title,const char *args)
{
//printf("addRefItem(sli=%p,key=%s,prefix=%s,name=%s,title=%s,args=%s)\n",sli,key,prefix,name,title,args);
- if (sli)
+ if (sli && key && key[0]!='@') // check for @ to skip anonymous stuff (see bug427012)
{
QListIterator<ListItemInfo> slii(*sli);
ListItemInfo *lii;
@@ -6230,8 +6306,8 @@ void addRefItem(const QList<ListItemInfo> *sli,
void addGroupListToTitle(OutputList &ol,Definition *d)
{
- LockingPtr<GroupList> groups = d->partOfGroups();
- if (groups!=0) // write list of group to which this definition belongs
+ GroupList *groups = d->partOfGroups();
+ if (groups) // write list of group to which this definition belongs
{
ol.pushGeneratorState();
ol.disableAllBut(OutputGenerator::Html);
@@ -6408,6 +6484,11 @@ QCString stripPath(const char *s)
{
result=result.mid(i+1);
}
+ i=result.findRev('\\');
+ if (i!=-1)
+ {
+ result=result.mid(i+1);
+ }
return result;
}
@@ -6712,6 +6793,24 @@ bool checkIfTypedef(Definition *scope,FileDef *fileScope,const char *n)
return FALSE;
}
+const char *writeUtf8Char(FTextStream &t,const char *s)
+{
+ char c=*s++;
+ t << c;
+ if (c<0) // multibyte character
+ {
+ t << *s++;
+ if (((uchar)c&0xE0)==0xE0)
+ {
+ t << *s++; // 111x.xxxx: >=3 byte character
+ }
+ if (((uchar)c&0xF0)==0xF0)
+ {
+ t << *s++; // 1111.xxxx: 4 byte character
+ }
+ }
+ return s;
+}
int nextUtf8CharPosition(const QCString &utf8Str,int len,int startPos)
{
@@ -7065,7 +7164,7 @@ void writeTypeConstraints(OutputList &ol,Definition *d,ArgumentList *al)
linkifyText(TextGeneratorOLImpl(ol),d,0,0,a->type);
ol.endConstraintType();
ol.startConstraintDocs();
- ol.parseDoc(d->docFile(),d->docLine(),d,0,a->docs,TRUE,FALSE);
+ ol.generateDoc(d->docFile(),d->docLine(),d,0,a->docs,TRUE,FALSE);
ol.endConstraintDocs();
}
ol.endConstraintList();
@@ -7108,7 +7207,7 @@ static int transcodeCharacterBuffer(const char *fileName,BufStr &srcBuf,int size
void *cd = portable_iconv_open(outputEncoding,inputEncoding);
if (cd==(void *)(-1))
{
- err("error: unsupported character conversion: '%s'->'%s': %s\n"
+ err("unsupported character conversion: '%s'->'%s': %s\n"
"Check the INPUT_ENCODING setting in the config file!\n",
inputEncoding,outputEncoding,strerror(errno));
exit(1);
@@ -7129,7 +7228,7 @@ static int transcodeCharacterBuffer(const char *fileName,BufStr &srcBuf,int size
}
else
{
- err("%s: error: failed to translate characters from %s to %s: check INPUT_ENCODING\n",
+ err("%s: failed to translate characters from %s to %s: check INPUT_ENCODING\n",
fileName,inputEncoding,outputEncoding);
exit(1);
}
@@ -7153,7 +7252,7 @@ bool readInputFile(const char *fileName,BufStr &inBuf)
QFile f(fileName);
if (!f.open(IO_ReadOnly))
{
- err("error: could not open file %s\n",fileName);
+ err("could not open file %s\n",fileName);
return FALSE;
}
size=fi.size();
@@ -7161,7 +7260,7 @@ bool readInputFile(const char *fileName,BufStr &inBuf)
inBuf.skip(size);
if (f.readBlock(inBuf.data()/*+oldPos*/,size)!=size)
{
- err("error: problems while reading file %s\n",fileName);
+ err("problems while reading file %s\n",fileName);
return FALSE;
}
}
@@ -7172,7 +7271,7 @@ bool readInputFile(const char *fileName,BufStr &inBuf)
FILE *f=portable_popen(cmd,"r");
if (!f)
{
- err("error: could not execute filter %s\n",filterName.data());
+ err("could not execute filter %s\n",filterName.data());
return FALSE;
}
const int bufSize=1024;
@@ -7438,13 +7537,13 @@ bool copyFile(const QCString &src,const QCString &dest)
}
else
{
- err("error: could not write to file %s\n",dest.data());
+ err("could not write to file %s\n",dest.data());
return FALSE;
}
}
else
{
- err("error: could not open user specified file %s\n",src.data());
+ err("could not open user specified file %s\n",src.data());
return FALSE;
}
return TRUE;
@@ -7638,3 +7737,46 @@ bool fileVisibleInIndex(FileDef *fd,bool &genSourceFile)
);
}
+void addDocCrossReference(MemberDef *src,MemberDef *dst)
+{
+ static bool referencedByRelation = Config_getBool("REFERENCED_BY_RELATION");
+ static bool referencesRelation = Config_getBool("REFERENCES_RELATION");
+ static bool callerGraph = Config_getBool("CALLER_GRAPH");
+ static bool callGraph = Config_getBool("CALL_GRAPH");
+
+ //printf("--> addDocCrossReference src=%s,dst=%s\n",src->name().data(),dst->name().data());
+ if (dst->isTypedef() || dst->isEnumerate()) return; // don't add types
+ if ((referencedByRelation || callerGraph || dst->hasCallerGraph()) &&
+ src->showInCallGraph()
+ )
+ {
+ dst->addSourceReferencedBy(src);
+ MemberDef *mdDef = dst->memberDefinition();
+ if (mdDef)
+ {
+ mdDef->addSourceReferencedBy(src);
+ }
+ MemberDef *mdDecl = dst->memberDeclaration();
+ if (mdDecl)
+ {
+ mdDecl->addSourceReferencedBy(src);
+ }
+ }
+ if ((referencesRelation || callGraph || src->hasCallGraph()) &&
+ src->showInCallGraph()
+ )
+ {
+ src->addSourceReferences(dst);
+ MemberDef *mdDef = src->memberDefinition();
+ if (mdDef)
+ {
+ mdDef->addSourceReferences(dst);
+ }
+ MemberDef *mdDecl = src->memberDeclaration();
+ if (mdDecl)
+ {
+ mdDecl->addSourceReferences(dst);
+ }
+ }
+}
+