Re: [PATCH] IGNORE_PREFIX for functions

"Eivind Magnus Hvidevold" <[email protected]>
Newsgroups gmane.text.doxygen.devel
Organization Artwork Systems
Message-ID <[email protected]>
On Fri, 07 Jul 2006 15:05:57 +0200, Eivind Magnus Hvidevold  
<[email protected]> wrote:

>
> Hi!
>
> I'm using Doxygen on an SDK where all C functions have the same prefix. I
> used the IGNORE_PREFIX setting to get them indexed properly by first
> letter after the prefix, but they all kept going under the first letter  
> of the prefix. So I searched the mailing lists for IGNORE_PREFIX and  
> found
> that it just works for classes. Here is a patch which makes it work also
> for functions. I'd be happy if this or something similar could be merged.
> Do you think there should there be a separate config setting? I was
> thinking of something like IGNORE_PREFIX_FUNCTIONS with YES|NO (using the
> list from IGNORE_PREFIX) or containing another ignore list. I don't need
> that extra setting but maybe others do?
The patch was incomplete. I forgot to resort the list with the prefix  
ignored,
so if there were functions with different prefix, the alphabetical index
would restart on 'a' for each prefix.

This patch includes resorting of the lists. It is against CVS from  
yesterday.

-- 
EMH

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
ignore_prefix_2.patch (application/octet-stream, 6 KB)
--- index.cpp.orig	2006-07-16 22:10:06.000000000 +0200
+++ index.cpp	2006-08-01 09:26:03.177299500 +0200
@@ -1140,7 +1140,7 @@
   {
     if (cd->isLinkableInProject() && cd->templateMaster()==0)
     {
-      int c = cd->displayName().at(0);
+      int c = cd->displayName().at(getPrefixIndex(cd->displayName()));
       g_classIndexLetterUsed[CHL_All][c]=TRUE;
       switch(cd->compoundType())
       {
@@ -1507,6 +1507,26 @@
 
 //----------------------------------------------------------------------------
 
+class PrefixIgnoreMemberNameSDict : public MemberNameSDict
+{
+public:
+  PrefixIgnoreMemberNameSDict(int size) : MemberNameSDict(size) {}
+  ~PrefixIgnoreMemberNameSDict() {}
+
+  virtual int compareItems(GCI item1, GCI item2)
+  {
+    MemberName *c1=(MemberName *)item1;
+    MemberName *c2=(MemberName *)item2;
+
+    QCString n1 = c1->memberName();
+    n1.remove (0, getPrefixIndex(n1));
+    QCString n2 = c2->memberName();
+    n2.remove (0, getPrefixIndex(n2));
+    
+    return stricmp (n1, n2);
+  }
+};
+
 void writeMemberList(OutputList &ol,bool useSections,
     ClassMemberHighlight filter,char sectionFilter)
 {
@@ -1514,11 +1534,22 @@
   char lastChar = 0;
   static bool hideFriendCompounds = Config_getBool("HIDE_FRIEND_COMPOUNDS");
 
-  MemberNameSDict::Iterator mnli(Doxygen::memberNameSDict);
+  MemberNameSDict::Iterator mnli_unsorted(Doxygen::memberNameSDict);
   MemberName *mn=0;
+  
+  // Make a new list sorted without prefix
+  PrefixIgnoreMemberNameSDict prefixIgnoreMemberNameSDict(10000);
+  for (mnli_unsorted.toFirst();(mn=mnli_unsorted.current());++mnli_unsorted) {
+      prefixIgnoreMemberNameSDict.inSort(mn->memberName(), mn);
+  }
+  MemberNameSDict::Iterator mnli(prefixIgnoreMemberNameSDict);
+
   for (mnli.toFirst();(mn=mnli.current());++mnli)
   {
-    if (sectionFilter==0 || tolower(sectionFilter)==tolower(mn->memberName()[0]))
+    QCString name = mn->memberName();
+    int startIndex = getPrefixIndex(name);
+    char indexLetter = tolower(name.at(startIndex));
+    if (sectionFilter==0 || tolower(sectionFilter)==indexLetter)
     {
       MemberDef *md=mn->first();
       bool found=FALSE;
@@ -1557,11 +1588,13 @@
         if (useSections)
         {
           QCString name = mn->memberName();
-          if (tolower(name.at(0))!=lastChar)
+          int startIndex = getPrefixIndex(name);
+          char indexLetter = tolower(name.at(startIndex));
+          if (indexLetter!=lastChar)
           {
             if (!first) ol.endItemList();
             char cs[2];
-            lastChar=cs[0]=tolower(name.at(0));cs[1]='\0';
+            lastChar=cs[0]=indexLetter;cs[1]='\0';
             QCString anchor=(QCString)"index_"+cs;
             QCString title=(QCString)"- "+cs+" -";
             ol.startSection(anchor,title,SectionInfo::Subsection);
@@ -1653,7 +1686,7 @@
     if (found)
     {
       QCString n = mn->memberName();
-      if (!n.isEmpty()) g_memberIndexLetterUsed[filter][tolower(n.at(0))]=TRUE;
+      if (!n.isEmpty()) g_memberIndexLetterUsed[filter][tolower(n.at(getPrefixIndex(n)))]=TRUE;
       count++;
     }
   }
@@ -1835,11 +1868,23 @@
 {
   char lastChar=0;
   bool first=TRUE;
-  MemberNameSDict::Iterator mnli(Doxygen::functionNameSDict);
+  
+  MemberNameSDict::Iterator mnli_unsorted(Doxygen::functionNameSDict);
   MemberName *mn=0;
+  
+  // Make a new list sorted without prefix
+  PrefixIgnoreMemberNameSDict prefixIgnoreMemberNameSDict(10000);
+  for (mnli_unsorted.toFirst();(mn=mnli_unsorted.current());++mnli_unsorted) {
+      prefixIgnoreMemberNameSDict.inSort(mn->memberName(), mn);
+  }
+  MemberNameSDict::Iterator mnli(prefixIgnoreMemberNameSDict);
+
   for (mnli.toFirst();(mn=mnli.current());++mnli)
   {
-    if (sectionFilter==0 || tolower(sectionFilter)==tolower(mn->memberName()[0]))
+    QCString name = mn->memberName();
+    int startIndex = getPrefixIndex(name);
+    char indexLetter = tolower(name.at(startIndex));
+    if (sectionFilter==0 || tolower(sectionFilter)==indexLetter)
     {
       MemberDef *md=mn->first();
       bool found=FALSE;
@@ -1873,11 +1918,13 @@
         if (useSections)
         {
           QCString name = mn->memberName();
-          if (tolower(name.at(0))!=lastChar)
+          int startIndex = getPrefixIndex(name);
+          char indexLetter = tolower(name.at(startIndex));
+          if (indexLetter!=lastChar)
           {
             if (!first) ol.endItemList();
             char cs[2];
-            lastChar=cs[0]=tolower(name.at(0));cs[1]='\0';
+            lastChar=cs[0]=indexLetter;cs[1]='\0';
             QCString anchor=(QCString)"index_"+cs;
             QCString title=(QCString)"- "+cs+" -";
             ol.startSection(anchor,title,SectionInfo::Subsection);
@@ -1966,11 +2013,13 @@
         if (useSections)
         {
           QCString name = mn->memberName();
-          if (tolower(name.at(0))!=lastChar)
+          int startIndex = getPrefixIndex(name);
+          char indexLetter = tolower(name.at(startIndex));
+          if (indexLetter!=lastChar)
           {
             if (!first) ol.endItemList();
             char cs[2];
-            lastChar=cs[0]=tolower(name.at(0));cs[1]='\0';
+            lastChar=cs[0]=indexLetter;cs[1]='\0';
             QCString anchor=(QCString)"index_"+cs;
             QCString title=(QCString)"- "+cs+" -";
             ol.startSection(anchor,title,SectionInfo::Subsection);
@@ -2043,7 +2092,7 @@
          )
       {
         QCString n = mn->memberName();
-        if (!n.isEmpty()) g_namespaceIndexLetterUsed[filter][tolower(n.at(0))]=TRUE;
+        if (!n.isEmpty()) g_namespaceIndexLetterUsed[filter][tolower(n.at(getPrefixIndex(n)))]=TRUE;
         found=TRUE;
       }
       else
@@ -2085,7 +2134,7 @@
         QCString n = mn->memberName();
         if (!n.isEmpty()) 
         {
-          g_fileIndexLetterUsed[filter][tolower(n.at(0))]=TRUE;
+          g_fileIndexLetterUsed[filter][tolower(n.at(getPrefixIndex(n)))]=TRUE;
         }
         found=TRUE;
       }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.