Source code of Windows XP (NT5)
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.

58 lines
1.5 KiB

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