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

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     sdboflow.cpp                                             |*/
  4. /*|                                                              |*/
  5. /*|     Class stdiobuf                                           |*/
  6. /*|          int stdiobuf::overflow( int )                       |*/
  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 <filesys.h>
  20. #include <stdiostr.h>
  21.  
  22. int stdiobuf::overflow(int c)
  23. {
  24.     if ( ferror(sio) )
  25.         return EOF;
  26.  
  27.     char *p;
  28.     int count = out_waiting();
  29.     if( count > 0 )
  30.         {
  31.         p = pbase();
  32.         do  {
  33.             putc(*p, sio);
  34.             ++p;
  35.             } while( --count );
  36.         }
  37.     if( c != EOF )
  38.         putc(c, sio);
  39.  
  40.     char *b = base();
  41.     setp(b+4, b+blen());
  42.     setg(b, b+4, b+4);
  43.  
  44.     return ferror(sio) ? EOF : 1;
  45. }
  46.  
  47.  
  48.