Browse Source

Plan 9 from Bell Labs 2005-03-24

David du Colombier 19 years ago
parent
commit
222d962a60

+ 5 - 4
dist/replica/_plan9.db

@@ -20,7 +20,7 @@
 386/bin/9660srv - 775 sys sys 1108354539 103973
 386/bin/aan - 775 sys sys 1108354539 130710
 386/bin/acid - 775 sys sys 1108960003 355983
-386/bin/acme - 775 sys sys 1111464452 428542
+386/bin/acme - 775 sys sys 1111607798 428512
 386/bin/ape - 20000000775 sys sys 1016944144 0
 386/bin/ape/basename - 775 sys sys 1087442501 132681
 386/bin/ape/cc - 775 sys sys 1104121958 70291
@@ -6809,12 +6809,12 @@ sys/src/cmd/acme/acme.c - 664 sys sys 1104430286 19613
 sys/src/cmd/acme/addr.c - 664 sys sys 1111171698 4805
 sys/src/cmd/acme/buff.c - 664 sys sys 1014926092 5573
 sys/src/cmd/acme/cols.c - 664 sys sys 1111119425 11229
-sys/src/cmd/acme/dat.h - 664 sys sys 1111171698 11124
+sys/src/cmd/acme/dat.h - 664 sys sys 1111606459 11106
 sys/src/cmd/acme/disk.c - 664 sys sys 1014926093 2151
-sys/src/cmd/acme/ecmd.c - 664 sys sys 1077376256 24294
+sys/src/cmd/acme/ecmd.c - 664 sys sys 1111606460 24205
 sys/src/cmd/acme/edit.c - 664 sys sys 1101910761 12068
 sys/src/cmd/acme/edit.h - 664 sys sys 969500816 2466
-sys/src/cmd/acme/elog.c - 664 sys sys 1078839859 7236
+sys/src/cmd/acme/elog.c - 664 sys sys 1111607796 7294
 sys/src/cmd/acme/exec.c - 664 sys sys 1111171699 28243
 sys/src/cmd/acme/file.c - 664 sys sys 1044626079 5717
 sys/src/cmd/acme/fns.h - 664 sys sys 1107154481 2916
@@ -12482,3 +12482,4 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+386/bin/acme - 775 sys sys 1111637282 428512

+ 4 - 4
dist/replica/plan9.db

@@ -20,7 +20,7 @@
 386/bin/9660srv - 775 sys sys 1108354539 103973
 386/bin/aan - 775 sys sys 1108354539 130710
 386/bin/acid - 775 sys sys 1108960003 355983
-386/bin/acme - 775 sys sys 1111464452 428542
+386/bin/acme - 775 sys sys 1111637282 428512
 386/bin/ape - 20000000775 sys sys 1016944144 0
 386/bin/ape/basename - 775 sys sys 1087442501 132681
 386/bin/ape/cc - 775 sys sys 1104121958 70291
@@ -6809,12 +6809,12 @@ sys/src/cmd/acme/acme.c - 664 sys sys 1104430286 19613
 sys/src/cmd/acme/addr.c - 664 sys sys 1111171698 4805
 sys/src/cmd/acme/buff.c - 664 sys sys 1014926092 5573
 sys/src/cmd/acme/cols.c - 664 sys sys 1111119425 11229
-sys/src/cmd/acme/dat.h - 664 sys sys 1111171698 11124
+sys/src/cmd/acme/dat.h - 664 sys sys 1111606459 11106
 sys/src/cmd/acme/disk.c - 664 sys sys 1014926093 2151
-sys/src/cmd/acme/ecmd.c - 664 sys sys 1077376256 24294
+sys/src/cmd/acme/ecmd.c - 664 sys sys 1111606460 24205
 sys/src/cmd/acme/edit.c - 664 sys sys 1101910761 12068
 sys/src/cmd/acme/edit.h - 664 sys sys 969500816 2466
-sys/src/cmd/acme/elog.c - 664 sys sys 1078839859 7236
+sys/src/cmd/acme/elog.c - 664 sys sys 1111607796 7294
 sys/src/cmd/acme/exec.c - 664 sys sys 1111171699 28243
 sys/src/cmd/acme/file.c - 664 sys sys 1044626079 5717
 sys/src/cmd/acme/fns.h - 664 sys sys 1107154481 2916

+ 6 - 0
dist/replica/plan9.log

@@ -13977,3 +13977,9 @@
 1111465860 0 c 386/bin/acme - 775 sys sys 1111464452 428542
 1111505409 0 c sys/src/9/ppc/mmu.c - 664 sys sys 1111504133 4864
 1111505409 1 c sys/src/games/music/playlistfs/fs.c - 664 sys sys 1111504109 17985
+1111604431 0 c sys/src/cmd/acme/ecmd.c - 664 sys sys 1111602957 24368
+1111608031 0 c 386/bin/acme - 775 sys sys 1111607798 428512
+1111608031 1 c sys/src/cmd/acme/dat.h - 664 sys sys 1111606459 11106
+1111608031 2 c sys/src/cmd/acme/ecmd.c - 664 sys sys 1111606460 24205
+1111608031 3 c sys/src/cmd/acme/elog.c - 664 sys sys 1111607796 7294
+1111638638 0 c 386/bin/acme - 775 sys sys 1111637282 428512

+ 0 - 1
sys/src/cmd/acme/dat.h

@@ -243,7 +243,6 @@ struct Window
 	uchar	noscroll;
 	Range	wrselrange;
 	int		rdselfd;
-	int		neditwrsel;
 	Column	*col;
 	Xfid		*eventx;
 	char		*events;

+ 6 - 10
sys/src/cmd/acme/ecmd.c

@@ -137,7 +137,6 @@ edittext(Window *w, int q, Rune *r, int nr)
 	case Inactive:
 		return "permission denied";
 	case Inserting:
-		w->neditwrsel += nr;
 		eloginsert(f, q, r, nr);
 		return nil;
 	case Collecting:
@@ -214,7 +213,7 @@ c_cmd(Text *t, Cmd *cp)
 {
 	elogreplace(t->file, addr.r.q0, addr.r.q1, cp->text->r, cp->text->n);
 	t->q0 = addr.r.q0;
-	t->q1 = addr.r.q0+cp->text->n;
+	t->q1 = addr.r.q0;
 	return TRUE;
 }
 
@@ -516,7 +515,7 @@ s_cmd(Text *t, Cmd *cp)
 	if(!didsub && nest==0)
 		editerror("no substitution");
 	t->q0 = addr.r.q0;
-	t->q1 = addr.r.q1+delta;
+	t->q1 = addr.r.q1;
 	return TRUE;
 
 Err:
@@ -596,7 +595,6 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
 		w = t->w;
 		t->q0 = addr.r.q0;
 		t->q1 = addr.r.q1;
-		w->neditwrsel = 0;
 		if(cmd == '<' || cmd=='|')
 			elogdelete(t->file, t->q0, t->q1);
 	}
@@ -626,10 +624,6 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
 	editing = Inactive;
 	if(t!=nil && t->w!=nil)
 		winlock(t->w, 'M');
-	if(state == Inserting){
-		t->q0 = addr.r.q0;
-		t->q1 = addr.r.q0 + t->w->neditwrsel;
-	}
 }
 
 int
@@ -740,7 +734,7 @@ append(File *f, Cmd *cp, long p)
 	if(cp->text->n > 0)
 		eloginsert(f, p, cp->text->r, cp->text->n);
 	f->curtext->q0 = p;
-	f->curtext->q1 = p+cp->text->n;
+	f->curtext->q1 = p;
 	return TRUE;
 }
 
@@ -1301,8 +1295,10 @@ cmdname(File *f, String *str, int set)
 		runemove(r, s, n);
 	}else{
 		newname = dirname(f->curtext, runestrdup(s), n);
-		r = newname.r;
 		n = newname.nr;
+		r = runemalloc(n+1);	/* NUL terminate */
+		runemove(r, newname.r, n);
+		free(newname.r);
 	}
 	fc.f = f;
 	fc.r = r;

+ 25 - 33
sys/src/cmd/acme/elog.c

@@ -218,7 +218,7 @@ elogapply(File *f)
 	Buflog b;
 	Rune *buf;
 	uint i, n, up, mod;
-	uint q0, q1, tq0, tq1;
+	uint tq0, tq1;
 	Buffer *log;
 	Text *t;
 
@@ -230,14 +230,14 @@ elogapply(File *f)
 	mod = FALSE;
 
 	/*
-	 * The edit commands have already updated the selection in t->q0, t->q1.
-	 * (At least, they are supposed to have updated them.
-	 * We still keep finding commands that don't do it right.)
-	 * The textinsert and textdelete calls below will update it again, so save the
-	 * current setting and restore it at the end.
+	 * The edit commands have already updated the selection in t->q0, t->q1,
+	 * but using coordinates relative to the unmodified buffer.  As we apply the log,
+	 * we have to update the coordinates to be relative to the modified buffer.
+	 * Textinsert and textdelete will do this for us; our only work is to apply the
+	 * convention that an insertion at t->q0==t->q1 is intended to select the 
+	 * inserted text.
 	 */
-	q0 = t->q0;
-	q1 = t->q1;
+
 	/*
 	 * We constrain the addresses in here (with textconstrain()) because
 	 * overlapping changes will generate bogus addresses.   We will warn
@@ -256,8 +256,8 @@ elogapply(File *f)
 
 		case Replace:
 			if(tracelog)
-				warning(nil, "elog replace %d %d\n",
-					b.q0, b.q0+b.nd);
+				warning(nil, "elog replace %d %d (%d %d)\n",
+					b.q0, b.q0+b.nd, t->q0, t->q1);
 			if(!mod){
 				mod = TRUE;
 				filemark(f);
@@ -272,12 +272,14 @@ elogapply(File *f)
 				bufread(log, up+i, buf, n);
 				textinsert(t, tq0+i, buf, n, TRUE);
 			}
+			if(t->q0 == b.q0 && t->q1 == b.q0)
+				t->q1 += b.nr;
 			break;
 
 		case Delete:
 			if(tracelog)
-				warning(nil, "elog delete %d %d\n",
-					b.q0, b.q0+b.nd);
+				warning(nil, "elog delete %d %d (%d %d)\n",
+					b.q0, b.q0+b.nd, t->q0, t->q1);
 			if(!mod){
 				mod = TRUE;
 				filemark(f);
@@ -288,8 +290,8 @@ elogapply(File *f)
 
 		case Insert:
 			if(tracelog)
-				warning(nil, "elog insert %d %d\n",
-					b.q0, b.q0+b.nr);
+				warning(nil, "elog insert %d %d (%d %d)\n",
+					b.q0, b.q0+b.nr, t->q0, t->q1);
 			if(!mod){
 				mod = TRUE;
 				filemark(f);
@@ -303,6 +305,8 @@ elogapply(File *f)
 				bufread(log, up+i, buf, n);
 				textinsert(t, tq0+i, buf, n, TRUE);
 			}
+			if(t->q0 == b.q0 && t->q1 == b.q0)
+				t->q1 += b.nr;
 			break;
 
 /*		case Filename:
@@ -323,28 +327,16 @@ elogapply(File *f)
 		bufdelete(log, up, log->nc);
 	}
 	fbuffree(buf);
-	if(warned){
-		/*
-		 * Changes were out of order, so the q0 and q1
-		 * computed while generating those changes are not
-		 * to be trusted.
-		 */
-		q1 = min(q1, f->nc);
-		q0 = min(q0, q1);
-	}
 	elogterm(f);
 
 	/*
-	 * The q0 and q1 are supposed to be fine (see comment
-	 * above, where we saved them), but bad addresses
-	 * will cause bufload to crash, so double check.
+	 * Bad addresses will cause bufload to crash, so double check.
+	 * If changes were out of order, we expect problems so don't complain further.
 	 */
-	if(q0 > f->nc || q1 > f->nc || q0 > q1){
-		warning(nil, "elogapply: can't happen %d %d %d\n", q0, q1, f->nc);
-		q1 = min(q1, f->nc);
-		q0 = min(q0, q1);
+	if(t->q0 > f->nc || t->q1 > f->nc || t->q0 > t->q1){
+		if(!warned)
+			warning(nil, "elogapply: can't happen %d %d %d\n", t->q0, t->q1, f->nc);
+		t->q1 = min(t->q1, f->nc);
+		t->q0 = min(t->q0, t->q1);
 	}
-
-	t->q0 = q0;
-	t->q1 = q1;
 }