File: patch-substitute-fails.diff

package info (click to toggle)
elvis-tiny 1.4-25
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,104 kB
  • sloc: ansic: 13,810; sh: 25; makefile: 13
file content (79 lines) | stat: -rw-r--r-- 1,920 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From: "David Douthitt" <ssrat@mailbag.com>
To: submit@bugs.debian.org
Date: Tue, 3 Oct 2000 11:01:13 -0500
Subject: Substitution command & fails on third (second?) try
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.

--- 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
 }