Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.4 KiB

  1. /***
  2. * istrget.cpp - definitions for istream class get() member functions
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Definitions of get() member functions for istream class.
  8. * [AT&T C++]
  9. *
  10. *Revision History:
  11. * 09-26-91 KRS Created. Split off from istream.cxx for granularity.
  12. * 06-14-95 CFW Comment cleanup.
  13. *
  14. *******************************************************************************/
  15. #include <cruntime.h>
  16. #include <internal.h>
  17. #include <iostream.h>
  18. #pragma hdrstop
  19. // unformatted input functions
  20. int istream::get()
  21. {
  22. int c;
  23. if (ipfx(1)) // resets x_gcount
  24. {
  25. if ((c=bp->sbumpc())==EOF)
  26. state |= ios::eofbit;
  27. else
  28. x_gcount++;
  29. isfx();
  30. return c;
  31. }
  32. return EOF;
  33. }
  34. // signed and unsigned char make inline calls to this:
  35. istream& istream::get( char& c)
  36. {
  37. int temp;
  38. if (ipfx(1)) // resets x_gcount
  39. {
  40. if ((temp=bp->sbumpc())==EOF)
  41. state |= (ios::failbit|ios::eofbit);
  42. else
  43. x_gcount++;
  44. c = (char) temp;
  45. isfx();
  46. }
  47. return *this;
  48. }
  49. // called by signed and unsigned char versions
  50. istream& istream::read(char * ptr, int n)
  51. {
  52. if (ipfx(1)) // resets x_gcount
  53. {
  54. x_gcount = bp->sgetn(ptr, n);
  55. if ((unsigned)x_gcount < (unsigned)n)
  56. state |= (ios::failbit|ios::eofbit);
  57. isfx();
  58. }
  59. return *this;
  60. }