messages_members.cc revision 102782
133965Sjdp// std::messages implementation details, GNU version -*- C++ -*- 2218822Sdim 3130561Sobrien// Copyright (C) 2001, 2002 Free Software Foundation, Inc. 4218822Sdim// 5218822Sdim// This file is part of the GNU ISO C++ Library. This library is free 6218822Sdim// software; you can redistribute it and/or modify it under the 7218822Sdim// terms of the GNU General Public License as published by the 8218822Sdim// Free Software Foundation; either version 2, or (at your option) 9218822Sdim// any later version. 10218822Sdim 11218822Sdim// This library is distributed in the hope that it will be useful, 12218822Sdim// but WITHOUT ANY WARRANTY; without even the implied warranty of 13218822Sdim// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14218822Sdim// GNU General Public License for more details. 15218822Sdim 16218822Sdim// You should have received a copy of the GNU General Public License along 17218822Sdim// with this library; see the file COPYING. If not, write to the Free 18218822Sdim// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19218822Sdim// USA. 20218822Sdim 21218822Sdim// As a special exception, you may use this file as part of a free software 22218822Sdim// library without restriction. Specifically, if other files instantiate 23218822Sdim// templates or use macros or inline functions from this file, or you compile 24218822Sdim// this file and link it with other files to produce an executable, this 25218822Sdim// file does not by itself cause the resulting executable to be covered by 26218822Sdim// the GNU General Public License. This exception does not however 27218822Sdim// invalidate any other reasons why the executable file might be covered by 28218822Sdim// the GNU General Public License. 29218822Sdim 30218822Sdim// 31218822Sdim// ISO C++ 14882: 22.2.7.1.2 messages virtual functions 32218822Sdim// 33218822Sdim 34218822Sdim// Written by Benjamin Kosnik <bkoz@redhat.com> 35218822Sdim 36218822Sdim#include <locale> 37218822Sdim 38218822Sdimnamespace std 39218822Sdim{ 40218822Sdim // Specializations. 41218822Sdim template<> 42218822Sdim string 43218822Sdim messages<char>::do_get(catalog, int, int, const string& __dfault) const 44218822Sdim { 45218822Sdim#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) 46218822Sdim __c_locale __old = __uselocale(_M_c_locale_messages); 47218822Sdim const char* __msg = const_cast<const char*>(gettext(__dfault.c_str())); 48218822Sdim __uselocale(__old); 49218822Sdim return string(__msg); 50218822Sdim#else 51218822Sdim char* __old = strdup(setlocale(LC_ALL, NULL)); 52218822Sdim setlocale(LC_ALL, _M_name_messages); 53218822Sdim const char* __msg = gettext(__dfault.c_str()); 54218822Sdim setlocale(LC_ALL, __old); 55218822Sdim free(__old); 56218822Sdim return string(__msg); 57218822Sdim#endif 58218822Sdim } 59218822Sdim} 60218822Sdim