aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/ecmd.c
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2020-01-14 11:41:08 +0100
committerPetter Rodhelind <petter.rodhelind@gmail.com>2020-01-14 11:41:08 +0100
commit02d7aa8915f9c3a3288dab01f321eb94ba219e3b (patch)
treef053238978479e408a2b83571443e132f30586ab /src/cmd/acme/ecmd.c
parentc0c9d8f883dfd3a7f5a74499d91bb95884b15873 (diff)
parent3d1382b98a502d0c34d5ba2c462396acc515016e (diff)
downloadplan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.tar.gz
plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.tar.bz2
plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/cmd/acme/ecmd.c')
-rw-r--r--src/cmd/acme/ecmd.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/cmd/acme/ecmd.c b/src/cmd/acme/ecmd.c
index ef92e339..f7613172 100644
--- a/src/cmd/acme/ecmd.c
+++ b/src/cmd/acme/ecmd.c
@@ -28,7 +28,7 @@ int append(File*, Cmd*, long);
int pdisplay(File*);
void pfilename(File*);
void looper(File*, Cmd*, int);
-void filelooper(Cmd*, int);
+void filelooper(Text*, Cmd*, int);
void linelooper(File*, Cmd*);
Address lineaddr(long, Address, int);
int filematch(File*, String*);
@@ -584,7 +584,7 @@ X_cmd(Text *t, Cmd *cp)
{
USED(t);
- filelooper(cp, cp->cmdc=='X');
+ filelooper(t, cp, cp->cmdc=='X');
return TRUE;
}
@@ -633,8 +633,8 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
/*
* The editoutlk exists only so that we can tell when
* the editout file has been closed. It can get closed *after*
- * the process exits because, since the process cannot be
- * connected directly to editout (no 9P kernel support),
+ * the process exits because, since the process cannot be
+ * connected directly to editout (no 9P kernel support),
* the process is actually connected to a pipe to another
* process (arranged via 9pserve) that reads from the pipe
* and then writes the data in the pipe to editout using
@@ -704,7 +704,7 @@ printposn(Text *t, int mode)
if (t != nil && t->file != nil && t->file->name != nil)
warning(nil, "%.*S:", t->file->nname, t->file->name);
-
+
switch(mode) {
case PosnChars:
warning(nil, "#%d", addr.r.q0);
@@ -712,7 +712,7 @@ printposn(Text *t, int mode)
warning(nil, ",#%d", addr.r.q1);
warning(nil, "\n");
return;
-
+
default:
case PosnLine:
l1 = 1+nlcount(t, 0, addr.r.q0, nil);
@@ -978,9 +978,10 @@ alllocker(Window *w, void *v)
}
void
-filelooper(Cmd *cp, int XY)
+filelooper(Text *t, Cmd *cp, int XY)
{
int i;
+ Text *targ;
if(Glooping++)
editerror("can't nest %c command", "YX"[XY]);
@@ -1001,8 +1002,26 @@ filelooper(Cmd *cp, int XY)
*/
allwindows(alllocker, (void*)1);
globalincref = 1;
- for(i=0; i<loopstruct.nw; i++)
- cmdexec(&loopstruct.w[i]->body, cp->u.cmd);
+
+ /*
+ * Unlock the window running the X command.
+ * We'll need to lock and unlock each target window in turn.
+ */
+ if(t && t->w)
+ winunlock(t->w);
+
+ for(i=0; i<loopstruct.nw; i++) {
+ targ = &loopstruct.w[i]->body;
+ if(targ && targ->w)
+ winlock(targ->w, cp->cmdc);
+ cmdexec(targ, cp->u.cmd);
+ if(targ && targ->w)
+ winunlock(targ->w);
+ }
+
+ if(t && t->w)
+ winlock(t->w, cp->cmdc);
+
allwindows(alllocker, (void*)0);
globalincref = 0;
free(loopstruct.w);