// class template regex -*- C++ -*-
-// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+// Copyright (C) 2013-2015 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
* Do not attempt to use it directly. @headername{regex}
*/
+// This macro defines the maximal state number a NFA can have.
+#ifndef _GLIBCXX_REGEX_STATE_LIMIT
+#define _GLIBCXX_REGEX_STATE_LIMIT 100000
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __detail
typedef _State<_TraitsT> _StateT;
typedef _Matcher<typename _TraitsT::char_type> _MatcherT;
- using _NFA_base::_NFA_base;
+ _NFA(const typename _TraitsT::locale_type& __loc, _FlagT __flags)
+ : _NFA_base(__flags)
+ { _M_traits.imbue(__loc); }
// for performance reasons _NFA objects should only be moved not copied
_NFA(const _NFA&) = delete;
_M_insert_state(_StateT __s)
{
this->push_back(std::move(__s));
+ if (this->size() > _GLIBCXX_REGEX_STATE_LIMIT)
+ __throw_regex_error(regex_constants::error_space);
return this->size()-1;
}
std::ostream&
_M_dot(std::ostream& __ostr) const;
#endif
+ public:
+ _TraitsT _M_traits;
};
/// Describes a sequence of one or more %_State, its current start