lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master c1edfef 04/12: Use more standard regex syntax


From: Greg Chicares
Subject: [lmi-commits] [lmi] master c1edfef 04/12: Use more standard regex syntax in the raw C++11 strings check
Date: Mon, 28 Jun 2021 18:44:27 -0400 (EDT)

branch: master
commit c1edfefe8fa49d1dd7b4b17ca3e78085cb6fad43
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use more standard regex syntax in the raw C++11 strings check
    
    The regex added in fec9d6d9b (Establish the One True nonempty
    d-char-sequence, 2021-03-08) used Vim "\<" regex construct which
    happened to work with boost::regex but is not recognized by ECMAScript
    regex flavour used with std::regex.
    
    Replace it with "\b" which works with both boost and std classes and is
    also consistent with the use of "\b" in many other places in the
    existing code.
    
    Also add a test for this check to test_coding_rules_test.sh to ensure
    that this continues to work as expected even after the switch to
    std::regex.
---
 test_coding_rules.cpp     | 2 +-
 test_coding_rules_test.sh | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 7815898..4d345df 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -614,7 +614,7 @@ void check_cxx(file const& f)
     {
     // See:
     //   https://lists.nongnu.org/archive/html/lmi/2021-03/msg00032.html
-    static boost::regex const r(R"(\<R"([^(]*)[(])");
+    static boost::regex const r(R"(\bR"([^(]*)[(])");
     boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
     boost::sregex_iterator const omega;
     for(; i != omega; ++i)
diff --git a/test_coding_rules_test.sh b/test_coding_rules_test.sh
index dca7142..8754635 100755
--- a/test_coding_rules_test.sh
+++ b/test_coding_rules_test.sh
@@ -229,6 +229,14 @@ Write a cv-qualifier after the type it modifies:
   void goo(const std::string&); // No.
 EOF
 
+cat >eraseme_cpp_005.cpp <<EOF
+$boilerplate
+auto const ok = R"--cut-here--(
+Uses the only allowed non-empty d-char-seq.
+)--cut-here--";
+auto const not_ok = R"==(disallowed)==";
+EOF
+
 # Headers.
 
 cat >eraseme_hpp_000.hpp <<EOF
@@ -409,6 +417,7 @@ File 'eraseme_cpp_003.cpp' should fuse '&' with type: 'foo 
&bar(); // bar() is a
 File 'eraseme_cpp_003.cpp' should fuse '*' with type: 'int *x;     // x is a 
'pointer variable of type int'?'.
 File 'eraseme_cpp_004.cpp' should write 'const' after the type it modifies: 
'const T&'.
 File 'eraseme_cpp_004.cpp' should write 'const' after the type it modifies: 
'const std::string&'.
+File 'eraseme_cpp_005.cpp' contains noncanonical d-char-seq: '=='. Instead, 
use '--cut-here--'.
 File 'eraseme_hpp_001.hpp' lacks end part of the canonical header guard.
 File 'eraseme_hpp_002.hpp' lacks start part of the canonical header guard.
 File 'eraseme_hpp_003.hpp' lacks start part of the canonical header guard.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]