зеркало из https://github.com/github/ruby.git
* io.c (fptr_finalize): should raise error when fclose fails.
* eval.c (method_inspect): proper output format to distinguish methods and singleton methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
49c720ff67
Коммит
8210c254be
|
@ -1,3 +1,10 @@
|
|||
Tue Feb 5 16:17:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* io.c (fptr_finalize): should raise error when fclose fails.
|
||||
|
||||
* eval.c (method_inspect): proper output format to distinguish
|
||||
methods and singleton methods.
|
||||
|
||||
Mon Feb 4 22:44:58 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* file.c (rb_file_s_expand_path): should terminate.
|
||||
|
@ -8,6 +15,8 @@ Mon Feb 4 15:38:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||
|
||||
* variable.c (classname): should follow ICLASS link explicitly.
|
||||
|
||||
* eval.c (rb_call): ditto.
|
||||
|
||||
Fri Feb 1 19:10:04 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* intern.h: prototypes for new functions; rb_cstr_to_inum(),
|
||||
|
|
36
eval.c
36
eval.c
|
@ -4669,6 +4669,9 @@ rb_call(klass, recv, mid, argc, argv, scope)
|
|||
|
||||
/* self must be kind of a specified form for private method */
|
||||
if ((noex & NOEX_PROTECTED)) {
|
||||
if (TYPE(klass) == T_ICLASS) {
|
||||
klass = RBASIC(klass)->klass;
|
||||
}
|
||||
if (!rb_obj_is_kind_of(ruby_frame->self, rb_class_real(klass)))
|
||||
return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
|
||||
}
|
||||
|
@ -6757,7 +6760,7 @@ method_unbind(obj)
|
|||
Data_Get_Struct(obj, struct METHOD, orig);
|
||||
method = Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, free, data);
|
||||
data->klass = orig->klass;
|
||||
data->recv = 0;
|
||||
data->recv = Qundef;
|
||||
data->id = orig->id;
|
||||
data->body = orig->body;
|
||||
data->rklass = orig->rklass;
|
||||
|
@ -6787,7 +6790,7 @@ rb_mod_method(mod, vid)
|
|||
VALUE mod;
|
||||
VALUE vid;
|
||||
{
|
||||
return mnew(mod, 0, rb_to_id(vid), rb_cUnboundMethod);
|
||||
return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -6913,18 +6916,35 @@ method_inspect(method)
|
|||
struct METHOD *data;
|
||||
VALUE str;
|
||||
const char *s;
|
||||
char *sharp = "#";
|
||||
|
||||
Data_Get_Struct(method, struct METHOD, data);
|
||||
str = rb_str_buf_new2("#<");
|
||||
s = rb_class2name(CLASS_OF(method));
|
||||
rb_str_buf_cat2(str, s);
|
||||
rb_str_buf_cat2(str, ": ");
|
||||
s = rb_class2name(data->rklass);
|
||||
rb_str_buf_cat2(str, s);
|
||||
rb_str_buf_cat2(str, "(");
|
||||
s = rb_class2name(data->klass);
|
||||
rb_str_buf_cat2(str, s);
|
||||
rb_str_buf_cat2(str, ")#");
|
||||
|
||||
if (FL_TEST(data->klass, FL_SINGLETON)) {
|
||||
VALUE v;
|
||||
|
||||
rb_str_buf_append(str, rb_inspect(data->recv));
|
||||
v = rb_iv_get(data->klass, "__attached__");
|
||||
if (data->recv != v) {
|
||||
rb_str_buf_cat2(str, "(");
|
||||
rb_str_buf_append(str, rb_inspect(v));
|
||||
rb_str_buf_cat2(str, ").");
|
||||
}
|
||||
else {
|
||||
rb_str_buf_cat2(str, ".");
|
||||
}
|
||||
}
|
||||
else {
|
||||
rb_str_buf_cat2(str, rb_class2name(data->rklass));
|
||||
rb_str_buf_cat2(str, "(");
|
||||
s = rb_class2name(data->klass);
|
||||
rb_str_buf_cat2(str, s);
|
||||
rb_str_buf_cat2(str, ")#");
|
||||
}
|
||||
s = rb_id2name(data->oid);
|
||||
rb_str_buf_cat2(str, s);
|
||||
rb_str_buf_cat2(str, ">");
|
||||
|
|
|
@ -191,6 +191,13 @@ init_sock(sock, fd)
|
|||
return sock;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
bsock_s_for_fd(klass, fd)
|
||||
VALUE klass, fd;
|
||||
{
|
||||
return init_sock(rb_obj_alloc(klass), NUM2INT(fd));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
bsock_shutdown(argc, argv, sock)
|
||||
int argc;
|
||||
|
@ -1533,13 +1540,6 @@ sock_init(sock, domain, type, protocol)
|
|||
return init_sock(sock, fd);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
sock_s_for_fd(klass, fd)
|
||||
VALUE klass, fd;
|
||||
{
|
||||
return init_sock(rb_obj_alloc(klass), NUM2INT(fd));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
sock_s_socketpair(klass, domain, type, protocol)
|
||||
VALUE klass, domain, type, protocol;
|
||||
|
@ -2123,6 +2123,7 @@ Init_socket()
|
|||
bsock_do_not_rev_lookup, 0);
|
||||
rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup=",
|
||||
bsock_do_not_rev_lookup_set, 1);
|
||||
rb_define_singleton_method(rb_cBasicSocket, "for_fd", bsock_s_for_fd, 1);
|
||||
|
||||
rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0);
|
||||
rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0);
|
||||
|
@ -2185,7 +2186,6 @@ Init_socket()
|
|||
#endif
|
||||
|
||||
rb_cSocket = rb_define_class("Socket", rb_cBasicSocket);
|
||||
rb_define_singleton_method(rb_cSocket, "for_fd", sock_s_for_fd, 1);
|
||||
|
||||
rb_define_method(rb_cSocket, "initialize", sock_init, 3);
|
||||
rb_define_method(rb_cSocket, "connect", sock_connect, 1);
|
||||
|
|
14
file.c
14
file.c
|
@ -1459,8 +1459,9 @@ rb_file_s_expand_path(argc, argv)
|
|||
if (!NIL_P(dname)) {
|
||||
dname = rb_file_s_expand_path(1, &dname);
|
||||
if (OBJ_TAINTED(dname)) tainted = 1;
|
||||
BUFCHECK (strlen(RSTRING(dname)->ptr) > buflen);
|
||||
strcpy(buf, RSTRING(dname)->ptr);
|
||||
BUFCHECK (RSTRING(dname)->len > buflen);
|
||||
memcpy(buf, RSTRING(dname)->ptr, RSTRING(dname)->len);
|
||||
p += RSTRING(dname)->len;
|
||||
}
|
||||
else {
|
||||
char *dir = my_getcwd();
|
||||
|
@ -1468,8 +1469,8 @@ rb_file_s_expand_path(argc, argv)
|
|||
tainted = 1;
|
||||
BUFCHECK (strlen(dir) > buflen);
|
||||
strcpy(buf, dir);
|
||||
p = &buf[strlen(buf)];
|
||||
}
|
||||
p = &buf[strlen(buf)];
|
||||
while (p > buf && *(p - 1) == '/') p--;
|
||||
}
|
||||
else {
|
||||
|
@ -1539,9 +1540,6 @@ rb_file_s_expand_path(argc, argv)
|
|||
memcpy(++p, b, s-b);
|
||||
p += s-b;
|
||||
}
|
||||
else if (p == buf) {
|
||||
p++;
|
||||
}
|
||||
#if defined(DOSISH)
|
||||
else if (ISALPHA(buf[0]) && (buf[1] == ':') && isdirsep(buf[2])) {
|
||||
/* root directory needs a trailing backslash,
|
||||
|
@ -1554,8 +1552,8 @@ rb_file_s_expand_path(argc, argv)
|
|||
#endif
|
||||
|
||||
if (tainted) OBJ_TAINT(result);
|
||||
*p = '\0';
|
||||
RSTRING(result)->len = p - buf;
|
||||
*p = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2308,7 +2306,7 @@ path_check_1(path)
|
|||
for (;;) {
|
||||
if (stat(p0, &st) == 0 && (st.st_mode & 002)) {
|
||||
if (p) *p = '/';
|
||||
rb_warn("Bad mode 0%o on %s", st.st_mode, p0);
|
||||
rb_warn("Unsecure world writeable dir %s , mode 0%o", p0, st.st_mode);
|
||||
return 0;
|
||||
}
|
||||
s = strrdirsep(p0);
|
||||
|
|
51
io.c
51
io.c
|
@ -1072,26 +1072,34 @@ rb_io_isatty(io)
|
|||
}
|
||||
|
||||
static void
|
||||
fptr_finalize(fptr)
|
||||
fptr_finalize(fptr, fin)
|
||||
OpenFile *fptr;
|
||||
{
|
||||
int n1 = 0, n2 = 0, e = 0;
|
||||
|
||||
if (fptr->f) {
|
||||
fclose(fptr->f);
|
||||
n1 = fclose(fptr->f);
|
||||
if (n1 < 0) e = errno;
|
||||
}
|
||||
if (fptr->f2) {
|
||||
fclose(fptr->f2);
|
||||
n2 = fclose(fptr->f2);
|
||||
}
|
||||
if (!fin && (n1 < 0 || n2 < 0)) {
|
||||
if (n2 == 0) errno = e;
|
||||
rb_sys_fail(fptr->path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rb_io_fptr_cleanup(fptr)
|
||||
rb_io_fptr_cleanup(fptr, fin)
|
||||
OpenFile *fptr;
|
||||
int fin;
|
||||
{
|
||||
if (fptr->finalize) {
|
||||
(*fptr->finalize)(fptr);
|
||||
}
|
||||
else {
|
||||
fptr_finalize(fptr);
|
||||
fptr_finalize(fptr, fin);
|
||||
}
|
||||
fptr->f = fptr->f2 = 0;
|
||||
|
||||
|
@ -1109,21 +1117,7 @@ rb_io_fptr_finalize(fptr)
|
|||
if (!fptr->f && !fptr->f2) return;
|
||||
if (fileno(fptr->f) < 3) return;
|
||||
|
||||
rb_io_fptr_cleanup(fptr);
|
||||
}
|
||||
|
||||
static void
|
||||
rb_io_fptr_close(fptr)
|
||||
OpenFile *fptr;
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!fptr) return;
|
||||
if (!fptr->f && !fptr->f2) return;
|
||||
|
||||
fd = fileno(fptr->f);
|
||||
rb_io_fptr_cleanup(fptr);
|
||||
rb_thread_fd_close(fd);
|
||||
rb_io_fptr_cleanup(fptr, Qtrue);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
@ -1131,9 +1125,16 @@ rb_io_close(io)
|
|||
VALUE io;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
int fd;
|
||||
|
||||
fptr = RFILE(io)->fptr;
|
||||
rb_io_fptr_close(fptr);
|
||||
if (!fptr) return;
|
||||
if (!fptr->f && !fptr->f2) return;
|
||||
|
||||
fd = fileno(fptr->f);
|
||||
rb_io_fptr_cleanup(fptr, Qfalse);
|
||||
rb_thread_fd_close(fd);
|
||||
|
||||
if (fptr->pid) {
|
||||
rb_syswait(fptr->pid);
|
||||
fptr->pid = 0;
|
||||
|
@ -2493,6 +2494,14 @@ rb_file_initialize(argc, argv, io)
|
|||
free(RFILE(io)->fptr);
|
||||
RFILE(io)->fptr = 0;
|
||||
}
|
||||
if (0 < argc && argc < 3) {
|
||||
VALUE fd = rb_check_convert_type(argv[0], T_FIXNUM, "Fixnum", "to_int");
|
||||
|
||||
if (!NIL_P(fd)) {
|
||||
argv[0] = fd;
|
||||
return rb_io_initialize(argc, argv, io);
|
||||
}
|
||||
}
|
||||
rb_open_file(argc, argv, io);
|
||||
|
||||
return io;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define RUBY_VERSION "1.7.2"
|
||||
#define RUBY_RELEASE_DATE "2002-02-04"
|
||||
#define RUBY_RELEASE_DATE "2002-02-05"
|
||||
#define RUBY_VERSION_CODE 172
|
||||
#define RUBY_RELEASE_CODE 20020204
|
||||
#define RUBY_RELEASE_CODE 20020205
|
||||
|
|
Загрузка…
Ссылка в новой задаче