Deleted Added
sdiff udiff text old ( 81220 ) new ( 90109 )
full compact
1/* glob.c: This file contains the global command routines for the ed line
2 editor */
3/*-
4 * Copyright (c) 1993 Andrew Moore, Talke Studio.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 14 unchanged lines hidden (view full) ---

23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef lint
30static const char rcsid[] =
31 "$FreeBSD: head/bin/ed/glbl.c 81220 2001-08-06 22:01:31Z mike $";
32#endif /* not lint */
33
34#include <sys/types.h>
35
36#include <sys/ioctl.h>
37#include <sys/wait.h>
38
39#include "ed.h"
40
41
42/* build_active_list: add line matching a pattern to the global-active list */
43int
44build_active_list(isgcmd)
45 int isgcmd;
46{
47 pattern_t *pat;
48 line_t *lp;
49 long n;
50 char *s;
51 char delimiter;
52
53 if ((delimiter = *ibufp) == ' ' || delimiter == '\n') {

--- 16 unchanged lines hidden (view full) ---

70 }
71 return 0;
72}
73
74
75/* exec_global: apply command list in the command buffer to the active
76 lines in a range; return command status */
77long
78exec_global(interact, gflag)
79 int interact;
80 int gflag;
81{
82 static char *ocmd = NULL;
83 static int ocmdsz = 0;
84
85 line_t *lp = NULL;
86 int status;
87 int n;
88 char *cmd = NULL;

--- 55 unchanged lines hidden (view full) ---

144line_t **active_list; /* list of lines active in a global command */
145long active_last; /* index of last active line in active_list */
146long active_size; /* size of active_list */
147long active_ptr; /* active_list index (non-decreasing) */
148long active_ndx; /* active_list index (modulo active_last) */
149
150/* set_active_node: add a line node to the global-active list */
151int
152set_active_node(lp)
153 line_t *lp;
154{
155 if (active_last + 1 > active_size) {
156 int ti = active_size;
157 line_t **ts;
158 SPL1();
159#if defined(sun) || defined(NO_REALLOC_NULL)
160 if (active_list != NULL) {
161#endif

--- 21 unchanged lines hidden (view full) ---

183 }
184 active_list[active_last++] = lp;
185 return 0;
186}
187
188
189/* unset_active_nodes: remove a range of lines from the global-active list */
190void
191unset_active_nodes(np, mp)
192 line_t *np, *mp;
193{
194 line_t *lp;
195 long i;
196
197 for (lp = np; lp != mp; lp = lp->q_forw)
198 for (i = 0; i < active_last; i++)
199 if (active_list[active_ndx] == lp) {
200 active_list[active_ndx] = NULL;
201 active_ndx = INC_MOD(active_ndx, active_last - 1);
202 break;
203 } else active_ndx = INC_MOD(active_ndx, active_last - 1);
204}
205
206
207/* next_active_node: return the next global-active line node */
208line_t *
209next_active_node()
210{
211 while (active_ptr < active_last && active_list[active_ptr] == NULL)
212 active_ptr++;
213 return (active_ptr < active_last) ? active_list[active_ptr++] : NULL;
214}
215
216
217/* clear_active_list: clear the global-active list */
218void
219clear_active_list()
220{
221 SPL1();
222 active_size = active_last = active_ptr = active_ndx = 0;
223 free(active_list);
224 active_list = NULL;
225 SPL0();
226}