aboutsummaryrefslogtreecommitdiff
path: root/jim-regexp.c
diff options
context:
space:
mode:
Diffstat (limited to 'jim-regexp.c')
-rw-r--r--jim-regexp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/jim-regexp.c b/jim-regexp.c
index 25ffd21..25e05a3 100644
--- a/jim-regexp.c
+++ b/jim-regexp.c
@@ -496,7 +496,10 @@ int Jim_RegsubCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
continue;
}
else {
- Jim_AppendString(interp, resultObj, replace_str + j - 1, 2);
+ /* If the replacement is a trailing backslash, just replace with a backslash, otherwise
+ * with the literal backslash and the following character
+ */
+ Jim_AppendString(interp, resultObj, replace_str + j - 1, (j == replace_len) ? 1 : 2);
continue;
}
}