home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 9.ddi / IOSTRSR1.ZIP / SRBUFLOW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.4 KB  |  47 lines

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     srbuflow.cpp                                             |*/
  4. /*|                                                              |*/
  5. /*|     Class strstreambuf                                       |*/
  6. /*|          int strstreambuf::underflow()                       |*/
  7. /*|                                                              |*/
  8. /*[]------------------------------------------------------------[]*/
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 5.0
  12.  *
  13.  *      Copyright (c) 1990, 1992 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18. #include <ioconfig.h>
  19. #include <strstrea.h>
  20.  
  21. int strstreambuf::underflow()
  22. {
  23.     if( egptr() > gptr() )
  24.         return (unsigned char) *gptr();
  25.  
  26.     if( base()  &&  ! unbuffered()  &&  pptr() > pbase() )
  27.         {
  28.         if( ! gptr()  ||  gptr() < pbase() )
  29.             {
  30.             // initialize get area to current put area
  31.             setg(base(), pbase(), pptr());
  32.             return (unsigned char) *gptr();
  33.             }
  34.         if( gptr() < pptr() )
  35.             {
  36.             // extend get area to match put area
  37.             setg(eback(), gptr(), pptr());
  38.             return (unsigned char) *gptr();
  39.             }
  40.         // else no more chars
  41.         }
  42.  
  43.     return EOF;
  44. }
  45.  
  46.  
  47.