Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : ISTRUINT.CXX

 
Output of file : ISTRUINT.CXX contained in archive : VCCRT1.ZIP
/***
* istruint.cxx - definitions for istream class operaotor>>(unsigned int) funct
*
* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Definitions of operator>>(unsigned int) member function for istream
* class.
* [AT&T C++]
*
*******************************************************************************/

#include
#include
#include
#include
#include
#pragma hdrstop

// CONSIDER: validify all this maximum length
#define MAXLONGSIZ 16

/***
*istream& istream::operator>>(unsigned int& n) - extract unsigned int
*
*Purpose:
* Extract unsigned int value from stream
* Valid range is INT_MIN to UINT_MAX.
*
*Entry:
* n = value to update
*
*Exit:
* n updated, or ios::failbit and n=UINT_MAX if error
*
*Exceptions:
* Stream error on entry or value out of range
*
*******************************************************************************/
istream& istream::operator>>(unsigned int& n)

{
_WINSTATIC char ibuffer[MAXLONGSIZ];
unsigned long value;
char ** endptr = (char**)NULL;
if (ipfx(0)) {
value = strtoul(ibuffer, endptr, getint(ibuffer));

// CONSIDER: all but the first check is to emulate strtoul behavior
if (((value>UINT_MAX) && (value<=(ULONG_MAX-(-INT_MIN))))
|| ((value==ULONG_MAX) && (errno==ERANGE)))
{
n = UINT_MAX;
state |= ios::failbit;
}
else
n = (unsigned int) value;
#if 0
if (**endptr)
{
//UNDONE: put back any unread characters, if possible
}
#endif
isfx();
}
return *this;
}


  3 Responses to “Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : ISTRUINT.CXX

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/