summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--win32/win32.c14
-rw-r--r--win32/win32.h3
3 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a4e36d3efd..b77f38ffe5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Dec 15 17:03:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
+ isatty because it never sets errno. (backported from CVS HEAD)
+
Wed Dec 15 15:39:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_x509name.c (ossl_x509name_to_a): avoid SEGV
diff --git a/win32/win32.c b/win32/win32.c
index a4cea9b287..f44b805ae6 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3322,6 +3322,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 d7222fc1b1..a7995a083b 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -125,6 +125,8 @@ extern "C++" {
#define stat(path,st) rb_w32_stat(path,st)
#undef execv
#define execv(path,argv) do_aspawn(P_OVERLAY,path,argv)
+#undef isatty
+#define isatty(h) rb_w32_isatty(h)
#ifdef __MINGW32__
struct timezone {
@@ -181,6 +183,7 @@ extern int do_spawn(int, char *);
extern int do_aspawn(int, char *, char **);
extern int kill(int, int);
extern pid_t rb_w32_getpid(void);
+extern int rb_w32_isatty(int);
#ifdef __BORLANDC__
extern FILE *rb_w32_fopen(const char *, const char *);