Annotation of 42BSD/usr.lib/libpc/READ8.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1979 Regents of the University of California */
        !             2: 
        !             3: static char sccsid[] = "@(#)READ8.c 1.5 4/9/82";
        !             4: 
        !             5: #include "h00vars.h"
        !             6: #include <errno.h>
        !             7: extern int errno;
        !             8: 
        !             9: double
        !            10: READ8(curfile)
        !            11: 
        !            12:        register struct iorec   *curfile;
        !            13: {
        !            14:        double                  data;
        !            15:        int                     retval;
        !            16: 
        !            17:        if (curfile->funit & FWRITE) {
        !            18:                ERROR("%s: Attempt to read, but open for writing\n",
        !            19:                        curfile->pfname);
        !            20:                return;
        !            21:        }
        !            22:        UNSYNC(curfile);
        !            23:        errno = 0;
        !            24:        retval = fscanf(curfile->fbuf, "%lf", &data);
        !            25:        if (retval == EOF) {
        !            26:                ERROR("%s: Tried to read past end of file\n", curfile->pfname);
        !            27:                return;
        !            28:        }
        !            29:        if (retval == 0) {
        !            30:                ERROR("%s: Bad data found on real read\n", curfile->pfname);
        !            31:                return;
        !            32:        }
        !            33:        if (errno == ERANGE) {
        !            34:                if (data == 0.0)
        !            35:                        ERROR("%s: Underflow on real read\n", curfile->pfname);
        !            36:                else
        !            37:                        ERROR("%s: Overflow on real read\n", curfile->pfname);
        !            38:                return;
        !            39:        }
        !            40:        if (errno != 0) {
        !            41:                PERROR(curfile->pfname);
        !            42:                return;
        !            43:        }
        !            44:        curfile->funit &= ~EOLN;
        !            45:        curfile->funit |= SYNC;
        !            46:        return data;
        !            47: }

unix.superglobalmegacorp.com

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