diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 123 |
1 files changed, 71 insertions, 52 deletions
diff --git a/src/util.cpp b/src/util.cpp index 944ce6a..e028660 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -518,10 +518,10 @@ static QDict<MemberDef> g_resolvedTypedefs; static QDict<Definition> g_visitedNamespaces; // forward declaration -static ClassDef *getResolvedClassRec(const Definition *scope, +static const ClassDef *getResolvedClassRec(const Definition *scope, const FileDef *fileScope, const char *n, - MemberDef **pTypeDef, + const MemberDef **pTypeDef, QCString *pTemplSpec, QCString *pResolvedType ); @@ -535,10 +535,12 @@ int isAccessibleFromWithExpScope(const Definition *scope,const FileDef *fileScop * * Example: typedef int T; will return 0, since "int" is not a class. */ -ClassDef *newResolveTypedef(const FileDef *fileScope,MemberDef *md, - MemberDef **pMemType,QCString *pTemplSpec, - QCString *pResolvedType, - ArgumentList *actTemplParams) +const ClassDef *newResolveTypedef(const FileDef *fileScope, + const MemberDef *md, + const MemberDef **pMemType, + QCString *pTemplSpec, + QCString *pResolvedType, + ArgumentList *actTemplParams) { //printf("newResolveTypedef(md=%p,cachedVal=%p)\n",md,md->getCachedTypedefVal()); bool isCached = md->isTypedefValCached(); // value already cached @@ -581,8 +583,8 @@ ClassDef *newResolveTypedef(const FileDef *fileScope,MemberDef *md, int sp=0; tl=type.length(); // length may have been changed while (sp<tl && type.at(sp)==' ') sp++; - MemberDef *memTypeDef = 0; - ClassDef *result = getResolvedClassRec(md->getOuterScope(), + const MemberDef *memTypeDef = 0; + const ClassDef *result = getResolvedClassRec(md->getOuterScope(), fileScope,type,&memTypeDef,0,pResolvedType); // if type is a typedef then return what it resolves to. if (memTypeDef && memTypeDef->isTypedef()) @@ -652,7 +654,7 @@ done: //printf("setting cached typedef %p in result %p\n",md,result); //printf("==> %s (%s,%d)\n",result->name().data(),result->getDefFileName().data(),result->getDefLine()); //printf("*pResolvedType=%s\n",pResolvedType?pResolvedType->data():"<none>"); - md->cacheTypedefVal(result, + const_cast<MemberDef*>(md)->cacheTypedefVal(result, pTemplSpec ? *pTemplSpec : QCString(), pResolvedType ? *pResolvedType : QCString() ); @@ -667,7 +669,7 @@ done: * value of the typedef or \a name if no typedef was found. */ static QCString substTypedef(const Definition *scope,const FileDef *fileScope,const QCString &name, - MemberDef **pTypeDef=0) + const MemberDef **pTypeDef=0) { QCString result=name; if (name.isEmpty()) return result; @@ -763,12 +765,12 @@ static const Definition *followPath(const Definition *start,const FileDef *fileS while ((is=getScopeFragment(path,ps,&l))!=-1) { // try to resolve the part if it is a typedef - MemberDef *typeDef=0; + const MemberDef *typeDef=0; QCString qualScopePart = substTypedef(current,fileScope,path.mid(is,l),&typeDef); //printf(" qualScopePart=%s\n",qualScopePart.data()); if (typeDef) { - ClassDef *type = newResolveTypedef(fileScope,typeDef); + const ClassDef *type = newResolveTypedef(fileScope,typeDef); if (type) { //printf("Found type %s\n",type->name().data()); @@ -1218,8 +1220,8 @@ static void getResolvedSymbol(const Definition *scope, const QCString &explicitScopePart, ArgumentList *actTemplParams, int &minDistance, - ClassDef *&bestMatch, - MemberDef *&bestTypedef, + const ClassDef *&bestMatch, + const MemberDef *&bestTypedef, QCString &bestTemplSpec, QCString &bestResolvedType ) @@ -1306,8 +1308,8 @@ static void getResolvedSymbol(const Definition *scope, QCString spec; QCString type; minDistance=distance; - MemberDef *enumType = 0; - ClassDef *cd = newResolveTypedef(fileScope,md,&enumType,&spec,&type,actTemplParams); + const MemberDef *enumType = 0; + const ClassDef *cd = newResolveTypedef(fileScope,md,&enumType,&spec,&type,actTemplParams); if (cd) // type resolves to a class { //printf(" bestTypeDef=%p spec=%s type=%s\n",md,spec.data(),type.data()); @@ -1377,10 +1379,10 @@ static void getResolvedSymbol(const Definition *scope, * match against the input name. Can recursively call itself when * resolving typedefs. */ -static ClassDef *getResolvedClassRec(const Definition *scope, +static const ClassDef *getResolvedClassRec(const Definition *scope, const FileDef *fileScope, const char *n, - MemberDef **pTypeDef, + const MemberDef **pTypeDef, QCString *pTemplSpec, QCString *pResolvedType ) @@ -1499,8 +1501,8 @@ static ClassDef *getResolvedClassRec(const Definition *scope, Doxygen::lookupCache->insert(key,new LookupInfo); } - ClassDef *bestMatch=0; - MemberDef *bestTypedef=0; + const ClassDef *bestMatch=0; + const MemberDef *bestTypedef=0; QCString bestTemplSpec; QCString bestResolvedType; int minDistance=10000; // init at "infinite" @@ -1566,10 +1568,10 @@ static ClassDef *getResolvedClassRec(const Definition *scope, * Loops through scope and each of its parent scopes looking for a * match against the input name. */ -ClassDef *getResolvedClass(const Definition *scope, +const ClassDef *getResolvedClass(const Definition *scope, const FileDef *fileScope, const char *n, - MemberDef **pTypeDef, + const MemberDef **pTypeDef, QCString *pTemplSpec, bool mayBeUnlinkable, bool mayBeHidden, @@ -1593,7 +1595,7 @@ ClassDef *getResolvedClass(const Definition *scope, // n, // mayBeUnlinkable // ); - ClassDef *result; + const ClassDef *result; if (optimizeOutputVhdl) { result = getClass(n); @@ -1675,6 +1677,7 @@ struct CharAroundSpace charMap['='].after=FALSE; charMap[' '].after=FALSE; + charMap['['].after=FALSE; charMap[']'].after=FALSE; charMap['\t'].after=FALSE; charMap['\n'].after=FALSE; @@ -2031,12 +2034,17 @@ void linkifyText(const TextGeneratorIntf &out, const Definition *scope, int floatingIndex=0; if (strLen==0) return; // read a word from the text string - while ((newIndex=regExp.match(txtStr,index,&matchLen))!=-1 && - (newIndex==0 || !(txtStr.at(newIndex-1)>='0' && txtStr.at(newIndex-1)<='9')) // avoid matching part of hex numbers - ) + while ((newIndex=regExp.match(txtStr,index,&matchLen))!=-1) { - // add non-word part to the result floatingIndex+=newIndex-skipIndex+matchLen; + if (newIndex>0 && txtStr.at(newIndex-1)=='0') // ignore hex numbers (match x00 in 0x00) + { + out.writeString(txtStr.mid(skipIndex,newIndex+matchLen-skipIndex),keepSpaces); + skipIndex=index=newIndex+matchLen; + continue; + } + + // add non-word part to the result bool insideString=FALSE; int i; for (i=index;i<newIndex;i++) @@ -2087,7 +2095,7 @@ void linkifyText(const TextGeneratorIntf &out, const Definition *scope, const GroupDef *gd=0; //printf("** Match word '%s'\n",matchWord.data()); - MemberDef *typeDef=0; + const MemberDef *typeDef=0; cd=getResolvedClass(scope,fileScope,matchWord,&typeDef); if (typeDef) // First look at typedef then class, see bug 584184. { @@ -3495,8 +3503,8 @@ static QCString getCanonicalTypeForIdentifier( //printf("getCanonicalTypeForIdentifier(%s,[%s->%s]) start\n", // word.data(),tSpec?tSpec->data():"<none>",templSpec.data()); - ClassDef *cd = 0; - MemberDef *mType = 0; + const ClassDef *cd = 0; + const MemberDef *mType = 0; QCString ts; QCString resolvedType; @@ -4129,8 +4137,8 @@ bool getDefs(const QCString &scName, className=mScope; } - MemberDef *tmd=0; - ClassDef *fcd=getResolvedClass(Doxygen::globalScope,0,className,&tmd); + const MemberDef *tmd=0; + const ClassDef *fcd=getResolvedClass(Doxygen::globalScope,0,className,&tmd); if (fcd==0 && className.find('<')!=-1) // try without template specifiers as well { QCString nameWithoutTemplates = stripTemplateSpecifiersFromScope(className,FALSE); @@ -4556,6 +4564,10 @@ static bool getScopeDefs(const char *docScope,const char *scope, scopeName=scopeName.right(scopeName.length()-2); explicitGlobalScope=TRUE; } + if (scopeName.isEmpty()) + { + return FALSE; + } QCString docScopeName=docScope; int scopeOffset=explicitGlobalScope ? 0 : docScopeName.length(); @@ -5129,7 +5141,7 @@ FileDef *findFileDef(const FileNameDict *fnDict,const char *n,bool &ambig) if (fn->count()==1) { FileDef *fd = fn->getFirst(); -#if defined(_WIN32) || defined(__MACOSX__) // Windows or MacOSX +#if defined(_WIN32) || defined(__MACOSX__) || defined(__CYGWIN__) // Windows or MacOSX bool isSamePath = fd->getPath().right(path.length()).lower()==path.lower(); #else // Unix bool isSamePath = fd->getPath().right(path.length())==path; @@ -5329,7 +5341,7 @@ QCString substituteKeywords(const QCString &s,const char *title, result = substitute(result,"$datetime",dateToString(TRUE)); result = substitute(result,"$date",dateToString(FALSE)); result = substitute(result,"$year",yearToString()); - result = substitute(result,"$doxygenversion",versionString); + result = substitute(result,"$doxygenversion",getVersion()); result = substitute(result,"$projectname",projName); result = substitute(result,"$projectnumber",projNum); result = substitute(result,"$projectbrief",projBrief); @@ -5475,10 +5487,12 @@ QCString escapeCharsInString(const char *name,bool allowDots,bool allowUnderscor case '(': growBuf.addStr("_07"); break; case ')': growBuf.addStr("_08"); break; case '+': growBuf.addStr("_09"); break; - case '=': growBuf.addStr("_0A"); break; - case '$': growBuf.addStr("_0B"); break; - case '\\': growBuf.addStr("_0C"); break; - case '@': growBuf.addStr("_0D"); break; + case '=': growBuf.addStr("_0a"); break; + case '$': growBuf.addStr("_0b"); break; + case '\\': growBuf.addStr("_0c"); break; + case '@': growBuf.addStr("_0d"); break; + case ']': growBuf.addStr("_0e"); break; + case '[': growBuf.addStr("_0f"); break; default: if (c<0) { @@ -6358,7 +6372,7 @@ QCString normalizeNonTemplateArgumentsInString( if (!found) { // try to resolve the type - ClassDef *cd = getResolvedClass(context,0,n); + const ClassDef *cd = getResolvedClass(context,0,n); if (cd) { result+=cd->name(); @@ -7079,6 +7093,7 @@ QCString latexFilterURL(const char *s) switch (c) { case '#': t << "\\#"; break; + case '%': t << "\\%"; break; default: t << c; break; @@ -7414,24 +7429,28 @@ void addCodeOnlyMappings() SrcLangExt getLanguageFromFileName(const QCString& fileName) { - int i = fileName.findRev('.'); - if (i!=-1) // name has an extension - { - QCString extStr=fileName.right(fileName.length()-i).lower(); - if (!extStr.isEmpty()) // non-empty extension + QFileInfo fi(fileName); + QCString extName = fi.extension().lower().data(); + if (extName.isEmpty()) extName=".no_extension"; + if (extName.at(0)!='.') extName.prepend("."); + int *pVal=g_extLookup.find(extName.data()); + if (pVal) // listed extension { - int *pVal=g_extLookup.find(extStr); - if (pVal) // listed extension - { - //printf("getLanguageFromFileName(%s)=%x\n",extStr.data(),*pVal); - return (SrcLangExt)*pVal; - } + //printf("getLanguageFromFileName(%s)=%x\n",fi.extension().data(),*pVal); + return (SrcLangExt)*pVal; } - } //printf("getLanguageFromFileName(%s) not found!\n",fileName.data()); return SrcLangExt_Cpp; // not listed => assume C-ish language. } +QCString getFileNameExtension(QCString fn) +{ + if (fn.isEmpty()) return ""; + int lastDot = fn.findRev('.'); + if (lastDot!=-1) return fn.mid(lastDot); + return ""; +} + //-------------------------------------------------------------------------- MemberDef *getMemberFromSymbol(const Definition *scope,const FileDef *fileScope, @@ -8138,7 +8157,7 @@ bool patternMatch(const QFileInfo &fi,const QStrList *patList) bool found = FALSE; // For Windows/Mac, always do the case insensitive match -#if defined(_WIN32) || defined(__MACOSX__) +#if defined(_WIN32) || defined(__MACOSX__) || defined(__CYGWIN__) caseSenseNames = FALSE; #endif |