aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2021-06-04 23:58:17 -0400
committerAdam Harrison <adamdharrison@gmail.com>2021-06-04 23:58:17 -0400
commit3b816a2b4a0c0543cafdd1c9698aa0a1df53348d (patch)
tree4670eaeecb44238cab076b0667c74b811874cfbe /src
parentcd5c64fe8c7a2aeb086a1d4440961a1fce21f096 (diff)
downloadlite-xl-3b816a2b4a0c0543cafdd1c9698aa0a1df53348d.tar.gz
lite-xl-3b816a2b4a0c0543cafdd1c9698aa0a1df53348d.zip
Changed regex error handling, so that errors can be handled gracefully in lua, and made it so gsub returns the exact matches and replacements.
Diffstat (limited to 'src')
-rw-r--r--src/api/regex.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/api/regex.c b/src/api/regex.c
index 5245d8c2..a5d17604 100644
--- a/src/api/regex.c
+++ b/src/api/regex.c
@@ -45,9 +45,11 @@ static int f_pcre_compile(lua_State *L) {
}
PCRE2_UCHAR buffer[256];
pcre2_get_error_message(errorNumber, buffer, sizeof(buffer));
- luaL_error(L, "regex compilation failed at offset %d: %s",
- (int)errorOffset, buffer);
- return 0;
+ lua_pushnil(L);
+ char message[1024];
+ len = snprintf(message, sizeof(message), "regex compilation failed at offset %d: %s", (int)errorOffset, buffer);
+ lua_pushlstring(L, message, len);
+ return 2;
}
// Takes string, compiled regex, returns list of indices of matched groups