KMIME Library
Go to the documentation of this file.
36 using namespace KMime;
57 mLineMin( 0xffffffff ),
62 if ( !buf.isEmpty() ) {
63 count( buf.data(), buf.size() );
75 mLineMin( 0xffffffff ),
80 if ( buf && len > 0 ) {
86 static inline bool isWS(
char ch )
88 return ( ch ==
'\t' || ch ==
' ' );
92 void CharFreq::count(
const char *it,
size_t len )
94 const char *end = it + len;
95 uint currentLineLength = 0;
99 char prevPrevChar = 0;
101 for ( ; it != end ; ++it ) {
104 case '\0': ++mNUL;
break;
105 case '\r': ++mCR;
break;
107 if ( prevChar ==
'\r' ) {
108 --currentLineLength; ++mCRLF;
110 if ( currentLineLength >= mLineMax ) {
111 mLineMax = currentLineLength-1;
113 if ( currentLineLength <= mLineMin ) {
114 mLineMin = currentLineLength-1;
116 if ( !mTrailingWS ) {
117 if ( isWS( prevChar ) ||
118 ( prevChar ==
'\r' && isWS( prevPrevChar ) ) ) {
122 currentLineLength = 0;
125 if ( !mLeadingFrom ) {
126 if ( prevChar ==
'\n' && end - it >= 5 &&
127 !qstrncmp(
"From ", it, 5 ) ) {
136 if ( c ==
'\t' || ( c >=
' ' && c <=
'~' ) ) {
138 }
else if ( c == 127 || c <
' ' ) {
145 prevPrevChar = prevChar;
150 if ( currentLineLength >= mLineMax ) {
151 mLineMax = currentLineLength;
153 if ( currentLineLength <= mLineMin ) {
154 mLineMin = currentLineLength;
158 if ( isWS( prevChar ) ) {
198 qDebug(
"Total: %d; NUL: %d; CTL: %d;\n"
199 "CR: %d; LF: %d; CRLF: %d;\n"
200 "lineMin: %d; lineMax: %d;\n"
201 "printable: %d; eightBit: %d;\n"
202 "trailing whitespace: %s;\n"
203 "leading 'From ': %s;\n",
204 total, NUL, CTL, CR, LF, CRLF, lineMin, lineMax,
206 mTrailingWS ?
"yes" :
"no" , mLeadingFrom ?
"yes" :
"no" );
214 if ( mLineMax > 988 ) {
217 if ( ( mLF != mCRLF && mCRLF > 0 ) || mCR != mCRLF ||
controlCodesRatio() > 0.2 ) {
224 if ( mLineMax > 988 ) {
227 if ( ( mLF != mCRLF && mCRLF > 0 ) || mCR != mCRLF ||
controlCodesRatio() > 0.2 ) {
238 return float( mPrintable ) / float( mTotal );
247 return float( mCTL ) / float( mTotal );
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:44 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.