Rune* getblock(int atl, int iof) { int bno, off; static uchar ibuff[BLKSIZE]; static uchar obuff[BLKSIZE]; bno = atl / (BLKSIZE/sizeof(Rune)); off = (atl*sizeof(Rune)) & (BLKSIZE-1) & ~03; if(bno >= NBLK) { lastc = '\n'; error(T); } nleft = BLKSIZE - off; if(bno == iblock) { ichanged |= iof; return (Rune*)(ibuff+off); } if(bno == oblock) return (Rune*)(obuff+off); if(iof == OREAD) { if(ichanged) blkio(iblock, ibuff, 0); ichanged = 0; iblock = bno; blkio(bno, ibuff, 1); return (Rune*)(ibuff+off); } if(oblock >= 0) blkio(oblock, obuff, 0); oblock = bno; return (Rune*)(obuff+off); }
char * getblock(unsigned int atl, int iof) { int bno, off; bno = (atl/(BLKSIZE/2)); off = (atl<<1) & (BLKSIZE-1) & ~03; if (bno >= NBLK) { lastc = '\n'; error(T); } nleft = BLKSIZE - off; if (bno==iblock) { ichanged |= iof; return(ibuff+off); } if (bno==oblock) return(obuff+off); if (iof==READ) { if (ichanged) blkio(iblock, ibuff, write); ichanged = 0; iblock = bno; blkio(bno, ibuff, read); return(ibuff+off); } if (oblock>=0) blkio(oblock, obuff, write); oblock = bno; return(obuff+off); }