Logo Search packages:      
Sourcecode: pan version File versions

std::string GNKSA::trim_references ( const StringView refs,
size_t  cutoff = 986u 
) [static]

Try to trim references down to an acceptable length for the NNTP server,

Parameters:
untrimmed "references" string
Returns:
newly-allocated trimmed "references" string

Definition at line 777 of file gnksa.cc.

References pan::StringView::begin(), pan::StringView::empty(), pan::StringView::end(), pan::StringView::len, and pan::StringView::pop_token().

Referenced by pan::BodyPane::create_followup_or_reply().

{
   std::string fixed (remove_broken_message_ids_from_references (refs));

   StringView left, unused, myrefs(fixed);
   myrefs.pop_token (left, ' ');
   const size_t len_left = cutoff - left.len - 1; // 1 for ' ' between left and right
   while (myrefs.len > len_left)
      myrefs.pop_token (unused, ' ');

   std::string s;
   s.insert (s.end(), left.begin(), left.end());
   if (!myrefs.empty())
     s += ' ';
   s.insert (s.end(), myrefs.begin(), myrefs.end());
   assert (s.size() <= cutoff);
   return s;
}


Generated by  Doxygen 1.6.0   Back to index