mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
Fix 15-year-old sam protocol bug.
This commit is contained in:
parent
ad2922ef28
commit
78439d25f8
4 changed files with 34 additions and 34 deletions
|
@ -265,18 +265,6 @@ filedeltext(File *f, Text *t)
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
fileinsert(File *f, uint p0, Rune *s, uint ns)
|
||||
{
|
||||
if(p0 > f->b.nc)
|
||||
panic("internal error: fileinsert");
|
||||
if(f->seq > 0)
|
||||
fileuninsert(f, &f->delta, p0, ns);
|
||||
bufinsert(&f->b, p0, s, ns);
|
||||
if(ns)
|
||||
f->mod = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fileuninsert(File *f, Buffer *delta, uint p0, uint ns)
|
||||
{
|
||||
|
@ -291,18 +279,6 @@ fileuninsert(File *f, Buffer *delta, uint p0, uint ns)
|
|||
bufinsert(delta, delta->nc, (Rune*)&u, Undosize);
|
||||
}
|
||||
|
||||
void
|
||||
filedelete(File *f, uint p0, uint p1)
|
||||
{
|
||||
if(!(p0<=p1 && p0<=f->b.nc && p1<=f->b.nc))
|
||||
panic("internal error: filedelete");
|
||||
if(f->seq > 0)
|
||||
fileundelete(f, &f->delta, p0, p1);
|
||||
bufdelete(&f->b, p0, p1);
|
||||
if(p1 > p0)
|
||||
f->mod = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fileundelete(File *f, Buffer *delta, uint p0, uint p1)
|
||||
{
|
||||
|
@ -499,6 +475,9 @@ fileundo(File *f, int isundo, int canredo, uint *q0p, uint *q1p, int flag)
|
|||
|
||||
raspstart(f);
|
||||
while(delta->nc > 0){
|
||||
/* rasp and buffer are in sync; sync with wire if needed */
|
||||
if(needoutflush())
|
||||
raspflush(f);
|
||||
up = delta->nc-Undosize;
|
||||
bufread(delta, up, (Rune*)&u, Undosize);
|
||||
if(isundo){
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "sam.h"
|
||||
|
||||
#define DEBUG
|
||||
Header h;
|
||||
uchar indata[DATASIZE];
|
||||
uchar outdata[2*DATASIZE+3]; /* room for overflow message */
|
||||
|
@ -10,7 +10,7 @@ Posn cmdpt;
|
|||
Posn cmdptadv;
|
||||
Buffer snarfbuf;
|
||||
int waitack;
|
||||
int noflush;
|
||||
int outbuffered;
|
||||
int tversion;
|
||||
|
||||
int inshort(void);
|
||||
|
@ -807,21 +807,26 @@ outsend(void)
|
|||
{
|
||||
int outcount;
|
||||
|
||||
if(outp >= outdata+nelem(outdata))
|
||||
panic("outsend");
|
||||
outcount = outp-outmsg;
|
||||
outcount -= 3;
|
||||
outmsg[1] = outcount;
|
||||
outmsg[2] = outcount>>8;
|
||||
outmsg = outp;
|
||||
if(!noflush){
|
||||
if(!outbuffered){
|
||||
outcount = outmsg-outdata;
|
||||
if (write(1, (char*) outdata, outcount) != outcount)
|
||||
rescue();
|
||||
outmsg = outdata;
|
||||
return;
|
||||
}
|
||||
if(outmsg < outdata+DATASIZE)
|
||||
return;
|
||||
outflush();
|
||||
}
|
||||
|
||||
int
|
||||
needoutflush(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -829,7 +834,7 @@ outflush(void)
|
|||
{
|
||||
if(outmsg == outdata)
|
||||
return;
|
||||
noflush = 0;
|
||||
outbuffered = 0;
|
||||
outT0(Hack);
|
||||
waitack = 1;
|
||||
do
|
||||
|
@ -839,5 +844,5 @@ outflush(void)
|
|||
}
|
||||
while(waitack);
|
||||
outmsg = outdata;
|
||||
noflush = 1;
|
||||
outbuffered = 1;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* GROWDATASIZE must be big enough that all errors go out as Hgrowdata's,
|
||||
* so they will be scrolled into visibility in the ~~sam~~ window (yuck!).
|
||||
*/
|
||||
#define GROWDATASIZE 50 /* if size is > this, send data with grow */
|
||||
#define GROWDATASIZE 50 /* if size is <= this, send data with grow */
|
||||
|
||||
void rcut(List*, Posn, Posn);
|
||||
int rterm(List*, Posn);
|
||||
|
@ -79,6 +79,20 @@ raspdone(File *f, int toterm)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
raspflush(File *f)
|
||||
{
|
||||
if(grown){
|
||||
outTsll(Hgrow, f->tag, growpos, grown);
|
||||
grown = 0;
|
||||
}
|
||||
else if(shrunk){
|
||||
outTsll(Hcut, f->tag, shrinkpos, shrunk);
|
||||
shrunk = 0;
|
||||
}
|
||||
outflush();
|
||||
}
|
||||
|
||||
void
|
||||
raspdelete(File *f, uint p1, uint p2, int toterm)
|
||||
{
|
||||
|
@ -323,3 +337,4 @@ rdata(List *r, Posn p1, Posn n)
|
|||
}
|
||||
return rg;
|
||||
}
|
||||
|
||||
|
|
|
@ -218,6 +218,7 @@ void raspstart(File*);
|
|||
void raspdelete(File*, uint, uint, int);
|
||||
void raspinsert(File*, uint, Rune*, uint, int);
|
||||
void raspdone(File*, int);
|
||||
void raspflush(File*);
|
||||
|
||||
/*
|
||||
* acme fns
|
||||
|
@ -404,4 +405,4 @@ void outTsll(Hmesg, int, long, long);
|
|||
void outTsl(Hmesg, int, long);
|
||||
void outTsv(Hmesg, int, vlong);
|
||||
void outflush(void);
|
||||
|
||||
int needoutflush(void);
|
||||
|
|
Loading…
Reference in a new issue