Skip to content

Commit

Permalink
Cleanup static variables in boost regex headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed May 12, 2024
1 parent c864296 commit 0d9953e
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion scintilla/include/boost/regex/v5/basic_regex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void bubble_down_one(I first, I last)
}
}

static const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
static constexpr int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);

template <class Iterator>
inline int hash_value_from_capture_name(Iterator i, Iterator j)
Expand Down
8 changes: 4 additions & 4 deletions scintilla/include/boost/regex/v5/basic_regex_creator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ basic_regex_creator<charT, traits>::basic_regex_creator(regex_data<charT, traits
{
m_pdata->m_data.clear();
m_pdata->m_status = ::boost::regex_constants::error_ok;
static const charT w = 'w';
static const charT s = 's';
const charT w = 'w';
const charT s = 's';
static const charT l[5] = { 'l', 'o', 'w', 'e', 'r', };
static const charT u[5] = { 'u', 'p', 'p', 'e', 'r', };
static const charT a[5] = { 'a', 'l', 'p', 'h', 'a', };
Expand Down Expand Up @@ -1467,7 +1467,7 @@ bool basic_regex_creator<charT, traits>::is_bad_repeat(re_syntax_base* pt)
unsigned state_id = static_cast<re_repeat*>(pt)->state_id;
if(state_id >= sizeof(m_bad_repeats) * CHAR_BIT)
return true; // run out of bits, assume we can't traverse this one.
static const std::uintmax_t one = 1uL;
constexpr std::uintmax_t one = 1uL;
return m_bad_repeats & (one << state_id);
}
default:
Expand All @@ -1487,7 +1487,7 @@ void basic_regex_creator<charT, traits>::set_bad_repeat(re_syntax_base* pt)
case syntax_element_long_set_rep:
{
unsigned state_id = static_cast<re_repeat*>(pt)->state_id;
static const std::uintmax_t one = 1uL;
constexpr std::uintmax_t one = 1uL;
if(state_id <= sizeof(m_bad_repeats) * CHAR_BIT)
m_bad_repeats |= (one << state_id);
}
Expand Down
8 changes: 4 additions & 4 deletions scintilla/include/boost/regex/v5/basic_regex_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ bool basic_regex_parser<charT, traits>::parse_extended_escape()
{
bool have_brace = false;
bool negative = false;
static const char incomplete_message[] = "Incomplete \\g escape found.";
const char * const incomplete_message = "Incomplete \\g escape found.";
if(++m_position == m_end)
{
fail(regex_constants::error_escape, m_position - m_base, incomplete_message);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ bool basic_regex_parser<charT, traits>::parse_repeat(std::size_t low, std::size_
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_repeat_range(bool isbasic)
{
static const char incomplete_message[] = "Missing } in quantified repetition.";
const char * const incomplete_message = "Missing } in quantified repetition.";
//
// parse a repeat-range:
//
Expand Down Expand Up @@ -1335,7 +1335,7 @@ bool basic_regex_parser<charT, traits>::parse_alt()
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_set()
{
static const char incomplete_message[] = "Character set declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";
const char * const incomplete_message = "Character set declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";
++m_position;
if(m_position == m_end)
{
Expand Down Expand Up @@ -1427,7 +1427,7 @@ bool basic_regex_parser<charT, traits>::parse_set()
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_inner_set(basic_char_set<charT, traits>& char_set)
{
static const char incomplete_message[] = "Character class declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";
const char * const incomplete_message = "Character class declaration starting with [ terminated prematurely - either no ] was found or the set had no content.";
//
// we have either a character class [:name:]
// a collating element [.name.]
Expand Down
8 changes: 4 additions & 4 deletions scintilla/include/boost/regex/v5/iterator_category.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ struct is_random_imp
private:
typedef typename std::iterator_traits<I>::iterator_category cat;
public:
static const bool value = (std::is_convertible<cat*, std::random_access_iterator_tag*>::value);
static constexpr bool value = (std::is_convertible<cat*, std::random_access_iterator_tag*>::value);
};

template <class I>
struct is_random_pointer_imp
{
static const bool value = true;
static constexpr bool value = true;
};

template <bool is_pointer_type>
Expand Down Expand Up @@ -72,11 +72,11 @@ struct is_random_access_iterator
typedef typename selector::template rebind<I> bound_type;
typedef typename bound_type::type answer;
public:
static const bool value = answer::value;
static constexpr bool value = answer::value;
};

template <class I>
const bool is_random_access_iterator<I>::value;
constexpr bool is_random_access_iterator<I>::value;

}

Expand Down
2 changes: 1 addition & 1 deletion scintilla/include/boost/regex/v5/perl_matcher_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(std
//
// Calculate NS^2 first:
//
static const std::ptrdiff_t k = 100000;
constexpr std::ptrdiff_t k = 100000;
std::ptrdiff_t dist = std::distance(base, last);
if(dist == 0)
dist = 1;
Expand Down
2 changes: 1 addition & 1 deletion scintilla/include/boost/regex/v5/regex_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace BOOST_REGEX_DETAIL_NS{
static char checker(...);
static T* get();

static const bool value = sizeof(checker(get())) > 1;
static constexpr bool value = sizeof(checker(get())) > 1;
};


Expand Down
20 changes: 10 additions & 10 deletions scintilla/include/boost/regex/v5/regex_traits_defaults.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ inline const char* get_default_syntax(regex_constants::syntax_type n)
{
// if the user hasn't supplied a message catalog, then this supplies
// default "messages" for us to load in the range 1-100.
const char* messages[] = {
static const char* messages[] = {
"",
"(",
")",
Expand Down Expand Up @@ -155,7 +155,7 @@ inline regex_constants::syntax_type get_default_syntax_type(char c)
// char_syntax determines how the compiler treats a given character
// in a regular expression.
//
static regex_constants::syntax_type char_syntax[] = {
static const regex_constants::syntax_type char_syntax[] = {
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
regex_constants::syntax_char, /**/
Expand Down Expand Up @@ -350,7 +350,7 @@ inline regex_constants::escape_syntax_type get_default_escape_syntax_type(char
// char_syntax determines how the compiler treats a given character
// in a regular expression.
//
static regex_constants::escape_syntax_type char_syntax[] = {
static const regex_constants::escape_syntax_type char_syntax[] = {
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
regex_constants::escape_type_identity, /**/
Expand Down Expand Up @@ -542,7 +542,7 @@ inline regex_constants::escape_syntax_type get_default_escape_syntax_type(char
// is charT c a combining character?
inline bool is_combining_implementation(std::uint_least16_t c)
{
const std::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
static const std::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
0x0483, 0x0486,
0x0903, 0x0903,
0x093E, 0x0940,
Expand Down Expand Up @@ -894,12 +894,12 @@ template<> inline wchar_t global_upper<wchar_t>(wchar_t c) { return do_global_u
template <class charT>
int global_value(charT c)
{
static const charT zero = '0';
static const charT nine = '9';
static const charT a = 'a';
static const charT f = 'f';
static const charT A = 'A';
static const charT F = 'F';
constexpr charT zero = '0';
constexpr charT nine = '9';
constexpr charT a = 'a';
constexpr charT f = 'f';
constexpr charT A = 'A';
constexpr charT F = 'F';

if(c > f) return -1;
if(c >= a) return 10 + (c - a);
Expand Down
12 changes: 6 additions & 6 deletions scintilla/include/boost/regex/v5/w32_regex_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,11 @@ class w32_regex_traits_implementation : public w32_regex_traits_char_layer<charT
{
public:
typedef typename w32_regex_traits<charT>::char_class_type char_class_type;
static const char_class_type mask_word = 0x0400; // must be C1_DEFINED << 1
static const char_class_type mask_unicode = 0x0800; // must be C1_DEFINED << 2
static const char_class_type mask_horizontal = 0x1000; // must be C1_DEFINED << 3
static const char_class_type mask_vertical = 0x2000; // must be C1_DEFINED << 4
static const char_class_type mask_base = 0x3ff; // all the masks used by the CT_CTYPE1 group
static constexpr char_class_type mask_word = 0x0400; // must be C1_DEFINED << 1
static constexpr char_class_type mask_unicode = 0x0800; // must be C1_DEFINED << 2
static constexpr char_class_type mask_horizontal = 0x1000; // must be C1_DEFINED << 3
static constexpr char_class_type mask_vertical = 0x2000; // must be C1_DEFINED << 4
static constexpr char_class_type mask_base = 0x3ff; // all the masks used by the CT_CTYPE1 group

typedef std::basic_string<charT> string_type;
typedef charT char_type;
Expand Down Expand Up @@ -586,7 +586,7 @@ w32_regex_traits_implementation<charT>::w32_regex_traits_implementation(::boost:
w32_regex_traits_implementation<charT>::mask_word,
w32_regex_traits_implementation<charT>::mask_unicode,
};
static const string_type null_string;
constexpr string_type null_string;
for(unsigned int j = 0; j <= 13; ++j)
{
string_type s(::boost::BOOST_REGEX_DETAIL_NS::w32_cat_get(cat, this->m_locale, j+300, null_string));
Expand Down

0 comments on commit 0d9953e

Please sign in to comment.