SETLOCAL(f);
f->bits &= (unsigned short)~SF_NULL; /* turn off /dev/null handling */
if ((f->bits & SF_MMAP) || (f->mode & SF_INIT))
- sfsetbuf(f, NULL, (size_t) SF_UNBOUND);
+ sfsetbuf(f, NULL, SF_UNBOUND);
else if (f->data == f->tiny)
sfsetbuf(f, NULL, 0);
else {
# include <sys/types.h>
#endif // HAVE_SYS_TYPES_H
+#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#define SF_SETFD (-1) /* about to set the file descriptor */
#define SF_BUFSIZE 8192 /* default buffer size */
-#define SF_UNBOUND (-1) /* unbounded buffer size */
+#define SF_UNBOUND SIZE_MAX // unbounded buffer size
extern ssize_t _Sfi;
return NULL;
if (f->data
- && ((flags & SF_STRING) || size != (size_t) SF_UNBOUND)) {
+ && ((flags & SF_STRING) || size != SF_UNBOUND)) {
if (sflags & SF_MALLOC)
free(f->data);
f->data = NULL;
f->getr = f->tiny[0] = 0;
f->mode |= SF_INIT;
- if (size != (size_t) SF_UNBOUND) {
+ if (size != SF_UNBOUND) {
f->size = size;
f->data = size <= 0 ? NULL : (uchar *) buf;
}
#endif
if (sflags & SF_STRING) {
- f = sfnew(f, (char *) file,
- file ? (size_t) strlen(file) : (size_t)
- SF_UNBOUND, -1, sflags);
+ f = sfnew(f, (char *)file, file ? strlen(file) : SF_UNBOUND, -1, sflags);
} else {
if (!file)
return NULL;
/* we may have to reset the file descriptor to its old value */
oldfd = f ? f->file : -1;
- if ((f = sfnew(f, NULL, (size_t) SF_UNBOUND, fd, sflags))
- && oldfd >= 0)
+ if ((f = sfnew(f, NULL, SF_UNBOUND, fd, sflags)) && oldfd >= 0)
(void) sfsetfd(f, oldfd);
}
/* pure read/string streams must have a valid string */
if ((f->flags & (SF_RDWR | SF_STRING)) == SF_RDSTR &&
- (size == (size_t) SF_UNBOUND || !buf))
+ (size == SF_UNBOUND || !buf))
size = 0;
/* set disc to the first discipline with a seekf */
/* get buffer space */
setbuf:
- if (size == (size_t) SF_UNBOUND) { /* define a default size suitable for block transfer */
+ if (size == SF_UNBOUND) { /* define a default size suitable for block transfer */
if (init && osize > 0)
size = osize;
else if (f == sfstderr && (f->mode & SF_WRITE))
/* make a string stream for unget characters */
if (f->disc != _Sfudisc) {
- if (!(uf = sfnew(NULL, NULL, (size_t) SF_UNBOUND,
- -1, SF_STRING | SF_READ))) {
+ if (!(uf = sfnew(NULL, NULL, SF_UNBOUND, -1, SF_STRING|SF_READ))) {
c = -1;
goto done;
}