OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [src/] [c++98/] [streambuf.cc] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// Stream buffer classes -*- C++ -*-
2
 
3
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4
// Free Software Foundation, Inc.
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 3, or (at your option)
10
// any later version.
11
 
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
 
17
// Under Section 7 of GPL version 3, you are granted additional
18
// permissions described in the GCC Runtime Library Exception, version
19
// 3.1, as published by the Free Software Foundation.
20
 
21
// You should have received a copy of the GNU General Public License and
22
// a copy of the GCC Runtime Library Exception along with this program;
23
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
// <http://www.gnu.org/licenses/>.
25
 
26
//
27
// ISO C++ 14882: 27.5  Stream buffers
28
//
29
 
30
#include <streambuf>
31
 
32
namespace std _GLIBCXX_VISIBILITY(default)
33
{
34
_GLIBCXX_BEGIN_NAMESPACE_VERSION
35
 
36
  template<>
37
    streamsize
38
    __copy_streambufs_eof(basic_streambuf<char>* __sbin,
39
                          basic_streambuf<char>* __sbout, bool& __ineof)
40
    {
41
      typedef basic_streambuf<char>::traits_type traits_type;
42
      streamsize __ret = 0;
43
      __ineof = true;
44
      traits_type::int_type __c = __sbin->sgetc();
45
      while (!traits_type::eq_int_type(__c, traits_type::eof()))
46
        {
47
          const streamsize __n = __sbin->egptr() - __sbin->gptr();
48
          if (__n > 1)
49
            {
50
              const streamsize __wrote = __sbout->sputn(__sbin->gptr(), __n);
51
              __sbin->__safe_gbump(__wrote);
52
              __ret += __wrote;
53
              if (__wrote < __n)
54
                {
55
                  __ineof = false;
56
                  break;
57
                }
58
              __c = __sbin->underflow();
59
            }
60
          else
61
            {
62
              __c = __sbout->sputc(traits_type::to_char_type(__c));
63
              if (traits_type::eq_int_type(__c, traits_type::eof()))
64
                {
65
                  __ineof = false;
66
                  break;
67
                }
68
              ++__ret;
69
              __c = __sbin->snextc();
70
            }
71
        }
72
      return __ret;
73
    }
74
 
75
#ifdef _GLIBCXX_USE_WCHAR_T
76
  template<>
77
    streamsize
78
    __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
79
                          basic_streambuf<wchar_t>* __sbout, bool& __ineof)
80
    {
81
      typedef basic_streambuf<wchar_t>::traits_type traits_type;
82
      streamsize __ret = 0;
83
      __ineof = true;
84
      traits_type::int_type __c = __sbin->sgetc();
85
      while (!traits_type::eq_int_type(__c, traits_type::eof()))
86
        {
87
          const streamsize __n = __sbin->egptr() - __sbin->gptr();
88
          if (__n > 1)
89
            {
90
              const streamsize __wrote = __sbout->sputn(__sbin->gptr(), __n);
91
              __sbin->__safe_gbump(__wrote);
92
              __ret += __wrote;
93
              if (__wrote < __n)
94
                {
95
                  __ineof = false;
96
                  break;
97
                }
98
              __c = __sbin->underflow();
99
            }
100
          else
101
            {
102
              __c = __sbout->sputc(traits_type::to_char_type(__c));
103
              if (traits_type::eq_int_type(__c, traits_type::eof()))
104
                {
105
                  __ineof = false;
106
                  break;
107
                }
108
              ++__ret;
109
              __c = __sbin->snextc();
110
            }
111
        }
112
      return __ret;
113
    }
114
#endif
115
 
116
_GLIBCXX_END_NAMESPACE_VERSION
117
} // namespace

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.