ted: update to 32-bit Runes - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit cfa81d56c6727c3adcaa160c202c914696097c58
 (DIR) parent 16e65a6d780d182ae8c1992a23952c567468a01c
 (HTM) Author: Russ Cox <russcox@gmail.com>
       Date:   Wed, 16 Sep 2009 16:46:07 -0400
       
       ed: update to 32-bit Runes
       
       http://codereview.appspot.com/116119
       
       Diffstat:
         M src/cmd/ed.c                        |      18 +++++++++---------
       
       1 file changed, 9 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/ed.c b/src/cmd/ed.c
       t@@ -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;
       t@@ -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;
                        }
                }
       t@@ -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;
       t@@ -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;
                        }
       t@@ -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);
       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])) {
       t@@ -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;