Annotation of researchv10dc/libI77/old/backspace.c, revision 1.1

1.1     ! root        1: /*     @(#)backspace.c 1.3     */
        !             2: /*     3.0 SID #       1.2     */
        !             3: #include "fio.h"
        !             4: f_back(a) alist *a;
        !             5: {      unit *b;
        !             6:        int n,i;
        !             7:        long x;
        !             8:        char buf[32];
        !             9:        if(a->aunit >= MXUNIT || a->aunit < 0)
        !            10:                err(a->aerr,101,"backspace")
        !            11:        b= &units[a->aunit];
        !            12:        if(b->useek==0) err(a->aerr,106,"backspace")
        !            13:        if(b->ufd==NULL) err(a->aerr,114,"backspace")
        !            14:        if(b->uend==1)
        !            15:        {       b->uend=0;
        !            16:                return(0);
        !            17:        }
        !            18:        if(b->uwrt)
        !            19:        {       (void) t_runc(b);
        !            20:                (void) nowreading(b);
        !            21:        }
        !            22:        if(b->url>0)
        !            23:        {       long y;
        !            24:                x=ftell(b->ufd);
        !            25:                y = x % b->url;
        !            26:                if(y == 0) x--;
        !            27:                x /= b->url;
        !            28:                x *= b->url;
        !            29:                (void) fseek(b->ufd,x,0);
        !            30:                return(0);
        !            31:        }
        !            32:        if(b->ufmt==0)
        !            33:        {       (void) fseek(b->ufd,-(long)sizeof(int),1);
        !            34:                (void) fread((char *)&n,sizeof(int),1,b->ufd);
        !            35:                (void) fseek(b->ufd,-(long)n-2*sizeof(int),1);
        !            36:                return(0);
        !            37:        }
        !            38:        for(;;)
        !            39:        {       long y;
        !            40:                y = x=ftell(b->ufd);
        !            41:                if(x<sizeof(buf)) x=0;
        !            42:                else x -= sizeof(buf);
        !            43:                (void) fseek(b->ufd,x,0);
        !            44:                n=fread(buf,1,(int)(y-x), b->ufd);
        !            45:                for(i=n-2;i>=0;i--)
        !            46:                {
        !            47:                        if(buf[i]!='\n') continue;
        !            48:                        (void) fseek(b->ufd,(long)(i+1-n),1);
        !            49:                        return(0);
        !            50:                }
        !            51:                if(x==0)
        !            52:                        {
        !            53:                        (void) fseek(b->ufd, 0L, 0);
        !            54:                        return(0);
        !            55:                        }
        !            56:                else if(n<=0) err(a->aerr,(EOF),"backspace")
        !            57:                (void) fseek(b->ufd, x, 0);
        !            58:        }
        !            59: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.