ed: update to 32-bit Runes

http://codereview.appspot.com/116119
This commit is contained in:
Russ Cox 2009-09-16 16:46:07 -04:00
parent 16e65a6d78
commit cfa81d56c6

View file

@ -55,7 +55,7 @@ Reprog *pattern;
int peekc;
int pflag;
int rescuing;
Rune rhsbuf[LBSIZE/2];
Rune rhsbuf[LBSIZE/sizeof(Rune)];
char savedfile[FNSIZE];
jmp_buf savej;
int subnewa;
@ -1009,11 +1009,11 @@ getline(int tl)
lp = linebuf;
bp = getblock(tl, OREAD);
nl = nleft;
tl &= ~((BLKSIZE/2) - 1);
tl &= ~((BLKSIZE/sizeof(Rune)) - 1);
while(*lp++ = *bp++) {
nl -= sizeof(Rune);
if(nl == 0) {
bp = getblock(tl += BLKSIZE/2, OREAD);
bp = getblock(tl += BLKSIZE/sizeof(Rune), OREAD);
nl = nleft;
}
}
@ -1031,7 +1031,7 @@ putline(void)
tl = tline;
bp = getblock(tl, OWRITE);
nl = nleft;
tl &= ~((BLKSIZE/2)-1);
tl &= ~((BLKSIZE/sizeof(Rune))-1);
while(*bp = *lp++) {
if(*bp++ == '\n') {
bp[-1] = 0;
@ -1040,7 +1040,7 @@ putline(void)
}
nl -= sizeof(Rune);
if(nl == 0) {
tl += BLKSIZE/2;
tl += BLKSIZE/sizeof(Rune);
bp = getblock(tl, OWRITE);
nl = nleft;
}
@ -1072,8 +1072,8 @@ getblock(int atl, int iof)
static uchar ibuff[BLKSIZE];
static uchar obuff[BLKSIZE];
bno = atl / (BLKSIZE/2);
off = (atl<<1) & (BLKSIZE-1) & ~03;
bno = atl / (BLKSIZE/sizeof(Rune));
off = (atl*sizeof(Rune)) & (BLKSIZE-1) & ~03;
if(bno >= NBLK) {
lastc = '\n';
error(T);
@ -1264,7 +1264,7 @@ compsub(void)
if(c == '\\') {
c = getchr();
*p++ = ESCFLG;
if(p >= &rhsbuf[LBSIZE/2])
if(p >= &rhsbuf[LBSIZE/sizeof(Rune)])
error(Q);
} else
if(c == '\n' && (!globp || !globp[0])) {
@ -1275,7 +1275,7 @@ compsub(void)
if(c == seof)
break;
*p++ = c;
if(p >= &rhsbuf[LBSIZE/2])
if(p >= &rhsbuf[LBSIZE/sizeof(Rune)])
error(Q);
}
*p = 0;