[前][次][番号順一覧][スレッド一覧]

ruby-changes:11563

From: akr <ko1@a...>
Date: Fri, 17 Apr 2009 01:58:23 +0900 (JST)
Subject: [ruby-changes:11563] Ruby:r23197 (trunk): * node.h (rb_notimplement_body_p): declared.

akr	2009-04-17 01:58:06 +0900 (Fri, 17 Apr 2009)

  New Revision: 23197

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23197

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/dir.c
    trunk/file.c
    trunk/io.c
    trunk/node.h
    trunk/process.c
    trunk/vm_method.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23196)
+++ ChangeLog	(revision 23197)
@@ -1,3 +1,53 @@
+Fri Apr 17 01:51:17 2009  Tanaka Akira  <akr@f...>
+
+	* 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.
+
 Fri Apr 17 00:53:47 2009  Yusuke Endoh  <mame@t...>
 
 	* lib/cgi/core.rb (read_multipart): When path is not defined,
Index: io.c
===================================================================
--- io.c	(revision 23196)
+++ io.c	(revision 23197)
@@ -1282,6 +1282,7 @@
     return sync;
 }
 
+#ifdef HAVE_FSYNC
 /*
  *  call-seq:
  *     ios.fsync   => 0 or nil
@@ -1297,7 +1298,6 @@
 static VALUE
 rb_io_fsync(VALUE io)
 {
-#ifdef HAVE_FSYNC
     rb_io_t *fptr;
 
     io = GetWriteIO(io);
@@ -1308,11 +1308,10 @@
     if (fsync(fptr->fd) < 0)
 	rb_sys_fail_path(fptr->pathv);
     return INT2FIX(0);
+}
 #else
-    rb_notimplement();
-    return Qnil;		/* not reached */
+#define rb_io_fsync rb_f_notimplement
 #endif
-}
 
 /*
  *  call-seq:
@@ -3024,6 +3023,7 @@
     return Qtrue;
 }
 
+#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
 /*
  *  call-seq:
  *     ios.close_on_exec?   => true or false
@@ -3041,7 +3041,6 @@
 static VALUE
 rb_io_close_on_exec_p(VALUE io)
 {
-#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
     rb_io_t *fptr;
     VALUE write_io;
     int fd, ret;
@@ -3061,12 +3060,12 @@
         if (!(ret & FD_CLOEXEC)) return Qfalse;
     }
     return Qtrue;
+}
 #else
-    rb_notimplement();
-    return Qnil;		/* not reached */
+#define rb_io_close_on_exec_p rb_f_notimplement
 #endif
-}
 
+#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
 /*
  *  call-seq:
  *     ios.close_on_exec = bool    => true or false
@@ -3082,7 +3081,6 @@
 static VALUE
 rb_io_set_close_on_exec(VALUE io, VALUE arg)
 {
-#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
     int flag = RTEST(arg) ? FD_CLOEXEC : 0;
     rb_io_t *fptr;
     VALUE write_io;
@@ -3111,11 +3109,11 @@
             if (ret == -1) rb_sys_fail_path(fptr->pathv);
         }
     }
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define rb_io_set_close_on_exec rb_f_notimplement
+#endif
 
 #define FMODE_PREP (1<<16)
 #define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
@@ -6937,6 +6935,7 @@
     return rb_io_ctl(io, req, arg, 1);
 }
 
+#ifdef HAVE_FCNTL
 /*
  *  call-seq:
  *     ios.fcntl(integer_cmd, arg)    => integer
@@ -6953,17 +6952,16 @@
 static VALUE
 rb_io_fcntl(int argc, VALUE *argv, VALUE io)
 {
-#ifdef HAVE_FCNTL
     VALUE req, arg;
 
     rb_scan_args(argc, argv, "11", &req, &arg);
     return rb_io_ctl(io, req, arg, 0);
+}
 #else
-    rb_notimplement();
-    return Qnil;		/* not reached */
+#define rb_io_fcntl rb_f_notimplement
 #endif
-}
 
+#if defined(HAVE_SYSCALL) && !defined(__CHECKER__)
 /*
  *  call-seq:
  *     syscall(fixnum [, args...])   => integer
@@ -6986,7 +6984,6 @@
 static VALUE
 rb_f_syscall(int argc, VALUE *argv)
 {
-#if defined(HAVE_SYSCALL) && !defined(__CHECKER__)
 #ifdef atarist
     unsigned long arg[14]; /* yes, we really need that many ! */
 #else
@@ -7078,11 +7075,10 @@
 
     if (retval < 0) rb_sys_fail(0);
     return INT2NUM(retval);
+}
 #else
-    rb_notimplement();
-    return Qnil;		/* not reached */
+#define rb_f_syscall rb_f_notimplement
 #endif
-}
 
 static VALUE
 io_new_instance(VALUE args)
Index: dir.c
===================================================================
--- dir.c	(revision 23196)
+++ dir.c	(revision 23197)
@@ -550,6 +550,7 @@
     return dir;
 }
 
+#ifdef HAVE_TELLDIR
 /*
  *  call-seq:
  *     dir.pos => integer
@@ -566,18 +567,18 @@
 static VALUE
 dir_tell(VALUE dir)
 {
-#ifdef HAVE_TELLDIR
     struct dir_data *dirp;
     long pos;
 
     GetDIR(dir, dirp);
     pos = telldir(dirp->dir);
     return rb_int2inum(pos);
+}
 #else
-    rb_notimplement();
+#define dir_tell rb_f_notimplement
 #endif
-}
 
+#ifdef HAVE_SEEKDIR
 /*
  *  call-seq:
  *     dir.seek( integer ) => dir
@@ -599,13 +600,12 @@
     long p = NUM2LONG(pos);
 
     GetDIR(dir, dirp);
-#ifdef HAVE_SEEKDIR
     seekdir(dirp->dir, p);
     return dir;
+}
 #else
-    rb_notimplement();
+#define dir_seek rb_f_notimplement
 #endif
-}
 
 /*
  *  call-seq:
@@ -826,6 +826,7 @@
     }
 }
 
+#if defined(HAVE_CHROOT) && !defined(__CHECKER__)
 /*
  *  call-seq:
  *     Dir.chroot( string ) => 0
@@ -838,18 +839,16 @@
 static VALUE
 dir_s_chroot(VALUE dir, VALUE path)
 {
-#if defined(HAVE_CHROOT) && !defined(__CHECKER__)
     check_dirname(&path);
 
     if (chroot(RSTRING_PTR(path)) == -1)
 	rb_sys_fail(RSTRING_PTR(path));
 
     return INT2FIX(0);
+}
 #else
-    rb_notimplement();
-    return Qnil;		/* not reached */
+#define dir_s_chroot rb_f_notimplement
 #endif
-}
 
 /*
  *  call-seq:
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 23196)
+++ vm_method.c	(revision 23197)
@@ -1160,7 +1160,7 @@
     undefined = rb_intern("method_undefined");
     singleton_undefined = rb_intern("singleton_method_undefined");
 
-    rb_global_variable(&notimplement_body);
+    rb_global_variable((VALUE*)&notimplement_body);
     notimplement_body = NEW_CFUNC(rb_f_notimplement, -1);
 }
 
Index: process.c
===================================================================
--- process.c	(revision 23196)
+++ process.c	(revision 23197)
@@ -2580,6 +2580,7 @@
 
 #endif
 
+#if defined(HAVE_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD)
 /*
  *  call-seq:
  *     Kernel.fork  [{ block }]   => fixnum or nil
@@ -2601,7 +2602,6 @@
  *  fork doesn't copy other threads.
  */
 
-#if defined(HAVE_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD)
 static VALUE
 rb_f_fork(VALUE obj)
 {
@@ -3251,6 +3251,7 @@
 }
 
 
+#if (defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)) || defined(HAVE_GETPGID)
 /*
  *  call-seq:
  *     Process.getpgrp   => integer
@@ -3265,27 +3266,25 @@
 static VALUE
 proc_getpgrp(void)
 {
-#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) || defined(HAVE_GETPGID)
     rb_pid_t pgrp;
-#endif
 
     rb_secure(2);
 #if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
     pgrp = getpgrp();
     if (pgrp < 0) rb_sys_fail(0);
     return PIDT2NUM(pgrp);
-#else
-# ifdef HAVE_GETPGID
+#else /* defined(HAVE_GETPGID) */
     pgrp = getpgid(0);
     if (pgrp < 0) rb_sys_fail(0);
     return PIDT2NUM(pgrp);
-# else
-    rb_notimplement();
-# endif
 #endif
 }
+#else
+#define proc_getpgrp rb_f_notimplement
+#endif
 
 
+#if defined(HAVE_SETPGID) || (defined(HAVE_SETPGRP) && defined(SETPGRP_VOID))
 /*
  *  call-seq:
  *     Process.setpgrp   => 0
@@ -3304,15 +3303,17 @@
   /* this confusion. */
 #ifdef HAVE_SETPGID
     if (setpgid(0,0) < 0) rb_sys_fail(0);
-#elif defined(HAVE_SETPGRP) && defined(SETPGRP_VOID)
+#else /* defined(HAVE_SETPGRP) && defined(SETPGRP_VOID) */
     if (setpgrp() < 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
 #endif
     return INT2FIX(0);
 }
+#else
+#define proc_setpgrp rb_f_notimplement
+#endif
 
 
+#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
 /*
  *  call-seq:
  *     Process.getpgid(pid)   => integer
@@ -3326,19 +3327,19 @@
 static VALUE
 proc_getpgid(VALUE obj, VALUE pid)
 {
-#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
     rb_pid_t i;
 
     rb_secure(2);
     i = getpgid(NUM2PIDT(pid));
     if (i < 0) rb_sys_fail(0);
     return PIDT2NUM(i);
+}
 #else
-    rb_notimplement();
+#define proc_getpgid rb_f_notimplement
 #endif
-}
 
 
+#ifdef HAVE_SETPGID
 /*
  *  call-seq:
  *     Process.setpgid(pid, integer)   => 0
@@ -3350,7 +3351,6 @@
 static VALUE
 proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
 {
-#ifdef HAVE_SETPGID
     rb_pid_t ipid, ipgrp;
 
     rb_secure(2);
@@ -3359,12 +3359,13 @@
 
     if (setpgid(ipid, ipgrp) < 0) rb_sys_fail(0);
     return INT2FIX(0);
+}
 #else
-    rb_notimplement();
+#define proc_setpgid rb_f_notimplement
 #endif
-}
 
 
+#if defined(HAVE_SETSID) || (defined(HAVE_SETPGRP) && defined(TIOCNOTTY))
 /*
  *  call-seq:
  *     Process.setsid   => fixnum
@@ -3386,7 +3387,7 @@
     pid = setsid();
     if (pid < 0) rb_sys_fail(0);
     return PIDT2NUM(pid);
-#elif defined(HAVE_SETPGRP) && defined(TIOCNOTTY)
+#else /* defined(HAVE_SETPGRP) && defined(TIOCNOTTY) */
     rb_pid_t pid;
     int ret;
 
@@ -3407,12 +3408,14 @@
 	close(fd);
     }
     return PIDT2NUM(pid);
-#else
-    rb_notimplement();
 #endif
 }
+#else
+#define proc_setsid rb_f_notimplement
+#endif
 
 
+#ifdef HAVE_GETPRIORITY
 /*
  *  call-seq:
  *     Process.getpriority(kind, integer)   => fixnum
@@ -3433,7 +3436,6 @@
 static VALUE
 proc_getpriority(VALUE obj, VALUE which, VALUE who)
 {
-#ifdef HAVE_GETPRIORITY
     int prio, iwhich, iwho;
 
     rb_secure(2);
@@ -3444,12 +3446,13 @@
     prio = getpriority(iwhich, iwho);
     if (errno) rb_sys_fail(0);
     return INT2FIX(prio);
+}
 #else
-    rb_notimplement();
+#define proc_getpriority rb_f_notimplement
 #endif
-}
 
 
+#ifdef HAVE_GETPRIORITY
 /*
  *  call-seq:
  *     Process.setpriority(kind, integer, priority)   => 0
@@ -3465,7 +3468,6 @@
 static VALUE
 proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio)
 {
-#ifdef HAVE_GETPRIORITY
     int iwhich, iwho, iprio;
 
     rb_secure(2);
@@ -3476,10 +3478,10 @@
     if (setpriority(iwhich, iwho, iprio) < 0)
 	rb_sys_fail(0);
     return INT2FIX(0);
+}
 #else
-    rb_notimplement();
+#define proc_setpriority rb_f_notimplement
 #endif
-}
 
 #if defined(RLIM2NUM)
 static int
@@ -3645,6 +3647,7 @@
 }
 #endif
 
+#if defined(HAVE_GETRLIMIT) && defined(RLIM2NUM)
 /*
  *  call-seq:
  *     Process.getrlimit(resource)   => [cur_limit, max_limit]
@@ -3668,7 +3671,6 @@
 static VALUE
 proc_getrlimit(VALUE obj, VALUE resource)
 {
-#if defined(HAVE_GETRLIMIT) && defined(RLIM2NUM)
     struct rlimit rlim;
 
     rb_secure(2);
@@ -3677,11 +3679,12 @@
 	rb_sys_fail("getrlimit");
     }
     return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max));
+}
 #else
-    rb_notimplement();
+#define proc_getrlimit rb_f_notimplement
 #endif
-}
 
+#if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
 /*
  *  call-seq:
  *     Process.setrlimit(resource, cur_limit, max_limit)        => nil
@@ -3731,7 +3734,6 @@
 static VALUE
 proc_setrlimit(int argc, VALUE *argv, VALUE obj)
 {
-#if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
     VALUE resource, rlim_cur, rlim_max;
     struct rlimit rlim;
 
@@ -3748,10 +3750,10 @@
 	rb_sys_fail("setrlimit");
     }
     return Qnil;
+}
 #else
-    rb_notimplement();
+#define proc_setrlimit rb_f_notimplement
 #endif
-}
 
 static int under_uid_switch = 0;
 static void
@@ -3785,6 +3787,7 @@
  */
 
 
+#if defined HAVE_SETUID
 /*
  *  call-seq:
  *     Process::Sys.setuid(integer)   => nil
@@ -3797,17 +3800,16 @@
 static VALUE
 p_sys_setuid(VALUE obj, VALUE id)
 {
-#if defined HAVE_SETUID
     check_uid_switch();
     if (setuid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setuid rb_f_notimplement
+#endif
 
 
-
+#if defined HAVE_SETRUID
 /*
  *  call-seq:
  *     Process::Sys.setruid(integer)   => nil
@@ -3820,16 +3822,16 @@
 static VALUE
 p_sys_setruid(VALUE obj, VALUE id)
 {
-#if defined HAVE_SETRUID
     check_uid_switch();
     if (setruid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setruid rb_f_notimplement
+#endif
 
 
+#if defined HAVE_SETEUID
 /*
  *  call-seq:
  *     Process::Sys.seteuid(integer)   => nil
@@ -3842,16 +3844,16 @@
 static VALUE
 p_sys_seteuid(VALUE obj, VALUE id)
 {
-#if defined HAVE_SETEUID
     check_uid_switch();
     if (seteuid(NUM2UIDT(id)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_seteuid rb_f_notimplement
+#endif
 
 
+#if defined HAVE_SETREUID
 /*
  *  call-seq:
  *     Process::Sys.setreuid(rid, eid)   => nil
@@ -3866,16 +3868,16 @@
 static VALUE
 p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
 {
-#if defined HAVE_SETREUID
     check_uid_switch();
     if (setreuid(NUM2UIDT(rid),NUM2UIDT(eid)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setreuid rb_f_notimplement
+#endif
 
 
+#if defined HAVE_SETRESUID
 /*
  *  call-seq:
  *     Process::Sys.setresuid(rid, eid, sid)   => nil
@@ -3890,14 +3892,13 @@
 static VALUE
 p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
 {
-#if defined HAVE_SETRESUID
     check_uid_switch();
     if (setresuid(NUM2UIDT(rid),NUM2UIDT(eid),NUM2UIDT(sid)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setresuid rb_f_notimplement
+#endif
 
 
 /*
@@ -4137,6 +4138,7 @@
 
 
 
+#if defined HAVE_SETGID
 /*
  *  call-seq:
  *     Process::Sys.setgid(integer)   => nil
@@ -4149,16 +4151,16 @@
 static VALUE
 p_sys_setgid(VALUE obj, VALUE id)
 {
-#if defined HAVE_SETGID
     check_gid_switch();
     if (setgid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setgid rb_f_notimplement
+#endif
 
 
+#if defined HAVE_SETRGID
 /*
  *  call-seq:
  *     Process::Sys.setrgid(integer)   => nil
@@ -4171,17 +4173,16 @@
 static VALUE
 p_sys_setrgid(VALUE obj, VALUE id)
 {
-#if defined HAVE_SETRGID
     check_gid_switch();
     if (setrgid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setrgid rb_f_notimplement
+#endif
 
 
-
+#if defined HAVE_SETEGID
 /*
  *  call-seq:
  *     Process::Sys.setegid(integer)   => nil
@@ -4194,16 +4195,16 @@
 static VALUE
 p_sys_setegid(VALUE obj, VALUE id)
 {
-#if defined HAVE_SETEGID
     check_gid_switch();
     if (setegid(NUM2GIDT(id)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setegid rb_f_notimplement
+#endif
 
 
+#if defined HAVE_SETREGID
 /*
  *  call-seq:
  *     Process::Sys.setregid(rid, eid)   => nil
@@ -4218,15 +4219,15 @@
 static VALUE
 p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
 {
-#if defined HAVE_SETREGID
     check_gid_switch();
     if (setregid(NUM2GIDT(rid),NUM2GIDT(eid)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setregid rb_f_notimplement
+#endif
 
+#if defined HAVE_SETRESGID
 /*
  *  call-seq:
  *     Process::Sys.setresgid(rid, eid, sid)   => nil
@@ -4241,16 +4242,16 @@
 static VALUE
 p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
 {
-#if defined HAVE_SETRESGID
     check_gid_switch();
     if (setresgid(NUM2GIDT(rid),NUM2GIDT(eid),NUM2GIDT(sid)) != 0) rb_sys_fail(0);
-#else
-    rb_notimplement();
-#endif
     return Qnil;
 }
+#else
+#define p_sys_setresgid rb_f_notimplement
+#endif
 
 
+#if defined HAVE_ISSETUGID
 /*
  *  call-seq:
  *     Process::Sys.issetugid   => true or false
@@ -4266,18 +4267,16 @@
 static VALUE
 p_sys_issetugid(VALUE obj)
 {
-#if defined HAVE_ISSETUGID
     rb_secure(2);
     if (issetugid()) {
 	return Qtrue;
     } else {
 	return Qfalse;
     }
+}
 #else
-    rb_notimplement();
-    return Qnil;		/* not reached */
+#define p_sys_issetugid rb_f_notimplement
 #endif
-}
 
 
 /*
@@ -4339,6 +4338,7 @@
 static size_t maxgroups = 32;
 
 
+#ifdef HAVE_GETGROUPS
 /*
  *  call-seq:
  *     Process.groups   => array
@@ -4353,7 +4353,6 @@
 static VALUE
 proc_getgroups(VALUE obj)
 {
-#ifdef HAVE_GETGROUPS
     VALUE ary;
     size_t ngroups;
     rb_gid_t *groups;
@@ -4370,13 +4369,13 @@
 	rb_ary_push(ary, GIDT2NUM(groups[i]));
 
     return ary;
+}
 #else
-    rb_notimplement();
-    return Qnil;
+#define proc_getgroups rb_f_notimplement
 #endif
-}
 
 
+#ifdef HAVE_SETGROUPS
 /*
  *  call-seq:
  *     Process.groups= array   => array
@@ -4393,7 +4392,6 @@
 static VALUE
 proc_setgroups(VALUE obj, VALUE ary)
 {
-#ifdef HAVE_SETGROUPS
     size_t ngroups;
     rb_gid_t *groups;
     int i;
@@ -4434,13 +4432,13 @@
 	rb_sys_fail(0);
 
     return proc_getgroups(obj);
+}
 #else
-    rb_notimplement();
-    return Qnil;
+#define proc_setgroups rb_f_notimplement
 #endif
-}
 
 
+#ifdef HAVE_INITGROUPS
 /*
  *  call-seq:
  *     Process.initgroups(username, gid)   => array
@@ -4461,16 +4459,14 @@
 static VALUE
 proc_initgroups(VALUE obj, VALUE uname, VALUE base_grp)
 {
-#ifdef HAVE_INITGROUPS
     if (initgroups(StringValuePtr(uname), NUM2GIDT(base_grp)) != 0) {
 	rb_sys_fail(0);
     }
     return proc_getgroups(obj);
+}
 #else
-    rb_notimplement();
-    return Qnil;
+#define proc_initgroups rb_f_notimplement
 #endif
-}
 
 
 /*
@@ -4511,6 +4507,7 @@
     return INT2FIX(maxgroups);
 }
 
+#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
 /*
  *  call-seq:
  *     Process.daemon()                        => fixnum
@@ -4528,9 +4525,7 @@
 proc_daemon(int argc, VALUE *argv)
 {
     VALUE nochdir, noclose;
-#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
     int n;
-#endif
 
     rb_secure(2);
     rb_scan_args(argc, argv, "02", &nochdir, &noclose);
@@ -4542,7 +4537,7 @@
     after_fork();
     if (n < 0) rb_sys_fail("daemon");
     return INT2FIX(n);
-#elif defined(HAVE_FORK)
+#else /* defined(HAVE_FORK) */
     switch (rb_fork(0, 0, 0, Qnil)) {
       case -1:
 	return (-1);
@@ -4565,10 +4560,11 @@
 	    (void)close (n);
     }
     return INT2FIX(0);
-#else
-    rb_notimplement();
 #endif
 }
+#else
+#define proc_daemon rb_f_notimplement
+#endif
 
 /********************************************************************
  *
@@ -5306,6 +5302,7 @@
 #endif
 
 
+#if defined(HAVE_TIMES) && !defined(__CHECKER__)
 /*
  *  call-seq:
  *     Process.times   => aStructTms
@@ -5321,7 +5318,6 @@
 VALUE
 rb_proc_times(VALUE obj)
 {
-#if defined(HAVE_TIMES) && !defined(__CHECKER__)
     const double hertz =
 #ifdef HAVE__SC_CLK_TCK
 	(double)sysconf(_SC_CLK_TCK);
@@ -5344,10 +5340,10 @@
 			 stime = DBL2NUM(buf.tms_stime / hertz),
 			 cutime = DBL2NUM(buf.tms_cutime / hertz),
 			 sctime = DBL2NUM(buf.tms_cstime / hertz));
+}
 #else
-    rb_notimplement();
+#define rb_proc_times rb_f_notimplement
 #endif
-}
 
 VALUE rb_mProcess;
 VALUE rb_mProcUID;
Index: NEWS
===================================================================
--- NEWS	(revision 23196)
+++ NEWS	(revision 23197)
@@ -50,7 +50,7 @@
   * Kernel
     * extended methods:
       * respond_to? returns false for not-implemented methods
-        such as fork on Windows.
+        such as Process.fork on Windows.
 
 * rss
 
Index: file.c
===================================================================
--- file.c	(revision 23196)
+++ file.c	(revision 23197)
@@ -2066,11 +2066,7 @@
     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 @@
     rb_sys_fail(buf);
 }
 
+#ifdef HAVE_LINK
 /*
  *  call-seq:
  *     File.link(old_name, new_name)    => 0
@@ -2259,7 +2256,6 @@
 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 @@
 	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 @@
 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 @@
 	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 @@
 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 @@
     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 @@
     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 @@
 #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 @@
 	}
 	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 @@
 #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
Index: node.h
===================================================================
--- node.h	(revision 23196)
+++ node.h	(revision 23197)
@@ -501,6 +501,8 @@
 NODE* rb_method_node(VALUE klass, ID id);
 int rb_node_arity(NODE* node);
 
+int rb_notimplement_body_p(NODE*);
+
 struct global_entry *rb_global_entry(ID);
 VALUE rb_gvar_get(struct global_entry *);
 VALUE rb_gvar_set(struct global_entry *, VALUE);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]