Clean up yacc files in mkcommon, mkhdr.

Add nan to lib9.
Fix memory corruption bugs in 9term.
This commit is contained in:
rsc 2003-12-04 19:16:29 +00:00
parent c5b9ff9fa8
commit dff7e27317
4 changed files with 33 additions and 15 deletions

View file

@ -361,6 +361,8 @@ mouse(void)
wordclick(&q0, &q1); wordclick(&q0, &q1);
if(q0 == q1) if(q0 == q1)
break; break;
t.q0 = t.q1 = t.nr;
updatesel();
paste(t.r+q0, q1-q0, 1); paste(t.r+q0, q1-q0, 1);
if(t.r[q1-1] != '\n') if(t.r[q1-1] != '\n')
paste(Lnl, 1, 1); paste(Lnl, 1, 1);
@ -384,7 +386,7 @@ mselect(void)
b = t.m.buttons; b = t.m.buttons;
q0 = frcharofpt(t.f, t.m.xy) + t.org; q0 = frcharofpt(t.f, t.m.xy) + t.org;
if(t.m.msec-clickmsec<500 && clickq0 == q0 && t.q0==t.q1 && b==1){ if(t.m.msec-clickmsec<500 && clickq0==q0 && t.q0==t.q1 && b==1){
doubleclick(&t.q0, &t.q1); doubleclick(&t.q0, &t.q1);
updatesel(); updatesel();
/* t.t.i->flush(); */ /* t.t.i->flush(); */
@ -408,19 +410,19 @@ mselect(void)
clickmsec = t.m.msec; clickmsec = t.m.msec;
clickq0 = t.q0; clickq0 = t.q0;
} }
if((t.m.buttons != b) && (b&1)){ if((t.m.buttons != b) &&(b&1)){
enum {Cancut = 1, Canpaste = 2} state = Cancut | Canpaste; enum{Cancut = 1, Canpaste = 2} state = Cancut | Canpaste;
while(t.m.buttons){ while(t.m.buttons){
if(t.m.buttons&2) { if(t.m.buttons&2){
if (state&Cancut) { if(state&Cancut){
snarf(); snarf();
cut(); cut();
state = Canpaste; state = Canpaste;
} }
} else if (t.m.buttons&4) { }else if(t.m.buttons&4){
if (state&Canpaste) { if(state&Canpaste){
snarfupdate(); snarfupdate();
if (t.nsnarf) { if(t.nsnarf){
paste(t.snarf, t.nsnarf, 0); paste(t.snarf, t.nsnarf, 0);
} }
state = Cancut|Canpaste; state = Cancut|Canpaste;
@ -841,7 +843,6 @@ cut(void)
void void
snarfupdate(void) snarfupdate(void)
{ {
char *pp; char *pp;
int n, i; int n, i;
Rune *p; Rune *p;
@ -861,10 +862,11 @@ snarfupdate(void)
} }
char sbuf[SnarfSize];
void void
snarf(void) snarf(void)
{ {
char buf[SnarfSize], *p; char *p;
int i, n; int i, n;
Rune *rp; Rune *rp;
@ -872,18 +874,19 @@ snarf(void)
return; return;
n = t.q1-t.q0; n = t.q1-t.q0;
t.snarf = runerealloc(t.snarf, n); t.snarf = runerealloc(t.snarf, n);
for(i=0,p=buf,rp=t.snarf; i<n && p < buf + SnarfSize-UTFmax; i++){ for(i=0,p=sbuf,rp=t.snarf; i<n && p < sbuf+SnarfSize-UTFmax; i++){
*rp++ = *(t.r+t.q0+i); *rp++ = *(t.r+t.q0+i);
p += runetochar(p, t.r+t.q0+i); p += runetochar(p, t.r+t.q0+i);
} }
t.nsnarf = rp-t.snarf; t.nsnarf = rp-t.snarf;
*p = '\0'; *p = '\0';
putsnarf(buf); putsnarf(sbuf);
} }
void void
paste(Rune *r, int n, int advance) paste(Rune *r, int n, int advance)
{ {
Rune *rbuf;
uint m; uint m;
uint q0; uint q0;
@ -908,6 +911,17 @@ paste(Rune *r, int n, int advance)
t.nr -= m; t.nr -= m;
runemove(t.r, t.r+m, t.nr); runemove(t.r, t.r+m, t.nr);
} }
/*
* if this is a button2 execute then we might have been passed
* runes inside the buffer. must save them before realloc.
*/
rbuf = nil;
if(t.r <= r && r < t.r+n){
rbuf = runemalloc(n);
runemove(rbuf, r, n);
r = rbuf;
}
t.r = runerealloc(t.r, t.nr+n); t.r = runerealloc(t.r, t.nr+n);
q0 = t.q0; q0 = t.q0;
runemove(t.r+q0+n, t.r+q0, t.nr-q0); runemove(t.r+q0+n, t.r+q0, t.nr-q0);
@ -925,6 +939,7 @@ paste(Rune *r, int n, int advance)
t.q0 += n; t.q0 += n;
t.q1 += n; t.q1 += n;
updatesel(); updatesel();
free(rbuf);
} }
void void

View file

@ -42,6 +42,7 @@ OFILES=\
main.$O\ main.$O\
malloctag.$O\ malloctag.$O\
mallocz.$O\ mallocz.$O\
nan.$O\
needsrcquote.$O\ needsrcquote.$O\
netmkaddr.$O\ netmkaddr.$O\
notify.$O\ notify.$O\

View file

@ -14,10 +14,10 @@ clean:V: clean-common
%.clean:V: %.clean-common %.clean:V: %.clean-common
nuke-common:V: nuke-common:V:
rm -f *.[$OS] [$OS].out $CLEANFILES $NUKEFILES rm -f *.[$OS] [$OS].out $CLEANFILES y.tab.[ch] $NUKEFILES
clean-common: clean-common:
rm -f *.[$OS] [$OS].out $CLEANFILES rm -f *.[$OS] [$OS].out $CLEANFILES y.tab.[ch]
%.clean-common:V: %.clean-common:V:
rm -f $stem.[$OS] [$OS].$stem $stem.acid $stem rm -f $stem.[$OS] [$OS].$stem $stem.acid $stem

View file

@ -20,6 +20,8 @@ LDFLAGS=
AFLAGS= AFLAGS=
CLEANFILES= CLEANFILES=
NUKEFILES= NUKEFILES=
YACC=yacc
YFLAGS=-d
<|cat $PLAN9/src/mk.$SYSNAME-$OBJTYPE 2>/dev/null || true <|cat $PLAN9/src/mk.$SYSNAME-$OBJTYPE 2>/dev/null || true