diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-04-09 11:41:50 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-04-09 11:41:50 +0000 |
commit | e18c274ced5b68c4c232d24a40a5387e19e770de (patch) | |
tree | dff32c80bc9e587d0d588b069ef2a9cbd9a80d3c /gnu/lib | |
parent | 809854bfc624b9f52a7c9d85901e611046c5edd8 (diff) |
bye, bye, sprintf.
create an actual openbsd configuration that we can tweak.
okay kettenis@
Diffstat (limited to 'gnu/lib')
6 files changed, 346 insertions, 1 deletions
diff --git a/gnu/lib/libstdc++/libstdc++/config/locale/generic/c_locale.h b/gnu/lib/libstdc++/libstdc++/config/locale/generic/c_locale.h index 1f2accb1c29..4d8ad16056d 100644 --- a/gnu/lib/libstdc++/libstdc++/config/locale/generic/c_locale.h +++ b/gnu/lib/libstdc++/libstdc++/config/locale/generic/c_locale.h @@ -64,7 +64,7 @@ namespace std setlocale(LC_ALL, "C"); int __ret; -#ifdef _GLIBCPP_USE_C99 +#if defined _GLIBCPP_USE_C99 || defined _GLIBCPP_USE_C99_SNPRINTF if (__prec >= 0) __ret = snprintf(__out, __size, __fmt, __prec, __v); else diff --git a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h new file mode 100644 index 00000000000..564093dd557 --- /dev/null +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_base.h @@ -0,0 +1,58 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// Default information, may not be appropriate for specific host. + + struct ctype_base + { + // Non-standard typedefs. + typedef const int* __to_type; + + // NB: Offsets into ctype<char>::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. + typedef unsigned int mask; + static const mask upper = 1 << 0; + static const mask lower = 1 << 1; + static const mask alpha = 1 << 2; + static const mask digit = 1 << 3; + static const mask xdigit = 1 << 4; + static const mask space = 1 << 5; + static const mask print = 1 << 6; + static const mask graph = 1 << 7; + static const mask cntrl = 1 << 8; + static const mask punct = 1 << 9; + static const mask alnum = 1 << 10; + }; + + + diff --git a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h new file mode 100644 index 00000000000..0da0c7ccfb5 --- /dev/null +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_inline.h @@ -0,0 +1,163 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) +// functions go in ctype.cc + +// The following definitions are portable, but insanely slow. If one +// cares at all about performance, then specialized ctype +// functionality should be added for the native os in question: see +// the config/os/bits/ctype_*.h files. + +// Constructing a synthetic "C" table should be seriously considered... + + bool + ctype<char>:: + is(mask __m, char __c) const + { + if (_M_table) + return _M_table[static_cast<unsigned char>(__c)] & __m; + else + { + bool __ret = true; + bool __any_match = false; + const size_t __bitmasksize = 10; + size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0 + for (;__ret && __bitcur <= __bitmasksize; ++__bitcur) + { + mask __bit = static_cast<mask>(1 << __bitcur); + if (__m & __bit) + { + __any_match = true; + bool __testis; + switch (__bit) + { + case space: + __testis = isspace(__c); + break; + case print: + __testis = isprint(__c); + break; + case cntrl: + __testis = iscntrl(__c); + break; + case upper: + __testis = isupper(__c); + break; + case lower: + __testis = islower(__c); + break; + case alpha: + __testis = isalpha(__c); + break; + case digit: + __testis = isdigit(__c); + break; + case punct: + __testis = ispunct(__c); + break; + case xdigit: + __testis = isxdigit(__c); + break; + case alnum: + __testis = isalnum(__c); + break; + case graph: + __testis = isgraph(__c); + break; + default: + __testis = false; + break; + } + __ret &= __testis; + } + } + return __ret & __any_match; + } + } + + const char* + ctype<char>:: + is(const char* __low, const char* __high, mask* __vec) const + { + if (_M_table) + while (__low < __high) + *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; + else + { + // Highest bitmask in ctype_base == 10. + const size_t __bitmasksize = 10; + for (;__low < __high; ++__vec, ++__low) + { + mask __m = 0; + // Lowest bitmask in ctype_base == 0 + size_t __i = 0; + for (;__i <= __bitmasksize; ++__i) + { + mask __bit = static_cast<mask>(1 << __i); + if (this->is(__bit, *__low)) + __m |= __bit; + } + *__vec = __m; + } + } + return __high; + } + + const char* + ctype<char>:: + scan_is(mask __m, const char* __low, const char* __high) const + { + if (_M_table) + while (__low < __high + && !(_M_table[static_cast<unsigned char>(*__low)] & __m)) + ++__low; + else + while (__low < __high && !this->is(__m, *__low)) + ++__low; + return __low; + } + + const char* + ctype<char>:: + scan_not(mask __m, const char* __low, const char* __high) const + { + if (_M_table) + while (__low < __high + && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0) + ++__low; + else + while (__low < __high && this->is(__m, *__low) != 0) + ++__low; + return __low; + } diff --git a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h new file mode 100644 index 00000000000..d07dc8b9d7c --- /dev/null +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/ctype_noninline.h @@ -0,0 +1,82 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// +// ISO C++ 14882: 22.1 Locales +// + +// Information as gleaned from /usr/include/ctype.h + + const ctype_base::mask* + ctype<char>::classic_table() throw() + { return 0; } + + ctype<char>::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { } + + ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_table(__table ? __table : classic_table()) + { } + + char + ctype<char>::do_toupper(char __c) const + { return ::toupper((int) __c); } + + const char* + ctype<char>::do_toupper(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = ::toupper((int) *__low); + ++__low; + } + return __high; + } + + char + ctype<char>::do_tolower(char __c) const + { return ::tolower((int) __c); } + + const char* + ctype<char>::do_tolower(char* __low, const char* __high) const + { + while (__low < __high) + { + *__low = ::tolower((int) *__low); + ++__low; + } + return __high; + } diff --git a/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/os_defines.h b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/os_defines.h new file mode 100644 index 00000000000..1edcff5504c --- /dev/null +++ b/gnu/lib/libstdc++/libstdc++/config/os/bsd/openbsd/os_defines.h @@ -0,0 +1,39 @@ +// Specific definitions for OpenBSD platforms -*- C++ -*- + +// Copyright (C) 2000 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + + +#ifndef _GLIBCPP_OS_DEFINES +#define _GLIBCPP_OS_DEFINES 1 + +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. +#define _GLIBCPP_USE_C99_SNPRINTF 1 + + +#endif diff --git a/gnu/lib/libstdc++/libstdc++/configure.target b/gnu/lib/libstdc++/libstdc++/configure.target index c1d1cb1829c..1eb5b2ba515 100644 --- a/gnu/lib/libstdc++/libstdc++/configure.target +++ b/gnu/lib/libstdc++/libstdc++/configure.target @@ -154,6 +154,9 @@ case "${target_os}" in netbsd*) os_include_dir="os/bsd/netbsd" ;; + openbsd*) + os_include_dir="os/bsd/openbsd" + ;; solaris2.5 | solaris2.5.[0-9]) os_include_dir="os/solaris/solaris2.5" ;; |