Commit Graph

20 Commits

Author SHA1 Message Date
Tim Shen 244901a572 re PR libstdc++/69794 (std::regex_search match failure with regex object with flags grep|icase)
2016-02-16  Tim Shen  <timshen@google.com>

	PR libstdc++/69794
	* include/bits/regex_scanner.h: Add different special character
	sets for grep and egrep regex.
	* include/bits/regex_scanner.tcc: Use _M_spec_char more uniformly.
	* testsuite/28_regex/regression.cc: Add new testcase.

From-SVN: r233482
2016-02-17 03:33:02 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Tim Shen 236d76c4a9 re PR libstdc++/67361 (std::regex_error::what() should say something about the error_code)
PR libstdc++/67361
	* include/bits/regex_error.h: Add __throw_regex_error that
	supports string.
	* include/bits/regex_automaton.h: Add more specific exception
	messages.
	* include/bits/regex_automaton.tcc: Likewise.
	* include/bits/regex_compiler.h: Likewise.
	* include/bits/regex_compiler.tcc: Likewise.
	* include/bits/regex_scanner.h: Likewise.
	* include/bits/regex_scanner.tcc: Likewise.

From-SVN: r227936
2015-09-19 20:56:27 +00:00
Jonathan Wakely 2f1e8e7c47 Enable lightweight checks with _GLIBCXX_ASSERTIONS.
* doc/xml/manual/using.xml (_GLIBCXX_ASSERTIONS): Document.
	* doc/html/manual/using_macros.html: Regenerate.
	* include/bits/c++config: Define _GLIBCXX_ASSERTIONS when
	_GLIBCXX_DEBUG is defined. Disable std::string extern templates when
	(_GLIBCXX_EXTERN_TEMPLATE, __glibcxx_assert): Depend on
	_GLIBCXX_ASSERTIONS instead of _GLIBCXX_DEBUG.
	* include/debug/debug.h [!_GLIBCXX_DEBUG]: Define
	__glibcxx_requires_non_empty_range and __glibcxx_requires_nonempty.
	* include/backward/auto_ptr.h (auto_ptr::operator*,
	auto_ptr::operator->): Replace _GLIBCXX_DEBUG_ASSERT with
	__glibcxx_assert.
	* include/bits/basic_string.h (basic_string::operator[],
	basic_string::front, basic_string::back, basic_string::pop_back):
	Likewise.
	* include/bits/random.h
	(uniform_int_distribution::param_type::param_type,
	uniform_real_distribution::param_type::param_type,
	normal_distribution::param_type::param_type,
	gamma_distribution::param_type::param_type,
	bernoulli_distribution::param_type::param_type,
	binomial_distribution::param_type::param_type,
	geometric_distribution::param_type::param_type,
	negative_binomial_distribution::param_type::param_type,
	poisson_distribution::param_type::param_type,
	exponential_distribution::param_type::param_type): Likewise.
	* include/bits/regex.h (match_results::operator[],
	match_results::prefix, match_results::suffix): Likewise.
	* include/bits/regex.tcc (format, regex_iterator::operator++):
	Likewise.
	* include/bits/regex_automaton.tcc (_StateSeq::_M_clone): Likewise.
	* include/bits/regex_compiler.tcc (_Compiler::_Compiler,
	_Compiler::_M_insert_character_class_matcher): Likewise.
	* include/bits/regex_executor.tcc (_Executor::_M_dfs): Likewise.
	* include/bits/regex_scanner.tcc (_Scanner::_M_advance,
	_Scanner::_M_scan_normal): Likewise.
	* include/bits/shared_ptr_base.h (__shared_ptr::_M_reset,
	__shared_ptr::operator*): Likewise.
	* include/bits/stl_iterator_base_funcs.h (__advance): Likewise.
	* include/bits/unique_ptr.h (unique_ptr::operator*,
	unique_ptr::operator[]): Likewise.
	* include/experimental/fs_path.h (path::path(string_type, _Type),
	path::iterator::operator++, path::iterator::operator--,
	path::iterator::operator*): Likewise.
	* include/experimental/string_view (basic_string_view::operator[],
	basic_string_view::front, basic_string_view::back,
	basic_string_view::remove_prefix): Likewise.
	* include/ext/random (beta_distribution::param_type::param_type,
	normal_mv_distribution::param_type::param_type,
	rice_distribution::param_type::param_type,
	pareto_distribution::param_type::param_type,
	k_distribution::param_type::param_type,
	arcsine_distribution::param_type::param_type,
	hoyt_distribution::param_type::param_type,
	triangular_distribution::param_type::param_type,
	von_mises_distribution::param_type::param_type,
	hypergeometric_distribution::param_type::param_type,
	logistic_distribution::param_type::param_type): Likewise.
	* include/ext/vstring.h (__versa_string::operator[]): Likewise.
	* include/std/complex (polar): Likewise.
	* include/std/mutex [!_GTHREAD_USE_MUTEX_TIMEDLOCK]
	(timed_mutex::~timed_mutex, timed_mutex::unlock,
	(recursive_timed_mutex::~timed_mutex, recursive_timed_mutex::unlock):
	Likewise.
	* include/std/shared_mutex [!PTHREAD_RWLOCK_INITIALIZER]
	(__shared_mutex_pthread::__shared_mutex_pthread,
	__shared_mutex_pthread::~__shared_mutex_pthread): Likewise.
	(__shared_mutex_pthread::lock, __shared_mutex_pthread::try_lock,
	__shared_mutex_pthread::unlock, __shared_mutex_pthread::lock_shared,
	__shared_mutex_pthread::try_lock_shared): Likewise.
	(__shared_mutex_cv::~__shared_mutex_cv, __shared_mutex_cv::unlock,
	__shared_mutex_cv::unlock_shared): Likewise.
	(shared_timed_mutex::try_lock_until,
	shared_timed_mutex::try_lock_shared_until): Likewise.
	* include/std/valarray (valarray::valarray(const _Tp*, size_t),
	valarray::operator=, valarray::sum, valarray::min, valarray::max,
	_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT, _DEFINE_BINARY_OPERATOR):
	Likewise.

From-SVN: r227595
2015-09-09 18:12:47 +01:00
Tim Shen cae4063cea re PR libstdc++/67362 (std::regex("((.)", std::regex_constants::basic) throws)
PR libstdc++/67362
	* include/bits/regex_scanner.tcc (_Scanner<>::_M_scan_normal):
	Always returns ordinary char token if the char isn't
	considered a special char.
	* testsuite/28_regex/regression.cc: New test file for collecting
	regression testcases from, typically, bugzilla.

From-SVN: r227289
2015-08-28 02:35:21 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Jonathan Wakely 8aed2f2f63 re PR libstdc++/63219 (Superfluous template parameter in match_result::format overload)
PR libstdc++/63219
	* include/bits/regex.h (match_results::format): Remove stray template
	parameter.
	* include/bits/regex_compiler.h (_RegexTranslator::_RegexTranslator):
	Remove parameter name to avoid -Wunused-parameter warning.
	* include/bits/regex_executor.h (_State_info::_State_info): Reorder
	mem-initializers to avoid -Wreorder warning.
	* include/bits/regex_executor.tcc (_Executor::_M_word_boundary):
	Remove parameter name to avoid -Wunused-parameter warning.
	* include/bits/regex_scanner.tcc (_Scanner::_M_advance): Add braces
	to avoid -Wempty-body warning when not in debug mode.

From-SVN: r215160
2014-09-11 11:01:20 +01:00
Jonathan Wakely 097f0bcf65 regex_compiler.h (__detail::_BracketMatcher): Reorder members to avoid wasted space when not using a cache.
* include/bits/regex_compiler.h (__detail::_BracketMatcher): Reorder
	members to avoid wasted space when not using a cache.
	(__detail::_BracketMatcher::_M_ready()): Sort and deduplicate set.
	* include/bits/regex_compiler.tcc
	(__detail::_BracketMatcher::_M_apply(_CharT, false_type)): Use binary
	search on set.
	* include/bits/regex_executor.h (__detail::_Executor::_Match_mode):
	New enumeration type to indicate match mode.
	(__detail::_Executor::_State_info): New type holding members only
	needed in BFS-mode. Replace unique_ptr<vector<bool>> with
	unique_ptr<bool[]>.
	(__detail::_Executor::_M_rep_once_more, __detail::_Executor::_M_dfs):
	Replace template parameter with run-time function parameter.
	(__detail::_Executor::_M_main): Likewise. Dispatch to ...
	(__detail::_Executor::_M_main_dispatch): New overloaded functions to
	implement DFS and BFS mode.
	* include/bits/regex_executor.tcc (__detail::_Executor::_M_main):
	Split implementation into ...
	(__detail::_Executor::_M_main_dispatch): New overloaded functions.
	(__detail::_Executor::_M_lookahead): Create nested executor on stack.
	(__detail::_Executor::_M_rep_once_more): Pass match mode as function
	argument instead of template argument.
	(__detail::_Executor::_M_dfs): Likewise.
	* include/bits/regex_scanner.tcc: Fix typos in comments.
	* testsuite/performance/28_regex/range.cc: New.

From-SVN: r211143
2014-06-02 20:36:14 +01:00
Tim Shen a670a9bb54 regex_automaton.h (_NFA<>::_M_insert_repeat): Add _S_opcode_repeat support to distingush a loop from _S_opcode_alternative.
2014-04-27  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_automaton.h (_NFA<>::_M_insert_repeat):
	Add _S_opcode_repeat support to distingush a loop from
	_S_opcode_alternative.
	* include/bits/regex_automaton.tcc (_State_base::_M_print,
	_State_base::_M_dot, _NFA<>::_M_eliminate_dummy,
	_StateSeq<>::_M_clone): Likewise.
	* include/bits/regex_compiler.tcc (_Compiler<>::_M_quantifier):
	Likewise.
	* include/bits/regex_executor.tcc (_Executor<>::_M_dfs): Likewise.
	* include/bits/regex_scanner.tcc (_Scanner<>::_M_eat_escape_ecma):
	Uglify local variable __i.
	* include/bits/regex_compiler.h (_BracketMatcher<>::_M_make_cache):
	Use size_t instead of int to compare with vector::size().

2014-04-27  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_executor.h: Add _M_rep_count to track how
	many times this repeat node are visited.
	* include/bits/regex_executor.tcc (_Executor<>::_M_rep_once_more,
	_Executor<>::_M_dfs): Use _M_rep_count to prevent entering
	infinite loop.

2014-04-27  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.tcc (__regex_algo_impl<>): Remove
	_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT and use
	_GLIBCXX_REGEX_USE_THOMPSON_NFA instead.
	* include/bits/regex_automaton.h: Remove quantifier counting variable.
	* include/bits/regex_automaton.tcc (_State_base::_M_dot):
	Adjust debug NFA dump.

From-SVN: r209844
2014-04-27 23:48:47 +00:00
Tim Shen 8f7082f5ea regex.tcc: Remove incorrect `nosubs` handling.
2014-01-21  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.tcc: Remove incorrect `nosubs` handling.
	* include/bits/regex_scanner.tcc: Handle `nosubs` correctly.
	* testsuite/28_regex/constants/syntax_option_type.cc: Add a test case.

From-SVN: r206906
2014-01-21 19:54:03 +00:00
Tim Shen ddf41e9db6 regex_automaton.tcc (_StateSeq<>::_M_clone()): Do not use std::map.
2014-01-17  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_automaton.tcc (_StateSeq<>::_M_clone()): Do not
	use std::map.
	* include/bits/regex_automaton.h: Do not use std::set.
	* include/bits/regex_compiler.h (_BracketMatcher<>::_M_add_char(),
	_BracketMatcher<>::_M_add_collating_element(),
	_BracketMatcher<>::_M_add_equivalence_class(),
	_BracketMatcher<>::_M_make_range()): Likewise.
	* include/bits/regex_compiler.tcc (_BracketMatcher<>::_M_apply()):
	Likewise.
	* include/bits/regex_executor.h: Do not use std::queue.
	* include/bits/regex_executor.tcc (_Executor<>::_M_main(),
	_Executor<>::_M_dfs()): Likewise.
	* include/std/regex: Remove <map>, <set> and <queue>.

2014-01-17  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.h (__compile_nfa<>(), basic_regex<>::basic_regex(),
	basic_regex<>::assign()): Change __compile_nfa to accept
	const _CharT* only.
	* include/bits/regex_compiler.h: Change _Compiler's template
	argument from <_FwdIter, _TraitsT> to <_TraitsT>.
	* include/bits/regex_compiler.tcc: Likewise.

2014-01-17  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_compiler.h: Change _ScannerT into char-type
	templated.
	* include/bits/regex_scanner.h (_Scanner<>::_Scanner()): Separate
	_ScannerBase from _Scanner; Change _Scanner's template argument from
	_FwdIter to _CharT. Avoid use of std::map and std::set by using arrays
	instead.
	* include/bits/regex_scanner.tcc (_Scanner<>::_Scanner(),
	_Scanner<>::_M_scan_normal(), _Scanner<>::_M_eat_escape_ecma(),
	_Scanner<>::_M_eat_escape_posix(), _Scanner<>::_M_eat_escape_awk()):
	Likewise.
	* include/std/regex: Add <cstring> for using strchr.

2014-01-17  Tim Shen  <timshen91@gmail.com>

	* bits/regex_automaton.tcc: Indentation fix.
	* bits/regex_compiler.h (__compile_nfa<>(), _Compiler<>,
	_RegexTranslator<> _AnyMatcher<>, _CharMatcher<>,
	_BracketMatcher<>): Add bool option template parameters and
	specializations to make matching more efficient and space saving.
	* bits/regex_compiler.tcc: Likewise.

From-SVN: r206690
2014-01-16 23:35:21 +00:00
Richard Sandiford aa118a03c4 Update copyright years in libstdc++-v3/
From-SVN: r206301
2014-01-02 22:30:10 +00:00
Tim Shen 7948838864 regex_scanner.tcc: (_Scanner<>::_M_scan_normal...
2013-10-18  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_scanner.tcc: (_Scanner<>::_M_scan_normal,
	_Scanner<>::_M_eat_escape_ecma, _Scanner<>::_M_eat_escape_posix,
	_Scanner<>::_M_eat_escape_awk): Narrow character before finding in maps.
	* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/cjk_match.cc:
	New.

From-SVN: r203827
2013-10-18 16:13:07 +00:00
Tim Shen ab1c993b94 regex.h (regex_token_iterator<>::regex_token_iterator): Fix initialization orders in initialization list and add explicit braces for...
2013-10-17  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.h (regex_token_iterator<>::regex_token_iterator):
	Fix initialization orders in initialization list and add explicit braces
	for potentially ambiguous(actually not) `else` branch to eliminate
	warnings.
	* include/bits/regex_automaton.h (_NFA<>::_NFA): Likewise.
	* include/bits/regex_compiler.h (_CharMatcher<>::_CharMatcher,
	_BracketMatcher<>::_BracketMatcher): Likewise.
	* include/bits/regex_compiler.tcc (_Compiler<>::_Compiler,
	_Compiler<>::_M_atom): Likewise.
	* include/bits/regex_executor.h (_Executor<>::_Executor): Likewise.
	* include/bits/regex_executor.tcc (_DFSExecutor<>::_M_dfs,
	_Executor<>::_M_word_boundry): Likewise.
	* include/bits/regex_scanner.tcc (_Scanner<>::_Scanner,
	_Scanner<>::_M_eat_class): Likewise.
	* include/bits/regex.tcc (__regex_algo_impl<>,
	regex_iterator<>::operator++): Likewise, and remove unused typedef.

From-SVN: r203798
2013-10-17 20:46:50 +00:00
Tim Shen 8d60fca50e regex_scanner.tcc (_Scanner<>::_M_eat_escape_posix): Let ordinary char escaping in POSIX be valid.
2013-09-28  Tim Shen <timshen91@gmail.com>

	* include/bits/regex_scanner.tcc (_Scanner<>::_M_eat_escape_posix):
	Let ordinary char escaping in POSIX be valid.
	* testsuite/28_regex/basic_regex/ctors/basic/raw_string.cc: Test this
	change.

From-SVN: r203005
2013-09-28 13:41:09 +00:00
Tim Shen d4e1260101 regex_error.h: Remove _S_error_last to follow the standard.
2013-09-26  Tim Shen  <timshen91@gmail.com>

	* regex_error.h: Remove _S_error_last to follow the standard.
	* regex_scanner.tcc:
	(_Scanner<_FwdIter>::_M_scan_in_brace): Change error_brace to
	error_badbrace.
	(_Scanner<>::_M_eat_escape_posix): Extended doesn't support
	back-reference.
	* testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc:
	Move here from ../../extended.
	* testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc:
	Likewise.

From-SVN: r202958
2013-09-26 21:48:04 +00:00
Tim Shen b21abceec3 regex.h: Add friend classes.
2013-09-18  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.h: Add friend classes.
	(match_results<>::position, regex_iterator<>::operator++):
	Implement position specification in regex_iterator.
	(regex_match<>, regex_search<>):
	Move match_results initializations to these function. Remove `todo`.
	* include/bits/regex_compiler.tcc:
	(_Compiler<>::_M_quantifier): Fix greedy/ungreedy of interval matching.
	* include/bits/regex_constants.h:
	Fix indentation. Change match_flag_type to enum type.
	* include/bits/regex_executor.h:
	Merge identical code to the base class _Executor.
	Support flags in regex_constants.
	* include/bits/regex_executor.tcc: Likewise.
	* include/bits/regex_scanner.h: Add comments.
	* include/bits/regex_scanner.tcc: Same.
	* testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc:
	Add a testcase.
	* testsuite/28_regex/algorithms/regex_search/ecma/flags.cc: New.
	* testsuite/28_regex/iterators/regex_iterator/char/
	string_position_01.cc: Remove `xfail`.
	* testsuite/28_regex/iterators/regex_iterator/wchar_t/string_02.cc:
	Remove `xfail` and make the case really work.

From-SVN: r202706
2013-09-18 15:56:20 +00:00
Tim Shen 7b86458e38 regex.h (regex_match<>, [...]): Change regex_executor caller.
2013-09-14  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.h (regex_match<>, regex_search<>):
	Change regex_executor caller. Now use their return value instead
	of checking __m[0].matched to find out if it's successful.
	(regex_search<>): Move the search logic to regex_executor.
	* include/bits/regex_automaton.h: Add some new _Opcode. Refactor
	_NFA::_M_insert_*.
	* include/bits/regex_automaton.tcc: Add DEBUG dump for new
	_Opcode. Refactor _NFA::_M_insert_*.
	* include/bits/regex_compiler.h (_Compiler<>::_M_get_nfa):
	Use make_shared instead of construct by hand.
	* include/bits/regex_compiler.tcc: Implement _Compiler<>::_M_assertion.
	* include/bits/regex_constants.h: Fix indentation and line breaking.
	* include/bits/regex_executor.h: Add _ResultsEntry to support
	greedy/ungreedy mode. Move regex_search logic here.
	* include/bits/regex_executor.tcc: Implement assertions and
	greedy/ungreedy matching.
	* include/bits/regex_scanner.h: Add a new token _S_token_ungreedy.
	* include/bits/regex_scanner.tcc: Parse a new token _S_token_ungreedy.
	* testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc: New.
	* testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc: New.
	* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc:
	Fix comment.

From-SVN: r202591
2013-09-14 14:23:44 +00:00
Tim Shen 7c812a2a57 regex_automaton.h: Add dummy node type.
2013-09-05  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_automaton.h: Add dummy node type. Rewrite
	_StateSeq.
	* include/bits/regex_automaton.tcc: Implement them.
	* include/bits/regex_compiler.h: Rewrite _Compiler to use new
	_StateSeq interfaces.
	* include/bits/regex_compiler.tcc: Implement them.
	* include/bits/regex_scanner.h: Add word boundry assertion token.
	* include/bits/regex_scanner.tcc (_Scanner<>::_M_eat_escape_ecma):
	Support word boundry.
	* testsuite/28_regex/algorithms/regex_match/basic/
	string_range_02_03.cc: Remove "xfail".
	* testsuite/28_regex/algorithms/regex_match/extended/cstring_plus.cc:
	Likewise.
	* testsuite/28_regex/algorithms/regex_match/extended/
	string_range_02_03.cc: Likewise.
	* testsuite/28_regex/algorithms/regex_match/extended/
	cstring_questionmark.cc: Remove xfail and get correct length of
	c-string.
	* testsuite/28_regex/algorithms/regex_match/extended/
	string_range_00_03.cc: Likewise.
	* testsuite/28_regex/algorithms/regex_match/ecma/char/quoted_char.cc:
	New.
	* testsuite/28_regex/algorithms/regex_match/extended/cstring_range.cc:
	New.
	* testsuite/28_regex/iterators/regex_iterator/wchar_t/string_02.cc: New.

From-SVN: r202290
2013-09-05 15:20:39 +00:00
Tim Shen 33fbbb766c Makefile.am: Add regex_scanner.{h,tcc}.
2013-08-26  Tim Shen  <timshen91@gmail.com>

	* include/Makefile.am: Add regex_scanner.{h,tcc}.
	* include/Makefile.in: Regenerate.
	* include/bits/regex.h (match_search): Handle the `__first == __last`
	  situation correctly.
	* include/bits/regex_compiler.h: Move _Scanner...
	* include/bits/regex_scanner.h: ...to here. New.
	* include/bits/regex_compiler.tcc: Move _Scanner...
	* include/bits/regex_scanner.tcc: ...to here, too. New.
	* include/bits/regex_executor.tcc: Use value instead of reference for
	  submatch.
	* include/std/regex: Add regex_scanner.h
	* testsuite/28_regex/algorithms/regex_match/awk/cstring_01.cc: New.
	* testsuite/28_regex/algorithms/regex_match/basic/empty_range.cc: New.
	* testsuite/28_regex/algorithms/regex_match/ecma/cstring_hex.cc: New.
	* testsuite/28_regex/algorithms/regex_match/ecma/empty_range.cc: New.
	* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc: New.

From-SVN: r202015
2013-08-27 02:49:22 +00:00