home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Genie / Projects / Pedestal / Source / Sources / Streams / PedStreamInputBufferedText.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  1.1 KB  |  51 lines

  1. /*    =============================
  2.  *    PedStreamInputBufferedText.cc
  3.  *    =============================
  4.  */
  5.  
  6. #include <string.h>
  7.  
  8. #include "PedStreamInputBufferedText.hh"
  9. #include "PedBuffer.hh"
  10. #include "PedDataSource.hh"
  11.  
  12. PedStreamInputBufferedText::PedStreamInputBufferedText(PedDataSource &inDataSource)
  13. : PedStreamInputBuffered(inDataSource)
  14. {
  15. }
  16.  
  17. PedStreamInputBufferedText::~PedStreamInputBufferedText()
  18. {
  19. }
  20.  
  21. long
  22. PedStreamInputBufferedText::GetChunk(long inCount, char *inBuf)
  23. {
  24.     inCount = PedStreamInputBuffered::GetChunk(inCount, inBuf);
  25.     if (inBuf[inCount - 1] == 13) {
  26.         if (mCurrentBuffer && mCurrentBuffer->Ptr()[0] == 10) {
  27.             mMark++;
  28.             inBuf[inCount - 1] = '\n';
  29.         }
  30.     }
  31.     return inCount;
  32. }
  33.  
  34. long
  35. PedStreamInputBufferedText::CountAheadThroughChar(char inChar)
  36. {
  37.     if (inChar != '\n') {
  38.          return PedStreamInputBuffered::CountAheadThroughChar(inChar);
  39.     }
  40.     long countCR = PedStreamInputBuffered::CountAheadThroughChar(13);
  41.     if (countCR < 0) {
  42.         return countCR;
  43.     }
  44.     long countLF = PedStreamInputBuffered::CountAheadThroughChar(10);
  45.     
  46.     long count = (countCR < countLF) 
  47.         ? (countCR > 0 ? countCR : countLF) 
  48.         : (countLF > 0 ? countLF : countCR);
  49.     return count;
  50. }
  51.