// // With _Fcin.fcptr>_Fcin.fcbuff, the stream pointer is advanced. // If _Fcin.fclast!=0, performs an sfreserve() for the next buffer. // If a notify function has been set, it is called. // If last is non-zero, and the stream is a file, 0 is returned when // the previous character is a 0 byte. // int fcfill(void) { int n; Sfio_t *f; unsigned char *last = _Fcin.fclast, *ptr = _Fcin.fcptr; f = fcfile(); if (!f) { // See whether pointer has passed null byte. if (ptr > _Fcin.fcbuff && *--ptr == 0) { _Fcin.fcptr = ptr; } else { _Fcin.fcoff = 0; } return 0; } if (last) { if (ptr < last && ptr > _Fcin.fcbuff && *(ptr - 1) == 0) return 0; if (_Fcin.fcchar) *last = _Fcin.fcchar; if (ptr > last) _Fcin.fcptr = ptr = last; } n = ptr - _Fcin.fcbuff; if (n && _Fcin.fcfun) (*_Fcin.fcfun)(f, (const char *)_Fcin.fcbuff, n, _Fcin.context); sfread(f, (char *)_Fcin.fcbuff, n); _Fcin.fcoff += n; _Fcin._fcfile = NULL; if (!last) { return 0; } else if (fcfopen(f) < 0) { return EOF; } return *_Fcin.fcptr++; }
/* * With _Fcin.fcptr>_Fcin.fcbuff, the stream pointer is advanced and * If _Fcin.fclast!=0, performs an sfreserve() for the next buffer. * If a notify function has been set, it is called * If last is non-zero, and the stream is a file, 0 is returned when * the previous character is a 0 byte. */ int fcfill(void) { register int n; register Sfio_t *f; register unsigned char *last=_Fcin.fclast, *ptr=_Fcin.fcptr; if(!(f=fcfile())) { /* see whether pointer has passed null byte */ if(ptr>_Fcin.fcbuff && *--ptr==0) _Fcin.fcptr=ptr; else _Fcin.fcoff = 0; return(0); } if(last) { if( ptr<last && ptr>_Fcin.fcbuff && *(ptr-1)==0) return(0); if(_Fcin.fcchar) *last = _Fcin.fcchar; if(ptr > last) _Fcin.fcptr = ptr = last; } if((n = ptr-_Fcin.fcbuff) && _Fcin.fcfun) (*_Fcin.fcfun)(f,(const char*)_Fcin.fcbuff,n,_Fcin.context); sfread(f, (char*)_Fcin.fcbuff, n); _Fcin.fcoff +=n; _Fcin._fcfile = 0; if(!last) return(0); else if(fcfopen(f) < 0) return(EOF); return(*_Fcin.fcptr++); }