diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-12-20 13:37:39 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-12-21 12:54:18 (GMT) |
commit | 59372719ef31d7a76e2cfb64ab4628a315ccaf3a (patch) | |
tree | b1aea66c40069d150439a08368d57517835e505c /src | |
parent | 2dcbf7b29510a99168b1ab3f7d67d21a28a70eaf (diff) | |
download | Doxygen-59372719ef31d7a76e2cfb64ab4628a315ccaf3a.zip Doxygen-59372719ef31d7a76e2cfb64ab4628a315ccaf3a.tar.gz Doxygen-59372719ef31d7a76e2cfb64ab4628a315ccaf3a.tar.bz2 |
Refactoring: modernize class index
Diffstat (limited to 'src')
-rw-r--r-- | src/classdef.cpp | 8 | ||||
-rw-r--r-- | src/config.xml | 10 | ||||
-rw-r--r-- | src/filedef.cpp | 8 | ||||
-rw-r--r-- | src/groupdef.cpp | 8 | ||||
-rw-r--r-- | src/index.cpp | 427 | ||||
-rw-r--r-- | src/namespacedef.cpp | 8 | ||||
-rw-r--r-- | src/util.cpp | 16 | ||||
-rw-r--r-- | src/util.h | 9 |
8 files changed, 167 insertions, 327 deletions
diff --git a/src/classdef.cpp b/src/classdef.cpp index d4c14d6..315f3f6 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -2849,25 +2849,25 @@ void ClassDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *current const MemberDef *md=mi->memberDef(); if (md->getClassDef()==this && md->isLinkable() && !md->isEnumValue()) { - ol.writeString(" <tr><td class=\"navtab\">"); if (md->isLinkableInProject()) { if (md==currentMd) // selected item => highlight { - ol.writeString("<a class=\"qindexHL\" "); + ol.writeString(" <tr><td class=\"navtabHL\">"); } else { - ol.writeString("<a class=\"qindex\" "); + ol.writeString(" <tr><td class=\"navtab\">"); } + ol.writeString("<a class=\"navtab\" "); ol.writeString("href=\""); if (createSubDirs) ol.writeString("../../"); ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor()); ol.writeString("\">"); ol.writeString(convertToHtml(md->name())); ol.writeString("</a>"); + ol.writeString("</td></tr>\n"); } - ol.writeString("</td></tr>\n"); } } } diff --git a/src/config.xml b/src/config.xml index 0701924..3f0d406 100644 --- a/src/config.xml +++ b/src/config.xml @@ -174,7 +174,6 @@ FILE_PATTERNS = *.cpp *.h q*.doc RECURSIVE = YES EXCLUDE_PATTERNS = *codec.cpp moc_* */compat/* */3rdparty/* ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 3 IGNORE_PREFIX = Q ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES @@ -1778,14 +1777,6 @@ to disable this feature. ]]> </docs> </option> - <option type='int' id='COLS_IN_ALPHA_INDEX' minval='1' maxval='20' defval='5' depends='ALPHABETICAL_INDEX'> - <docs> -<![CDATA[ - The \c COLS_IN_ALPHA_INDEX tag can be - used to specify the number of columns in which the alphabetical index list will be split. -]]> - </docs> - </option> <option type='list' id='IGNORE_PREFIX' format='string' depends='ALPHABETICAL_INDEX'> <docs> <![CDATA[ @@ -3739,5 +3730,6 @@ temporary files. <option type='obsolete' id='PERL_PATH'/> <option type='obsolete' id='MSCGEN_PATH'/> <option type='obsolete' id='TCL_SUBST'/> + <option type='obsolete' id='COLS_IN_ALPHA_INDEX'/> </group> </doxygenconfig> diff --git a/src/filedef.cpp b/src/filedef.cpp index 3ac4e67..4d80ae4 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -1104,25 +1104,25 @@ void FileDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *currentM { if (md->getFileDef()==this && md->getNamespaceDef()==0 && md->isLinkable() && !md->isEnumValue()) { - ol.writeString(" <tr><td class=\"navtab\">"); if (md->isLinkableInProject()) { if (md==currentMd) // selected item => highlight { - ol.writeString("<a class=\"qindexHL\" "); + ol.writeString(" <tr><td class=\"navtabHL\">"); } else { - ol.writeString("<a class=\"qindex\" "); + ol.writeString(" <tr><td class=\"navtab\">"); } + ol.writeString("<a class=\"navtab\" "); ol.writeString("href=\""); if (createSubDirs) ol.writeString("../../"); ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor()); ol.writeString("\">"); ol.writeString(convertToHtml(md->localName())); ol.writeString("</a>"); + ol.writeString("</td></tr>\n"); } - ol.writeString("</td></tr>\n"); } } } diff --git a/src/groupdef.cpp b/src/groupdef.cpp index 5dfc0ae..ed042ab 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -1361,25 +1361,25 @@ void GroupDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *current { if (md->getGroupDef()==this && md->isLinkable() && !md->isEnumValue()) { - ol.writeString(" <tr><td class=\"navtab\">"); if (md->isLinkableInProject()) { if (md==currentMd) // selected item => highlight { - ol.writeString("<a class=\"qindexHL\" "); + ol.writeString(" <tr><td class=\"navtabHL\">"); } else { - ol.writeString("<a class=\"qindex\" "); + ol.writeString(" <tr><td class=\"navtab\">"); } + ol.writeString("<a class=\"navtab\" "); ol.writeString("href=\""); if (createSubDirs) ol.writeString("../../"); ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor()); ol.writeString("\">"); ol.writeString(convertToHtml(md->localName())); ol.writeString("</a>"); + ol.writeString("</td></tr>\n"); } - ol.writeString("</td></tr>\n"); } } diff --git a/src/index.cpp b/src/index.cpp index 82430ef..259dd9f 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -177,74 +177,41 @@ const int maxItemsBeforeQuickIndex = MAX_ITEMS_BEFORE_QUICK_INDEX; static void startQuickIndexList(OutputList &ol,bool letterTabs=FALSE) { - bool fancyTabs = TRUE; - if (fancyTabs) + if (letterTabs) { - if (letterTabs) - { - ol.writeString(" <div id=\"navrow4\" class=\"tabs3\">\n"); - } - else - { - ol.writeString(" <div id=\"navrow3\" class=\"tabs2\">\n"); - } - ol.writeString(" <ul class=\"tablist\">\n"); + ol.writeString(" <div id=\"navrow4\" class=\"tabs3\">\n"); } else { - ol.writeString(" <div class=\"qindex\">"); + ol.writeString(" <div id=\"navrow3\" class=\"tabs2\">\n"); } + ol.writeString(" <ul class=\"tablist\">\n"); } static void endQuickIndexList(OutputList &ol) { - bool fancyTabs = TRUE; - if (fancyTabs) - { - ol.writeString(" </ul>\n"); - } + ol.writeString(" </ul>\n"); ol.writeString(" </div>\n"); } static void startQuickIndexItem(OutputList &ol,const char *l, bool hl,bool compact,bool &first) { - bool fancyTabs = TRUE; - if (!first && compact && !fancyTabs) ol.writeString(" | "); first=FALSE; - if (fancyTabs) - { - ol.writeString(" <li"); - if (hl) ol.writeString(" class=\"current\""); - ol.writeString("><a "); - } - else - { - if (!compact) ol.writeString("<li>"); - if (hl && compact) - { - ol.writeString("<a class=\"qindexHL\" "); - } - else - { - ol.writeString("<a class=\"qindex\" "); - } - } + ol.writeString(" <li"); + if (hl) ol.writeString(" class=\"current\""); + ol.writeString("><a "); ol.writeString("href=\""); ol.writeString(l); ol.writeString("\">"); - if (fancyTabs) - { - ol.writeString("<span>"); - } + ol.writeString("<span>"); } static void endQuickIndexItem(OutputList &ol) { - bool fancyTabs=TRUE; - if (fancyTabs) ol.writeString("</span>"); + ol.writeString("</span>"); ol.writeString("</a>"); - if (fancyTabs) ol.writeString("</li>\n"); + ol.writeString("</li>\n"); } // don't make this static as it is called from a template function and some @@ -2041,6 +2008,29 @@ static QCString letterToString(uint letter) return QString(QChar(letter)).utf8(); } +static QCString letterToLabel(const char *startLetter) +{ + const char *p = startLetter; + if (startLetter==0 || *startLetter==0) return ""; + char c = *p; + QCString result; + if (isId1(c)) + { + result+=c; + } + else + { + result="0x"; + const char hex[]="0123456789abcdef"; + while ((c=*p++)) + { + result+=hex[((unsigned char)c)>>4]; + result+=hex[((unsigned char)c)&0xf]; + } + } + return result; +} + static QCString letterToLabel(uint startLetter) { char s[11]; // max 0x12345678 + '\0' @@ -2078,87 +2068,31 @@ static QCString letterToLabel(uint startLetter) return s; } -//---------------------------------------------------------------------------- -/** Special class list where sorting takes IGNORE_PREFIX into account. */ -class PrefixIgnoreClassList : public ClassList -{ - public: - typedef const ClassDef ElementType; - PrefixIgnoreClassList(uint letter) : m_letter(letter) {} - uint letter() const { return m_letter; } - private: - virtual int compareValue(const ClassDef *c1, const ClassDef *c2) const - { - QCString n1 = c1->className(); - QCString n2 = c2->className(); - return qstricmp (n1.data()+getPrefixIndex(n1), n2.data()+getPrefixIndex(n2)); - } - uint m_letter; -}; +//---------------------------------------------------------------------------- /** Class representing a cell in the alphabetical class index. */ class AlphaIndexTableCell { public: - AlphaIndexTableCell(int row,int col,uint letter,const ClassDef *cd) : + AlphaIndexTableCell(int row,int col,const std::string &letter,const ClassDef *cd) : m_letter(letter), m_class(cd), m_row(row), m_col(col) - { //printf("AlphaIndexTableCell(%d,%d,%c,%s)\n",row,col,letter!=0 ? letter: '-', - // cd!=(ClassDef*)0x8 ? cd->name().data() : "<null>"); + { } const ClassDef *classDef() const { return m_class; } - uint letter() const { return m_letter; } - int row() const { return m_row; } - int column() const { return m_col; } + std::string letter() const { return m_letter; } + int row() const { return m_row; } + int column() const { return m_col; } private: - uint m_letter; + std::string m_letter; const ClassDef *m_class; int m_row; int m_col; }; -/** Class representing a row in the alphabetical class index. */ -class AlphaIndexTableRows : public QList<AlphaIndexTableCell> -{ - public: - AlphaIndexTableRows() { setAutoDelete(TRUE); } -}; - -/** Iterator for the cells in a row of the alphabetical class index. */ -class AlphaIndexTableRowsIterator : public QListIterator<AlphaIndexTableCell> -{ - public: - AlphaIndexTableRowsIterator(const AlphaIndexTableRows &list_) : - QListIterator<AlphaIndexTableCell>(list_) {} -}; - -/** Class representing the columns in the alphabetical class index. */ -class AlphaIndexTableColumns : public QList<AlphaIndexTableRows> -{ - public: - AlphaIndexTableColumns() { setAutoDelete(TRUE); } -}; - -class UsedIndexLetters : public SIntDict<uint> -{ - public: - UsedIndexLetters() : SIntDict<uint>(257) { setAutoDelete(TRUE); } - void add(uint letter) - { - uint *v = find(letter); - if (v==0) - { - append(letter,new uint(letter)); - } - } - private: - int compareValues( const uint *p1, const uint *p2) const - { - return (int)*p1 - (int)*p2; // subtracting is done by int not uint. - } -}; +using UsedIndexLetters = std::set<std::string>; // write an alphabetical index of all class with a header for each letter static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct, int annotatedCount) @@ -2169,8 +2103,6 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct UsedIndexLetters indexLettersUsed; // first count the number of headers - uint startLetter=0; - int headerItems=0; for (const auto &cd : *Doxygen::classLinkedMap) { if (sliceOpt && cd->compoundType() != ct) @@ -2182,49 +2114,35 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct int index = getPrefixIndex(cd->className()); //printf("name=%s index=%d %d\n",cd->className().data(),index,cd->protection()); - startLetter=getUtf8CodeToLower(cd->className(),index); - indexLettersUsed.add(startLetter); + char charStr[MAX_UTF8_CHAR_SIZE]; + if (getUtf8Char(cd->className().data()+index,charStr,CaseModifier::ToUpper)>0) + // get the first UTF8 character (after the part that should be ignored) + { + indexLettersUsed.insert(charStr); + } } } - indexLettersUsed.sort(); // write quick link index (row of letters) QCString alphaLinks = "<div class=\"qindex\">"; - SIntDict<uint>::Iterator it(indexLettersUsed); - uint *pLetter; - for (it.toFirst();(pLetter=it.current());++it) - { - if (headerItems) alphaLinks += " | "; - headerItems++; - QCString li = letterToLabel(*pLetter); - QCString ls = letterToString(*pLetter); + bool first=true; + for (const auto &letter : indexLettersUsed) + { + if (!first) alphaLinks += " | "; + first=false; + QCString li = letterToLabel(letter.c_str()); alphaLinks += (QCString)"<a class=\"qindex\" href=\"#letter_" + li + "\">" + - ls + "</a>"; + letter + "</a>"; } alphaLinks += "</div>\n"; ol.writeString(alphaLinks); - - // the number of columns in the table - const int columns = Config_getInt(COLS_IN_ALPHA_INDEX); - - int i,j; - int totalItems = headerItems*2 + annotatedCount; // number of items in the table (headers span 2 items) - int rows = (totalItems + columns - 1)/columns; // number of rows in the table - - //printf("headerItems=%d totalItems=%d columns=%d rows=%d itemsInLastRow=%d\n", - // headerItems,totalItems,columns,rows,itemsInLastRow); - - // Keep a list of classes for each starting letter - LetterToIndexMap<PrefixIgnoreClassList> classesByLetter; - AlphaIndexTableColumns tableColumns; + std::map<std::string, std::vector<const ClassDef*> > classesByLetter; // fill the columns with the class list (row elements in each column, // expect for the columns with number >= itemsInLastRow, which get one // item less. - //int icount=0; - startLetter=0; for (const auto &cd : *Doxygen::classLinkedMap) { if (sliceOpt && cd->compoundType() != ct) @@ -2235,185 +2153,100 @@ static void writeAlphabeticalClassList(OutputList &ol, ClassDef::CompoundType ct if (cd->isLinkableInProject() && cd->templateMaster()==0) { int index = getPrefixIndex(cd->className()); - startLetter=getUtf8CodeToLower(cd->className(),index); - // Do some sorting again, since the classes are sorted by name with - // prefix, which should be ignored really. - if (cd->getLanguage()==SrcLangExt_VHDL) + char charStr[MAX_UTF8_CHAR_SIZE]; + if (getUtf8Char(cd->className().data()+index,charStr,CaseModifier::ToUpper)>0) + // get the first UTF8 character (after the part that should be ignored) { - if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS )// no architecture + auto it = classesByLetter.find(charStr); + if (it!=classesByLetter.end()) // add class to the existing list { - classesByLetter.append(startLetter,cd.get()); + it->second.push_back(cd.get()); + } + else // new entry + { + classesByLetter.insert( + std::make_pair(std::string(charStr), + std::vector<const ClassDef*>({ cd.get() }))); } } - else - { - classesByLetter.append(startLetter,cd.get()); - } - } - } - - #define NEXT_ROW() \ - do \ - { \ - if (row>maxRows) maxRows=row; \ - if (row>=rows && col<columns) \ - { \ - col++; \ - row=0; \ - tableRows = new AlphaIndexTableRows; \ - tableColumns.append(tableRows); \ - } \ - } \ - while(0) \ - - AlphaIndexTableRows *tableRows = new AlphaIndexTableRows; - tableColumns.append(tableRows); - int col=0,row=0,maxRows=0; - PrefixIgnoreClassList *cl; - SIntDict<PrefixIgnoreClassList>::Iterator lit(classesByLetter); - for (lit.toFirst();(cl=lit.current());++lit) - { - uint l = cl->letter(); - // add special header cell - tableRows->append(new AlphaIndexTableCell(row,col,l,(ClassDef*)0x8)); - row++; - tableRows->append(new AlphaIndexTableCell(row,col,0,(ClassDef*)0x8)); - row++; - ClassListIterator cit(*cl); - cit.toFirst(); - ClassDef *cd = cit.current(); - ++cit; - tableRows->append(new AlphaIndexTableCell(row,col,0,cd)); - row++; - NEXT_ROW(); - for (;(cd=cit.current()); ++cit) - { - // add normal cell - tableRows->append(new AlphaIndexTableCell(row,col,0,cd)); - row++; - NEXT_ROW(); } } - // create row iterators for each column - AlphaIndexTableRowsIterator **colIterators = new AlphaIndexTableRowsIterator*[columns]; - for (i=0;i<columns;i++) + // sort the class lists per letter while ignoring the prefix + for (auto &kv : classesByLetter) { - if (i<(int)tableColumns.count()) - { - colIterators[i] = new AlphaIndexTableRowsIterator(*tableColumns.at(i)); - } - else // empty column - { - colIterators[i] = 0; - } + std::sort(kv.second.begin(), kv.second.end(), + [](const auto &c1,const auto &c2) + { + QCString n1 = c1->className(); + QCString n2 = c2->className(); + return qstricmp(n1.data()+getPrefixIndex(n1), n2.data()+getPrefixIndex(n2))<0; + }); } - ol.writeString("<table class=\"classindex\">\n"); // generate table - for (i=0;i<=maxRows;i++) // foreach table row - { - //printf("writing row %d\n",i); - //ol.nextTableRow(); - ol.writeString("<tr>"); - // the last column may contain less items then the others - //int colsInRow = (i<rows-1) ? columns : itemsInLastRow; - //printf("row [%d]\n",i); - bool cellCont = false; - for (j=0;j<columns;j++) // foreach table column - { - if (colIterators[j]) + if (!classesByLetter.empty()) + { + ol.writeString("<div class=\"classindex\">\n"); + int counter=0; + for (const auto &cl : classesByLetter) + { + QCString parity = (counter++%2)==0 ? "even" : "odd"; + ol.writeString("<dl class=\"classindex " + parity + "\">\n"); + + // write character heading + ol.writeString("<dt class=\"alphachar\">"); + QCString s = letterToLabel(cl.first.c_str()); + ol.writeString("<a name=\"letter_"); + ol.writeString(s); + ol.writeString("\">"); + ol.writeString(cl.first.c_str()); + ol.writeString("</a>"); + ol.writeString("</dt>\n"); + + // write class links + for (const auto &cd : cl.second) { - AlphaIndexTableCell *cell = colIterators[j]->current(); - if (cell) + ol.writeString("<dd>"); + QCString namesp,cname; + extractNamespaceName(cd->name(),cname,namesp); + QCString nsDispName; + SrcLangExt lang = cd->getLanguage(); + QCString sep = getLanguageSpecificSeparator(lang); + if (sep!="::") { - if (cell->row()==i) - { - if (cell->letter()!=0) - { - cellCont = true; - QCString s = letterToLabel(cell->letter()); - ol.writeString("<td rowspan=\"2\" valign=\"bottom\">"); - ol.writeString("<a name=\"letter_"); - ol.writeString(s); - ol.writeString("\"></a>"); - ol.writeString("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" - "<tr>" - "<td><div class=\"ah\">  "); - ol.writeString(letterToString(cell->letter())); - ol.writeString( "  </div>" - "</td>" - "</tr>" - "</table>\n"); - } - else if (cell->classDef()!=(ClassDef*)0x8) - { - cellCont = true; - const ClassDef *cd = cell->classDef(); - ol.writeString("<td valign=\"top\">"); - QCString namesp,cname; - //if (cd->getNamespaceDef()) namesp=cd->getNamespaceDef()->displayName(); - //QCString cname=cd->className(); - extractNamespaceName(cd->name(),cname,namesp); - QCString nsDispName; - SrcLangExt lang = cd->getLanguage(); - QCString sep = getLanguageSpecificSeparator(lang); - if (sep!="::") - { - nsDispName=substitute(namesp,"::",sep); - cname=substitute(cname,"::",sep); - } - else - { - nsDispName=namesp; - } - - ol.writeObjectLink(cd->getReference(), - cd->getOutputFileBase(),cd->anchor(),cname); - if (!namesp.isEmpty()) - { - ol.docify(" ("); - NamespaceDef *nd = getResolvedNamespace(namesp); - if (nd && nd->isLinkable()) - { - ol.writeObjectLink(nd->getReference(), - nd->getOutputFileBase(),0,nsDispName); - } - else - { - ol.docify(nsDispName); - } - ol.docify(")"); - } - ol.writeNonBreakableSpace(3); - } - ++(*colIterators[j]); - if (cell->letter()!=0 || cell->classDef()!=(ClassDef*)0x8) - { - ol.writeString("</td>\n"); - } - } + nsDispName=substitute(namesp,"::",sep); + cname=substitute(cname,"::",sep); } else { - cellCont = true; - ol.writeString("<td></td>"); + nsDispName=namesp; } - } - } - if (!cellCont) ol.writeString("<td></td>"); // we need at least one cell in case of xhtml - ol.writeString("</tr>\n"); - } - ol.writeString("</table>\n"); - ol.writeString(alphaLinks); + ol.writeObjectLink(cd->getReference(), + cd->getOutputFileBase(),cd->anchor(),cname); + if (!namesp.isEmpty()) + { + ol.writeString(" ("); + NamespaceDef *nd = getResolvedNamespace(namesp); + if (nd && nd->isLinkable()) + { + ol.writeObjectLink(nd->getReference(), + nd->getOutputFileBase(),0,nsDispName); + } + else + { + ol.docify(nsDispName); + } + ol.writeString(")"); + } + ol.writeString("</dd>"); + } - // release the temporary memory - for (i=0;i<columns;i++) - { - delete colIterators[i]; + ol.writeString("</dl>\n"); + } + ol.writeString("</div>\n"); } - delete[] colIterators; } //---------------------------------------------------------------------------- diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 95374f3..6a0bd4b 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -1123,25 +1123,25 @@ void NamespaceDefImpl::writeQuickMemberLinks(OutputList &ol,const MemberDef *cur { if (md->getNamespaceDef()==this && md->isLinkable() && !md->isEnumValue()) { - ol.writeString(" <tr><td class=\"navtab\">"); if (md->isLinkableInProject()) { if (md==currentMd) // selected item => highlight { - ol.writeString("<a class=\"qindexHL\" "); + ol.writeString(" <tr><td class=\"navtabHL\">"); } else { - ol.writeString("<a class=\"qindex\" "); + ol.writeString(" <tr><td class=\"navtab\">"); } + ol.writeString("<a class=\"navtab\" "); ol.writeString("href=\""); if (createSubDirs) ol.writeString("../../"); ol.writeString(md->getOutputFileBase()+Doxygen::htmlFileExtension+"#"+md->anchor()); ol.writeString("\">"); ol.writeString(convertToHtml(md->localName())); ol.writeString("</a>"); + ol.writeString("</td></tr>\n"); } - ol.writeString("</td></tr>\n"); } } } diff --git a/src/util.cpp b/src/util.cpp index 2ec2ff0..3aa5863 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3575,22 +3575,28 @@ bool hasVisibleRoot(const BaseClassList &bcl) // copies the next UTF8 character from input stream into buffer ids // returns the size of the character in bytes (or 0 if it is invalid) // the character itself will be copied as a UTF-8 encoded string to ids. -int getUtf8Char(const signed char *input,char ids[5]) +int getUtf8Char(const char *input,char ids[MAX_UTF8_CHAR_SIZE],CaseModifier modifier) { int inputLen=1; const unsigned char uc = (unsigned char)*input; bool validUTF8Char = false; if (uc <= 0xf7) { - ids[ 0 ] = *input; - const signed char* pt = input+1; + const char* pt = input+1; int l = 0; if ((uc&0x80)==0x00) { + switch (modifier) + { + case CaseModifier::None: ids[0]=*input; break; + case CaseModifier::ToUpper: ids[0]=toupper(*input); break; + case CaseModifier::ToLower: ids[0]=tolower(*input); break; + } l=1; // 0xxx.xxxx => normal single byte ascii character } else { + ids[ 0 ] = *input; if ((uc&0xE0)==0xC0) { l=2; // 110x.xxxx: >=2 byte character @@ -3635,7 +3641,7 @@ QCString escapeCharsInString(const char *name,bool allowDots,bool allowUnderscor if (name==0) return ""; GrowBuf growBuf; signed char c; - const signed char *p=(const signed char*)name; + const char *p=name; while ((c=*p++)!=0) { switch(c) @@ -3671,7 +3677,7 @@ QCString escapeCharsInString(const char *name,bool allowDots,bool allowUnderscor default: if (c<0) { - char ids[5]; + char ids[MAX_UTF8_CHAR_SIZE]; bool doEscape = true; if (allowUnicodeNames) { @@ -459,6 +459,15 @@ QCString getDotImageExtension(); bool fileVisibleInIndex(const FileDef *fd,bool &genSourceFile); +const int MAX_UTF8_CHAR_LEN = 4; +const int MAX_UTF8_CHAR_SIZE = MAX_UTF8_CHAR_LEN+1; // include 0 terminator +enum class CaseModifier +{ + None, + ToUpper, + ToLower +}; +int getUtf8Char(const char *input,char ids[MAX_UTF8_CHAR_SIZE],CaseModifier modifier=CaseModifier::None); uint getUtf8Code( const QCString& s, int idx ); uint getUtf8CodeToLower( const QCString& s, int idx ); uint getUtf8CodeToUpper( const QCString& s, int idx ); |