diff options
| author | Steve Bennett <steveb@workware.net.au> | 2015-12-13 15:00:05 +1000 |
|---|---|---|
| committer | Steve Bennett <steveb@workware.net.au> | 2015-12-13 15:00:56 +1000 |
| commit | 749313615f97b2498f39d2f2e5e293d2d6fc63d3 (patch) | |
| tree | 7ccbca3d8fa53a34e26983a65c500c421a3c8595 /jim-regexp.c | |
| parent | e56199a18844adff0b0d393a378ced02c9a4cd77 (diff) | |
| download | jimtcl-749313615f97b2498f39d2f2e5e293d2d6fc63d3.zip jimtcl-749313615f97b2498f39d2f2e5e293d2d6fc63d3.tar.gz jimtcl-749313615f97b2498f39d2f2e5e293d2d6fc63d3.tar.bz2 | |
regsub: fix substitution with a trailing backslash
Should just replace with the bare backslash, not backslash '\0'
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-regexp.c')
| -rw-r--r-- | jim-regexp.c | 5 |
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; } } |
