home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / c / gcc / g++libsrc.spk / cc / igetsb < prev    next >
Text File  |  1993-08-04  |  2KB  |  49 lines

  1. //    This is part of the iostream library, providing input/output for C++.
  2. //    Copyright (C) 1992 Per Bothner.
  3. //
  4. //    This library is free software; you can redistribute it and/or
  5. //    modify it under the terms of the GNU Library General Public
  6. //    License as published by the Free Software Foundation; either
  7. //    version 2 of the License, or (at your option) any later version.
  8. //
  9. //    This library is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. //    Library General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU Library General Public
  15. //    License along with this library; if not, write to the Free
  16. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include "ioprivate.h"
  19. #include "iostream.h"
  20.  
  21. istream& istream::get(streambuf& sb, char delim /* = '\n' */)
  22. {
  23.     _gcount = 0;
  24.     if (ipfx1()) {
  25.     register streambuf* isb = rdbuf();
  26.     for (;;) {
  27.         int len = isb->egptr() - isb->gptr();
  28.         if (len <= 0)
  29.         if (isb->underflow() == EOF)
  30.             break;
  31.         else
  32.             len = isb->egptr() - isb->gptr();
  33.         char *delimp = (char*)memchr((void*)isb->gptr(), delim, len);
  34.         if (delimp != NULL)
  35.         len = delimp - isb->gptr();
  36.         int written = sb.sputn(isb->gptr(), len);
  37.         isb->gbump(written);
  38.         _gcount += written;
  39.         if (written != len) {
  40.         set(ios::failbit);
  41.         break;
  42.         }
  43.         if (delimp != NULL)
  44.         break;
  45.     }
  46.     }
  47.     return *this;
  48. }
  49.