* Refill a stdio buffer.
* Return EOF on eof or error, 0 otherwise.
*/
-int
-__srefill(FILE *fp)
+__private_extern__ int
+__srefill0(FILE *fp)
{
/* make sure stdio is set up */
- if (!__sdidinit)
- __sinit();
+ pthread_once(&__sdidinit, __sinit);
ORIENT(fp, -1);
if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
__sflush(fp);
}
+ return (1);
+}
+
+__private_extern__ int
+__srefill1(FILE *fp)
+{
+
fp->_p = fp->_bf._base;
fp->_r = _sread(fp, (char *)fp->_p, fp->_bf._size);
fp->_flags &= ~__SMOD; /* buffer contents are again pristine */
}
return (0);
}
+
+int
+__srefill(FILE *fp)
+{
+ int ret;
+
+ if ((ret = __srefill0(fp)) <= 0)
+ return ret;
+ return __srefill1(fp);
+}