Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv451/src/modules

Modified Files:
        BareBonesEditor.cpp 
Log Message:
readded the worker function of DetectSignature here, it is still needed (though 
shouldn't be)

Index: BareBonesEditor.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/BareBonesEditor.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -b -u -2 -r1.29 -r1.30
--- BareBonesEditor.cpp 12 May 2004 21:58:38 -0000      1.29
+++ BareBonesEditor.cpp 14 Jul 2004 16:25:42 -0000      1.30
@@ -283,4 +283,40 @@
 };
 
+// FIXME: this duplicates the code in Singature.cpp and Trailer.cpp
+//        and should somehow be shared (but it is also used incorrectly
+//        here, i.e. we don't detect signature starting from the end...)
+bool DoesSignatureStartHere(const wxChar *cptr)
+{
+   bool isSig = false;
+
+   // hard coded detection for standard signature separator "--"
+   // and the mailing list trailer "____...___"
+   if ( cptr[0] == '-' && cptr[1] == '-' )
+   {
+      // there may be an optional space after "--" (in fact the
+      // space should be there but some people don't put it)
+      const wxChar *p = cptr + 2;
+      if ( IsEndOfLine(p) || (*p == ' ' && IsEndOfLine(p + 1)) )
+      {
+         // looks like the start of the sig
+         isSig = true;
+      }
+   }
+   else if ( cptr[0] == '_' )
+   {
+      const wxChar *p = cptr + 1;
+      while ( *p == '_' )
+         p++;
+
+      // arbitrarily consider that there should be at least 40 underscores...
+      if ( IsEndOfLine(p) && p - cptr >= 40 )
+      {
+         // looks like the mailing list trailer
+         isSig = true;
+      }
+   }
+
+   return isSig;
+}
 
 // ============================================================================
@@ -624,12 +660,9 @@
    int count = m_control->GetNumberOfLines();
 
-   DetectSignature detector;
-   detector.Initialize(m_profile);
-
-   for(m_signature = 0; m_signature < count; ++m_signature)
+   for ( m_signature = 0; m_signature < count; ++m_signature )
    {
       String line = m_control->GetLineText(m_signature);
       line += '\n';
-      if( detector.StartsHere(line.c_str()) )
+      if ( DoesSignatureStartHere(line) )
          break;
    }



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to