head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.11
	netbsd-11-0-RC3:1.1.1.11
	netbsd-11-0-RC2:1.1.1.11
	netbsd-11-0-RC1:1.1.1.11
	gcc-14-3-0:1.1.1.12
	perseant-exfatfs-base-20250801:1.1.1.11
	netbsd-11:1.1.1.11.0.4
	netbsd-11-base:1.1.1.11
	gcc-12-5-0:1.1.1.11
	netbsd-10-1-RELEASE:1.1.1.10
	perseant-exfatfs-base-20240630:1.1.1.11
	gcc-12-4-0:1.1.1.11
	perseant-exfatfs:1.1.1.11.0.2
	perseant-exfatfs-base:1.1.1.11
	netbsd-8-3-RELEASE:1.1.1.3
	netbsd-9-4-RELEASE:1.1.1.5
	netbsd-10-0-RELEASE:1.1.1.10
	netbsd-10-0-RC6:1.1.1.10
	netbsd-10-0-RC5:1.1.1.10
	netbsd-10-0-RC4:1.1.1.10
	netbsd-10-0-RC3:1.1.1.10
	netbsd-10-0-RC2:1.1.1.10
	netbsd-10-0-RC1:1.1.1.10
	gcc-12-3-0:1.1.1.11
	gcc-10-5-0:1.1.1.10
	netbsd-10:1.1.1.10.0.6
	netbsd-10-base:1.1.1.10
	netbsd-9-3-RELEASE:1.1.1.5
	gcc-10-4-0:1.1.1.10
	cjep_sun2x-base1:1.1.1.10
	cjep_sun2x:1.1.1.10.0.4
	cjep_sun2x-base:1.1.1.10
	cjep_staticlib_x-base1:1.1.1.10
	netbsd-9-2-RELEASE:1.1.1.5
	cjep_staticlib_x:1.1.1.10.0.2
	cjep_staticlib_x-base:1.1.1.10
	gcc-10-3-0:1.1.1.10
	netbsd-9-1-RELEASE:1.1.1.5
	gcc-9-3-0:1.1.1.9
	gcc-7-5-0:1.1.1.7
	phil-wifi-20200421:1.1.1.6
	phil-wifi-20200411:1.1.1.6
	is-mlppp:1.1.1.6.0.2
	is-mlppp-base:1.1.1.6
	phil-wifi-20200406:1.1.1.6
	netbsd-8-2-RELEASE:1.1.1.3
	gcc-8-4-0:1.1.1.8
	netbsd-9-0-RELEASE:1.1.1.5
	netbsd-9-0-RC2:1.1.1.5
	netbsd-9-0-RC1:1.1.1.5
	phil-wifi-20191119:1.1.1.6
	gcc-8-3-0:1.1.1.6
	netbsd-9:1.1.1.5.0.2
	netbsd-9-base:1.1.1.5
	phil-wifi-20190609:1.1.1.5
	netbsd-8-1-RELEASE:1.1.1.3
	netbsd-8-1-RC1:1.1.1.3
	pgoyette-compat-merge-20190127:1.1.1.4.2.1
	pgoyette-compat-20190127:1.1.1.5
	gcc-7-4-0:1.1.1.5
	pgoyette-compat-20190118:1.1.1.4
	pgoyette-compat-1226:1.1.1.4
	pgoyette-compat-1126:1.1.1.4
	gcc-6-5-0:1.1.1.4
	pgoyette-compat-1020:1.1.1.4
	pgoyette-compat-0930:1.1.1.4
	pgoyette-compat-0906:1.1.1.4
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.4
	netbsd-8-0-RELEASE:1.1.1.3
	phil-wifi:1.1.1.4.0.4
	phil-wifi-base:1.1.1.4
	pgoyette-compat-0625:1.1.1.4
	netbsd-8-0-RC2:1.1.1.3
	pgoyette-compat-0521:1.1.1.4
	pgoyette-compat-0502:1.1.1.4
	pgoyette-compat-0422:1.1.1.4
	netbsd-8-0-RC1:1.1.1.3
	pgoyette-compat-0415:1.1.1.4
	pgoyette-compat-0407:1.1.1.4
	pgoyette-compat-0330:1.1.1.4
	pgoyette-compat-0322:1.1.1.4
	pgoyette-compat-0315:1.1.1.4
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.4.0.2
	pgoyette-compat-base:1.1.1.4
	gcc-6-4-0:1.1.1.4
	netbsd-7-1-1-RELEASE:1.1.1.2
	gcc-5-5-0:1.1.1.3
	matt-nb8-mediatek:1.1.1.3.0.12
	matt-nb8-mediatek-base:1.1.1.3
	perseant-stdc-iso10646:1.1.1.3.0.10
	perseant-stdc-iso10646-base:1.1.1.3
	netbsd-8:1.1.1.3.0.8
	netbsd-8-base:1.1.1.3
	prg-localcount2-base3:1.1.1.3
	prg-localcount2-base2:1.1.1.3
	prg-localcount2-base1:1.1.1.3
	prg-localcount2:1.1.1.3.0.6
	prg-localcount2-base:1.1.1.3
	pgoyette-localcount-20170426:1.1.1.3
	bouyer-socketcan-base1:1.1.1.3
	pgoyette-localcount-20170320:1.1.1.3
	netbsd-7-1:1.1.1.2.0.10
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.3.0.4
	bouyer-socketcan-base:1.1.1.3
	pgoyette-localcount-20170107:1.1.1.3
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.3
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.3
	netbsd-7-nhusb:1.1.1.2.0.8
	netbsd-7-nhusb-base:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.3
	pgoyette-localcount-20160726:1.1.1.3
	pgoyette-localcount:1.1.1.3.0.2
	pgoyette-localcount-base:1.1.1.3
	gcc-5-4-0:1.1.1.3
	netbsd-7-0-1-RELEASE:1.1.1.2
	gcc-5-3-0:1.1.1.3
	netbsd-7-0:1.1.1.2.0.6
	netbsd-7-0-RELEASE:1.1.1.2
	gcc-4-8-5-pre-gcc-old-import:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	post-gcc-4-8-5-merge:1.1.1.2
	gcc-4-8-5:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	gcc-4-8-4:1.1.1.2
	gcc-4-8-20141009:1.1.1.2
	netbsd-6-0-6-RELEASE:1.1.1.1
	netbsd-6-1-5-RELEASE:1.1.1.1
	netbsd-7:1.1.1.2.0.4
	netbsd-7-base:1.1.1.2
	gcc-4-8-3:1.1.1.2
	yamt-pagecache-base9:1.1.1.2
	yamt-pagecache-tag8:1.1.1.1
	netbsd-6-1-4-RELEASE:1.1.1.1
	netbsd-6-0-5-RELEASE:1.1.1.1
	tls-earlyentropy:1.1.1.2.0.2
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	gcc-4-8-3-pre-r208254:1.1.1.2
	gcc-4-8-3-pre-r206687:1.1.1.2
	imported-to-gcc-old-20140227-0107:1.1.1.1
	netbsd-6-1-3-RELEASE:1.1.1.1
	netbsd-6-0-4-RELEASE:1.1.1.1
	netbsd-6-1-2-RELEASE:1.1.1.1
	netbsd-6-0-3-RELEASE:1.1.1.1
	netbsd-6-1-1-RELEASE:1.1.1.1
	riastradh-drm2-base2:1.1.1.1
	riastradh-drm2-base1:1.1.1.1
	riastradh-drm2:1.1.1.1.0.12
	riastradh-drm2-base:1.1.1.1
	netbsd-6-1:1.1.1.1.0.16
	netbsd-6-0-2-RELEASE:1.1.1.1
	netbsd-6-1-RELEASE:1.1.1.1
	netbsd-6-1-RC4:1.1.1.1
	netbsd-6-1-RC3:1.1.1.1
	agc-symver:1.1.1.1.0.14
	agc-symver-base:1.1.1.1
	netbsd-6-1-RC2:1.1.1.1
	netbsd-6-1-RC1:1.1.1.1
	yamt-pagecache-base8:1.1.1.1
	netbsd-6-0-1-RELEASE:1.1.1.1
	yamt-pagecache-base7:1.1.1.1
	matt-nb6-plus-nbase:1.1.1.1
	yamt-pagecache-base6:1.1.1.1
	netbsd-6-0:1.1.1.1.0.10
	netbsd-6-0-RELEASE:1.1.1.1
	gcc-4-5-4:1.1.1.1
	netbsd-6-0-RC2:1.1.1.1
	tls-maxphys:1.1.1.1.0.8
	tls-maxphys-base:1.1.1.2
	matt-nb6-plus:1.1.1.1.0.6
	matt-nb6-plus-base:1.1.1.1
	netbsd-6-0-RC1:1.1.1.1
	yamt-pagecache-base5:1.1.1.1
	yamt-pagecache-base4:1.1.1.1
	netbsd-6:1.1.1.1.0.4
	netbsd-6-base:1.1.1.1
	yamt-pagecache-base3:1.1.1.1
	yamt-pagecache-base2:1.1.1.1
	yamt-pagecache:1.1.1.1.0.2
	yamt-pagecache-base:1.1.1.1
	gcc-4-5-3:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2011.06.21.01.24.41;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2011.06.21.01.24.41;	author mrg;	state Exp;
branches
	1.1.1.1.2.1
	1.1.1.1.8.1;
next	1.1.1.2;

1.1.1.2
date	2014.03.01.08.41.35;	author mrg;	state Exp;
branches;
next	1.1.1.3;
commitid	TtaB91QNTknAoYqx;

1.1.1.3
date	2016.01.24.06.05.52;	author mrg;	state Exp;
branches;
next	1.1.1.4;
commitid	uWWfbLp08zOK79Sy;

1.1.1.4
date	2018.02.02.01.59.04;	author mrg;	state Exp;
branches
	1.1.1.4.2.1
	1.1.1.4.4.1;
next	1.1.1.5;
commitid	XNKaycqpfhzd5epA;

1.1.1.5
date	2019.01.19.10.14.12;	author mrg;	state Exp;
branches;
next	1.1.1.6;
commitid	VQ8OwWIg5RS9kn8B;

1.1.1.6
date	2019.10.01.09.36.07;	author mrg;	state Exp;
branches;
next	1.1.1.7;
commitid	smvgr2IPAQDr89FB;

1.1.1.7
date	2020.08.11.05.10.40;	author mrg;	state Exp;
branches;
next	1.1.1.8;
commitid	5dBRDT7i6e65xBjC;

1.1.1.8
date	2020.08.11.05.30.09;	author mrg;	state Exp;
branches;
next	1.1.1.9;
commitid	7AI4OfpLi4eqEBjC;

1.1.1.9
date	2020.09.05.07.52.10;	author mrg;	state Exp;
branches;
next	1.1.1.10;
commitid	ZRYA7IOuwfMjAPmC;

1.1.1.10
date	2021.04.10.22.10.03;	author mrg;	state Exp;
branches;
next	1.1.1.11;
commitid	eC4g0MRpqTvEkNOC;

1.1.1.11
date	2023.07.30.05.21.19;	author mrg;	state Exp;
branches;
next	1.1.1.12;
commitid	tk6nV4mbc9nVEMyE;

1.1.1.12
date	2025.09.13.23.45.47;	author mrg;	state Exp;
branches;
next	;
commitid	KwhwN4krNWa6XBaG;

1.1.1.1.2.1
date	2014.05.22.16.37.48;	author yamt;	state Exp;
branches;
next	;
commitid	DX8bafDLmqEbpyBx;

1.1.1.1.8.1
date	2014.08.19.23.54.49;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.4.2.1
date	2019.01.26.21.59.33;	author pgoyette;	state Exp;
branches;
next	;
commitid	JKpcmvSjdT25dl9B;

1.1.1.4.4.1
date	2019.06.10.21.54.50;	author christos;	state Exp;
branches;
next	1.1.1.4.4.2;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.4.4.2
date	2020.04.13.07.58.36;	author martin;	state Exp;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.1
log
@Initial revision
@
text
@// Locale support -*- C++ -*-

// Copyright (C) 2007, 2008, 2009, 2010 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 3, 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.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @@file locale_facets_nonio.tcc
 *  This is an internal header file, included by other library headers.
 *  You should not attempt to use it directly.
 */

#ifndef _LOCALE_FACETS_NONIO_TCC
#define _LOCALE_FACETS_NONIO_TCC 1

#pragma GCC system_header

_GLIBCXX_BEGIN_NAMESPACE(std)

  template<typename _CharT, bool _Intl>
    struct __use_cache<__moneypunct_cache<_CharT, _Intl> >
    {
      const __moneypunct_cache<_CharT, _Intl>*
      operator() (const locale& __loc) const
      {
	const size_t __i = moneypunct<_CharT, _Intl>::id._M_id();
	const locale::facet** __caches = __loc._M_impl->_M_caches;
	if (!__caches[__i])
	  {
	    __moneypunct_cache<_CharT, _Intl>* __tmp = NULL;
	    __try
	      {
		__tmp = new __moneypunct_cache<_CharT, _Intl>;
		__tmp->_M_cache(__loc);
	      }
	    __catch(...)
	      {
		delete __tmp;
		__throw_exception_again;
	      }
	    __loc._M_impl->_M_install_cache(__tmp, __i);
	  }
	return static_cast<
	  const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]);
      }
    };

  template<typename _CharT, bool _Intl>
    void
    __moneypunct_cache<_CharT, _Intl>::_M_cache(const locale& __loc)
    {
      _M_allocated = true;

      const moneypunct<_CharT, _Intl>& __mp =
	use_facet<moneypunct<_CharT, _Intl> >(__loc);

      _M_decimal_point = __mp.decimal_point();
      _M_thousands_sep = __mp.thousands_sep();
      _M_frac_digits = __mp.frac_digits();

      char* __grouping = 0;
      _CharT* __curr_symbol = 0;
      _CharT* __positive_sign = 0;
      _CharT* __negative_sign = 0;     
      __try
	{
	  _M_grouping_size = __mp.grouping().size();
	  __grouping = new char[_M_grouping_size];
	  __mp.grouping().copy(__grouping, _M_grouping_size);
	  _M_grouping = __grouping;
	  _M_use_grouping = (_M_grouping_size
			     && static_cast<signed char>(_M_grouping[0]) > 0
			     && (_M_grouping[0]
				 != __gnu_cxx::__numeric_traits<char>::__max));

	  _M_curr_symbol_size = __mp.curr_symbol().size();
	  __curr_symbol = new _CharT[_M_curr_symbol_size];
	  __mp.curr_symbol().copy(__curr_symbol, _M_curr_symbol_size);
	  _M_curr_symbol = __curr_symbol;

	  _M_positive_sign_size = __mp.positive_sign().size();
	  __positive_sign = new _CharT[_M_positive_sign_size];
	  __mp.positive_sign().copy(__positive_sign, _M_positive_sign_size);
	  _M_positive_sign = __positive_sign;

	  _M_negative_sign_size = __mp.negative_sign().size();
	  __negative_sign = new _CharT[_M_negative_sign_size];
	  __mp.negative_sign().copy(__negative_sign, _M_negative_sign_size);
	  _M_negative_sign = __negative_sign;

	  _M_pos_format = __mp.pos_format();
	  _M_neg_format = __mp.neg_format();

	  const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
	  __ct.widen(money_base::_S_atoms,
		     money_base::_S_atoms + money_base::_S_end, _M_atoms);
	}
      __catch(...)
	{
	  delete [] __grouping;
	  delete [] __curr_symbol;
	  delete [] __positive_sign;
	  delete [] __negative_sign;
	  __throw_exception_again;
	}
    }

_GLIBCXX_BEGIN_LDBL_NAMESPACE

  template<typename _CharT, typename _InIter>
    template<bool _Intl>
      _InIter
      money_get<_CharT, _InIter>::
      _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
		 ios_base::iostate& __err, string& __units) const
      {
	typedef char_traits<_CharT>			  __traits_type;
	typedef typename string_type::size_type	          size_type;	
	typedef money_base::part			  part;
	typedef __moneypunct_cache<_CharT, _Intl>         __cache_type;
	
	const locale& __loc = __io._M_getloc();
	const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

	__use_cache<__cache_type> __uc;
	const __cache_type* __lc = __uc(__loc);
	const char_type* __lit = __lc->_M_atoms;

	// Deduced sign.
	bool __negative = false;
	// Sign size.
	size_type __sign_size = 0;
	// True if sign is mandatory.
	const bool __mandatory_sign = (__lc->_M_positive_sign_size
				       && __lc->_M_negative_sign_size);
	// String of grouping info from thousands_sep plucked from __units.
	string __grouping_tmp;
	if (__lc->_M_use_grouping)
	  __grouping_tmp.reserve(32);
	// Last position before the decimal point.
	int __last_pos = 0;
	// Separator positions, then, possibly, fractional digits.
	int __n = 0;
	// If input iterator is in a valid state.
	bool __testvalid = true;
	// Flag marking when a decimal point is found.
	bool __testdecfound = false;

	// The tentative returned string is stored here.
	string __res;
	__res.reserve(32);

	const char_type* __lit_zero = __lit + money_base::_S_zero;
	const money_base::pattern __p = __lc->_M_neg_format;
	for (int __i = 0; __i < 4 && __testvalid; ++__i)
	  {
	    const part __which = static_cast<part>(__p.field[__i]);
	    switch (__which)
	      {
	      case money_base::symbol:
		// According to 22.2.6.1.2, p2, symbol is required
		// if (__io.flags() & ios_base::showbase), otherwise
		// is optional and consumed only if other characters
		// are needed to complete the format.
		if (__io.flags() & ios_base::showbase || __sign_size > 1
		    || __i == 0
		    || (__i == 1 && (__mandatory_sign
				     || (static_cast<part>(__p.field[0])
					 == money_base::sign)
				     || (static_cast<part>(__p.field[2])
					 == money_base::space)))
		    || (__i == 2 && ((static_cast<part>(__p.field[3])
				      == money_base::value)
				     || (__mandatory_sign
					 && (static_cast<part>(__p.field[3])
					     == money_base::sign)))))
		  {
		    const size_type __len = __lc->_M_curr_symbol_size;
		    size_type __j = 0;
		    for (; __beg != __end && __j < __len
			   && *__beg == __lc->_M_curr_symbol[__j];
			 ++__beg, ++__j);
		    if (__j != __len
			&& (__j || __io.flags() & ios_base::showbase))
		      __testvalid = false;
		  }
		break;
	      case money_base::sign:
		// Sign might not exist, or be more than one character long.
		if (__lc->_M_positive_sign_size && __beg != __end
		    && *__beg == __lc->_M_positive_sign[0])
		  {
		    __sign_size = __lc->_M_positive_sign_size;
		    ++__beg;
		  }
		else if (__lc->_M_negative_sign_size && __beg != __end
			 && *__beg == __lc->_M_negative_sign[0])
		  {
		    __negative = true;
		    __sign_size = __lc->_M_negative_sign_size;
		    ++__beg;
		  }
		else if (__lc->_M_positive_sign_size
			 && !__lc->_M_negative_sign_size)
		  // "... if no sign is detected, the result is given the sign
		  // that corresponds to the source of the empty string"
		  __negative = true;
		else if (__mandatory_sign)
		  __testvalid = false;
		break;
	      case money_base::value:
		// Extract digits, remove and stash away the
		// grouping of found thousands separators.
		for (; __beg != __end; ++__beg)
		  {
		    const char_type __c = *__beg;
		    const char_type* __q = __traits_type::find(__lit_zero, 
							       10, __c);
		    if (__q != 0)
		      {
			__res += money_base::_S_atoms[__q - __lit];
			++__n;
		      }
		    else if (__c == __lc->_M_decimal_point 
			     && !__testdecfound)
		      {
			if (__lc->_M_frac_digits <= 0)
			  break;

			__last_pos = __n;
			__n = 0;
			__testdecfound = true;
		      }
		    else if (__lc->_M_use_grouping
			     && __c == __lc->_M_thousands_sep
			     && !__testdecfound)
		      {
			if (__n)
			  {
			    // Mark position for later analysis.
			    __grouping_tmp += static_cast<char>(__n);
			    __n = 0;
			  }
			else
			  {
			    __testvalid = false;
			    break;
			  }
		      }
		    else
		      break;
		  }
		if (__res.empty())
		  __testvalid = false;
		break;
	      case money_base::space:
		// At least one space is required.
		if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
		  ++__beg;
		else
		  __testvalid = false;
	      case money_base::none:
		// Only if not at the end of the pattern.
		if (__i != 3)
		  for (; __beg != __end
			 && __ctype.is(ctype_base::space, *__beg); ++__beg);
		break;
	      }
	  }

	// Need to get the rest of the sign characters, if they exist.
	if (__sign_size > 1 && __testvalid)
	  {
	    const char_type* __sign = __negative ? __lc->_M_negative_sign
	                                         : __lc->_M_positive_sign;
	    size_type __i = 1;
	    for (; __beg != __end && __i < __sign_size
		   && *__beg == __sign[__i]; ++__beg, ++__i);
	    
	    if (__i != __sign_size)
	      __testvalid = false;
	  }

	if (__testvalid)
	  {
	    // Strip leading zeros.
	    if (__res.size() > 1)
	      {
		const size_type __first = __res.find_first_not_of('0');
		const bool __only_zeros = __first == string::npos;
		if (__first)
		  __res.erase(0, __only_zeros ? __res.size() - 1 : __first);
	      }

	    // 22.2.6.1.2, p4
	    if (__negative && __res[0] != '0')
	      __res.insert(__res.begin(), '-');
	    
	    // Test for grouping fidelity.
	    if (__grouping_tmp.size())
	      {
		// Add the ending grouping.
		__grouping_tmp += static_cast<char>(__testdecfound ? __last_pos
						                   : __n);
		if (!std::__verify_grouping(__lc->_M_grouping,
					    __lc->_M_grouping_size,
					    __grouping_tmp))
		  __err |= ios_base::failbit;
	      }
	    
	    // Iff not enough digits were supplied after the decimal-point.
	    if (__testdecfound && __n != __lc->_M_frac_digits)
	      __testvalid = false;
	  }

	// Iff valid sequence is not recognized.
	if (!__testvalid)
	  __err |= ios_base::failbit;
	else
	  __units.swap(__res);
	
	// Iff no more characters are available.
	if (__beg == __end)
	  __err |= ios_base::eofbit;
	return __beg;
      }

#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
  template<typename _CharT, typename _InIter>
    _InIter
    money_get<_CharT, _InIter>::
    __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
	     ios_base::iostate& __err, double& __units) const
    {
      string __str;
      __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
                     : _M_extract<false>(__beg, __end, __io, __err, __str);
      std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
      return __beg;
    }
#endif

  template<typename _CharT, typename _InIter>
    _InIter
    money_get<_CharT, _InIter>::
    do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
	   ios_base::iostate& __err, long double& __units) const
    {
      string __str;
      __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
	             : _M_extract<false>(__beg, __end, __io, __err, __str);
      std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    money_get<_CharT, _InIter>::
    do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
	   ios_base::iostate& __err, string_type& __digits) const
    {
      typedef typename string::size_type                  size_type;

      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

      string __str;
      __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
	             : _M_extract<false>(__beg, __end, __io, __err, __str);
      const size_type __len = __str.size();
      if (__len)
	{
	  __digits.resize(__len);
	  __ctype.widen(__str.data(), __str.data() + __len, &__digits[0]);
	}
      return __beg;
    }

  template<typename _CharT, typename _OutIter>
    template<bool _Intl>
      _OutIter
      money_put<_CharT, _OutIter>::
      _M_insert(iter_type __s, ios_base& __io, char_type __fill,
		const string_type& __digits) const
      {
	typedef typename string_type::size_type	          size_type;
	typedef money_base::part                          part;
	typedef __moneypunct_cache<_CharT, _Intl>         __cache_type;
      
	const locale& __loc = __io._M_getloc();
	const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

	__use_cache<__cache_type> __uc;
	const __cache_type* __lc = __uc(__loc);
	const char_type* __lit = __lc->_M_atoms;

	// Determine if negative or positive formats are to be used, and
	// discard leading negative_sign if it is present.
	const char_type* __beg = __digits.data();

	money_base::pattern __p;
	const char_type* __sign;
	size_type __sign_size;
	if (!(*__beg == __lit[money_base::_S_minus]))
	  {
	    __p = __lc->_M_pos_format;
	    __sign = __lc->_M_positive_sign;
	    __sign_size = __lc->_M_positive_sign_size;
	  }
	else
	  {
	    __p = __lc->_M_neg_format;
	    __sign = __lc->_M_negative_sign;
	    __sign_size = __lc->_M_negative_sign_size;
	    if (__digits.size())
	      ++__beg;
	  }
       
	// Look for valid numbers in the ctype facet within input digits.
	size_type __len = __ctype.scan_not(ctype_base::digit, __beg,
					   __beg + __digits.size()) - __beg;
	if (__len)
	  {
	    // Assume valid input, and attempt to format.
	    // Break down input numbers into base components, as follows:
	    //   final_value = grouped units + (decimal point) + (digits)
	    string_type __value;
	    __value.reserve(2 * __len);

	    // Add thousands separators to non-decimal digits, per
	    // grouping rules.
	    long __paddec = __len - __lc->_M_frac_digits;
	    if (__paddec > 0)
  	      {
		if (__lc->_M_frac_digits < 0)
		  __paddec = __len;
  		if (__lc->_M_grouping_size)
  		  {
		    __value.assign(2 * __paddec, char_type());
 		    _CharT* __vend = 
		      std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
					  __lc->_M_grouping,
					  __lc->_M_grouping_size,
					  __beg, __beg + __paddec);
		    __value.erase(__vend - &__value[0]);
  		  }
  		else
		  __value.assign(__beg, __paddec);
	      }

	    // Deal with decimal point, decimal digits.
	    if (__lc->_M_frac_digits > 0)
	      {
		__value += __lc->_M_decimal_point;
		if (__paddec >= 0)
		  __value.append(__beg + __paddec, __lc->_M_frac_digits);
		else
		  {
		    // Have to pad zeros in the decimal position.
		    __value.append(-__paddec, __lit[money_base::_S_zero]);
		    __value.append(__beg, __len);
		  }
  	      }
  
	    // Calculate length of resulting string.
	    const ios_base::fmtflags __f = __io.flags() 
	                                   & ios_base::adjustfield;
	    __len = __value.size() + __sign_size;
	    __len += ((__io.flags() & ios_base::showbase)
		      ? __lc->_M_curr_symbol_size : 0);

	    string_type __res;
	    __res.reserve(2 * __len);
	    
	    const size_type __width = static_cast<size_type>(__io.width());  
	    const bool __testipad = (__f == ios_base::internal
				     && __len < __width);
	    // Fit formatted digits into the required pattern.
	    for (int __i = 0; __i < 4; ++__i)
	      {
		const part __which = static_cast<part>(__p.field[__i]);
		switch (__which)
		  {
		  case money_base::symbol:
		    if (__io.flags() & ios_base::showbase)
		      __res.append(__lc->_M_curr_symbol,
				   __lc->_M_curr_symbol_size);
		    break;
		  case money_base::sign:
		    // Sign might not exist, or be more than one
		    // character long. In that case, add in the rest
		    // below.
		    if (__sign_size)
		      __res += __sign[0];
		    break;
		  case money_base::value:
		    __res += __value;
		    break;
		  case money_base::space:
		    // At least one space is required, but if internal
		    // formatting is required, an arbitrary number of
		    // fill spaces will be necessary.
		    if (__testipad)
		      __res.append(__width - __len, __fill);
		    else
		      __res += __fill;
		    break;
		  case money_base::none:
		    if (__testipad)
		      __res.append(__width - __len, __fill);
		    break;
		  }
	      }
	    
	    // Special case of multi-part sign parts.
	    if (__sign_size > 1)
	      __res.append(__sign + 1, __sign_size - 1);
	    
	    // Pad, if still necessary.
	    __len = __res.size();
	    if (__width > __len)
	      {
		if (__f == ios_base::left)
		  // After.
		  __res.append(__width - __len, __fill);
		else
		  // Before.
		  __res.insert(0, __width - __len, __fill);
		__len = __width;
	      }
	    
	    // Write resulting, fully-formatted string to output iterator.
	    __s = std::__write(__s, __res.data(), __len);
	  }
	__io.width(0);
	return __s;    
      }

#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__
  template<typename _CharT, typename _OutIter>
    _OutIter
    money_put<_CharT, _OutIter>::
    __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
	     double __units) const
    { return this->do_put(__s, __intl, __io, __fill, (long double) __units); }
#endif

  template<typename _CharT, typename _OutIter>
    _OutIter
    money_put<_CharT, _OutIter>::
    do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
	   long double __units) const
    {
      const locale __loc = __io.getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
#ifdef _GLIBCXX_USE_C99
      // First try a buffer perhaps big enough.
      int __cs_size = 64;
      char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 328. Bad sprintf format modifier in money_put<>::do_put()
      int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
					"%.*Lf", 0, __units);
      // If the buffer was not large enough, try again with the correct size.
      if (__len >= __cs_size)
	{
	  __cs_size = __len + 1;
	  __cs = static_cast<char*>(__builtin_alloca(__cs_size));
	  __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
					"%.*Lf", 0, __units);
	}
#else
      // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
      const int __cs_size =
	__gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
      char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
      int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", 
					0, __units);
#endif
      string_type __digits(__len, char_type());
      __ctype.widen(__cs, __cs + __len, &__digits[0]);
      return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
	            : _M_insert<false>(__s, __io, __fill, __digits);
    }

  template<typename _CharT, typename _OutIter>
    _OutIter
    money_put<_CharT, _OutIter>::
    do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
	   const string_type& __digits) const
    { return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
	            : _M_insert<false>(__s, __io, __fill, __digits); }

_GLIBCXX_END_LDBL_NAMESPACE

  // NB: Not especially useful. Without an ios_base object or some
  // kind of locale reference, we are left clawing at the air where
  // the side of the mountain used to be...
  template<typename _CharT, typename _InIter>
    time_base::dateorder
    time_get<_CharT, _InIter>::do_date_order() const
    { return time_base::no_order; }

  // Expand a strftime format string and parse it.  E.g., do_get_date() may
  // pass %m/%d/%Y => extracted characters.
  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
			  ios_base::iostate& __err, tm* __tm,
			  const _CharT* __format) const
    {
      const locale& __loc = __io._M_getloc();
      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
      const size_t __len = char_traits<_CharT>::length(__format);

      ios_base::iostate __tmperr = ios_base::goodbit;
      for (size_t __i = 0; __beg != __end && __i < __len && !__tmperr; ++__i)
	{
	  if (__ctype.narrow(__format[__i], 0) == '%')
	    {
	      // Verify valid formatting code, attempt to extract.
	      char __c = __ctype.narrow(__format[++__i], 0);
	      int __mem = 0;
	      if (__c == 'E' || __c == 'O')
		__c = __ctype.narrow(__format[++__i], 0);
	      switch (__c)
		{
		  const char* __cs;
		  _CharT __wcs[10];
		case 'a':
		  // Abbreviated weekday name [tm_wday]
		  const char_type*  __days1[7];
		  __tp._M_days_abbreviated(__days1);
		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
					  7, __io, __tmperr);
		  break;
		case 'A':
		  // Weekday name [tm_wday].
		  const char_type*  __days2[7];
		  __tp._M_days(__days2);
		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
					  7, __io, __tmperr);
		  break;
		case 'h':
		case 'b':
		  // Abbreviated month name [tm_mon]
		  const char_type*  __months1[12];
		  __tp._M_months_abbreviated(__months1);
		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
					  __months1, 12, __io, __tmperr);
		  break;
		case 'B':
		  // Month name [tm_mon].
		  const char_type*  __months2[12];
		  __tp._M_months(__months2);
		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
					  __months2, 12, __io, __tmperr);
		  break;
		case 'c':
		  // Default time and date representation.
		  const char_type*  __dt[2];
		  __tp._M_date_time_formats(__dt);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, 
						__tm, __dt[0]);
		  break;
		case 'd':
		  // Day [01, 31]. [tm_mday]
		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
					 __io, __tmperr);
		  break;
		case 'e':
		  // Day [1, 31], with single digits preceded by
		  // space. [tm_mday]
		  if (__ctype.is(ctype_base::space, *__beg))
		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
					   1, __io, __tmperr);
		  else
		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
					   2, __io, __tmperr);
		  break;
		case 'D':
		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
		  __cs = "%m/%d/%y";
		  __ctype.widen(__cs, __cs + 9, __wcs);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, 
						__tm, __wcs);
		  break;
		case 'H':
		  // Hour [00, 23]. [tm_hour]
		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
					 __io, __tmperr);
		  break;
		case 'I':
		  // Hour [01, 12]. [tm_hour]
		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
					 __io, __tmperr);
		  break;
		case 'm':
		  // Month [01, 12]. [tm_mon]
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, 
					 __io, __tmperr);
		  if (!__tmperr)
		    __tm->tm_mon = __mem - 1;
		  break;
		case 'M':
		  // Minute [00, 59]. [tm_min]
		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
					 __io, __tmperr);
		  break;
		case 'n':
		  if (__ctype.narrow(*__beg, 0) == '\n')
		    ++__beg;
		  else
		    __tmperr |= ios_base::failbit;
		  break;
		case 'R':
		  // Equivalent to (%H:%M).
		  __cs = "%H:%M";
		  __ctype.widen(__cs, __cs + 6, __wcs);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, 
						__tm, __wcs);
		  break;
		case 'S':
		  // Seconds. [tm_sec]
		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
#ifdef _GLIBCXX_USE_C99
		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
#else
		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
#endif
					 __io, __tmperr);
		  break;
		case 't':
		  if (__ctype.narrow(*__beg, 0) == '\t')
		    ++__beg;
		  else
		    __tmperr |= ios_base::failbit;
		  break;
		case 'T':
		  // Equivalent to (%H:%M:%S).
		  __cs = "%H:%M:%S";
		  __ctype.widen(__cs, __cs + 9, __wcs);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, 
						__tm, __wcs);
		  break;
		case 'x':
		  // Locale's date.
		  const char_type*  __dates[2];
		  __tp._M_date_formats(__dates);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, 
						__tm, __dates[0]);
		  break;
		case 'X':
		  // Locale's time.
		  const char_type*  __times[2];
		  __tp._M_time_formats(__times);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, 
						__tm, __times[0]);
		  break;
		case 'y':
		case 'C': // C99
		  // Two digit year.
		case 'Y':
		  // Year [1900).
		  // NB: We parse either two digits, implicitly years since
		  // 1900, or 4 digits, full year.  In both cases we can 
		  // reconstruct [tm_year].  See also libstdc++/26701.
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
					 __io, __tmperr);
		  if (!__tmperr)
		    __tm->tm_year = __mem < 0 ? __mem + 100 : __mem - 1900;
		  break;
		case 'Z':
		  // Timezone info.
		  if (__ctype.is(ctype_base::upper, *__beg))
		    {
		      int __tmp;
		      __beg = _M_extract_name(__beg, __end, __tmp,
				       __timepunct_cache<_CharT>::_S_timezones,
					      14, __io, __tmperr);

		      // GMT requires special effort.
		      if (__beg != __end && !__tmperr && __tmp == 0
			  && (*__beg == __ctype.widen('-')
			      || *__beg == __ctype.widen('+')))
			{
			  __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
						 __io, __tmperr);
			  __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
						 __io, __tmperr);
			}
		    }
		  else
		    __tmperr |= ios_base::failbit;
		  break;
		default:
		  // Not recognized.
		  __tmperr |= ios_base::failbit;
		}
	    }
	  else
	    {
	      // Verify format and input match, extract and discard.
	      if (__format[__i] == *__beg)
		++__beg;
	      else
		__tmperr |= ios_base::failbit;
	    }
	}

      if (__tmperr)
	__err |= ios_base::failbit;
  
      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    _M_extract_num(iter_type __beg, iter_type __end, int& __member,
		   int __min, int __max, size_t __len,
		   ios_base& __io, ios_base::iostate& __err) const
    {
      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

      // As-is works for __len = 1, 2, 4, the values actually used.
      int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1);

      ++__min;
      size_t __i = 0;
      int __value = 0;
      for (; __beg != __end && __i < __len; ++__beg, ++__i)
	{
	  const char __c = __ctype.narrow(*__beg, '*');
	  if (__c >= '0' && __c <= '9')
	    {
	      __value = __value * 10 + (__c - '0');
	      const int __valuec = __value * __mult;
	      if (__valuec > __max || __valuec + __mult < __min)
		break;
	      __mult /= 10;
	    }
	  else
	    break;
	}
      if (__i == __len)
	__member = __value;
      // Special encoding for do_get_year, 'y', and 'Y' above.
      else if (__len == 4 && __i == 2)
	__member = __value - 100;
      else
	__err |= ios_base::failbit;

      return __beg;
    }

  // Assumptions:
  // All elements in __names are unique.
  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    _M_extract_name(iter_type __beg, iter_type __end, int& __member,
		    const _CharT** __names, size_t __indexlen,
		    ios_base& __io, ios_base::iostate& __err) const
    {
      typedef char_traits<_CharT>		__traits_type;
      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

      int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
							  * __indexlen));
      size_t __nmatches = 0;
      size_t __pos = 0;
      bool __testvalid = true;
      const char_type* __name;

      // Look for initial matches.
      // NB: Some of the locale data is in the form of all lowercase
      // names, and some is in the form of initially-capitalized
      // names. Look for both.
      if (__beg != __end)
	{
	  const char_type __c = *__beg;
	  for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
	    if (__c == __names[__i1][0]
		|| __c == __ctype.toupper(__names[__i1][0]))
	      __matches[__nmatches++] = __i1;
	}

      while (__nmatches > 1)
	{
	  // Find smallest matching string.
	  size_t __minlen = __traits_type::length(__names[__matches[0]]);
	  for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
	    __minlen = std::min(__minlen,
			      __traits_type::length(__names[__matches[__i2]]));
	  ++__beg, ++__pos;
	  if (__pos < __minlen && __beg != __end)
	    for (size_t __i3 = 0; __i3 < __nmatches;)
	      {
		__name = __names[__matches[__i3]];
		if (!(__name[__pos] == *__beg))
		  __matches[__i3] = __matches[--__nmatches];
		else
		  ++__i3;
	      }
	  else
	    break;
	}

      if (__nmatches == 1)
	{
	  // Make sure found name is completely extracted.
	  ++__beg, ++__pos;
	  __name = __names[__matches[0]];
	  const size_t __len = __traits_type::length(__name);
	  while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
	    ++__beg, ++__pos;

	  if (__len == __pos)
	    __member = __matches[0];
	  else
	    __testvalid = false;
	}
      else
	__testvalid = false;
      if (!__testvalid)
	__err |= ios_base::failbit;

      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member,
			     const _CharT** __names, size_t __indexlen,
			     ios_base& __io, ios_base::iostate& __err) const
    {
      typedef char_traits<_CharT>		__traits_type;
      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);

      int* __matches = static_cast<int*>(__builtin_alloca(2 * sizeof(int)
							  * __indexlen));
      size_t __nmatches = 0;
      size_t* __matches_lengths = 0;
      size_t __pos = 0;

      if (__beg != __end)
	{
	  const char_type __c = *__beg;
	  for (size_t __i = 0; __i < 2 * __indexlen; ++__i)
	    if (__c == __names[__i][0]
		|| __c == __ctype.toupper(__names[__i][0]))
	      __matches[__nmatches++] = __i;
	}

      if (__nmatches)
	{
	  ++__beg, ++__pos;

	  __matches_lengths
	    = static_cast<size_t*>(__builtin_alloca(sizeof(size_t)
						    * __nmatches));
	  for (size_t __i = 0; __i < __nmatches; ++__i)
	    __matches_lengths[__i]
	      = __traits_type::length(__names[__matches[__i]]);
	}

      for (; __beg != __end; ++__beg, ++__pos)
	{
	  size_t __nskipped = 0;
	  const char_type __c = *__beg;
	  for (size_t __i = 0; __i < __nmatches;)
	    {
	      const char_type* __name = __names[__matches[__i]];
	      if (__pos >= __matches_lengths[__i])
		++__nskipped, ++__i;
	      else if (!(__name[__pos] == __c))
		{
		  --__nmatches;
		  __matches[__i] = __matches[__nmatches];
		  __matches_lengths[__i] = __matches_lengths[__nmatches];
		}
	      else
		++__i;
	    }
	  if (__nskipped == __nmatches)
	    break;
	}

      if ((__nmatches == 1 && __matches_lengths[0] == __pos)
	  || (__nmatches == 2 && (__matches_lengths[0] == __pos
				  || __matches_lengths[1] == __pos)))
	__member = (__matches[0] >= __indexlen
		    ? __matches[0] - __indexlen : __matches[0]);
      else
	__err |= ios_base::failbit;

      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
		ios_base::iostate& __err, tm* __tm) const
    {
      const locale& __loc = __io._M_getloc();
      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
      const char_type*  __times[2];
      __tp._M_time_formats(__times);
      __beg = _M_extract_via_format(__beg, __end, __io, __err, 
				    __tm, __times[0]);
      if (__beg == __end)
	__err |= ios_base::eofbit;
      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
		ios_base::iostate& __err, tm* __tm) const
    {
      const locale& __loc = __io._M_getloc();
      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
      const char_type*  __dates[2];
      __tp._M_date_formats(__dates);
      __beg = _M_extract_via_format(__beg, __end, __io, __err, 
				    __tm, __dates[0]);
      if (__beg == __end)
	__err |= ios_base::eofbit;
      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
		   ios_base::iostate& __err, tm* __tm) const
    {
      typedef char_traits<_CharT>		__traits_type;
      const locale& __loc = __io._M_getloc();
      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
      const char_type* __days[14];
      __tp._M_days_abbreviated(__days);
      __tp._M_days(__days + 7);
      int __tmpwday;
      ios_base::iostate __tmperr = ios_base::goodbit;

      __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
				       __io, __tmperr);
      if (!__tmperr)
	__tm->tm_wday = __tmpwday;
      else
	__err |= ios_base::failbit;

      if (__beg == __end)
	__err |= ios_base::eofbit;
      return __beg;
     }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    do_get_monthname(iter_type __beg, iter_type __end,
                     ios_base& __io, ios_base::iostate& __err, tm* __tm) const
    {
      typedef char_traits<_CharT>		__traits_type;
      const locale& __loc = __io._M_getloc();
      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
      const char_type*  __months[24];
      __tp._M_months_abbreviated(__months);
      __tp._M_months(__months + 12);
      int __tmpmon;
      ios_base::iostate __tmperr = ios_base::goodbit;

      __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
				       __io, __tmperr);
      if (!__tmperr)
	__tm->tm_mon = __tmpmon;
      else
	__err |= ios_base::failbit;

      if (__beg == __end)
	__err |= ios_base::eofbit;
      return __beg;
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
    do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
		ios_base::iostate& __err, tm* __tm) const
    {
      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
      int __tmpyear;
      ios_base::iostate __tmperr = ios_base::goodbit;

      __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 9999, 4,
			     __io, __tmperr);
      if (!__tmperr)
	__tm->tm_year = __tmpyear < 0 ? __tmpyear + 100 : __tmpyear - 1900;
      else
	__err |= ios_base::failbit;

      if (__beg == __end)
	__err |= ios_base::eofbit;
      return __beg;
    }

  template<typename _CharT, typename _OutIter>
    _OutIter
    time_put<_CharT, _OutIter>::
    put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
	const _CharT* __beg, const _CharT* __end) const
    {
      const locale& __loc = __io._M_getloc();
      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
      for (; __beg != __end; ++__beg)
	if (__ctype.narrow(*__beg, 0) != '%')
	  {
	    *__s = *__beg;
	    ++__s;
	  }
	else if (++__beg != __end)
	  {
	    char __format;
	    char __mod = 0;
	    const char __c = __ctype.narrow(*__beg, 0);
	    if (__c != 'E' && __c != 'O')
	      __format = __c;
	    else if (++__beg != __end)
	      {
		__mod = __c;
		__format = __ctype.narrow(*__beg, 0);
	      }
	    else
	      break;
	    __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
	  }
	else
	  break;
      return __s;
    }

  template<typename _CharT, typename _OutIter>
    _OutIter
    time_put<_CharT, _OutIter>::
    do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
	   char __format, char __mod) const
    {
      const locale& __loc = __io._M_getloc();
      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);

      // NB: This size is arbitrary. Should this be a data member,
      // initialized at construction?
      const size_t __maxlen = 128;
      char_type __res[__maxlen];

      // NB: In IEE 1003.1-200x, and perhaps other locale models, it
      // is possible that the format character will be longer than one
      // character. Possibilities include 'E' or 'O' followed by a
      // format character: if __mod is not the default argument, assume
      // it's a valid modifier.
      char_type __fmt[4];
      __fmt[0] = __ctype.widen('%');
      if (!__mod)
	{
	  __fmt[1] = __format;
	  __fmt[2] = char_type();
	}
      else
	{
	  __fmt[1] = __mod;
	  __fmt[2] = __format;
	  __fmt[3] = char_type();
	}

      __tp._M_put(__res, __maxlen, __fmt, __tm);

      // Write resulting, fully-formatted string to output iterator.
      return std::__write(__s, __res, char_traits<char_type>::length(__res));
    }


  // Inhibit implicit instantiations for required instantiations,
  // which are defined via explicit instantiations elsewhere.
  // NB: This syntax is a GNU extension.
#if _GLIBCXX_EXTERN_TEMPLATE
  extern template class moneypunct<char, false>;
  extern template class moneypunct<char, true>;
  extern template class moneypunct_byname<char, false>;
  extern template class moneypunct_byname<char, true>;
  extern template class _GLIBCXX_LDBL_NAMESPACE money_get<char>;
  extern template class _GLIBCXX_LDBL_NAMESPACE money_put<char>;
  extern template class __timepunct<char>;
  extern template class time_put<char>;
  extern template class time_put_byname<char>;
  extern template class time_get<char>;
  extern template class time_get_byname<char>;
  extern template class messages<char>;
  extern template class messages_byname<char>;

  extern template
    const moneypunct<char, true>&
    use_facet<moneypunct<char, true> >(const locale&);

  extern template
    const moneypunct<char, false>&
    use_facet<moneypunct<char, false> >(const locale&);

  extern template
    const money_put<char>&
    use_facet<money_put<char> >(const locale&);

  extern template
    const money_get<char>&
    use_facet<money_get<char> >(const locale&);

  extern template
    const __timepunct<char>&
    use_facet<__timepunct<char> >(const locale&);

  extern template
    const time_put<char>&
    use_facet<time_put<char> >(const locale&);

  extern template
    const time_get<char>&
    use_facet<time_get<char> >(const locale&);

  extern template
    const messages<char>&
    use_facet<messages<char> >(const locale&);

  extern template
    bool
    has_facet<moneypunct<char> >(const locale&);

  extern template
    bool
    has_facet<money_put<char> >(const locale&);

  extern template
    bool
    has_facet<money_get<char> >(const locale&);

  extern template
    bool
    has_facet<__timepunct<char> >(const locale&);

  extern template
    bool
    has_facet<time_put<char> >(const locale&);

  extern template
    bool
    has_facet<time_get<char> >(const locale&);

  extern template
    bool
    has_facet<messages<char> >(const locale&);

#ifdef _GLIBCXX_USE_WCHAR_T
  extern template class moneypunct<wchar_t, false>;
  extern template class moneypunct<wchar_t, true>;
  extern template class moneypunct_byname<wchar_t, false>;
  extern template class moneypunct_byname<wchar_t, true>;
  extern template class _GLIBCXX_LDBL_NAMESPACE money_get<wchar_t>;
  extern template class _GLIBCXX_LDBL_NAMESPACE money_put<wchar_t>;
  extern template class __timepunct<wchar_t>;
  extern template class time_put<wchar_t>;
  extern template class time_put_byname<wchar_t>;
  extern template class time_get<wchar_t>;
  extern template class time_get_byname<wchar_t>;
  extern template class messages<wchar_t>;
  extern template class messages_byname<wchar_t>;

  extern template
    const moneypunct<wchar_t, true>&
    use_facet<moneypunct<wchar_t, true> >(const locale&);

  extern template
    const moneypunct<wchar_t, false>&
    use_facet<moneypunct<wchar_t, false> >(const locale&);

  extern template
    const money_put<wchar_t>&
    use_facet<money_put<wchar_t> >(const locale&);

  extern template
    const money_get<wchar_t>&
    use_facet<money_get<wchar_t> >(const locale&);

  extern template
    const __timepunct<wchar_t>&
    use_facet<__timepunct<wchar_t> >(const locale&);

  extern template
    const time_put<wchar_t>&
    use_facet<time_put<wchar_t> >(const locale&);

  extern template
    const time_get<wchar_t>&
    use_facet<time_get<wchar_t> >(const locale&);

  extern template
    const messages<wchar_t>&
    use_facet<messages<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<moneypunct<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<money_put<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<money_get<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<__timepunct<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<time_put<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<time_get<wchar_t> >(const locale&);

  extern template
    bool
    has_facet<messages<wchar_t> >(const locale&);
#endif
#endif

_GLIBCXX_END_NAMESPACE

#endif
@


1.1.1.1
log
@initial import of GCC 4.5.3 sources.  changes since 4.1 are way too numerous
to review, please see http://gcc.gnu.org/gcc-4.5/changes.html (and the 4.2,
4.3 and 4.4 versions, too.)

this includes the core, c++, objc and the non java/ada/fortran parts of the
testsuite.
@
text
@@


1.1.1.1.8.1
log
@Rebase to HEAD as of a few days ago.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
d25 1
a25 1
/** @@file bits/locale_facets_nonio.tcc
d27 1
a27 1
 *  Do not attempt to use it directly. @@headername{locale}
d35 1
a35 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
d47 1
a47 1
	    __moneypunct_cache<_CharT, _Intl>* __tmp = 0;
d125 1
a125 1
_GLIBCXX_BEGIN_NAMESPACE_LDBL
d611 1
a611 1
_GLIBCXX_END_NAMESPACE_LDBL
d636 1
a636 2
      size_t __i = 0;
      for (; __beg != __end && __i < __len && !__tmperr; ++__i)
d830 1
a830 1
      if (__tmperr || __i != __len)
d1215 1
d1221 2
a1222 2
  extern template class _GLIBCXX_NAMESPACE_LDBL money_get<char>;
  extern template class _GLIBCXX_NAMESPACE_LDBL money_put<char>;
d1296 2
a1297 2
  extern template class _GLIBCXX_NAMESPACE_LDBL money_get<wchar_t>;
  extern template class _GLIBCXX_NAMESPACE_LDBL money_put<wchar_t>;
d1368 1
a1368 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
@


1.1.1.1.2.1
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@d3 1
a3 1
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
d25 1
a25 1
/** @@file bits/locale_facets_nonio.tcc
d27 1
a27 1
 *  Do not attempt to use it directly. @@headername{locale}
d35 1
a35 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
d47 1
a47 1
	    __moneypunct_cache<_CharT, _Intl>* __tmp = 0;
d125 1
a125 1
_GLIBCXX_BEGIN_NAMESPACE_LDBL
d611 1
a611 1
_GLIBCXX_END_NAMESPACE_LDBL
d636 1
a636 2
      size_t __i = 0;
      for (; __beg != __end && __i < __len && !__tmperr; ++__i)
d830 1
a830 1
      if (__tmperr || __i != __len)
d1215 1
d1221 2
a1222 2
  extern template class _GLIBCXX_NAMESPACE_LDBL money_get<char>;
  extern template class _GLIBCXX_NAMESPACE_LDBL money_put<char>;
d1296 2
a1297 2
  extern template class _GLIBCXX_NAMESPACE_LDBL money_get<wchar_t>;
  extern template class _GLIBCXX_NAMESPACE_LDBL money_put<wchar_t>;
d1368 1
a1368 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
@


1.1.1.2
log
@import GCC 4.8 branch at r206687.

highlights from: http://gcc.gnu.org/gcc-4.6/changes.html

   GCC now has stricter checks for invalid command-line options
   New -Wunused-but-set-variable and -Wunused-but-set-parameter
      warnings
   Many platforms have been obsoleted
   Link-time optimization improvements
   A new switch -fstack-usage has been added
   A new function attribute leaf was introduced
   A new warning, enabled by -Wdouble-promotion
   Support for selectively enabling and disabling warnings via
      #pragma GCC diagnostic has been added
   There is now experimental support for some features from the
      upcoming C1X revision of the ISO C standard
   Improved experimental support for the upcoming C++0x ISO C++
      standard
   G++ now issues clearer diagnostics in several cases
   Updates for ARM, x86, MIPS, PPC/PPC64, SPARC
   Darwin, FreeBSD, Solaris 2, MinGW and Cygwin now all support
      __float128 on 32-bit and 64-bit x86 targets. [*1]

highlights from: http://gcc.gnu.org/gcc-4.7/changes.html

   The -fconserve-space flag has been deprecated
   Support for a new parameter --param case-values-threshold=n
      was added
   Interprocedural and Link-time optimization improvements
   A new built-in, __builtin_assume_aligned, has been added
   A new warning option -Wunused-local-typedefs was added
   A new experimental command-line option -ftrack-macro-expansion
      was added
   Support for atomic operations specifying the C++11/C11 memory
      model has been added
   There is support for some more features from the C11 revision
      of the ISO C standard
   Improved experimental support for the new ISO C++ standard,
      C++11
   Updates for ARM, x86, MIPS, PPC/PPC64, SH, SPARC, TILE*
   A new option (-grecord-gcc-switches) was added

highlights from: http://gcc.gnu.org/gcc-4.8/changes.html

   GCC now uses C++ as its implementation language.  This means
      that to build GCC from sources, you will need a C++
      compiler that understands C++ 2003
   DWARF4 is now the default when generating DWARF debug
      information
   A new general optimization level, -Og, has been introduced
   A new option -ftree-partial-pre was added
   The option -fconserve-space has been removed
   The command-line options -fipa-struct-reorg and
      -fipa-matrix-reorg have been removed
   Interprocedural and Link-time optimization improvements
   AddressSanitizer, a fast memory error detector, has been
      added  [*2]
   A new -Wsizeof-pointer-memaccess warning has been added
   G++ now supports a -std=c++1y option for experimentation
      with features proposed for the next revision of the
      standard, expected around 2014
   Improved experimental support for the new ISO C++ standard,
      C++11
   A new port has been added to support AArch64
   Updates for ARM, x86, MIPS, PPC/PPC64, SH, SPARC, TILE*


[*1] we should support this too!
[*2] we should look into this.
     https://code.google.com/p/address-sanitizer/
@
text
@d3 1
a3 1
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
d25 1
a25 1
/** @@file bits/locale_facets_nonio.tcc
d27 1
a27 1
 *  Do not attempt to use it directly. @@headername{locale}
d35 1
a35 3
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
d47 1
a47 1
	    __moneypunct_cache<_CharT, _Intl>* __tmp = 0;
d125 1
a125 1
_GLIBCXX_BEGIN_NAMESPACE_LDBL
d611 1
a611 1
_GLIBCXX_END_NAMESPACE_LDBL
d636 1
a636 2
      size_t __i = 0;
      for (; __beg != __end && __i < __len && !__tmperr; ++__i)
d830 1
a830 1
      if (__tmperr || __i != __len)
d1215 1
d1221 2
a1222 2
  extern template class _GLIBCXX_NAMESPACE_LDBL money_get<char>;
  extern template class _GLIBCXX_NAMESPACE_LDBL money_put<char>;
d1296 2
a1297 2
  extern template class _GLIBCXX_NAMESPACE_LDBL money_get<wchar_t>;
  extern template class _GLIBCXX_NAMESPACE_LDBL money_put<wchar_t>;
d1368 1
a1368 2
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
@


1.1.1.3
log
@import GCC 5.3.0.  see these urls for details which are too large to
include here:

	http://gcc.gnu.org/gcc-4.9/changes.html
	http://gcc.gnu.org/gcc-5/changes.html

(note that GCC 5.x is a release stream like GCC 4.9.x, 4.8.x, etc.)


the main issues we will have are:

The default mode for C is now -std=gnu11 instead of -std=gnu89.

ARM:
The deprecated option -mwords-little-endian has been removed.
The options -mapcs, -mapcs-frame, -mtpcs-frame and -mtpcs-leaf-frame
 which are only applicable to the old ABI have been deprecated.

MIPS:
The o32 ABI has been modified and extended. The o32 64-bit
 floating-point register support is now obsolete and has been removed.
 It has been replaced by three ABI extensions FPXX, FP64A, and FP64.
 The meaning of the -mfp64 command-line option has changed. It is now
 used to enable the FP64A and FP64 ABI extensions.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2015 Free Software Foundation, Inc.
d71 2
d86 1
a86 2
	  const string& __g = __mp.grouping();
	  _M_grouping_size = __g.size();
d88 2
a89 1
	  __g.copy(__grouping, _M_grouping_size);
d91 2
a92 2
			     && static_cast<signed char>(__grouping[0]) > 0
			     && (__grouping[0]
d95 1
a95 2
	  const basic_string<_CharT>& __cs = __mp.curr_symbol();
	  _M_curr_symbol_size = __cs.size();
d97 2
a98 1
	  __cs.copy(__curr_symbol, _M_curr_symbol_size);
d100 1
a100 2
	  const basic_string<_CharT>& __ps = __mp.positive_sign();
	  _M_positive_sign_size = __ps.size();
d102 2
a103 1
	  __ps.copy(__positive_sign, _M_positive_sign_size);
d105 1
a105 2
	  const basic_string<_CharT>& __ns = __mp.negative_sign();
	  _M_negative_sign_size = __ns.size();
d107 2
a108 1
	  __ns.copy(__negative_sign, _M_negative_sign_size);
a115 6

	  _M_grouping = __grouping;
	  _M_curr_symbol = __curr_symbol;
	  _M_positive_sign = __positive_sign;
	  _M_negative_sign = __negative_sign;
	  _M_allocated = true;
d127 1
a127 1
_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
d347 1
a347 2
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
      && _GLIBCXX_USE_CXX11_ABI == 0
d558 1
a558 2
#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
      && _GLIBCXX_USE_CXX11_ABI == 0
d613 1
a613 1
_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
d1067 1
d1095 1
a1139 107
#if __cplusplus >= 201103L
  template<typename _CharT, typename _InIter>
    inline
    _InIter
    time_get<_CharT, _InIter>::
    get(iter_type __s, iter_type __end, ios_base& __io,
        ios_base::iostate& __err, tm* __tm, const char_type* __fmt,
        const char_type* __fmtend) const
    {
      const locale& __loc = __io._M_getloc();
      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
      __err = ios_base::goodbit;
      while (__fmt != __fmtend &&
             __err == ios_base::goodbit)
        {
          if (__s == __end)
            {
              __err = ios_base::eofbit | ios_base::failbit;
              break;
            }
          else if (__ctype.narrow(*__fmt, 0) == '%')
            {
              char __format;
              char __mod = 0;
              if (++__fmt == __fmtend)
                {
                  __err = ios_base::failbit;
                  break;
                }
              const char __c = __ctype.narrow(*__fmt, 0);
              if (__c != 'E' && __c != 'O')
                __format = __c;
              else if (++__fmt != __fmtend)
                {
                  __mod = __c;
                  __format = __ctype.narrow(*__fmt, 0);
                }
              else
                {
                  __err = ios_base::failbit;
                  break;
                }
              __s = this->do_get(__s, __end, __io, __err, __tm, __format,
				 __mod);
              ++__fmt;
            }
          else if (__ctype.is(ctype_base::space, *__fmt))
            {
              ++__fmt;
              while (__fmt != __fmtend &&
                     __ctype.is(ctype_base::space, *__fmt))
                ++__fmt;

              while (__s != __end &&
                     __ctype.is(ctype_base::space, *__s))
                ++__s;
            }
          // TODO real case-insensitive comparison
          else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) ||
                   __ctype.toupper(*__s) == __ctype.toupper(*__fmt))
            {
              ++__s;
              ++__fmt;
            }
          else
            {
              __err = ios_base::failbit;
              break;
            }
        }
      return __s;
    }

  template<typename _CharT, typename _InIter>
    inline
    _InIter
    time_get<_CharT, _InIter>::
    do_get(iter_type __beg, iter_type __end, ios_base& __io,
           ios_base::iostate& __err, tm* __tm,
           char __format, char __mod) const
    {
      const locale& __loc = __io._M_getloc();
      ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
      __err = ios_base::goodbit;

      char_type __fmt[4];
      __fmt[0] = __ctype.widen('%');
      if (!__mod)
        {
          __fmt[1] = __format;
          __fmt[2] = char_type();
        }
      else
        {
          __fmt[1] = __mod;
          __fmt[2] = __format;
          __fmt[3] = char_type();
        }

      __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt);
      if (__beg == __end)
	__err |= ios_base::eofbit;
      return __beg;
    }

#endif // __cplusplus >= 201103L

d1223 2
a1224 2
  extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get<char>;
  extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put<char>;
d1298 2
a1299 2
  extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get<wchar_t>;
  extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put<wchar_t>;
@


1.1.1.4
log
@import GCC 6.4.0.  see this url for details which are too large to
include here:

   http://gcc.gnu.org/gcc-6/changes.html

the main visible changes appear to be:

- The default mode for C++ is now -std=gnu++14 instead of -std=gnu++98.
- The C and C++ compilers now support attributes on enumerators.
- Diagnostics can now contain "fix-it hints"
- more warnings (some added to -Wall)
@
text
@d3 1
a3 1
// Copyright (C) 2007-2016 Free Software Foundation, Inc.
d205 1
a205 1
			 ++__beg, (void)++__j);
d301 1
a301 1
		   && *__beg == __sign[__i]; ++__beg, (void)++__i);
d581 1
a581 1
#if _GLIBCXX_USE_C99_STDIO
d754 1
a754 1
#if _GLIBCXX_USE_C99
d861 1
a861 1
      for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
d926 1
a926 2
	  ++__beg;
	  ++__pos;
d943 1
a943 2
	  ++__beg;
	  ++__pos;
d947 1
a947 1
	    ++__beg, (void)++__pos;
d990 1
a990 2
	  ++__beg;
	  ++__pos;
d1000 1
a1000 1
      for (; __beg != __end; ++__beg, (void)++__pos)
@


1.1.1.4.4.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
// Copyright (C) 2007-2017 Free Software Foundation, Inc.
d662 1
a662 1
		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
a663 2
		  if (!__tmperr)
		    __tm->tm_wday = __mem;
d669 1
a669 1
		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
a670 2
		  if (!__tmperr)
		    __tm->tm_wday = __mem;
d677 1
a677 1
		  __beg = _M_extract_name(__beg, __end, __mem,
a678 2
		  if (!__tmperr)
		    __tm->tm_mon = __mem;
d684 1
a684 1
		  __beg = _M_extract_name(__beg, __end, __mem,
a685 2
		  if (!__tmperr)
		    __tm->tm_mon = __mem;
d696 1
a696 1
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
a697 2
		  if (!__tmperr)
		    __tm->tm_mday = __mem;
d703 1
a703 1
		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
d706 1
a706 1
		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
a707 2
		  if (!__tmperr)
		    __tm->tm_mday = __mem;
d718 1
a718 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
a719 2
		  if (!__tmperr)
		    __tm->tm_hour = __mem;
d723 1
a723 1
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
a724 2
		  if (!__tmperr)
		    __tm->tm_hour = __mem;
d735 1
a735 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
a736 2
		  if (!__tmperr)
		    __tm->tm_min = __mem;
d755 1
a755 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
d757 1
a757 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
a759 2
		  if (!__tmperr)
		  __tm->tm_sec = __mem;
@


1.1.1.4.4.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@d3 1
a3 1
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
a284 1
		// fallthrough
d1098 1
d1125 1
d1150 2
@


1.1.1.4.2.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
// Copyright (C) 2007-2017 Free Software Foundation, Inc.
d662 1
a662 1
		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
a663 2
		  if (!__tmperr)
		    __tm->tm_wday = __mem;
d669 1
a669 1
		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
a670 2
		  if (!__tmperr)
		    __tm->tm_wday = __mem;
d677 1
a677 1
		  __beg = _M_extract_name(__beg, __end, __mem,
a678 2
		  if (!__tmperr)
		    __tm->tm_mon = __mem;
d684 1
a684 1
		  __beg = _M_extract_name(__beg, __end, __mem,
a685 2
		  if (!__tmperr)
		    __tm->tm_mon = __mem;
d696 1
a696 1
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
a697 2
		  if (!__tmperr)
		    __tm->tm_mday = __mem;
d703 1
a703 1
		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
d706 1
a706 1
		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
a707 2
		  if (!__tmperr)
		    __tm->tm_mday = __mem;
d718 1
a718 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
a719 2
		  if (!__tmperr)
		    __tm->tm_hour = __mem;
d723 1
a723 1
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
a724 2
		  if (!__tmperr)
		    __tm->tm_hour = __mem;
d735 1
a735 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
a736 2
		  if (!__tmperr)
		    __tm->tm_min = __mem;
d755 1
a755 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
d757 1
a757 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
a759 2
		  if (!__tmperr)
		  __tm->tm_sec = __mem;
@


1.1.1.5
log
@import GCC 7.4.0.  main changes include:

The non-standard C++0x type traits has_trivial_default_constructor,
has_trivial_copy_constructor and has_trivial_copy_assign have been
removed.

On ARM targets (arm*-*-*), a bug introduced in GCC 5 that affects
conformance to the procedure call standard (AAPCS) has been fixed.

Many optimiser improvements

DWARF-5 support.

Many new and enhanced warnings.

Warnings about format strings now underline the pertinent part of
the string, and can offer suggested fixes.

Several new warnings related to buffer overflows and buffer
truncation.

New __builtin_add_overflow_p, __builtin_sub_overflow_p,
__builtin_mul_overflow_p built-ins added that test for overflow.

The C++ front end has experimental support for all of the current
C++17 draft.

The -fverbose-asm option has been expanded to prints comments
showing the source lines that correspond to the assembly.

The gcc and g++ driver programs will now provide suggestions for
misspelled arguments to command-line options.


AArch64 specific:

GCC has been updated to the latest revision of the procedure call
standard (AAPCS64) to provide support for parameter passing when
data types have been over-aligned.

The ARMv8.2-A and ARMv8.3-A architecture are now supported.

ARM specific:

Support for the ARMv5 and ARMv5E architectures has been
deprecated (which have no known implementations).

A new command-line option -mpure-code has been added. It does not
allow constant data to be placed in code sections.

x86 specific:

Support for the AVX-512 4FMAPS, 4VNNIW, VPOPCNTDQ and Software
Guard Extensions (SGX) ISA extensions has been added.

PPC specific:

GCC now diagnoses inline assembly that clobbers register r2.

RISC-V specific:

Support for the RISC-V instruction set has been added.

SH specific:

Support for SH5/SH64 has been removed.

Support for SH2A has been enhanced.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2017 Free Software Foundation, Inc.
d662 1
a662 1
		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
a663 2
		  if (!__tmperr)
		    __tm->tm_wday = __mem;
d669 1
a669 1
		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
a670 2
		  if (!__tmperr)
		    __tm->tm_wday = __mem;
d677 1
a677 1
		  __beg = _M_extract_name(__beg, __end, __mem,
a678 2
		  if (!__tmperr)
		    __tm->tm_mon = __mem;
d684 1
a684 1
		  __beg = _M_extract_name(__beg, __end, __mem,
a685 2
		  if (!__tmperr)
		    __tm->tm_mon = __mem;
d696 1
a696 1
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
a697 2
		  if (!__tmperr)
		    __tm->tm_mday = __mem;
d703 1
a703 1
		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
d706 1
a706 1
		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
a707 2
		  if (!__tmperr)
		    __tm->tm_mday = __mem;
d718 1
a718 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
a719 2
		  if (!__tmperr)
		    __tm->tm_hour = __mem;
d723 1
a723 1
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
a724 2
		  if (!__tmperr)
		    __tm->tm_hour = __mem;
d735 1
a735 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
a736 2
		  if (!__tmperr)
		    __tm->tm_min = __mem;
d755 1
a755 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
d757 1
a757 1
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
a759 2
		  if (!__tmperr)
		  __tm->tm_sec = __mem;
@


1.1.1.6
log
@import GCC 8.3.  it includes these new features:
- many optimisations improved: inter-procedural, profile-directed,
  LTO, loops including user-controllable unroll support, and more.
- columns numbers added to line numbers in dwarf
- gcov extended significantly
- many sanitizer updates
- many new warning messages
- many better hints and more useful error messages
- minor ABI changes on x86-64 libstdc++, and some c++17 modes
- draft c++2a features
- better c++17 experimental support
- Armv8.4-A supported, better 8.2-A and 8.3-A support, including
  32 bit arm port.  cortex a-55, a-75 and a-55.a-75 combo support.
- in the GCC bugzilla, 8.1 shows 1149 bugs fixed, 8.2 shows 100, and
  8.3 shows 158.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
a284 1
		// fallthrough
d1098 1
d1125 1
d1150 2
@


1.1.1.7
log
@import GCC 7.5.0.  doing this here so that the vendor branch has
the code we'll merge into gcc.old and the netbsd-9 tree gcc tree.
GCC 8.4.0 will be imported immediately on top of this again,
restoring the current status.

these PRs in the GCC bugzilla are fixed with this update:

89869 80693 89795 84272 85593 86669 87148 87647 87895 88103 88107 88563
88870 88976 89002 89187 89195 89234 89303 89314 89354 89361 89403 89412
89512 89520 89590 89621 89663 89679 89704 89734 89872 89933 90090 90208
87075 85870 89009 89242 88167 80864 81933 85890 86608 87145 88857 89024
89119 89214 89511 89612 89705 89400 81740 82186 84552 86554 87609 88105
88149 88415 88739 88903 89135 89223 89296 89505 89572 89677 89698 89710
90006 90020 90071 90328 90474 91126 91162 91812 91887 90075 88998 89945
87047 87506 88074 88656 88740 91137 89008 84010 89349 91136 91347 91995
89397 87030 60702 78884 85594 87649 87725 88181 88470 88553 88568 88588
88620 88644 88906 88949 89246 89587 89726 89768 89796 89998 90108 90756
90950 91704 88825 88983 86538 51333 89446 90220 91308 92143 89392 90213
90278 91131 91200 91510 89037 91481 87673 88418 88938 88948 90547 27221
58321 61250 67183 67958 77583 83531 86215 88648 88720 88726 89091 89466
89629 90105 90329 90585 90760 90924 91087 89222 81956 71861 35031 69455
81849 82993 85798 88138 88155 88169 88205 88206 88228 88249 88269 88376
77703 80260 82077 86248 88393 90786 57048 66089 66695 67679 68009 71723
72714 84394 85544 87734 88298 90937 91557 63891 64132 65342 68649 68717
71066 71860 71935 77746 78421 78645 78865 78983 79485 79540 85953 88326
89651 90744
@
text
@d3 1
a3 1
// Copyright (C) 2007-2017 Free Software Foundation, Inc.
d285 1
a1098 1
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
a1124 1
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
a1148 2
      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
@


1.1.1.8
log
@re-import GCC 8.4.0.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2018 Free Software Foundation, Inc.
a284 1
		// fallthrough
d1098 1
d1125 1
d1150 2
@


1.1.1.9
log
@initial import of GCC 9.3.0.  changes include:

- live patching support
- shell completion help
- generally better diagnostic output (less verbose/more useful)
- diagnostics and optimisation choices can be emitted in json
- asan memory usage reduction
- many general, and specific to switch, inter-procedure,
  profile and link-time optimisations.  from the release notes:
  "Overall compile time of Firefox 66 and LibreOffice 6.2.3 on
  an 8-core machine was reduced by about 5% compared to GCC 8.3"
- OpenMP 5.0 support
- better spell-guesser
- partial experimental support for c2x and c++2a
- c++17 is no longer experimental
- arm AAPCS GCC 6-8 structure passing bug fixed, may cause
  incompatibility (restored compat with GCC 5 and earlier.)
- openrisc support
@
text
@d3 1
a3 1
// Copyright (C) 2007-2019 Free Software Foundation, Inc.
@


1.1.1.10
log
@initial import of GCC 10.3.0.  main changes include:

caveats:
- ABI issue between c++14 and c++17 fixed
- profile mode is removed from libstdc++
- -fno-common is now the default

new features:
- new flags -fallocation-dce, -fprofile-partial-training,
  -fprofile-reproducible, -fprofile-prefix-path, and -fanalyzer
- many new compile and link time optimisations
- enhanced drive optimisations
- openacc 2.6 support
- openmp 5.0 features
- new warnings: -Wstring-compare and -Wzero-length-bounds
- extended warnings: -Warray-bounds, -Wformat-overflow,
  -Wrestrict, -Wreturn-local-addr, -Wstringop-overflow,
  -Warith-conversion, -Wmismatched-tags, and -Wredundant-tags
- some likely C2X features implemented
- more C++20 implemented
- many new arm & intel CPUs known

hundreds of reported bugs are fixed.  full list of changes
can be found at:

   https://gcc.gnu.org/gcc-10/changes.html
@
text
@d3 1
a3 1
// Copyright (C) 2007-2020 Free Software Foundation, Inc.
d1049 2
a1050 2
	__member = (__matches[0] >= (int)__indexlen
		    ? __matches[0] - (int)__indexlen : __matches[0]);
@


1.1.1.11
log
@initial import of GCC 12.3.0.

major changes in GCC 11 included:

- The default mode for C++ is now -std=gnu++17 instead of -std=gnu++14.
- When building GCC itself, the host compiler must now support C++11,
  rather than C++98.
- Some short options of the gcov tool have been renamed: -i to -j and
  -j to -H.
- ThreadSanitizer improvements.
- Introduce Hardware-assisted AddressSanitizer support.
- For targets that produce DWARF debugging information GCC now defaults
  to DWARF version 5. This can produce up to 25% more compact debug
  information compared to earlier versions.
- Many optimisations.
- The existing malloc attribute has been extended so that it can be
  used to identify allocator/deallocator API pairs. A pair of new
  -Wmismatched-dealloc and -Wmismatched-new-delete warnings are added.
- Other new warnings:
  -Wsizeof-array-div, enabled by -Wall, warns about divisions of two
    sizeof operators when the first one is applied to an array and the
    divisor does not equal the size of the array element.
  -Wstringop-overread, enabled by default, warns about calls to string
    functions reading past the end of the arrays passed to them as
    arguments.
  -Wtsan, enabled by default, warns about unsupported features in
    ThreadSanitizer (currently std::atomic_thread_fence).
- Enchanced warnings:
  -Wfree-nonheap-object detects many more instances of calls to
    deallocation functions with pointers not returned from a dynamic
    memory allocation function.
  -Wmaybe-uninitialized diagnoses passing pointers or references to
    uninitialized memory to functions taking const-qualified arguments.
  -Wuninitialized detects reads from uninitialized dynamically
    allocated memory.
  -Warray-parameter warns about functions with inconsistent array forms.
  -Wvla-parameter warns about functions with inconsistent VLA forms.
- Several new features from the upcoming C2X revision of the ISO C
  standard are supported with -std=c2x and -std=gnu2x.
- Several C++20 features have been implemented.
- The C++ front end has experimental support for some of the upcoming
  C++23 draft.
- Several new C++ warnings.
- Enhanced Arm, AArch64, x86, and RISC-V CPU support.
- The implementation of how program state is tracked within
  -fanalyzer has been completely rewritten with many enhancements.

see https://gcc.gnu.org/gcc-11/changes.html for a full list.

major changes in GCC 12 include:

- An ABI incompatibility between C and C++ when passing or returning
  by value certain aggregates containing zero width bit-fields has
  been discovered on various targets. x86-64, ARM and AArch64
  will always ignore them (so there is a C ABI incompatibility
  between GCC 11 and earlier with GCC 12 or later), PowerPC64 ELFv2
  always take them into account (so there is a C++ ABI
  incompatibility, GCC 4.4 and earlier compatible with GCC 12 or
  later, incompatible with GCC 4.5 through GCC 11). RISC-V has
  changed the handling of these already starting with GCC 10. As
  the ABI requires, MIPS takes them into account handling function
  return values so there is a C++ ABI incompatibility with GCC 4.5
  through 11.
- STABS: Support for emitting the STABS debugging format is
  deprecated and will be removed in the next release. All ports now
  default to emit DWARF (version 2 or later) debugging info or are
  obsoleted.
- Vectorization is enabled at -O2 which is now equivalent to the
  original -O2 -ftree-vectorize -fvect-cost-model=very-cheap.
- GCC now supports the ShadowCallStack sanitizer.
- Support for __builtin_shufflevector compatible with the clang
  language extension was added.
- Support for attribute unavailable was added.
- Support for __builtin_dynamic_object_size compatible with the
  clang language extension was added.
- New warnings:
  -Wbidi-chars warns about potentially misleading UTF-8
    bidirectional control characters.
  -Warray-compare warns about comparisons between two operands of
    array type.
- Some new features from the upcoming C2X revision of the ISO C
  standard are supported with -std=c2x and -std=gnu2x.
- Several C++23 features have been implemented.
- Many C++ enhancements across warnings and -f options.

see https://gcc.gnu.org/gcc-12/changes.html for a full list.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2022 Free Software Foundation, Inc.
a73 39
      struct _Scoped_str
      {
	size_t _M_len;
	_CharT* _M_str;

	explicit
	_Scoped_str(const basic_string<_CharT>& __str)
	: _M_len(__str.size()), _M_str(new _CharT[_M_len])
	{ __str.copy(_M_str, _M_len); }

	~_Scoped_str() { delete[] _M_str; }

	void
	_M_release(const _CharT*& __p, size_t& __n)
	{
	  __p = _M_str;
	  __n = _M_len;
	  _M_str = 0;
	}
      };

      _Scoped_str __curr_symbol(__mp.curr_symbol());
      _Scoped_str __positive_sign(__mp.positive_sign());
      _Scoped_str __negative_sign(__mp.negative_sign());

      const string& __g = __mp.grouping();
      const size_t __g_size = __g.size();
      char* const __grouping = new char[__g_size];
      __g.copy(__grouping, __g_size);

      // All allocations succeeded without throwing, OK to modify *this now.

      _M_grouping = __grouping;
      _M_grouping_size = __g_size;
      _M_use_grouping = (__g_size
			 && static_cast<signed char>(__grouping[0]) > 0
			 && (__grouping[0]
			     != __gnu_cxx::__numeric_traits<char>::__max));

a75 5

      __curr_symbol._M_release(_M_curr_symbol, _M_curr_symbol_size);
      __positive_sign._M_release(_M_positive_sign, _M_positive_sign_size);
      __negative_sign._M_release(_M_negative_sign, _M_negative_sign_size);

a76 2
      _M_pos_format = __mp.pos_format();
      _M_neg_format = __mp.neg_format();
d78 51
a128 5
      const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
      __ct.widen(money_base::_S_atoms,
		 money_base::_S_atoms + money_base::_S_end, _M_atoms);

      _M_allocated = true;
d353 1
a353 1
      && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
a403 16
#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
      && defined __LONG_DOUBLE_IEEE128__
  template<typename _CharT, typename _InIter>
    _InIter
    money_get<_CharT, _InIter>::
    __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
	     ios_base::iostate& __err, __ibm128& __units) const
    {
      string __str;
      __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
	             : _M_extract<false>(__beg, __end, __io, __err, __str);
      std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
      return __beg;
    }
#endif

d459 1
a459 1
	      {
d462 2
a463 2
		if (__lc->_M_grouping_size)
		  {
d465 1
a465 1
		    _CharT* __vend =
d471 2
a472 2
		  }
		else
d488 1
a488 1
	      }
d565 1
a565 1
      && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
a619 38
#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
      && defined __LONG_DOUBLE_IEEE128__
extern "C"
__typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 __asm__("snprintf");

  template<typename _CharT, typename _OutIter>
    _OutIter
    money_put<_CharT, _OutIter>::
    __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
	     __ibm128 __units) const
    {
      const locale __loc = __io.getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
      // First try a buffer perhaps big enough.
      int __cs_size = 64;
      char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
      const __c_locale __old = __gnu_cxx::__uselocale(_S_get_c_locale());

      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 328. Bad sprintf format modifier in money_put<>::do_put()
      int __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0,
					     __units);
      // If the buffer was not large enough, try again with the correct size.
      if (__len >= __cs_size)
	{
	  __cs_size = __len + 1;
	  __cs = static_cast<char*>(__builtin_alloca(__cs_size));
	  __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0,
					     __units);
	}
      __gnu_cxx::__uselocale(__old);
      string_type __digits(__len, char_type());
      __ctype.widen(__cs, __cs + __len, &__digits[0]);
      return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
	            : _M_insert<false>(__s, __io, __fill, __digits);
    }
#endif

d630 1
a630 1
  // Expand a strptime format string and parse it.  E.g., do_get_date() may
d637 1
a637 2
			  const _CharT* __format,
			  __time_get_state &__state) const
d660 8
d669 5
a673 6
		  // Weekday name (possibly abbreviated) [tm_wday]
		  const char_type*  __days[14];
		  __tp._M_days(&__days[0]);
		  __tp._M_days_abbreviated(&__days[7]);
		  __beg = _M_extract_name(__beg, __end, __mem, __days,
					  14, __io, __tmperr);
d675 1
a675 4
		    {
		      __tm->tm_wday = __mem % 7;
		      __state._M_have_wday = 1;
		    }
d679 8
d688 3
a690 4
		  // Month name (possibly abbreviated) [tm_mon]
		  const char_type*  __months[24];
		  __tp._M_months(&__months[0]);
		  __tp._M_months_abbreviated(&__months[12]);
d692 1
a692 1
					  __months, 24, __io, __tmperr);
d694 1
a694 5
		    {
		      __tm->tm_mon = __mem % 12;
		      __state._M_have_mon = 1;
		      __state._M_want_xday = 1;
		    }
d701 1
a701 3
						__tm, __dt[0], __state);
		  if (!__tmperr)
		    __state._M_want_xday = 1;
d703 3
a705 3
		case 'C':
		  // Century.
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
d708 1
a708 5
		    {
		      __state._M_century = __mem;
		      __state._M_have_century = 1;
		      __state._M_want_xday = 1;
		    }
a709 1
		case 'd':
d711 2
a712 1
		  // Day [1, 31]. [tm_mday]
d714 5
a718 3
		    ++__beg;
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
					 __io, __tmperr);
d720 1
a720 5
		    {
		      __tm->tm_mday = __mem;
		      __state._M_have_mday = 1;
		      __state._M_want_xday = 1;
		    }
d727 1
a727 3
						__tm, __wcs, __state);
		  if (!__tmperr)
		    __state._M_want_xday = 1;
d734 1
a734 4
		    {
		      __tm->tm_hour = __mem;
		      __state._M_have_I = 0;
		    }
d741 1
a741 14
		    {
		      __tm->tm_hour = __mem % 12;
		      __state._M_have_I = 1;
		    }
		  break;
		case 'j':
		  // Day number of year.
		  __beg = _M_extract_num(__beg, __end, __mem, 1, 366, 3,
					 __io, __tmperr);
		  if (!__tmperr)
		    {
		      __tm->tm_yday = __mem - 1;
		      __state._M_have_yday = 1;
		    }
d748 1
a748 4
		    {
		      __tm->tm_mon = __mem - 1;
		      __state._M_have_mon = 1;
		    }
d758 1
a758 3
		case 't':
		  while (__beg != __end
			 && __ctype.is(ctype_base::space, *__beg))
d760 2
a761 18
		  break;
		case 'p':
		  // Locale's a.m. or p.m.
		  const char_type*  __ampm[2];
		  __tp._M_am_pm(&__ampm[0]);
		  if (!__ampm[0][0] || !__ampm[1][0])
		    break;
		  __beg = _M_extract_name(__beg, __end, __mem, __ampm,
					  2, __io, __tmperr);
		  if (!__tmperr && __mem)
		    __state._M_is_pm = 1;
		  break;
		case 'r':
		  // Locale's 12-hour clock time format (in C %I:%M:%S %p).
		  const char_type*  __ampm_format;
		  __tp._M_am_pm_format(&__ampm_format);
		  __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
						__tm, __ampm_format, __state);
d768 1
a768 1
						__tm, __wcs, __state);
d780 7
a786 1
		    __tm->tm_sec = __mem;
d793 1
a793 31
						__tm, __wcs, __state);
		  break;
		case 'U':
		  // Week number of the year (Sunday as first day of week).
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
					 __io, __tmperr);
		  if (!__tmperr)
		    {
		      __state._M_week_no = __mem;
		      __state._M_have_uweek = 1;
		    }
		  break;
		case 'w':
		  // Weekday [tm_wday]
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 6, 1,
					 __io, __tmperr);
		  if (!__tmperr)
		    {
		      __tm->tm_wday = __mem;
		      __state._M_have_wday = 1;
		    }
		  break;
		case 'W':
		  // Week number of the year (Monday as first day of week).
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
					 __io, __tmperr);
		  if (!__tmperr)
		    {
		      __state._M_week_no = __mem;
		      __state._M_have_wweek = 1;
		    }
d800 1
a800 1
						__tm, __dates[0], __state);
d807 1
a807 1
						__tm, __times[0], __state);
d810 2
a811 35
		  // The last 2 digits of year.
		  __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
					 __io, __tmperr);
		  if (!__tmperr)
		    {
		      __state._M_want_century = 1;
		      __state._M_want_xday = 1;
		      // As an extension, if the 2 digits are followed by
		      // 1-2 further digits, treat it like %Y.
		      __c = 0;
		      if (__beg != __end)
			__c = __ctype.narrow(*__beg, '*');
		      if (__c >= '0' && __c <= '9')
			{
			  ++__beg;
			  __mem = __mem * 10 + (__c - '0');
			  if (__beg != __end)
			    {
			      __c = __ctype.narrow(*__beg, '*');
			      if (__c >= '0' && __c <= '9')
				{
				  ++__beg;
				  __mem = __mem * 10 + (__c - '0');
				}
			    }
			  __mem -= 1900;
			  __state._M_want_century = 0;
			}
		      // Otherwise, as per POSIX 2008, 00-68 is 2000-2068,
		      // while 69-99 is 1969-1999.
		      else if (__mem < 69)
			__mem += 100;
		      __tm->tm_year = __mem;
		    }
		  break;
d813 4
a816 1
		  // Year.
d820 1
a820 5
		    {
		      __tm->tm_year = __mem - 1900;
		      __state._M_want_century = 0;
		      __state._M_want_xday = 1;
		    }
a844 6
		case '%':
		  if (*__beg == __ctype.widen('%'))
		    ++__beg;
		  else
		    __tmperr |= ios_base::failbit;
		  break;
a849 7
	  else if (__ctype.is(ctype_base::space, __format[__i]))
	    {
	      // Skip any whitespace.
	      while (__beg != __end
		     && __ctype.is(ctype_base::space, *__beg))
		++__beg;
	    }
d853 1
a853 3
	      // TODO real case-insensitive comparison
	      if (__ctype.tolower(__format[__i]) == __ctype.tolower(*__beg)
		  || __ctype.toupper(__format[__i]) == __ctype.toupper(*__beg))
a868 12
    _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
			  ios_base::iostate& __err, tm* __tm,
			  const _CharT* __format) const
    {
      __time_get_state __state = __time_get_state();
      return _M_extract_via_format(__beg, __end, __io, __err, __tm,
				   __format, __state);
    }

  template<typename _CharT, typename _InIter>
    _InIter
    time_get<_CharT, _InIter>::
d876 4
d888 2
a889 1
	      if (__value > __max)
d891 1
d896 1
a896 1
      if (__i && __value >= __min && __value <= __max)
d898 3
d908 1
a908 4
  // All elements in __names are unique, except if __indexlen is
  // even __names in the first half could be the same as corresponding
  // __names in the second half (May is abbreviated as May).  Some __names
  // elements could be prefixes of other __names elements.
d920 2
a921 4
      size_t* __matches
	= static_cast<size_t*>(__builtin_alloca(2 * sizeof(size_t)
						* __indexlen));
      size_t* __lengths = __matches + __indexlen;
a925 1
      bool __begupdated = false;
d928 3
a933 3
	  // TODO real case-insensitive comparison
	  const char_type __cl = __ctype.tolower(__c);
	  const char_type __cu = __ctype.toupper(__c);
d935 3
a937 7
	    if (__cl == __ctype.tolower(__names[__i1][0])
		|| __cu == __ctype.toupper(__names[__i1][0]))
	      {
		__lengths[__nmatches]
		  = __traits_type::length(__names[__i1]);
		__matches[__nmatches++] = __i1;
	      }
d943 1
a943 1
	  size_t __minlen = __lengths[0];
d945 3
a947 1
	    __minlen = std::min(__minlen, __lengths[__i2]);
d949 6
a954 34
	  ++__beg;
	  if (__pos == __minlen)
	    {
	      // If some match has remaining length of 0,
	      // need to decide if any match with remaining
	      // length non-zero matches the next character.
	      // If so, remove all matches with remaining length
	      // 0 from consideration, otherwise keep only matches
	      // with remaining length 0.
	      bool __match_longer = false;

	      if (__beg != __end)
		{
		  // TODO real case-insensitive comparison
		  const char_type __cl = __ctype.tolower(*__beg);
		  const char_type __cu = __ctype.toupper(*__beg);
		  for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
		    {
		      __name = __names[__matches[__i3]];
		      if (__lengths[__i3] > __pos
			  && (__ctype.tolower(__name[__pos]) == __cl
			      || __ctype.toupper(__name[__pos]) == __cu))
			{
			  __match_longer = true;
			  break;
			}
		    }
		}
	      for (size_t __i4 = 0; __i4 < __nmatches;)
		if (__match_longer == (__lengths[__i4] == __pos))
		  {
		    __matches[__i4] = __matches[--__nmatches];
		    __lengths[__i4] = __lengths[__nmatches];
		  }
d956 2
a957 47
		  ++__i4;
	      if (__match_longer)
		{
		  __minlen = __lengths[0];
		  for (size_t __i5 = 1; __i5 < __nmatches; ++__i5)
		    __minlen = std::min(__minlen, __lengths[__i5]);
		}
	      else
		{
		  // Deal with May being full as well as abbreviated month
		  // name.  Pick the smaller index.
		  if (__nmatches == 2 && (__indexlen & 1) == 0)
		    {
		      if (__matches[0] < __indexlen / 2)
			{
			  if (__matches[1] == __matches[0] + __indexlen / 2)
			    __nmatches = 1;
			}
		      else if (__matches[1] == __matches[0] - __indexlen / 2)
			{
			  __matches[0] = __matches[1];
			  __lengths[0] = __lengths[1];
			  __nmatches = 1;
			}
		    }
		  __begupdated = true;
		  break;
		}
	    }
	  if (__pos < __minlen && __beg != __end)
	    {
	      // TODO real case-insensitive comparison
	      const char_type __cl = __ctype.tolower(*__beg);
	      const char_type __cu = __ctype.toupper(*__beg);
	      for (size_t __i6 = 0; __i6 < __nmatches;)
		{
		  __name = __names[__matches[__i6]];
		  if (__ctype.tolower(__name[__pos]) != __cl
		      && __ctype.toupper(__name[__pos]) != __cu)
		    {
		      __matches[__i6] = __matches[--__nmatches];
		      __lengths[__i6] = __lengths[__nmatches];
		    }
		  else
		    ++__i6;
		}
	    }
d965 2
a966 5
	  if (!__begupdated)
	    {
	      ++__beg;
	      ++__pos;
	    }
d968 2
a969 7
	  const size_t __len = __lengths[0];
	  while (__pos < __len
		 && __beg != __end
		 // TODO real case-insensitive comparison
		 && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
		     || (__ctype.toupper(__name[__pos])
			 == __ctype.toupper(*__beg))))
a1066 1
      __time_get_state __state = __time_get_state();
d1068 1
a1068 2
				    __tm, __times[0], __state);
      __state._M_finalize_state(__tm);
a1083 1
      __time_get_state __state = __time_get_state();
d1085 1
a1085 2
				    __tm, __dates[0], __state);
      __state._M_finalize_state(__tm);
a1150 2
      const locale& __loc = __io._M_getloc();
      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
d1152 1
a1152 1
      __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2,
d1155 1
a1155 26
	{
	  char __c = 0;
	  if (__beg != __end)
	    __c = __ctype.narrow(*__beg, '*');
	  // For 1-2 digit year, assume 69-99 is 1969-1999, 0-68 is 2000-2068.
	  // For 3-4 digit year, use it as year.
	  // __tm->tm_year needs year - 1900 though.
	  if (__c >= '0' && __c <= '9')
	    {
	      ++__beg;
	      __tmpyear = __tmpyear * 10 + (__c - '0');
	      if (__beg != __end)
		{
		  __c = __ctype.narrow(*__beg, '*');
		  if (__c >= '0' && __c <= '9')
		    {
		      ++__beg;
		      __tmpyear = __tmpyear * 10 + (__c - '0');
		    }
		}
	      __tmpyear -= 1900;
	    }
	  else if (__tmpyear < 69)
	    __tmpyear += 100;
	  __tm->tm_year = __tmpyear;
	}
a1175 15
      bool __use_state = false;
#if __GNUC__ >= 5 && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpmf-conversions"
      // Nasty hack.  The C++ standard mandates that get invokes the do_get
      // virtual method, but unfortunately at least without an ABI change
      // for the facets we can't keep state across the different do_get
      // calls.  So e.g. if __fmt is "%p %I:%M:%S", we can't handle it
      // properly, because we first handle the %p am/pm specifier and only
      // later the 12-hour format specifier.
      if ((void*)(this->*(&time_get::do_get)) == (void*)(&time_get::do_get))
	__use_state = true;
#pragma GCC diagnostic pop
#endif
      __time_get_state __state = __time_get_state();
a1185 1
	      const char_type* __fmt_start = __fmt;
d1206 2
a1207 20
	      if (__use_state)
		{
		  char_type __new_fmt[4];
		  __new_fmt[0] = __fmt_start[0];
		  __new_fmt[1] = __fmt_start[1];
		  if (__mod)
		    {
		      __new_fmt[2] = __fmt_start[2];
		      __new_fmt[3] = char_type();
		    }
		  else
		    __new_fmt[2] = char_type();
		  __s = _M_extract_via_format(__s, __end, __io, __err, __tm,
					      __new_fmt, __state);
		  if (__s == __end)
		    __err |= ios_base::eofbit;
		}
	      else
		__s = this->do_get(__s, __end, __io, __err, __tm, __format,
				   __mod);
a1233 2
      if (__use_state)
	__state._M_finalize_state(__tm);
d1263 1
a1263 4
      __time_get_state __state = __time_get_state();
      __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt,
				    __state);
      __state._M_finalize_state(__tm);
@


1.1.1.12
log
@initial import of GCC 14.3.0.

major changes in GCC 13:
- improved sanitizer
- zstd debug info compression
- LTO improvements
- SARIF based diagnostic support
- new warnings: -Wxor-used-as-pow, -Wenum-int-mismatch, -Wself-move,
  -Wdangling-reference
- many new -Wanalyzer* specific warnings
- enhanced warnings: -Wpessimizing-move, -Wredundant-move
- new attributes to mark file descriptors, c++23 "assume"
- several C23 features added
- several C++23 features added
- many new features for Arm, x86, RISC-V

major changes in GCC 14:
- more strict C99 or newer support
- ia64* marked deprecated (but seemingly still in GCC 15.)
- several new hardening features
- support for "hardbool", which can have user supplied values of true/false
- explicit support for stack scrubbing upon function exit
- better auto-vectorisation support
- added clang-compatible __has_feature and __has_extension
- more C23, including -std=c23
- several C++26 features added
- better diagnostics in C++ templates
- new warnings: -Wnrvo, Welaborated-enum-base
- many new features for Arm, x86, RISC-V
- possible ABI breaking change for SPARC64 and small structures with arrays
  of floats.
@
text
@d3 1
a3 1
// Copyright (C) 2007-2024 Free Software Foundation, Inc.
d1651 1
a1651 1
      // NB: In IEEE 1003.1-200x, and perhaps other locale models, it
a1679 3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
#pragma GCC diagnostic ignored "-Wlong-long"
a1694 32
    const moneypunct<char, true>*
    __try_use_facet<moneypunct<char, true> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const moneypunct<char, false>*
    __try_use_facet<moneypunct<char, false> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const money_put<char>*
    __try_use_facet<money_put<char> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const money_get<char>*
    __try_use_facet<money_get<char> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const __timepunct<char>*
    __try_use_facet<__timepunct<char> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const time_put<char>*
    __try_use_facet<time_put<char> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const time_get<char>*
    __try_use_facet<time_get<char> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const messages<char>*
    __try_use_facet<messages<char> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
a1769 32
    const moneypunct<wchar_t, true>*
    __try_use_facet<moneypunct<wchar_t, true> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const moneypunct<wchar_t, false>*
    __try_use_facet<moneypunct<wchar_t, false> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const money_put<wchar_t>*
    __try_use_facet<money_put<wchar_t> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const money_get<wchar_t>*
    __try_use_facet<money_get<wchar_t> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const __timepunct<wchar_t>*
    __try_use_facet<__timepunct<wchar_t> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const time_put<wchar_t>*
    __try_use_facet<time_put<wchar_t> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const time_get<wchar_t>*
    __try_use_facet<time_get<wchar_t> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
    const messages<wchar_t>*
    __try_use_facet<messages<wchar_t> >(const locale&) _GLIBCXX_NOTHROW;

  extern template
a1828 1
#pragma GCC diagnostic pop
@


