// strpatch.h - patch to the template /* The revised getline function is a variation on getline, specifically for reading from the Win95 console. It prevents the user from having to press Enter twice to end the input. Format: istream & getline( istream &, const string &, char delim, bool isConsole ); */ _STD_BEGIN template inline basic_istream<_E, _Tr>& __cdecl ugetline(basic_istream<_E, _Tr>& _I, basic_string<_E, _Tr, _A>& _X) { return (ugetline(_I, _X, _I.widen('\n'))); } template inline basic_istream<_E, _Tr>& __cdecl ugetline(basic_istream<_E, _Tr>& _I, basic_string<_E, _Tr, _A>& _X, const _E _D) {typedef basic_istream<_E, _Tr> _Myis; ios_base::iostate _St = ios_base::goodbit; bool _Chg = false; _X.erase(); const _Myis::sentry _Ok(_I, true); if (_Ok) {_TRY_IO_BEGIN _Tr::int_type _C = _I.rdbuf()->sgetc(); for (; ; _C = _I.rdbuf()->snextc()) if (_Tr::eq_int_type(_Tr::eof(), _C)) {_St |= ios_base::eofbit; break; } else if (_Tr::eq(_C, _D)) {_Chg = true; // The original version reads an additional character here (which is // appropriate for file input but not screen input: //_I.rdbuf()->snextc(); break; } else if (_X.max_size() <= _X.size()) {_St |= ios_base::failbit; break; } else _X += _Tr::to_char_type(_C), _Chg = true; _CATCH_IO_(_I); } if (!_Chg) _St |= ios_base::failbit; _I.setstate(_St); return (_I); } inline istream & getline( istream & inp, string & s, char delim, bool isConsole ) { if( isConsole ) return ugetline( inp, s, delim ); else return getline( inp, s, delim ); } _STD_END