Skip to content

Commit

Permalink
Merge pull request #11 from Sicos1977/revert-10-patch-2
Browse files Browse the repository at this point in the history
Revert "Fix chunk breaks."
  • Loading branch information
Kees committed Aug 3, 2015
2 parents 1b8128e + ab4ab90 commit 1082a63
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions IFilterTextReader/FilterReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ public override int Read(char[] buffer, int index, int count)

var textBuffer = new char[textLength + 1];
var textRead = false;
bool PrependBreak = false;

switch (_chunk.flags)
{
Expand Down Expand Up @@ -434,7 +433,6 @@ public override int Read(char[] buffer, int index, int count)
case NativeMethods.IFilterReturnCode.FILTER_S_LAST_TEXT:

textRead = true;
PrependBreak = false;
// Remove junk from the buffer
CleanUpCharacters(textLength, textBuffer);

Expand All @@ -450,8 +448,11 @@ public override int Read(char[] buffer, int index, int count)
case NativeMethods.CHUNK_BREAKTYPE.CHUNK_EOC:
case NativeMethods.CHUNK_BREAKTYPE.CHUNK_EOP:
case NativeMethods.CHUNK_BREAKTYPE.CHUNK_EOS:
PrependBreak = true;
textLength++;
if (textBuffer[textLength - 1] != ' ' && textBuffer[textLength - 1] != '\n')
{
textBuffer[textLength] = '\n';
textLength += 1;
}
break;
}

Expand All @@ -476,12 +477,9 @@ public override int Read(char[] buffer, int index, int count)
read -= charsLeft;
}
else
_charsLeftFromLastRead = null;
if (PrependBreak)
{
buffer[index + charsRead] = ' ';
}
Array.Copy(textBuffer, 0, buffer, index + charsRead + (PrependBreak ? 1 : 0), read - (PrependBreak ? 1 : 0));
_charsLeftFromLastRead = null;

Array.Copy(textBuffer, 0, buffer, index + charsRead, read);
charsRead += read;
}
}
Expand Down

0 comments on commit 1082a63

Please sign in to comment.