summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--win32/win32.c11
2 files changed, 13 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 95a5e29..c656873 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Oct 12 23:44:11 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_putc): wrong condition to fill or flush on
+ bccwin32. [ruby-win32:408]
+
Fri Oct 11 06:05:30 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* win32/win32.c (rb_w32_fclose, rb_w32_close): use closesocket()
diff --git a/win32/win32.c b/win32/win32.c
index 0e155ef..c4086fe 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -51,7 +51,12 @@
#ifdef __BORLANDC__
# define _filbuf _fgetc
-# define _flsbuf fputc
+# define _flsbuf _fputc
+# define enough_to_get(n) (--(n) >= 0)
+# define enough_to_put(n) (++(n) < 0)
+#else
+# define enough_to_get(n) (--(n) >= 0)
+# define enough_to_put(n) (--(n) >= 0)
#endif
#if HAVE_WSAWAITFORMULTIPLEEVENTS
@@ -2788,7 +2793,7 @@ static void catch_interrupt(void)
int rb_w32_getc(FILE* stream)
{
int c, trap_immediate = rb_trap_immediate;
- if (--stream->FILE_COUNT >= 0) {
+ if (enough_to_get(stream->FILE_COUNT)) {
c = (unsigned char)*stream->FILE_READPTR++;
rb_trap_immediate = trap_immediate;
}
@@ -2810,7 +2815,7 @@ int rb_w32_getc(FILE* stream)
int rb_w32_putc(int c, FILE* stream)
{
int trap_immediate = rb_trap_immediate;
- if (--stream->FILE_COUNT >= 0) {
+ if (enough_to_put(stream->FILE_COUNT)) {
c = (unsigned char)(*stream->FILE_READPTR++ = (char)c);
rb_trap_immediate = trap_immediate;
}