diff options
Diffstat (limited to 'regsub.c')
-rw-r--r-- | regsub.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -196,10 +196,18 @@ void regsub(re, src, dst) } *dst = '\0'; - /* remember what text we inserted this time */ - if (previous) - free(previous); - previous = (char *)malloc((unsigned)(strlen(start) + 1)); - if (previous) - strcpy(previous, start); +#ifndef NO_MAGIC + /* Don't copy the pattern if it is '~'; leave previous copy alone */ + if (! (*start == '~' && *o_magic)) + { +#endif + /* remember what text we inserted this time */ + if (previous) + free(previous); + previous = (char *)malloc((unsigned)(strlen(start) + 1)); + if (previous) + strcpy(previous, start); +#ifndef NO_MAGIC + } +#endif } |