summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-02 14:59:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-02 14:59:25 +0000
commit3a76a401967aca5a5386e980f26a7bd925da64b6 (patch)
tree9126bfc47ee662b8a7e2e47d28de217bed3fc948 /configure.in
parent0c767620cd00ec0739debea2b2a33f0f3e3ab65f (diff)
* configure.in (RUBY_CHECK_IO_NEED_FLUSH): check whether fflush()
is needed. * io.c (flush_before_seek): flush before seek if buffered data may remain. * io.c (rb_io_check_readable): flush if the last operation was write. * io.c (rb_io_check_writable): flush if the last operation was read. * rubyio.h (FMODE_RBUF): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in48
1 files changed, 48 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 8310f89523..90d2230f6b 100644
--- a/configure.in
+++ b/configure.in
@@ -249,11 +249,15 @@ darwin*) LIBS="-lobjc $LIBS";;
human*) ac_cv_func_getpgrp_void=yes;;
beos*) ;;
cygwin*) rb_cv_have_daylight=no
+ rb_cv_need_io_flush_between_rw=no
+ rb_cv_need_io_flush_before_seek=no
ac_cv_var_tzname=no
ac_cv_func__setjmp=no
ac_cv_func_setitimer=no
;;
mingw*) LIBS="-lwsock32 -lmsvcrt $LIBS"
+ rb_cv_need_io_flush_between_rw=no
+ rb_cv_need_io_flush_before_seek=no
ac_cv_header_a_out_h=no
ac_cv_header_pwd_h=no
ac_cv_header_utime_h=no
@@ -569,6 +573,50 @@ else
fi
fi
+AC_DEFUN(RUBY_CHECK_IO_NEED_FLUSH,
+[AC_CACHE_CHECK(whether need to flush [$1], [$2],
+ [AC_TRY_RUN([
+#include <stdio.h>
+
+char *fn = "conftest.dat";
+char *wombat = "wombat\n";
+char *koara = "koara\n";
+
+int main()
+{
+ char buf[BUFSIZ];
+ FILE *f;
+ int r = 1;
+
+ if (!(f = fopen(fn, "w+"))) return 1;
+ fputs(wombat, f);
+ fflush(f);
+ fseek(f, 0, 0);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ ]ifelse(index($2,between_rw),-1,fflush(f);)[
+ fputs(koara, f);
+ ]ifelse(index($2,before_seek),-1,fflush(f);)[
+ fseek(f, 0, 0);
+ ]ifelse(index($2,between_rw),-1,fflush(f);)[
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara)) goto fail;
+ r = 0;
+ fail:
+ fclose(f);
+ unlink(fn);
+ return r;
+}
+], [$2]=no, [$2]=yes, [$2]=yes)])])
+
+RUBY_CHECK_IO_NEED_FLUSH(between R/W, rb_cv_need_io_flush_between_rw)
+RUBY_CHECK_IO_NEED_FLUSH(before seek, rb_cv_need_io_flush_before_seek)
+if test "$rb_cv_need_io_flush_between_rw" = yes; then
+ AC_DEFINE(NEED_IO_FLUSH_BETWEEN_RW, 1)
+fi
+if test "$rb_cv_need_io_flush_before_seek" = yes; then
+ AC_DEFINE(NEED_IO_FLUSH_BEFORE_SEEK, 1)
+fi
+
dnl default value for $KANJI
DEFAULT_KCODE="KCODE_NONE"