#include "fio.h" #include "fmt.h" extern int cursor; rd_ed(p,ptr,len) char *ptr; struct syl *p; ftnlen len; { int ch; for(;cursor>0;cursor--) if((ch=(*getn)())<0) return(ch); if(cursor<0) { if(recpos+cursor < 0) err(elist->cierr,110,"fmt") if(curunit->useek) fseek(cf,(long) cursor,1); else err(elist->cierr,106,"fmt"); cursor=0; } switch(p->op) { default: fprintf(stderr,"rd_ed, unexpected code: %d\n%s\n", p->op,fmtbuf); abort(); case I: ch = (rd_I(ptr,p->p1,len, 10)); break; case IM: ch = (rd_I(ptr,p->p1,len, 10)); break; case O: ch = (rd_I(ptr, p->p1, len, 8)); break; case L: ch = (rd_L(ptr,p->p1)); break; case A: ch = (rd_A(ptr,len)); break; case AW: ch = (rd_AW(ptr,p->p1,len)); break; case E: case EE: case D: case G: case GE: case F: ch = (rd_F(ptr,p->p1,p->p2,len)); break; } if(ch == 0) return(ch); else if(feof(cf)) return(EOF); clearerr(cf); return(errno); } rd_ned(p,ptr) char *ptr; struct syl *p; { switch(p->op) { default: fprintf(stderr,"rd_ned, unexpected code: %d\n%s\n", p->op,fmtbuf); abort(); case APOS: return(rd_POS(p->p1)); case H: return(rd_H(p->p1,p->p2)); case SLASH: return((*donewrec)()); case TR: case X: cursor += p->p1; return(1); case T: cursor=p->p1-recpos; return(1); case TL: cursor -= p->p1; return(1); } } rd_I(n,w,len, base) ftnlen len; uint *n; register int base; { long x=0; int i,sign=0,ch; for(i=0;iis=x; else if(len == sizeof(char)) n->ic = x; else n->il=x; return(0); } rd_L(n,w) ftnint *n; { int ch,i,v = -1; for(i=0;i='0') x=10*x+ch-'0'; else if(ch=='e' || ch=='d' || ch=='.') break; else if(cblank && (ch==' ' || ch== '\n')) x*=10; else if(ch==',') { i=w; break; } else return(errno = 115); } if(ch=='.') dot=1; while(i='0') y=10*y+ch-'0'; else if(cblank && (ch==' ' || ch == '\n')) y *= 10; else if(ch==',') {i=w; break;} else if(ch==' ') continue; else continue; ny++; } expon: if(ch=='-') sz=1; while(i='0') z=10*z+ch-'0'; else if(cblank && (ch==' ' || ch == '\n')) z *= 10; else if(ch==',') break; else if(ch==' ') continue; else if(ch=='+') continue; else if(ch!='\n') return(errno=115); } if(!dot) for(i=0;i0;i--) x /= 10; for(i=scale;i<0;i++) x *= 10; } if(len==sizeof(float)) p->pf=x; else p->pd=x; return(0); } rd_A(p,len) char *p; ftnlen len; { int i,ch; for(i=0;i=len) { for(i=0;i