From 1de50c518b9a5244bef0473eab46d4b892fe817d Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 12 Oct 2002 14:47:07 +0000 Subject: * win32/win32.c (rb_w32_putc): wrong condition to fill or flush on bccwin32. [ruby-win32:408] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ win32/win32.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95a5e2923d..c656873198 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Oct 12 23:44:11 2002 Nobuyoshi Nakada + + * 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 * win32/win32.c (rb_w32_fclose, rb_w32_close): use closesocket() diff --git a/win32/win32.c b/win32/win32.c index 0e155ef9e6..c4086fe159 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; } -- cgit v1.2.3