aboutsummaryrefslogtreecommitdiffstats
path: root/src/word.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2007-11-20 21:45:54 +0000
committerVincent Richard <[email protected]>2007-11-20 21:45:54 +0000
commita87652e7b4f2854d9009847b10cdcdc7d131b217 (patch)
tree65693e9fed76dbe1a1009382382888af3c581391 /src/word.cpp
parentInitialize Winsock before using gethostbyname(). (diff)
downloadvmime-a87652e7b4f2854d9009847b10cdcdc7d131b217.tar.gz
vmime-a87652e7b4f2854d9009847b10cdcdc7d131b217.zip
Fixed incorrect white-space between words.
Diffstat (limited to 'src/word.cpp')
-rw-r--r--src/word.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/word.cpp b/src/word.cpp
index a33ab2ca..5c83ef98 100644
--- a/src/word.cpp
+++ b/src/word.cpp
@@ -309,16 +309,21 @@ void word::parse(const string& buffer, const string::size_type position,
void word::generate(utility::outputStream& os, const string::size_type maxLineLength,
const string::size_type curLinePos, string::size_type* newLinePos) const
{
- generate(os, maxLineLength, curLinePos, newLinePos, 0, true);
+ generate(os, maxLineLength, curLinePos, newLinePos, 0, NULL);
}
void word::generate(utility::outputStream& os, const string::size_type maxLineLength,
const string::size_type curLinePos, string::size_type* newLinePos, const int flags,
- const bool isFirstWord) const
+ generatorState* state) const
{
string::size_type curLineLength = curLinePos;
+ generatorState defaultGeneratorState;
+
+ if (state == NULL)
+ state = &defaultGeneratorState;
+
// Calculate the number of ASCII chars to check whether encoding is needed
// and _which_ encoding to use.
const string::size_type asciiCount =
@@ -374,7 +379,7 @@ void word::generate(utility::outputStream& os, const string::size_type maxLineLe
// we write the full line no matter of the max line length...
if (!newLine && p != end && lastWSpos == end &&
- !isFirstWord && curLineStart == m_buffer.begin())
+ !state->isFirstWord && curLineStart == m_buffer.begin())
{
// Here, we are continuing on the line of previous encoded
// word, but there is not even enough space to put the
@@ -428,7 +433,7 @@ void word::generate(utility::outputStream& os, const string::size_type maxLineLe
// last white-space.
#if 1
- if (curLineLength != 1 && !isFirstWord)
+ if (curLineLength != NEW_LINE_SEQUENCE_LENGTH && !state->isFirstWord && state->prevWordIsEncoded)
os << " "; // Separate from previous word
#endif
@@ -521,7 +526,7 @@ void word::generate(utility::outputStream& os, const string::size_type maxLineLe
}
// Encode and fold input buffer
- if (curLineLength != 1 && !isFirstWord)
+ if (!startNewLine && !state->isFirstWord && state->prevWordIsEncoded)
{
os << " "; // Separate from previous word
++curLineLength;
@@ -554,11 +559,15 @@ void word::generate(utility::outputStream& os, const string::size_type maxLineLe
// End of the encoded word
os << wordEnd;
+
+ state->prevWordIsEncoded = true;
}
}
if (newLinePos)
*newLinePos = curLineLength;
+
+ state->isFirstWord = false;
}