home *** CD-ROM | disk | FTP | other *** search
- /* =============================
- * PedStreamInputBufferedText.cc
- * =============================
- */
-
- #include <string.h>
-
- #include "PedStreamInputBufferedText.hh"
- #include "PedBuffer.hh"
- #include "PedDataSource.hh"
-
- PedStreamInputBufferedText::PedStreamInputBufferedText(PedDataSource &inDataSource)
- : PedStreamInputBuffered(inDataSource)
- {
- }
-
- PedStreamInputBufferedText::~PedStreamInputBufferedText()
- {
- }
-
- long
- PedStreamInputBufferedText::GetChunk(long inCount, char *inBuf)
- {
- inCount = PedStreamInputBuffered::GetChunk(inCount, inBuf);
- if (inBuf[inCount - 1] == 13) {
- if (mCurrentBuffer && mCurrentBuffer->Ptr()[0] == 10) {
- mMark++;
- inBuf[inCount - 1] = '\n';
- }
- }
- return inCount;
- }
-
- long
- PedStreamInputBufferedText::CountAheadThroughChar(char inChar)
- {
- if (inChar != '\n') {
- return PedStreamInputBuffered::CountAheadThroughChar(inChar);
- }
- long countCR = PedStreamInputBuffered::CountAheadThroughChar(13);
- if (countCR < 0) {
- return countCR;
- }
- long countLF = PedStreamInputBuffered::CountAheadThroughChar(10);
-
- long count = (countCR < countLF)
- ? (countCR > 0 ? countCR : countLF)
- : (countLF > 0 ? countLF : countCR);
- return count;
- }
-