summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-16 16:58:06 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-16 16:58:06 +0000
commit8e8ae2a9c53d58a59bc680c6d05c453ac866db8c (patch)
tree4a78ab16c0142d94ed7d1be9d20eceaa68eeee7f /file.c
parent50cea7a5c90eb70539c07ccc63532b4e880e0557 (diff)
* node.h (rb_notimplement_body_p): declared.
* vm_method.c (Init_eval_method): suppress a warning. * io.c (rb_io_fsync): use rb_f_notimplement if not implemented. (rb_io_close_on_exec_p): ditto. (rb_io_set_close_on_exec): ditto. (rb_io_fcntl): ditto. (rb_f_syscall): ditto. * dir.c (dir_tell): ditto. (dir_seek): ditto. (dir_s_chroot): ditto. * process.c (proc_getpgrp): ditto. (proc_setpgrp): ditto. (proc_getpgid): ditto. (proc_setpgid): ditto. (proc_setsid): ditto. (proc_getpriority): ditto. (proc_setpriority): ditto. (proc_getrlimit): ditto. (proc_setrlimit): ditto. (p_sys_setuid): ditto. (p_sys_setruid): ditto. (p_sys_seteuid): ditto. (p_sys_setreuid): ditto. (p_sys_setresuid): ditto. (p_sys_setgid): ditto. (p_sys_setrgid): ditto. (p_sys_setegid): ditto. (p_sys_setregid): ditto. (p_sys_setreuid): ditto. (p_sys_setresgid): ditto. (p_sys_issetugid): ditto. (proc_getgroups): ditto. (proc_setgroups): ditto. (proc_initgroups): ditto. (proc_daemon): ditto. (rb_proc_times): ditto. * file.c (rb_file_s_lchown): ditto. (rb_file_s_link): ditto. (rb_file_s_symlink): ditto. (rb_file_s_readlink): ditto. (rb_file_s_truncate): ditto. (rb_file_truncate): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/file.c b/file.c
index 5a9d04f927..40bf0267af 100644
--- a/file.c
+++ b/file.c
@@ -2066,11 +2066,7 @@ rb_file_s_lchown(int argc, VALUE *argv)
return LONG2FIX(n);
}
#else
-static VALUE
-rb_file_s_lchown(int argc, VALUE *argv)
-{
- rb_notimplement();
-}
+#define rb_file_s_lchown rb_f_notimplement
#endif
struct timespec rb_time_timespec(VALUE time);
@@ -2244,6 +2240,7 @@ sys_fail2(VALUE s1, VALUE s2)
rb_sys_fail(buf);
}
+#ifdef HAVE_LINK
/*
* call-seq:
* File.link(old_name, new_name) => 0
@@ -2259,7 +2256,6 @@ sys_fail2(VALUE s1, VALUE s2)
static VALUE
rb_file_s_link(VALUE klass, VALUE from, VALUE to)
{
-#ifdef HAVE_LINK
rb_secure(2);
FilePathValue(from);
FilePathValue(to);
@@ -2268,12 +2264,12 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
sys_fail2(from, to);
}
return INT2FIX(0);
+}
#else
- rb_notimplement();
- return Qnil; /* not reached */
+#define rb_file_s_link rb_f_notimplement
#endif
-}
+#ifdef HAVE_SYMLINK
/*
* call-seq:
* File.symlink(old_name, new_name) => 0
@@ -2289,7 +2285,6 @@ rb_file_s_link(VALUE klass, VALUE from, VALUE to)
static VALUE
rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
{
-#ifdef HAVE_SYMLINK
rb_secure(2);
FilePathValue(from);
FilePathValue(to);
@@ -2298,12 +2293,12 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
sys_fail2(from, to);
}
return INT2FIX(0);
+}
#else
- rb_notimplement();
- return Qnil; /* not reached */
+#define rb_file_s_symlink rb_f_notimplement
#endif
-}
+#ifdef HAVE_READLINK
/*
* call-seq:
* File.readlink(link_name) -> file_name
@@ -2318,7 +2313,6 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to)
static VALUE
rb_file_s_readlink(VALUE klass, VALUE path)
{
-#ifdef HAVE_READLINK
char *buf;
int size = 100;
ssize_t rv;
@@ -2343,11 +2337,10 @@ rb_file_s_readlink(VALUE klass, VALUE path)
xfree(buf);
return v;
+}
#else
- rb_notimplement();
- return Qnil; /* not reached */
+#define rb_file_s_readlink rb_f_notimplement
#endif
-}
static void
unlink_internal(const char *path, void *arg)
@@ -3383,6 +3376,7 @@ rb_file_s_join(VALUE klass, VALUE args)
return rb_file_join(args, separator);
}
+#if defined(HAVE_TRUNCATE) || defined(HAVE_CHSIZE)
/*
* call-seq:
* File.truncate(file_name, integer) => 0
@@ -3409,8 +3403,7 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
#ifdef HAVE_TRUNCATE
if (truncate(StringValueCStr(path), pos) < 0)
rb_sys_fail(RSTRING_PTR(path));
-#else
-# ifdef HAVE_CHSIZE
+#else /* defined(HAVE_CHSIZE) */
{
int tmpfd;
@@ -3429,13 +3422,14 @@ rb_file_s_truncate(VALUE klass, VALUE path, VALUE len)
}
close(tmpfd);
}
-# else
- rb_notimplement();
-# endif
#endif
return INT2FIX(0);
}
+#else
+#define rb_file_s_truncate rb_f_notimplement
+#endif
+#if defined(HAVE_FTRUNCATE) || defined(HAVE_CHSIZE)
/*
* call-seq:
* file.truncate(integer) => 0
@@ -3466,16 +3460,15 @@ rb_file_truncate(VALUE obj, VALUE len)
#ifdef HAVE_FTRUNCATE
if (ftruncate(fptr->fd, pos) < 0)
rb_sys_fail_path(fptr->pathv);
-#else
-# ifdef HAVE_CHSIZE
+#else /* defined(HAVE_CHSIZE) */
if (chsize(fptr->fd, pos) < 0)
rb_sys_fail(fptr->pathv);
-# else
- rb_notimplement();
-# endif
#endif
return INT2FIX(0);
}
+#else
+#define rb_file_truncate rb_f_notimplement
+#endif
# ifndef LOCK_SH
# define LOCK_SH 1