* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@1192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-02-16 07:53:21 +00:00
parent 9ac8f70f3d
commit e1c29a3f13
10 changed files with 173 additions and 59 deletions

View File

@ -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> Thu Feb 15 11:33:49 2001 Shugo Maeda <shugo@ruby-lang.org>
* lib/cgi/session.rb (close): fixed reversed condition. * 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> 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> Sat Apr 1 00:16:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>

9
ToDo
View File

@ -20,7 +20,7 @@ Language Spec.
+ remove scope by block + remove scope by block
+ variables appears within block may have independent values. + variables appears within block may have independent values.
* Regexp: make /o thread safe. * 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). * a +1 to be a+1, not a(+1).
* unify == and eql? again * unify == and eql? again
* to_i returns nil if str contains no digit. * to_i returns nil if str contains no digit.
@ -51,6 +51,10 @@ Standard Libraries
- Enume#inject - Enume#inject
- Array#fetch - Array#fetch
- IO::for_fd - 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 * Enumerable#sort_by for Schwartzian transformation
* String#scanf(?) * String#scanf(?)
* Object#fmt(?) * Object#fmt(?)
@ -63,16 +67,13 @@ Standard Libraries
* optional stepsize argument for succ() * optional stepsize argument for succ()
* Ruby module -- Ruby::Version, Ruby::Interpreter * Ruby module -- Ruby::Version, Ruby::Interpreter
* introduce Boolean class; super of TrueClass, FalseClass * introduce Boolean class; super of TrueClass, FalseClass
* Process::waitall [ruby-talk:4557]
* synchronized method - synchronized{...}, synchronized :foo, :bar * synchronized method - synchronized{...}, synchronized :foo, :bar
* move Time::times to Process.
* Array#&, Array#| to allow duplication. ??? * Array#&, Array#| to allow duplication. ???
* fork_and_kill_other_threads. * fork_and_kill_other_threads.
* way to specify immortal (fork endurance) thread; * way to specify immortal (fork endurance) thread;
* or raise ForkException to every thread but fork caller. * or raise ForkException to every thread but fork caller.
* Hash::new{default} or recommend Hash#fetch? * Hash::new{default} or recommend Hash#fetch?
* new user-defined marshal scheme. _dump(dumper), _load(restorer) * new user-defined marshal scheme. _dump(dumper), _load(restorer)
* lchown, lchmod, etc.
Extension Libraries Extension Libraries

View File

@ -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\ AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
truncate chsize times utimes fcntl lockf lstat symlink readlink\ truncate chsize times utimes fcntl lockf lstat symlink readlink\
setitimer setruid seteuid setreuid setresuid \ setitimer setruid seteuid setreuid setresuid \
setrgid setegid setregid setresgid pause\ setrgid setegid setregid setresgid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\ getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\
dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod) dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod)
AC_STRUCT_TIMEZONE AC_STRUCT_TIMEZONE

View File

@ -895,16 +895,11 @@ tcp_s_open(argc, argv, class)
&local_host, &local_serv); &local_host, &local_serv);
Check_SafeStr(remote_host); Check_SafeStr(remote_host);
if (!NIL_P(local_host)) { if (!NIL_P(local_host)) {
Check_SafeStr(local_host); Check_SafeStr(local_host);
} }
if (NIL_P(local_serv)) {
local_serv = INT2NUM(0);
}
return open_inet(class, remote_host, remote_serv, return open_inet(class, remote_host, remote_serv,
local_host, local_serv, INET_CLIENT); local_host, local_serv, INET_CLIENT);
} }

85
file.c
View File

@ -951,6 +951,42 @@ rb_file_chmod(obj, vmode)
return INT2FIX(0); 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 { struct chown_args {
int owner, group; int owner, group;
}; };
@ -1012,6 +1048,53 @@ rb_file_chown(obj, owner, group)
return INT2FIX(0); 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(); struct timeval rb_time_timeval();
#if defined(HAVE_UTIMES) && !defined(__CHECKER__) #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, "utime", rb_file_s_utime, -1);
rb_define_singleton_method(rb_cFile, "chmod", rb_file_s_chmod, -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, "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, "link", rb_file_s_link, 2);
rb_define_singleton_method(rb_cFile, "symlink", rb_file_s_symlink, 2); rb_define_singleton_method(rb_cFile, "symlink", rb_file_s_symlink, 2);

View File

@ -260,6 +260,7 @@ void rb_lastline_set _((VALUE));
/* process.c */ /* process.c */
int rb_proc_exec _((const char*)); int rb_proc_exec _((const char*));
void rb_syswait _((int)); void rb_syswait _((int));
VALUE rb_proc_times _((VALUE));
/* range.c */ /* range.c */
VALUE rb_range_new _((VALUE, VALUE, int)); VALUE rb_range_new _((VALUE, VALUE, int));
VALUE rb_range_beg_len _((VALUE, long*, long*, long, int)); VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));

2
io.c
View File

@ -2242,8 +2242,6 @@ set_outfile(val, var, orig, stdf)
GetOpenFile(val, fptr); GetOpenFile(val, fptr);
rb_io_check_writable(fptr); rb_io_check_writable(fptr);
GetOpenFile(*var, fptr);
f = GetWriteFile(fptr); f = GetWriteFile(fptr);
dup2(fileno(f), fileno(stdf)); dup2(fileno(f), fileno(stdf));

View File

@ -49,6 +49,14 @@ struct timeval rb_time_interval _((VALUE));
#undef HAVE_GETPGRP #undef HAVE_GETPGRP
#endif #endif
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
#if defined(HAVE_TIMES) || defined(NT)
static VALUE S_Tms;
#endif
static VALUE static VALUE
get_pid() get_pid()
{ {
@ -108,7 +116,16 @@ pst_bitand(st1, st2)
} }
static VALUE 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; VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -120,7 +137,7 @@ pst_ifstopped(st)
} }
static VALUE static VALUE
pst_stopsig(st) pst_wstopsig(st)
VALUE st; VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -129,7 +146,7 @@ pst_stopsig(st)
} }
static VALUE static VALUE
pst_ifsignaled(st) pst_wifsignaled(st)
VALUE st; VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -141,7 +158,7 @@ pst_ifsignaled(st)
} }
static VALUE static VALUE
pst_termsig(st) pst_wtermsig(st)
VALUE st; VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -150,7 +167,7 @@ pst_termsig(st)
} }
static VALUE static VALUE
pst_ifexited(st) pst_wifexited(st)
VALUE st; VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -162,7 +179,7 @@ pst_ifexited(st)
} }
static VALUE static VALUE
pst_exitstatus(st) pst_wexitstatus(st)
VALUE st; VALUE st;
{ {
int status = NUM2INT(st); int status = NUM2INT(st);
@ -171,7 +188,7 @@ pst_exitstatus(st)
} }
static VALUE static VALUE
pst_coredump(st) pst_wcoredump(st)
VALUE st; VALUE st;
{ {
#ifdef WCOREDUMP #ifdef WCOREDUMP
@ -1254,6 +1271,31 @@ proc_setegid(obj, egid)
return 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; VALUE rb_mProcess;
void void
@ -1297,18 +1339,19 @@ Init_process()
rb_define_method(rb_cProcStatus, "==", pst_equal, 1); rb_define_method(rb_cProcStatus, "==", pst_equal, 1);
rb_define_method(rb_cProcStatus, "&", pst_bitand, 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_i", pst_to_i, 0);
rb_define_method(rb_cProcStatus, "to_int", 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, "to_s", pst_to_s, 0);
rb_define_method(rb_cProcStatus, "inspect", 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, "stopped?", pst_wifstopped, 0);
rb_define_method(rb_cProcStatus, "stopsig", pst_stopsig, 0); rb_define_method(rb_cProcStatus, "stopsig", pst_wstopsig, 0);
rb_define_method(rb_cProcStatus, "ifsignaled?", pst_ifsignaled, 0); rb_define_method(rb_cProcStatus, "signaled?", pst_wifsignaled, 0);
rb_define_method(rb_cProcStatus, "termsig", pst_termsig, 0); rb_define_method(rb_cProcStatus, "termsig", pst_wtermsig, 0);
rb_define_method(rb_cProcStatus, "ifexited?", pst_ifexited, 0); rb_define_method(rb_cProcStatus, "exited?", pst_wifexited, 0);
rb_define_method(rb_cProcStatus, "exitstatus", pst_exitstatus, 0); rb_define_method(rb_cProcStatus, "exitstatus", pst_wexitstatus, 0);
rb_define_method(rb_cProcStatus, "coredump?", pst_coredump, 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, "pid", get_pid, 0);
rb_define_module_function(rb_mProcess, "ppid", get_ppid, 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, "euid=", proc_seteuid, 1);
rb_define_module_function(rb_mProcess, "egid", proc_getegid, 0); 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, "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
} }

32
time.c
View File

@ -26,18 +26,11 @@ struct timeval {
#endif #endif
#endif /* NT */ #endif /* NT */
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
VALUE rb_cTime; VALUE rb_cTime;
#if defined(HAVE_TIMES) || defined(NT)
static VALUE S_Tms;
#endif
struct time_object { struct time_object {
struct timeval tv; struct timeval tv;
@ -953,25 +946,8 @@ static VALUE
time_s_times(obj) time_s_times(obj)
VALUE obj; VALUE obj;
{ {
#if defined(HAVE_TIMES) && !defined(__CHECKER__) rb_warn("obsolete method Time::times; use Process::times");
#ifndef HZ return rb_proc_times(obj);
# 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
} }
static VALUE static VALUE
@ -1113,10 +1089,6 @@ Init_Time()
rb_define_method(rb_cTime, "strftime", time_strftime, 1); rb_define_method(rb_cTime, "strftime", time_strftime, 1);
#if defined(HAVE_TIMES) || defined(NT)
S_Tms = rb_struct_define("Tms", "utime", "stime", "cutime", "cstime", 0);
#endif
/* methods for marshaling */ /* methods for marshaling */
rb_define_method(rb_cTime, "_dump", time_dump, -1); rb_define_method(rb_cTime, "_dump", time_dump, -1);
rb_define_singleton_method(rb_cTime, "_load", time_load, 1); rb_define_singleton_method(rb_cTime, "_load", time_load, 1);

View File

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.0" #define RUBY_VERSION "1.7.0"
#define RUBY_RELEASE_DATE "2001-02-15" #define RUBY_RELEASE_DATE "2001-02-16"
#define RUBY_VERSION_CODE 170 #define RUBY_VERSION_CODE 170
#define RUBY_RELEASE_CODE 20010215 #define RUBY_RELEASE_CODE 20010216