diff options
| author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-18 11:52:46 +0000 |
|---|---|---|
| committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-11-18 11:52:46 +0000 |
| commit | b3e2b9aca1a6aaae71e8da8c8a96b1f694a6b8b2 (patch) | |
| tree | bdb449ab7d166dd7ea69ccd4088d87e0ba02e8c7 /win32 | |
| parent | 4560ba4aca6b2726fd4735a1052f3b695e7e7a01 (diff) | |
| download | ruby-b3e2b9aca1a6aaae71e8da8c8a96b1f694a6b8b2.tar.gz ruby-b3e2b9aca1a6aaae71e8da8c8a96b1f694a6b8b2.tar.xz ruby-b3e2b9aca1a6aaae71e8da8c8a96b1f694a6b8b2.zip | |
* win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
isatty because it never sets errno.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/win32.c | 14 | ||||
| -rw-r--r-- | win32/win32.h | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c index b212d3874..1e30ffec9 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3424,6 +3424,20 @@ rb_w32_snprintf(char *buf, size_t size, const char *format, ...) return ret; } +int +rb_w32_isatty(int fd) +{ + if (!(_osfile(fd) & FOPEN)) { + errno = EBADF; + return 0; + } + if (!(_osfile(fd) & FDEV)) { + errno = ENOTTY; + return 0; + } + return 1; +} + // // Fix bcc32's stdio bug // diff --git a/win32/win32.h b/win32/win32.h index e811a8bdd..16acd1c95 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -121,11 +121,14 @@ extern "C++" { #undef fsopen #define fsopen(p, m, sh) rb_w32_fsopen(p, m, sh) #endif + #define fsync(h) _commit(h) #undef stat #define stat(path,st) rb_w32_stat(path,st) #undef execv #define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv) +#undef isatty +#define isatty(h) rb_w32_isatty(h) #ifdef __MINGW32__ struct timezone { @@ -185,6 +188,7 @@ extern int rb_w32_aspawn(int, const char *, char *const *); extern int kill(int, int); extern int fcntl(int, int, ...); extern pid_t rb_w32_getpid(void); +extern int rb_w32_isatty(int); #ifdef __BORLANDC__ extern int rb_w32_fstat(int, struct stat *); |
