summaryrefslogtreecommitdiffstats
path: root/private/crt32/iostream/istrget.cxx
blob: 7b099cda788c62905729f7763e9d2a59635ad53e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/***
* istrget.cxx - definitions for istream class get() member functions
*
*	Copyright (c) 1991-1992, Microsoft Corporation.  All rights reserved.
*
*Purpose:
*	Definitions of get() member functions for istream class.
*	[AT&T C++]
*
*Revision History:
*	09-26-91   KRS	Created.  Split off from istream.cxx for granularity.
*
*******************************************************************************/

#include <cruntime.h>
#include <internal.h>
#include <iostream.h>
#pragma hdrstop

// unformatted input functions

int istream::get()
{
    int c;
    if (ipfx(1))	// resets x_gcount
	{
	if ((c=bp->sbumpc())==EOF)
	    state |= ios::eofbit;
	else
	    x_gcount++;
	isfx();
	return c;
	}
    return EOF;
}

// signed and unsigned char make inline calls to this:
istream& istream::get( char& c)
{
    int temp;
    if (ipfx(1))	// resets x_gcount
	{
	if ((temp=bp->sbumpc())==EOF)
	    state |= (ios::failbit|ios::eofbit);	// UNDONE ??
	else
	    x_gcount++;
	c = (char) temp;
	isfx();
	}
    return *this;
}


// called by signed and unsigned char versions
istream& istream::read(char * ptr, int n)
{
    if (ipfx(1))	// resets x_gcount
	{
	x_gcount = bp->sgetn(ptr, n);
	if ((unsigned)x_gcount < (unsigned)n)
	    state |= (ios::failbit|ios::eofbit);
	isfx();
	}
    return *this;
}