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.

57 lines
1.5 KiB

  1. /***
  2. * istrlong.cpp - definitions for istream class operator>>(long) member function
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Definitions of operator>>(long) member function(s) 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. * 01-06-92 KRS Added check of errno.
  13. * 12-30-92 KRS Fix indirection problem with **endptr.
  14. * 05-24-94 GJF Moved definition of MAXLONGSIZ to istream.h.
  15. * 06-14-95 CFW Comment cleanup.
  16. *
  17. *******************************************************************************/
  18. #include <cruntime.h>
  19. #include <internal.h>
  20. #include <stdlib.h>
  21. #include <limits.h>
  22. #include <errno.h>
  23. #include <iostream.h>
  24. #pragma hdrstop
  25. /***
  26. *istream& istream::operator>>(long& n) - extract long
  27. *
  28. *Purpose:
  29. * Extract long value from stream
  30. *
  31. *Entry:
  32. * n = value to update
  33. *
  34. *Exit:
  35. * n updated, or ios::failbit & n=LONG_MAX/LONG_MIN on overflow/underflow
  36. *
  37. *Exceptions:
  38. * Stream error on entry or value out of range
  39. *
  40. *******************************************************************************/
  41. istream& istream::operator>>(long& n)
  42. {
  43. _WINSTATIC char ibuffer[MAXLONGSIZ];
  44. char ** endptr = (char**)NULL;
  45. if (ipfx(0)) {
  46. n = strtol(ibuffer, endptr, getint(ibuffer));
  47. if (errno==ERANGE)
  48. {
  49. state |= ios::failbit;
  50. }
  51. isfx();
  52. }
  53. return *this;
  54. }