diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-16 10:20:26 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-16 10:20:26 +0000 |
commit | ddd90c76e150f88ffb1a64f591dcefee8afa1f56 (patch) | |
tree | 8c3d9e4cfa977602595508e735c6af8e91dbaf98 | |
parent | 94a1bece4a4adb5c0f8f09fb9b95356bae24912b (diff) |
exception name on -d
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | config.sub | 4 | ||||
-rw-r--r-- | eval.c | 16 | ||||
-rw-r--r-- | ext/socket/socket.c | 28 | ||||
-rw-r--r-- | lib/ftplib.rb | 19 | ||||
-rw-r--r-- | struct.c | 71 |
6 files changed, 108 insertions, 53 deletions
@@ -1,4 +1,11 @@ -Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp> +Thu Apr 16 16:52:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * eval.c (rb_longjmp): trace event on exception in raising + context, just before raising exception. + + * struct.c (struct_s_members): forgot to check singletons. + + * struct.c (struct_aref): members can be accessed by names too. * array.c (ary_flatten): new method. @@ -6,6 +13,8 @@ Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * object.c (any_to_s): remove class name restriction. +Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + * file.c (thread_flock): do not block other threads. * eval.c (thread_trap_eval): signals are now delivered to the @@ -14,6 +23,14 @@ Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * string.c (str_new4): need not to duplicate frozen strings. +Wed Apr 15 12:24:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * config.sub: x68 condition restored. + +Wed Apr 15 08:33:47 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp> + + * struct.c (struct_inspect): remove restriction for struct names. + Wed Apr 15 01:22:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * string.c (str_dup_frozen): do not duplicate frozen strings. @@ -28,6 +45,10 @@ Wed Apr 15 01:22:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * io.c (f_p): ditto. +Tue Apr 14 22:18:17 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp> + + * struct.c (struct_aref): should not subtract negative index. + Tue Apr 14 11:34:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * experimental release 1.1b9_10. diff --git a/config.sub b/config.sub index 5bb67e96b6..b16b2c0c7d 100644 --- a/config.sub +++ b/config.sub @@ -662,6 +662,10 @@ case $basic_machine in orion105) basic_machine=clipper-highlevel ;; + human) + basic_machine=m68k-sharp + os=-human + ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 @@ -2672,13 +2672,12 @@ rb_longjmp(tag, mesg, at) if (NIL_P(errinfo) && NIL_P(mesg)) { errinfo = exc_new(eRuntimeError, 0, 0); } -#if 1 - if (debug) { - fprintf(stderr, "Exception `%s' occurred at %s:%d\n", + + if (debug && !NIL_P(errinfo)) { + fprintf(stderr, "Exception `%s' at %s:%d\n", rb_class2name(CLASS_OF(errinfo)), sourcefile, sourceline); } -#endif if (!NIL_P(at)) { errat = check_errat(at); } @@ -2695,13 +2694,12 @@ rb_longjmp(tag, mesg, at) } str_freeze(errinfo); } -#if 0 - if (debug) { - error_print(); - } -#endif trap_restore_mask(); + if (trace_func && tag != TAG_FATAL) { + call_trace_func("raise", sourcefile, sourceline, + the_frame->self, the_frame->last_func); + } JUMP_TAG(tag); } diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 5aaff22c04..d35e029f34 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -541,10 +541,8 @@ static VALUE tcp_s_open(class, host, serv) VALUE class, host, serv; { - VALUE s; Check_SafeStr(host); - s = open_inet(class, host, serv, INET_CLIENT); - return s; + return open_inet(class, host, serv, INET_CLIENT); } #ifdef SOCKS @@ -553,7 +551,6 @@ socks_s_open(class, host, serv) VALUE class, host, serv; { static init = 0; - VALUE s; if (init == 0) { SOCKSinit("ruby"); @@ -561,8 +558,7 @@ socks_s_open(class, host, serv) } Check_SafeStr(host); - s = open_inet(class, host, serv, INET_SOCKS); - return s; + return open_inet(class, host, serv, INET_SOCKS); } #endif @@ -572,13 +568,12 @@ tcp_svr_s_open(argc, argv, class) VALUE *argv; VALUE class; { - VALUE arg1, arg2, s; + VALUE arg1, arg2; if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) - s = open_inet(class, arg1, arg2, INET_SERVER); + return open_inet(class, arg1, arg2, INET_SERVER); else - s = open_inet(class, 0, arg1, INET_SERVER); - return s; + return open_inet(class, 0, arg1, INET_SERVER); } static VALUE @@ -807,10 +802,7 @@ static VALUE udp_s_open(class) VALUE class; { - VALUE s; - - s = sock_new(class, socket(AF_INET, SOCK_DGRAM, 0)); - return s; + return sock_new(class, socket(AF_INET, SOCK_DGRAM, 0)); } static void @@ -953,9 +945,7 @@ static VALUE unix_s_sock_open(sock, path) VALUE sock, path; { - VALUE s; - s = open_unix(sock, path, 0); - return s; + return open_unix(sock, path, 0); } static VALUE @@ -979,9 +969,7 @@ static VALUE unix_svr_s_open(sock, path) VALUE sock, path; { - VALUE s; - s = open_unix(sock, path, 1); - return s; + return open_unix(sock, path, 1); } static VALUE diff --git a/lib/ftplib.rb b/lib/ftplib.rb index 4069089cc3..e79868b0ef 100644 --- a/lib/ftplib.rb +++ b/lib/ftplib.rb @@ -1,7 +1,7 @@ ## ftplib.rb # Author: Shugo Maeda <shugo@po.aianet.ne.jp> -# Version: $Revision: 1.6 $ +# Version: $Revision: 1.7 $ ## Code: @@ -16,7 +16,7 @@ class FTPProtoError < FTPError; end class FTP - RCS_ID = %q$Id: ftplib.rb,v 1.6 1998/03/01 08:49:57 shugo Exp shugo $ + RCS_ID = %q$Id: ftplib.rb,v 1.7 1998/04/13 12:34:24 shugo Exp shugo $ include MonitorMixin @@ -444,11 +444,20 @@ class FTP def size(filename) voidcmd("TYPE I") resp = sendcmd("SIZE " + filename) - if resp[0, 3] == "213" - return resp[3 .. -1].strip.to_i + if resp[0, 3] != "213" + raise FTPReplyError, resp end + return resp[3..-1].strip end - + + MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ + + def mtime(filename) + str = mdtm(filename) + ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i} + return Time.gm(*ary) + end + def mkdir(dirname) resp = sendcmd("MKD " + dirname) return parse257(resp) @@ -15,18 +15,28 @@ VALUE cStruct; extern VALUE mEnumerable; static VALUE +class_of(obj) + VALUE obj; +{ + obj = CLASS_OF(obj); + if (FL_TEST(obj, FL_SINGLETON)) + return RCLASS(obj)->super; + return obj; +} + +static VALUE struct_s_members(obj) VALUE obj; { - struct RArray *member; - VALUE ary, *p, *pend; + VALUE member, ary; + VALUE *p, *pend; - member = RARRAY(rb_iv_get(obj, "__member__")); + member = rb_iv_get(obj, "__member__"); if (NIL_P(member)) { - Fatal("non-initialized struct"); + Bug("non-initialized struct"); } - ary = ary_new2(member->len); - p = member->ptr; pend = p + member->len; + ary = ary_new2(RARRAY(member)->len); + p = RARRAY(member)->ptr; pend = p + RARRAY(member)->len; while (p < pend) { ary_push(ary, str_new2(rb_id2name(FIX2INT(*p)))); p++; @@ -39,7 +49,7 @@ static VALUE struct_members(obj) VALUE obj; { - return struct_s_members(CLASS_OF(obj)); + return struct_s_members(class_of(obj)); } VALUE @@ -47,11 +57,10 @@ struct_getmember(obj, id) VALUE obj; ID id; { - VALUE nstr, member, slot; + VALUE member, slot; int i; - nstr = CLASS_OF(obj); - member = rb_iv_get(nstr, "__member__"); + member = rb_iv_get(class_of(obj), "__member__"); if (NIL_P(member)) { Bug("non-initialized struct"); } @@ -100,11 +109,10 @@ static VALUE struct_set(obj, val) VALUE obj, val; { - VALUE nstr, member, slot; + VALUE member, slot; int i; - nstr = CLASS_OF(obj); - member = rb_iv_get(nstr, "__member__"); + member = rb_iv_get(class_of(obj), "__member__"); if (NIL_P(member)) { Fatal("non-initialized struct"); } @@ -280,7 +288,6 @@ struct_inspect(s) { char *name = rb_class2name(CLASS_OF(s)); VALUE str, member; - char buf[256]; int i; member = rb_iv_get(CLASS_OF(s), "__member__"); @@ -288,8 +295,9 @@ struct_inspect(s) Fatal("non-initialized struct"); } - sprintf(buf, "#<%s ", name); - str = str_new2(buf); + str = str_new2("#<"); + str_cat(str, name, strlen(name)); + str_cat(str, " ", 1); for (i=0; i<RSTRUCT(s)->len; i++) { VALUE str2, slot; char *p; @@ -331,14 +339,41 @@ struct_clone(s) return (VALUE)st; } +static VALUE +struct_aref_id(s, id) + VALUE s; + ID id; +{ + VALUE member; + int i, len; + VALUE *p; + + member = rb_iv_get(CLASS_OF(s), "__member__"); + if (NIL_P(member)) { + Bug("non-initialized struct"); + } + + len = RARRAY(member)->len; + for (i=0; i<len; i++) { + if (FIX2INT(RARRAY(member)->ptr[i]) == id) { + return RSTRUCT(s)->ptr[i]; + } + } + NameError("no member '%s' in struct", rb_id2name(id)); +} + VALUE struct_aref(s, idx) VALUE s, idx; { int i; + if (TYPE(idx) == T_STRING) { + return struct_aref_id(s, rb_to_id(idx)); + } + i = NUM2INT(idx); - if (i < 0) i = RSTRUCT(s)->len - i; + if (i < 0) i = RSTRUCT(s)->len + i; if (i < 0) IndexError("offset %d too small for struct(size:%d)", i, RSTRUCT(s)->len); if (RSTRUCT(s)->len <= i) @@ -353,7 +388,7 @@ struct_aset(s, idx, val) int i; i = NUM2INT(idx); - if (i < 0) i = RSTRUCT(s)->len - i; + if (i < 0) i = RSTRUCT(s)->len + i; if (i < 0) IndexError("offset %d too small for struct(size:%d)", i, RSTRUCT(s)->len); if (RSTRUCT(s)->len <= i) |