Permalink
Browse files

* io.c (set_outfile): f should be the FILE* from the assigning value.

* ext/socket/socket.c (tcp_s_open): should not give default value
  to local_host.

* time.c (time_s_times): move to Process::times.

* file.c (rb_file_s_lchmod): new method File::lchmod.

* file.c (rb_file_s_lchown): new method File::lchown.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 90248f8 commit d4cab5cd66af1263de18681a5b09940abcc71a95 matz committed Feb 16, 2001
Showing with 173 additions and 59 deletions.
  1. +14 −1 ChangeLog
  2. +5 −4 ToDo
  3. +1 −1 configure.in
  4. +0 −5 ext/socket/socket.c
  5. +85 −0 file.c
  6. +1 −0 intern.h
  7. +0 −2 io.c
  8. +63 −14 process.c
  9. +2 −30 time.c
  10. +2 −2 version.h
View
@@ -1,3 +1,16 @@
+Fri Feb 16 01:44:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (set_outfile): f should be the FILE* from the assigning value.
+
+ * ext/socket/socket.c (tcp_s_open): should not give default value
+ to local_host.
+
+ * time.c (time_s_times): move to Process::times.
+
+ * file.c (rb_file_s_lchmod): new method File::lchmod.
+
+ * file.c (rb_file_s_lchown): new method File::lchown.
+
Thu Feb 15 11:33:49 2001 Shugo Maeda <shugo@ruby-lang.org>
* lib/cgi/session.rb (close): fixed reversed condition.
@@ -3271,7 +3284,7 @@ Sat Apr 1 22:50:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
Sat Apr 1 21:30:53 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
- * io.c(rb_io_printf, rb_f_printf): should use rb_io_write.
+ * io.c (rb_io_printf, rb_f_printf): should use rb_io_write.
Sat Apr 1 00:16:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
View
@@ -20,7 +20,7 @@ Language Spec.
+ remove scope by block
+ variables appears within block may have independent values.
* Regexp: make /o thread safe.
-* decide if begin with rescue or ensure make do..while loop.
+* decide whether begin with rescue or ensure make do..while loop.
* a +1 to be a+1, not a(+1).
* unify == and eql? again
* to_i returns nil if str contains no digit.
@@ -51,6 +51,10 @@ Standard Libraries
- Enume#inject
- Array#fetch
- IO::for_fd
+- Process::waitall [ruby-talk:4557]
+- Process::Status
+- File::lchown, File::lchmod; xxx - still need work for non existing platforms
+- move Time::times to Process.
* Enumerable#sort_by for Schwartzian transformation
* String#scanf(?)
* Object#fmt(?)
@@ -63,16 +67,13 @@ Standard Libraries
* optional stepsize argument for succ()
* Ruby module -- Ruby::Version, Ruby::Interpreter
* introduce Boolean class; super of TrueClass, FalseClass
-* Process::waitall [ruby-talk:4557]
* synchronized method - synchronized{...}, synchronized :foo, :bar
-* move Time::times to Process.
* Array#&, Array#| to allow duplication. ???
* fork_and_kill_other_threads.
* way to specify immortal (fork endurance) thread;
* or raise ForkException to every thread but fork caller.
* Hash::new{default} or recommend Hash#fetch?
* new user-defined marshal scheme. _dump(dumper), _load(restorer)
-* lchown, lchmod, etc.
Extension Libraries
View
@@ -248,7 +248,7 @@ AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
truncate chsize times utimes fcntl lockf lstat symlink readlink\
setitimer setruid seteuid setreuid setresuid \
- setrgid setegid setregid setresgid pause\
+ setrgid setegid setregid setresgid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\
dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod)
AC_STRUCT_TIMEZONE
View
@@ -895,16 +895,11 @@ tcp_s_open(argc, argv, class)
&local_host, &local_serv);
Check_SafeStr(remote_host);
-
if (!NIL_P(local_host)) {
Check_SafeStr(local_host);
}
- if (NIL_P(local_serv)) {
- local_serv = INT2NUM(0);
- }
-
return open_inet(class, remote_host, remote_serv,
local_host, local_serv, INET_CLIENT);
}
View
@@ -951,6 +951,42 @@ rb_file_chmod(obj, vmode)
return INT2FIX(0);
}
+#if defined(HAVE_LCHMOD)
+static void
+lchmod_internal(path, mode)
+ const char *path;
+ int mode;
+{
+ if (lchmod(path, mode) == -1)
+ rb_sys_fail(path);
+}
+
+static VALUE
+rb_file_s_lchmod(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE vmode;
+ VALUE rest;
+ int mode, n;
+
+ rb_secure(2);
+ rb_scan_args(argc, argv, "1*", &vmode, &rest);
+ mode = NUM2INT(vmode);
+
+ n = apply2files(lchmod_internal, rest, mode);
+ return INT2FIX(n);
+}
+#else
+static VALUE
+rb_file_s_lchmod(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ rb_notimplement();
+}
+#endif
+
struct chown_args {
int owner, group;
};
@@ -1012,6 +1048,53 @@ rb_file_chown(obj, owner, group)
return INT2FIX(0);
}
+#if defined(HAVE_LCHOWN)
+static void
+lchown_internal(path, args)
+ const char *path;
+ struct chown_args *args;
+{
+ if (lchown(path, args->owner, args->group) < 0)
+ rb_sys_fail(path);
+}
+
+static VALUE
+rb_file_s_lchown(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE o, g, rest;
+ struct chown_args arg;
+ int n;
+
+ rb_secure(2);
+ rb_scan_args(argc, argv, "2*", &o, &g, &rest);
+ if (NIL_P(o)) {
+ arg.owner = -1;
+ }
+ else {
+ arg.owner = NUM2INT(o);
+ }
+ if (NIL_P(g)) {
+ arg.group = -1;
+ }
+ else {
+ arg.group = NUM2INT(g);
+ }
+
+ n = apply2files(lchown_internal, rest, &arg);
+ return INT2FIX(n);
+}
+#else
+static VALUE
+rb_file_s_lchown(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ rb_notimplement();
+}
+#endif
+
struct timeval rb_time_timeval();
#if defined(HAVE_UTIMES) && !defined(__CHECKER__)
@@ -2206,6 +2289,8 @@ Init_File()
rb_define_singleton_method(rb_cFile, "utime", rb_file_s_utime, -1);
rb_define_singleton_method(rb_cFile, "chmod", rb_file_s_chmod, -1);
rb_define_singleton_method(rb_cFile, "chown", rb_file_s_chown, -1);
+ rb_define_singleton_method(rb_cFile, "lchmod", rb_file_s_lchmod, -1);
+ rb_define_singleton_method(rb_cFile, "lchown", rb_file_s_lchown, -1);
rb_define_singleton_method(rb_cFile, "link", rb_file_s_link, 2);
rb_define_singleton_method(rb_cFile, "symlink", rb_file_s_symlink, 2);
View
@@ -260,6 +260,7 @@ void rb_lastline_set _((VALUE));
/* process.c */
int rb_proc_exec _((const char*));
void rb_syswait _((int));
+VALUE rb_proc_times _((VALUE));
/* range.c */
VALUE rb_range_new _((VALUE, VALUE, int));
VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
View
@@ -2242,8 +2242,6 @@ set_outfile(val, var, orig, stdf)
GetOpenFile(val, fptr);
rb_io_check_writable(fptr);
-
- GetOpenFile(*var, fptr);
f = GetWriteFile(fptr);
dup2(fileno(f), fileno(stdf));
View
@@ -49,6 +49,14 @@ struct timeval rb_time_interval _((VALUE));
#undef HAVE_GETPGRP
#endif
+#ifdef HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+
+#if defined(HAVE_TIMES) || defined(NT)
+static VALUE S_Tms;
+#endif
+
static VALUE
get_pid()
{
@@ -108,7 +116,16 @@ pst_bitand(st1, st2)
}
static VALUE
-pst_ifstopped(st)
+pst_rshift(st1, st2)
+ VALUE st1, st2;
+{
+ int status = NUM2INT(st1) >> NUM2INT(st2);
+
+ return INT2NUM(status);
+}
+
+static VALUE
+pst_wifstopped(st)
VALUE st;
{
int status = NUM2INT(st);
@@ -120,7 +137,7 @@ pst_ifstopped(st)
}
static VALUE
-pst_stopsig(st)
+pst_wstopsig(st)
VALUE st;
{
int status = NUM2INT(st);
@@ -129,7 +146,7 @@ pst_stopsig(st)
}
static VALUE
-pst_ifsignaled(st)
+pst_wifsignaled(st)
VALUE st;
{
int status = NUM2INT(st);
@@ -141,7 +158,7 @@ pst_ifsignaled(st)
}
static VALUE
-pst_termsig(st)
+pst_wtermsig(st)
VALUE st;
{
int status = NUM2INT(st);
@@ -150,7 +167,7 @@ pst_termsig(st)
}
static VALUE
-pst_ifexited(st)
+pst_wifexited(st)
VALUE st;
{
int status = NUM2INT(st);
@@ -162,7 +179,7 @@ pst_ifexited(st)
}
static VALUE
-pst_exitstatus(st)
+pst_wexitstatus(st)
VALUE st;
{
int status = NUM2INT(st);
@@ -171,7 +188,7 @@ pst_exitstatus(st)
}
static VALUE
-pst_coredump(st)
+pst_wcoredump(st)
VALUE st;
{
#ifdef WCOREDUMP
@@ -1254,6 +1271,31 @@ proc_setegid(obj, egid)
return egid;
}
+VALUE
+rb_proc_times(obj)
+ VALUE obj;
+{
+#if defined(HAVE_TIMES) && !defined(__CHECKER__)
+#ifndef HZ
+# ifdef CLK_TCK
+# define HZ CLK_TCK
+# else
+# define HZ 60
+# endif
+#endif /* HZ */
+ struct tms buf;
+
+ if (times(&buf) == -1) rb_sys_fail(0);
+ return rb_struct_new(S_Tms,
+ rb_float_new((double)buf.tms_utime / HZ),
+ rb_float_new((double)buf.tms_stime / HZ),
+ rb_float_new((double)buf.tms_cutime / HZ),
+ rb_float_new((double)buf.tms_cstime / HZ));
+#else
+ rb_notimplement();
+#endif
+}
+
VALUE rb_mProcess;
void
@@ -1297,18 +1339,19 @@ Init_process()
rb_define_method(rb_cProcStatus, "==", pst_equal, 1);
rb_define_method(rb_cProcStatus, "&", pst_bitand, 1);
+ rb_define_method(rb_cProcStatus, ">>", pst_rshift, 1);
rb_define_method(rb_cProcStatus, "to_i", pst_to_i, 0);
rb_define_method(rb_cProcStatus, "to_int", pst_to_i, 0);
rb_define_method(rb_cProcStatus, "to_s", pst_to_s, 0);
rb_define_method(rb_cProcStatus, "inspect", pst_to_s, 0);
- rb_define_method(rb_cProcStatus, "ifstopped?", pst_ifstopped, 0);
- rb_define_method(rb_cProcStatus, "stopsig", pst_stopsig, 0);
- rb_define_method(rb_cProcStatus, "ifsignaled?", pst_ifsignaled, 0);
- rb_define_method(rb_cProcStatus, "termsig", pst_termsig, 0);
- rb_define_method(rb_cProcStatus, "ifexited?", pst_ifexited, 0);
- rb_define_method(rb_cProcStatus, "exitstatus", pst_exitstatus, 0);
- rb_define_method(rb_cProcStatus, "coredump?", pst_coredump, 0);
+ rb_define_method(rb_cProcStatus, "stopped?", pst_wifstopped, 0);
+ rb_define_method(rb_cProcStatus, "stopsig", pst_wstopsig, 0);
+ rb_define_method(rb_cProcStatus, "signaled?", pst_wifsignaled, 0);
+ rb_define_method(rb_cProcStatus, "termsig", pst_wtermsig, 0);
+ rb_define_method(rb_cProcStatus, "exited?", pst_wifexited, 0);
+ rb_define_method(rb_cProcStatus, "exitstatus", pst_wexitstatus, 0);
+ rb_define_method(rb_cProcStatus, "coredump?", pst_wcoredump, 0);
rb_define_module_function(rb_mProcess, "pid", get_pid, 0);
rb_define_module_function(rb_mProcess, "ppid", get_ppid, 0);
@@ -1338,4 +1381,10 @@ Init_process()
rb_define_module_function(rb_mProcess, "euid=", proc_seteuid, 1);
rb_define_module_function(rb_mProcess, "egid", proc_getegid, 0);
rb_define_module_function(rb_mProcess, "egid=", proc_setegid, 1);
+
+ rb_define_module_function(rb_mProcess, "times", rb_proc_times, 0);
+
+#if defined(HAVE_TIMES) || defined(NT)
+ S_Tms = rb_struct_define("Tms", "utime", "stime", "cutime", "cstime", 0);
+#endif
}
Oops, something went wrong. Retry.

0 comments on commit d4cab5c

Please sign in to comment.