summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Douthitt <ssrat@mailbag.com>2000-10-03 11:01:13 -0500
committerMiquel van Smoorenburg <miquels@debian.org>2016-11-11 07:07:17 -0800
commit928d5f48b5a2cfab676efab6013cde888c8c3816 (patch)
tree8055f7122e1173877a46970844c90080c960a6b8
parent441d9c90b9d2e3cd0b1b54802af40c799d437c73 (diff)
Substitution command & fails on third (second?) try
To: submit@bugs.debian.org Reply-to: ddouthitt@mennonite.minister.net Message-ID: <39D9BC79.32551.23FF0C@localhost> Package: elvis-tiny Version: 1.4 Do the following on a file: :s/tcp/TCP!/ j & j & The first substitution works, then the first & , then on the second & it replaces the substitution string with a '~' character. For example, given: my-tcp his-tcp her-tcp their-tcp The results would be: my-TCP! his-TCP! her-~ their-~ This is consistent. From: "David Douthitt" <ssrat@mailbag.com> To: miquels@cistron.nl Date: Wed, 13 Dec 2000 09:36:44 -0600 Subject: elvis-tiny Reply-to: n9ubh@callsign.net Message-ID: <3A37432C.147.3BB4F415@localhost> I have a few fixes for elvis-tiny, one for bug #55407 (vi segfaults) and one for bug #73059 (substitute & fails on third substitution). I've included them in the text below. They're two separate patches; so cut them out into two files. I don't know if I qualify as "maintainer" but I'll see if I can keep fixing and learning as time goes on. Gbp-Pq: Name patch-substitute-fails.diff
-rw-r--r--regsub.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/regsub.c b/regsub.c
index 26f62b4..2b114fd 100644
--- a/regsub.c
+++ b/regsub.c
@@ -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
}