From 26b977c96795172b1e095c06222eb30cfc6f4cb7 Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Tue, 20 Oct 2015 09:48:09 +0100 Subject: Fixed segfault in RegEx.get_capture() --- drivers/nrex/regex.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/nrex/regex.cpp') diff --git a/drivers/nrex/regex.cpp b/drivers/nrex/regex.cpp index 0a813c349..2707249a6 100644 --- a/drivers/nrex/regex.cpp +++ b/drivers/nrex/regex.cpp @@ -54,7 +54,9 @@ bool RegEx::is_valid() const { }; int RegEx::get_capture_count() const { - + + ERR_FAIL_COND_V( !exp.valid(), 0 ); + return exp.capture_size(); } -- cgit v1.2.3-70-g09d2 From f0d246a7bce9f8f22e9886d474f1758e0c20d8cb Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Tue, 20 Oct 2015 10:05:55 +0100 Subject: Exposed RegEx expanded option to scripts --- drivers/nrex/regex.cpp | 6 +++--- drivers/nrex/regex.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/nrex/regex.cpp') diff --git a/drivers/nrex/regex.cpp b/drivers/nrex/regex.cpp index 2707249a6..246384b10 100644 --- a/drivers/nrex/regex.cpp +++ b/drivers/nrex/regex.cpp @@ -15,7 +15,7 @@ void RegEx::_bind_methods() { - ObjectTypeDB::bind_method(_MD("compile","pattern"),&RegEx::compile); + ObjectTypeDB::bind_method(_MD("compile","pattern", "expanded"),&RegEx::compile, DEFVAL(true)); ObjectTypeDB::bind_method(_MD("find","text","start","end"),&RegEx::find, DEFVAL(0), DEFVAL(-1)); ObjectTypeDB::bind_method(_MD("clear"),&RegEx::clear); ObjectTypeDB::bind_method(_MD("is_valid"),&RegEx::is_valid); @@ -68,11 +68,11 @@ String RegEx::get_capture(int capture) const { } -Error RegEx::compile(const String& p_pattern) { +Error RegEx::compile(const String& p_pattern, bool expanded) { clear(); - exp.compile(p_pattern.c_str()); + exp.compile(p_pattern.c_str(), expanded); ERR_FAIL_COND_V( !exp.valid(), FAILED ); diff --git a/drivers/nrex/regex.h b/drivers/nrex/regex.h index 062602970..be52da814 100644 --- a/drivers/nrex/regex.h +++ b/drivers/nrex/regex.h @@ -36,7 +36,7 @@ public: bool is_valid() const; int get_capture_count() const; String get_capture(int capture) const; - Error compile(const String& p_pattern); + Error compile(const String& p_pattern, bool expanded = false); int find(const String& p_text, int p_start = 0, int p_end = -1) const; RegEx(); -- cgit v1.2.3-70-g09d2