summaryrefslogtreecommitdiffstats
path: root/private/crt32/iostream/istream1.cxx
blob: ff2bc8098f1a88d7c21ce80ef2da9a008fa11d79 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/***
* istream1.cxx - non-core definitions for istream & istream_withassign classes
*
*	Copyright (c) 1991-1992, Microsoft Corporation.  All rights reserved.
*
*Purpose:
*	Definitions of non-core member functions for istream and
*	istream_withassign classes.
*	[AT&T C++]
*
*Revision History:
*	09-23-91   KRS	Created.  Split off from istream.cxx for granularity.
*	10-07-91   KRS	Increment x_gcount in get(sb).
*	10-24-91   KRS	Fix istream_withassign::operator=() functions.
*	11-20-91   KRS  Make operator= inline.
*	03-30-92   KRS	Add multithread locking.
*
*******************************************************************************/

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

istream& istream::operator>>(streambuf* _sbuf)
{
    int c;
    if (ipfx(0))
	{
	while ((c=bp->sbumpc())!=EOF)
	    {
	    if (_sbuf->sputc(c)==EOF)
		{
		state |= ios::failbit;
		}
	    }
	isfx();
	}
return *this;
}


// unformatted input functions

istream& istream::get( streambuf& sbuf, char delim)
{
    int c;
    if (ipfx(1))	// resets x_gcount
	{
	while ((c  = bp->sgetc())!=delim)
	    {
	    if (c==EOF)  // stop if EOF encountered
		{
		state |= ios::eofbit;
		break;
		}
	    bp->stossc();	// advance get pointer
	    x_gcount++;		// and increment count

	    // store c into sbuf  // UNDONE:  is this what they meant???
	    if (sbuf.sputc(c)==EOF)
 		state |= ios::failbit;
	    }
	isfx();
	}
    return *this;
}

istream& istream::seekg(streampos _strmp)
{
    lockbuf();
    if (bp->seekpos(_strmp, ios::in)==EOF)
	{
	clear(state | failbit);
	}
    unlockbuf();
    return(*this);
}

istream& istream::seekg(streamoff _strmf, seek_dir _sd)
{
    lockbuf();
    if (bp->seekoff(_strmf, _sd, ios::in)==EOF)
	clear(state | failbit);
    unlockbuf();
    return(*this);
}

streampos istream::tellg()
{
    streampos retval;
    lockbuf();
    if ((retval=bp->seekoff(streamoff(0), ios::cur, ios::in))==EOF)
	clear(state | failbit);
    unlockbuf();
    return(retval);
}