diff --git a/ChangeLog b/ChangeLog index 84f4dcd4ef..13f8efe144 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun May 12 17:25:46 2013 KOSAKI Motohiro + + * configure.in: removes AC_CHECK_FUNCS(truncate64) because it's + unused. + * file.c (rb_file_s_truncate): use correct type. chsize takes + a long. + Sun May 12 17:18:46 2013 KOSAKI Motohiro * process.c: move '#define SPAWNV 1' to win32/Makefile.sub. diff --git a/configure.in b/configure.in index 8c8daa8703..09a29b0742 100644 --- a/configure.in +++ b/configure.in @@ -1810,7 +1810,7 @@ AC_CHECK_FUNCS(telldir) AC_CHECK_FUNCS(timegm) AC_CHECK_FUNCS(times) AC_CHECK_FUNCS(truncate) -AC_CHECK_FUNCS(truncate64) +AC_CHECK_FUNCS(truncate64) # used for Win32 AC_CHECK_FUNCS(unsetenv) AC_CHECK_FUNCS(utimensat) AC_CHECK_FUNCS(utimes) diff --git a/file.c b/file.c index 3b52c900a1..9b6ae64ae1 100644 --- a/file.c +++ b/file.c @@ -4098,10 +4098,16 @@ rb_file_s_join(VALUE klass, VALUE args) static VALUE rb_file_s_truncate(VALUE klass, VALUE path, VALUE len) { +#ifdef HAVE_TRUNCATE +#define NUM2POS(n) NUM2OFFT(n) off_t pos; +#else +#define NUM2POS(n) NUM2LONG(n) + long pos; +#endif rb_secure(2); - pos = NUM2OFFT(len); + pos = NUM2POS(len); FilePathValue(path); path = rb_str_encode_ospath(path); #ifdef HAVE_TRUNCATE @@ -4123,6 +4129,7 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len) } #endif return INT2FIX(0); +#undef NUM2POS } #else #define rb_file_s_truncate rb_f_notimplement