blob: a8ce283cf04a347474e7e14163ca8b9c8d7ddb85 (
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
|
/***
* istrgetl.cxx - definitions for istream class getl() member function
*
* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Definitions of get and getline member functions istream class.
* [AT&T C++]
*
*Revision History:
* 09-26-91 KRS Created. Split off from istream.cxx for granularity.
* 01-23-92 KRS C700 #5880: Add cast to fix comparison in get().
*
*******************************************************************************/
#include <cruntime.h>
#include <internal.h>
#include <iostream.h>
#pragma hdrstop
// unformatted input functions
// signed and unsigned char make inline calls to this:
// all versions of getline also share this code:
istream& istream::get( char *b, int lim, char delim)
{
int c;
unsigned int i = 0;
if (ipfx(1)) // resets x_gcount
{
if (lim--)
{
while (i < (unsigned)lim)
{
c=bp->sgetc();
if (c==EOF)
{
state |= ios::eofbit;
if (!i)
state |= ios::failbit;
break;
}
else if (c==(int)(unsigned char)delim)
{
if (_fGline)
{
x_gcount++;
bp->stossc(); // extract delim if called from getline
}
break;
}
else
{
if (b)
b[i] = (char)c;
bp->stossc(); // advance pointer
}
i++;
}
x_gcount += i; // set gcount()
}
isfx();
lim++; // restore lim for test below
}
if ((b) && (lim)) // always null-terminate, if possible
b[i] = '\0';
_fGline = 0;
return *this;
}
|