Compare commits

...
2 Commits
Author SHA1 Message Date
Justine Tunney 7724664b13 Release Cosmopolitan v3.3.8 2024-05-25 05:59:20 -07:00
Justine Tunney 1df4296208 Fix stdio for character device regression
Caused by ed93fc3dd7
2024-05-25 05:58:09 -07:00
4 changed files with 20 additions and 10 deletions

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
#define __COSMOPOLITAN_MAJOR__ 3
#define __COSMOPOLITAN_MINOR__ 3
#define __COSMOPOLITAN_PATCH__ 7
#define __COSMOPOLITAN_PATCH__ 8
#define __COSMOPOLITAN__ \
(100000000 * __COSMOPOLITAN_MAJOR__ + 1000000 * __COSMOPOLITAN_MINOR__ + \
__COSMOPOLITAN_PATCH__)
+6 -1
View File
@@ -17,9 +17,11 @@
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/s.h"
#include "libc/sysv/errfuns.h"
#include "libc/thread/thread.h"
@@ -33,9 +35,12 @@
*/
FILE *fdopen(int fd, const char *mode) {
FILE *f;
struct stat st;
if (fstat(fd, &st))
return 0;
if ((f = __stdio_alloc())) {
f->fd = fd;
f->bufmode = ischardev(fd) ? _IOLBF : _IOFBF;
f->bufmode = S_ISREG(st.st_mode) ? _IOFBF : _IONBF;
f->iomode = fopenflags(mode);
f->buf = f->mem;
f->size = BUFSIZ;
+10 -6
View File
@@ -29,16 +29,15 @@
#include "libc/sysv/errfuns.h"
static ssize_t readvall(int fd, struct iovec *iov, int iovlen) {
int olde;
ssize_t rc;
size_t got, toto;
toto = 0;
olde = errno;
do {
if ((rc = readv(fd, iov, iovlen)) == -1) {
if (toto && errno == EINTR) {
errno = olde;
continue;
if (toto) {
if (errno == EINTR)
continue;
return toto;
}
return -1;
}
@@ -135,7 +134,12 @@ size_t fread_unlocked(void *buf, size_t stride, size_t count, FILE *f) {
iov[1].iov_base = NULL;
iov[1].iov_len = 0;
}
if ((rc = readvall(f->fd, iov, 2)) == -1) {
if (f->bufmode == _IONBF) {
rc = readv(f->fd, iov, 2);
} else {
rc = readvall(f->fd, iov, 2);
}
if (rc == -1) {
f->state = errno;
return 0;
}
+3 -2
View File
@@ -867,8 +867,9 @@ if not _port then
-- {year=(1 << 31) + 1899, month=12, day=31, hour=23, min=59, sec=59}))
-- this is too much
checkerr("represented", os.time,
{year=(1 << 31) + 1899, month=12, day=31, hour=23, min=59, sec=60})
-- [jart] recent tz library upgrade seems to think it's ok
-- checkerr("represented", os.time,
-- {year=(1 << 31) + 1899, month=12, day=31, hour=23, min=59, sec=60})
end
-- internal 'int' fields cannot hold these values