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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [27_io/] [basic_filebuf/] [imbue/] [12206.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Copyright (C) 2003, 2009 Free Software Foundation, Inc.
2
//
3
// This file is part of the GNU ISO C++ Library.  This library is free
4
// software; you can redistribute it and/or modify it under the
5
// terms of the GNU General Public License as published by the
6
// Free Software Foundation; either version 3, or (at your option)
7
// any later version.
8
 
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
 
14
// You should have received a copy of the GNU General Public License along
15
// with this library; see the file COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// 27.8.1.4 Overridden virtual functions
19
 
20
#include <fstream>
21
 
22
typedef unsigned char Char;
23
 
24
namespace std
25
{
26
  template <>
27
  class codecvt<Char, char, mbstate_t> :
28
    public locale::facet, public codecvt_base
29
  {
30
  public:
31
    typedef Char intern_type;
32
    typedef char extern_type;
33
    typedef mbstate_t state_type;
34
 
35
    explicit codecvt(size_t refs = 0)
36
      : locale::facet(refs) { }
37
    result out(mbstate_t& state, const Char* from,
38
               const Char* from_end, const Char*& from_next,
39
               char* to, char* to_limit, char*& to_next) const
40
    {
41
      return do_out(state, from, from_end, from_next,
42
                    to, to_limit, to_next);
43
    }
44
    result in(mbstate_t& state, const char* from,
45
              const char* from_end, const char*& from_next,
46
              Char* to, Char* to_limit, Char*& to_next) const
47
    {
48
      return do_in(state, from, from_end, from_next,
49
                   to, to_limit, to_next);
50
    }
51
    result unshift(mbstate_t& state, char* to, char* to_end,
52
                   char*& to_next) const
53
    { return do_unshift(state, to, to_end, to_next); }
54
    int length(mbstate_t& state, const char* from,
55
               const char* from_end, size_t max) const
56
    { return do_length(state, from, from_end, max); }
57
    int encoding() const throw()
58
    { return do_encoding(); }
59
    bool always_noconv() const throw()
60
    { return do_always_noconv(); }
61
    int max_length() const throw()
62
    { return do_max_length(); }
63
 
64
    static locale::id id;
65
 
66
  protected:
67
    virtual result do_out(mbstate_t&, const Char*,
68
                          const Char*,
69
                          const Char*&, char*,
70
                          char*, char*&) const
71
    { return ok; }
72
    virtual result do_in(mbstate_t&, const char*,
73
                         const char*,
74
                         const char*&, Char*,
75
                         Char*, Char*&) const
76
    { return ok; }
77
    virtual result do_unshift(mbstate_t&, char*, char*,
78
                              char*&) const
79
    { return noconv; }
80
    virtual int do_length(mbstate_t&, const char*,
81
                          const char*, size_t) const
82
    { return 1; }
83
    virtual int do_encoding() const throw()
84
    { return 1; }
85
    virtual bool do_always_noconv() const throw()
86
    { return false; }
87
    virtual int do_max_length() const throw()
88
    { return 1; }
89
  };
90
 
91
  locale::id codecvt<Char, char, mbstate_t>::id;
92
}
93
 
94
// libstdc++/12206
95
void test01()
96
{
97
  using namespace std;
98
  bool test __attribute__((unused)) = true;
99
 
100
  locale loc(locale::classic(),
101
             new codecvt<Char, char, std::mbstate_t>);
102
  locale::global(loc);
103
 
104
  basic_filebuf<Char, char_traits<Char> > fb;
105
 
106
  loc = locale::classic();
107
  locale::global(loc);
108
  fb.pubimbue(loc);
109
 
110
  fb.open("tmp_12206", ios_base::out);
111
  try
112
    {
113
      fb.pubseekoff(0, ios_base::cur);
114
    }
115
  catch (std::exception&)
116
    {
117
    }
118
  fb.close();
119
}
120
 
121
int main()
122
{
123
  test01();
124
  return 0;
125
}

powered by: WebSVN 2.1.0

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