projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 1998-11-26 09:17:22 by sof]
[ghc-hetmet.git]
/
ghc
/
lib
/
std
/
cbits
/
getBufferMode.lc
diff --git
a/ghc/lib/std/cbits/getBufferMode.lc
b/ghc/lib/std/cbits/getBufferMode.lc
index
cb0b984
..
fc894a7
100644
(file)
--- a/
ghc/lib/std/cbits/getBufferMode.lc
+++ b/
ghc/lib/std/cbits/getBufferMode.lc
@@
-27,13
+27,15
@@
#define GBM_ERR (-3)
StgInt
#define GBM_ERR (-3)
StgInt
-getBufferMode(fp)
-StgForeignObj fp;
+getBufferMode(ptr)
+StgForeignObj ptr;
{
{
+ IOFileObject* fo = (IOFileObject*)ptr;
struct stat sb;
struct stat sb;
+ int fd = fo->fd;
/* Try to find out the file type */
/* Try to find out the file type */
- while (fstat(fileno((FILE *) fp), &sb) < 0) {
+ while (fstat(fd, &sb) < 0) {
/* highly unlikely */
if (errno != EINTR) {
cvtErrno();
/* highly unlikely */
if (errno != EINTR) {
cvtErrno();
@@
-42,11
+44,14
@@
StgForeignObj fp;
}
}
/* Terminals are line-buffered by default */
}
}
/* Terminals are line-buffered by default */
- if (S_ISCHR(sb.st_mode) && isatty(fileno((FILE *) fp)) == 1)
+ if (S_ISCHR(sb.st_mode) && isatty(fd) == 1) {
+ fo ->flags |= FILEOBJ_LB;
return GBM_LB;
/* Default size block buffering for the others */
return GBM_LB;
/* Default size block buffering for the others */
- else
+ } else {
+ fo ->flags |= FILEOBJ_BB;
return GBM_BB;
return GBM_BB;
+ }
}
\end{code}
}
\end{code}