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