Skip to content

Commit

Permalink
Remove usage of std::regex
Browse files Browse the repository at this point in the history
  • Loading branch information
rschu1ze committed Jul 8, 2024
1 parent 6fe48d3 commit b8a996c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/rocksdb/utilities/object_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,23 @@ class ObjectLibrary {
: Entry(name), factory_(std::move(f)) {
// FIXME: the API needs to expose this failure mode. For now, bad regexes
// will match nothing.
Regex::Parse(name, &regex_).PermitUncheckedError();
/// Regex::Parse(name, &regex_).PermitUncheckedError();
}
~FactoryEntry() override {}
bool matches(const std::string& target) const override {
return regex_.Matches(target);
}
/// No more std::regex, see https://github.com/ClickHouse/llvm-project/pull/38
/// Luckily, nobody calls this function. If this is no longer the case, please link rocksdb
/// to RE2 and use re2::FullMatch() instead of regex_match().
/// bool matches(const std::string& target) const override {
/// return regex_.Matches(target);
/// }
// Creates a new T object.
T* NewFactoryObject(const std::string& target, std::unique_ptr<T>* guard,
std::string* msg) const {
return factory_(target, guard, msg);
}

private:
Regex regex_; // The pattern for this entry
/// Regex regex_; // The pattern for this entry
FactoryFunc<T> factory_;
}; // End class FactoryEntry
public:
Expand Down
4 changes: 4 additions & 0 deletions include/rocksdb/utilities/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include "rocksdb/status.h"

#if 0 /// ClickHouse-specific patch: disallow std::regexp

namespace ROCKSDB_NAMESPACE {

// A wrapper for parsed regular expressions. The regex syntax and matching is
Expand Down Expand Up @@ -45,4 +47,6 @@ class Regex {
};
} // namespace ROCKSDB_NAMESPACE

#endif // 0

#endif // ROCKSDB_LITE
4 changes: 4 additions & 0 deletions util/regex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "rocksdb/utilities/regex.h"

#if 0 /// ClickHouse-specific patch: disallow std::regexp

#include <cassert>
#include <regex>

Expand Down Expand Up @@ -47,4 +49,6 @@ Status Regex::Parse(const char *pattern, Regex *out) {

} // namespace ROCKSDB_NAMESPACE

#endif // 0

#endif // ROCKSDB_LITE

0 comments on commit b8a996c

Please sign in to comment.