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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [config/] [locale/] [gnu/] [c_locale.cc] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 jlechner
// Wrapper for underlying C-language localization -*- C++ -*-
2
 
3
// Copyright (C) 2001, 2002, 2003, 2004, 2005 
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 2, 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
// You should have received a copy of the GNU General Public License along
18
// with this library; see the file COPYING.  If not, write to the Free
19
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
// USA.
21
 
22
// As a special exception, you may use this file as part of a free software
23
// library without restriction.  Specifically, if other files instantiate
24
// templates or use macros or inline functions from this file, or you compile
25
// this file and link it with other files to produce an executable, this
26
// file does not by itself cause the resulting executable to be covered by
27
// the GNU General Public License.  This exception does not however
28
// invalidate any other reasons why the executable file might be covered by
29
// the GNU General Public License.
30
 
31
//
32
// ISO C++ 14882: 22.8  Standard locale categories.
33
//
34
 
35
// Written by Benjamin Kosnik <bkoz@redhat.com>
36
 
37
#include <cerrno>  // For errno
38
#include <locale>
39
#include <stdexcept>
40
#include <langinfo.h>
41
#include <bits/c++locale_internal.h>
42
 
43
namespace std
44
{
45
  template<>
46
    void
47
    __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
48
                   const __c_locale& __cloc)
49
    {
50
      char* __sanity;
51
      errno = 0;
52
      float __f = __strtof_l(__s, &__sanity, __cloc);
53
      if (__sanity != __s && errno != ERANGE)
54
        __v = __f;
55
      else
56
        __err |= ios_base::failbit;
57
    }
58
 
59
  template<>
60
    void
61
    __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
62
                   const __c_locale& __cloc)
63
    {
64
      char* __sanity;
65
      errno = 0;
66
      double __d = __strtod_l(__s, &__sanity, __cloc);
67
      if (__sanity != __s && errno != ERANGE)
68
        __v = __d;
69
      else
70
        __err |= ios_base::failbit;
71
    }
72
 
73
  template<>
74
    void
75
    __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
76
                   const __c_locale& __cloc)
77
    {
78
      char* __sanity;
79
      errno = 0;
80
      long double __ld = __strtold_l(__s, &__sanity, __cloc);
81
      if (__sanity != __s && errno != ERANGE)
82
        __v = __ld;
83
      else
84
        __err |= ios_base::failbit;
85
    }
86
 
87
  void
88
  locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
89
                                    __c_locale __old)
90
  {
91
    __cloc = __newlocale(1 << LC_ALL, __s, __old);
92
    if (!__cloc)
93
      {
94
        // This named locale is not supported by the underlying OS.
95
        __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
96
                              "name not valid"));
97
      }
98
  }
99
 
100
  void
101
  locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
102
  {
103
    if (__cloc && _S_get_c_locale() != __cloc)
104
      __freelocale(__cloc);
105
  }
106
 
107
  __c_locale
108
  locale::facet::_S_clone_c_locale(__c_locale& __cloc)
109
  { return __duplocale(__cloc); }
110
} // namespace std
111
 
112
namespace __gnu_cxx
113
{
114
  const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
115
    {
116
      "LC_CTYPE",
117
      "LC_NUMERIC",
118
      "LC_TIME",
119
      "LC_COLLATE",
120
      "LC_MONETARY",
121
      "LC_MESSAGES",
122
      "LC_PAPER",
123
      "LC_NAME",
124
      "LC_ADDRESS",
125
      "LC_TELEPHONE",
126
      "LC_MEASUREMENT",
127
      "LC_IDENTIFICATION"
128
    };
129
}
130
 
131
namespace std
132
{
133
  const char* const* const locale::_S_categories = __gnu_cxx::category_names;
134
}  // namespace std

powered by: WebSVN 2.1.0

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