mirror of https://github.com/djcb/mu.git
mu-regex: make backward-compatible with older glib
This commit is contained in:
parent
feb436ce96
commit
60e9d54a7c
|
@ -28,6 +28,10 @@ namespace Mu {
|
|||
* PCRE rather than std::regex because it is much faster.
|
||||
*/
|
||||
struct Regex {
|
||||
#if !GLIB_CHECK_VERSION(2,74,0) /* backward compat */
|
||||
#define G_REGEX_DEFAULT (static_cast<GRegexCompileFlags>(0))
|
||||
#define G_REGEX_MATCH_DEFAULT (static_cast<GRegexMatchFlags>(0))
|
||||
#endif
|
||||
/**
|
||||
* Trivial constructor
|
||||
*
|
||||
|
@ -35,7 +39,6 @@ struct Regex {
|
|||
*/
|
||||
Regex() noexcept: rx_{} {}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Regex object
|
||||
*
|
||||
|
@ -47,7 +50,7 @@ struct Regex {
|
|||
*/
|
||||
static Result<Regex> make(const std::string& ptrn,
|
||||
GRegexCompileFlags cflags = G_REGEX_DEFAULT,
|
||||
GRegexMatchFlags mflags = G_REGEX_MATCH_DEFAULT) noexcept try {
|
||||
GRegexMatchFlags mflags = G_REGEX_MATCH_DEFAULT) noexcept try {
|
||||
return Regex(ptrn.c_str(), cflags, mflags);
|
||||
} catch (const Error& err) {
|
||||
return Err(err);
|
||||
|
|
Loading…
Reference in New Issue