Fix some issues and do some code cleanup

This commit is contained in:
Justine Tunney 2022-05-23 10:15:53 -07:00
parent 1f229e4efc
commit 312ed5c67c
72 changed files with 880 additions and 982 deletions

View file

@ -16,17 +16,13 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/bits/weaken.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/metastat.internal.h"
#include "libc/calls/struct/stat.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/nt/enum/filetype.h"
#include "libc/nt/files.h"
#include "libc/sysv/errfuns.h"
#include "libc/zipos/zipos.internal.h"
/**
* Returns true if file descriptor is backed by character i/o.
@ -44,15 +40,7 @@ bool32 ischardev(int fd) {
int e;
union metastat st;
if (__isfdkind(fd, kFdZip)) {
e = errno;
if (weaken(__zipos_fstat)(
(struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, &st.cosmo) !=
-1) {
return S_ISCHR(st.cosmo.st_mode);
} else {
errno = e;
return false;
}
return false;
} else if (IsMetal()) {
return true;
} else if (!IsWindows()) {