Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv25546/src/mail

Modified Files:
        MailFolder.cpp 
Log Message:
fixed subject normalization code (bug 628)

Index: MailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolder.cpp,v
retrieving revision 1.291
retrieving revision 1.292
diff -b -u -2 -r1.291 -r1.292
--- MailFolder.cpp      8 Sep 2002 19:23:11 -0000       1.291
+++ MailFolder.cpp      8 Sep 2002 20:23:07 -0000       1.292
@@ -890,5 +890,5 @@
       size_t replyLevel = 0;
 
-            // the search is case insensitive
+      // the search is case insensitive, so transform everything to lower case
       wxString subjectLower(subject.Lower()),
          replyPrefixLower(replyPrefixWithoutColon.Lower());
@@ -902,68 +902,75 @@
          static const char *replyPrefixStandard = gettext_noop("re");
 
-         size_t matchLen = 0;
-         const char *pMatch = strstr(pStart, replyPrefixLower);
-         if ( !pMatch )
-            pMatch = strstr(pStart, replyPrefixStandard);
-         else if ( !matchLen )
-            matchLen = replyPrefixLower.length();
-         if ( !pMatch )
-            pMatch = strstr(pStart, _(replyPrefixStandard));
-         else if ( !matchLen )
+         // first configured string
+         size_t matchLen = replyPrefixLower.length();
+         if ( strncmp(pStart, replyPrefixLower, matchLen) != 0 )
+         {
+            // next the standard string
             matchLen = strlen(replyPrefixStandard);
-         if ( !pMatch
-              || (*(pMatch+matchLen) != '[' &&
-                  *(pMatch+matchLen) != ':'
-                  && *(pMatch+matchLen) != '(')
-            )
+            if ( strncmp(pStart, replyPrefixStandard, matchLen) != 0 )
+            {
+               // finally the translation of the standard string
+               const char * const replyPrefixTrans =
+                  wxGetTranslation(replyPrefixStandard);
+               matchLen = strlen(replyPrefixTrans);
+               if ( strncmp(pStart, replyPrefixTrans, matchLen) != 0 )
+               {
+                  // failed to find any reply prefix
             break;
-         else if ( !matchLen )
-            matchLen = strlen(_(replyPrefixStandard));
-         pStart = pMatch + matchLen;
-         replyLevel++;
+               }
+            }
       }
 
-      //            if ( replyLevel == 1 )
-      //            {
+         // we found the reply prefix, now check that it is followed by
+         // one of the allowed symbols -- it has to for it to count as reply
+         // prefix
+         char chNext = pStart[matchLen];
+         if ( chNext == '[' || chNext == '(')
+         {
       // try to see if we don't have "Re[N]" string already
       int replyLevelOld;
-      if ( sscanf(pStart, "[%d]", &replyLevelOld) == 1 ||
-           sscanf(pStart, "(%d)", &replyLevelOld) == 1 )
+            if ( sscanf(pStart + matchLen, "[%d]", &replyLevelOld) == 1 ||
+                 sscanf(pStart + matchLen, "(%d)", &replyLevelOld) == 1 )
       {
-         replyLevel += replyLevelOld;
-         replyLevel --; // one was already counted
-         pStart++; // opening [ or (
-         while( isdigit(*pStart) )
-            pStart ++;
-         pStart++; // closing ] or )
+               // we've got a "Re[N]"
+               matchLen++; // opening [ or (
+               while( isdigit(pStart[matchLen]) )
+                  matchLen++;
+               matchLen++; // closing ] or )
+
+               // we're going to add 1 to replyLevel below anyhpw
+               replyLevel += replyLevelOld - 1;
+               chNext = pStart[matchLen];
+            }
+            else // doesn't seem like a reply prefix neither
+            {
+               break;
+            }
       }
-      //            }
-
-            // skip spaces
-      while ( isspace(*pStart) )
-         pStart++;
 
-            // skip also the ":" after "Re" is there was one
-      if ( replyLevel > 0 && *pStart == ':' )
+         if ( chNext == ':' )
       {
+            replyLevel++;
          pStart++;
+         }
+         else // not a reply prefix
+         {
+            break;
+         }
+
+         pStart += matchLen;
 
-         // ... and the spaces after ':' if any too
+         // skip spaces
          while ( isspace(*pStart) )
             pStart++;
       }
 
-      // this is the start of real subject
-      subject = subject.Mid(pStart - subjectLower.c_str());
+      // now pStart points to the start of the real subject but in the lower
+      // case string
+      subject = subject.c_str() + (pStart - subjectLower.c_str());
 
       if ( collapse == SmartCollapse && replyLevel > 0 )
       {
-         // TODO not configurable enough, allow the user to specify the
-         //      format string himself and also decide whether we use powers
-         //      of 2, just multiply by 2 or nothing at all
-         // for now we just increment the replyLevel by one,
-         // everything else is funny as it doesn't maintain
-         // powers of two :-) KB
-         replyLevel ++;
+         replyLevel++;
          newSubject.Printf("%s[%d]: %s",
                            replyPrefixWithoutColon.c_str(),
@@ -973,7 +980,7 @@
    }
 
-   // in cases of {No|Dumb}Collapse we fall here
    if ( !newSubject )
    {
+      // we get here in cases of {No|Dumb}Collapse
       newSubject = replyPrefix + subject;
    }



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to