From 55841a73fcc9ab9ce02a8ea91962c22523e8bb91 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 18 Aug 2014 15:10:09 +0100 Subject: [PATCH 1/3] Add metadata file. --- meta/libraries.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 meta/libraries.json diff --git a/meta/libraries.json b/meta/libraries.json new file mode 100644 index 00000000..a2aadf92 --- /dev/null +++ b/meta/libraries.json @@ -0,0 +1,17 @@ +{ + "key": "regex", + "name": "Regex", + "authors": [ + "John Maddock" + ], + "description": "Regular expression library.", + "std": [ + "tr1" + ], + "category": [ + "String" + ], + "maintainers": [ + "John Maddock " + ] +} From 05b582761d7d76a1ac1c1f5e843fe0beb00d9d8e Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 25 Sep 2014 11:45:26 +0100 Subject: [PATCH 2/3] Fix case that differs from Perl behavior. --- include/boost/regex/v4/basic_regex_parser.hpp | 9 +++++++-- test/regress/test_simple_repeats.cpp | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index 27578988..ca1adde3 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -346,8 +346,13 @@ bool basic_regex_parser::parse_extended() ++m_position; return parse_repeat_range(false); case regex_constants::syntax_close_brace: - fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {."); - return false; + if((this->flags() & regbase::no_perl_ex) == regbase::no_perl_ex) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {."); + return false; + } + result = parse_literal(); + break; case regex_constants::syntax_or: return parse_alt(); case regex_constants::syntax_open_set: diff --git a/test/regress/test_simple_repeats.cpp b/test/regress/test_simple_repeats.cpp index d0e3a299..1691673a 100644 --- a/test/regress/test_simple_repeats.cpp +++ b/test/regress/test_simple_repeats.cpp @@ -172,6 +172,10 @@ void test_simple_repeats() TEST_REGEX_SEARCH("^a{0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("^(?:a){0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("^a(?:bc)?", perl, "abcbc", match_any|match_all, make_array(-2, -2)); + TEST_REGEX_SEARCH("a}", perl, "a}", match_default, make_array(0, 2, -2, -2)); + TEST_REGEX_SEARCH("a{12b", perl, "a{12bc", match_default, make_array(0, 5, -2, -2)); + TEST_INVALID_REGEX("a{b", extended); + TEST_INVALID_REGEX("a}b", extended); test_simple_repeats2(); } From a50c438d77e4acb9fcc3774408616de5507833b7 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 25 Sep 2014 11:54:14 +0100 Subject: [PATCH 3/3] Document {} behaving as literals in some contexts. Regen docs. --- doc/html/boost_regex/syntax/perl_syntax.html | 7 +++++++ doc/html/index.html | 2 +- doc/syntax_perl.qbk | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/html/boost_regex/syntax/perl_syntax.html b/doc/html/boost_regex/syntax/perl_syntax.html index 3b2c26fd..e985e24f 100644 --- a/doc/html/boost_regex/syntax/perl_syntax.html +++ b/doc/html/boost_regex/syntax/perl_syntax.html @@ -176,6 +176,13 @@
a
 aaaa
 
+

+ Note that the "{" and "}" characters will treated as + ordinary literals when used in a context that is not a repeat: this matches + Perl 5.x behavior. For example in the expressions "ab{1", "ab1}" + and "a{b}c" the curly brackets are all treated as literals and + no error will be raised. +

It is an error to use a repeat operator, if the preceding construct can not be repeated, for example: diff --git a/doc/html/index.html b/doc/html/index.html index d431db4d..b6af5423 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -198,7 +198,7 @@

- +

Last revised: May 23, 2014 at 12:15:55 GMT

Last revised: September 25, 2014 at 10:52:51 GMT


diff --git a/doc/syntax_perl.qbk b/doc/syntax_perl.qbk index 73fa2814..a7927adc 100644 --- a/doc/syntax_perl.qbk +++ b/doc/syntax_perl.qbk @@ -115,6 +115,11 @@ But neither of: a aaaa +Note that the "{" and "}" characters will treated as ordinary literals when used +in a context that is not a repeat: this matches Perl 5.x behavior. For example in +the expressions "ab{1", "ab1}" and "a{b}c" the curly brackets are all treated as +literals and ['no error will be raised]. + It is an error to use a repeat operator, if the preceding construct can not be repeated, for example: