diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-03-16 08:30:09 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-03-16 08:30:09 +0000 |
commit | b842d5f571bb67206c0083f31df16aefcf43f7c1 (patch) | |
tree | 3019fbaf784a9ab4e0a25a0bb6f41009d10730ea | |
parent | 7f74a38b72626051f1f6013b627f8662b2ead3a7 (diff) |
* dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | README.jp | 7 | ||||
-rw-r--r-- | dir.c | 49 | ||||
-rw-r--r-- | eval.c | 3 | ||||
-rw-r--r-- | intern.h | 4 | ||||
-rw-r--r-- | version.h | 4 |
7 files changed, 53 insertions, 23 deletions
@@ -1,3 +1,7 @@ +Thu Mar 15 01:28:02 2001 Yukihiro Matsumoto <[email protected]> + + * dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016). + Fri Mar 16 17:14:17 2001 Akinori MUSHA <[email protected]> * configure.in: Set SOLIBS properly for all ELF and @@ -120,9 +120,8 @@ You can redistribute it and/or modify it under either the terms of the GPL software (possibly commercial). But some files in the distribution are not written by the author, so that they are not under this terms. - They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some - files under the ./missing directory. See each file for the copying - condition. + They are utils.c(partly), regex.[ch], st.[ch] and some files under + the ./missing directory. See each file for the copying condition. 5. The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the @@ -178,10 +178,9 @@ Public License)�ޤ��ϰʲ��˼��������ܥץ�����������ۤ� �������ܥץ������˴ޤޤ��¾�κ�Ԥˤ�륳���ɤϡ��� �줾��κ�Ԥΰո��ˤ�����¤��ä������礬����ޤ��� - ����Ū�ˤ�gc.c(����)��util.c(����)��st.[ch]��regex.[ch] - ����� ./missing�ǥ��쥯�ȥ겼�Υե����뷲���������ޤ��� - ���줾������۾��ʤɤ��դ��Ƥϳƥե�����Ȥ��Ƥ� - �������� + ����Ū�ˤ�util.c(����)��st.[ch]��regex.[ch] ����� + ./missing�ǥ��쥯�ȥ겼�Υե����뷲���������ޤ������줾 + ������۾��ʤɤ��դ��Ƥϳƥե�����Ȥ��Ƥ��������� 5. �ܥץ������ؤ����ϤȤʤ륹����ץȤ���ӡ��ܥץ����� �फ��ν��Ϥθ������ܥץ������κ�ԤǤϤʤ������줾 @@ -389,13 +389,38 @@ dir_close(dir) return Qnil; } +static void +dir_chdir(path) + const char *path; +{ + if (chdir(path) < 0) + rb_sys_fail(path); +} + +static int chdir_blocking = 0; + +static VALUE +chdir_restore(path) + const char *path; +{ + chdir_blocking--; + dir_chdir(path); + return Qnil; +} + +#ifdef HAVE_GETCWD +#define GETCWD(path) if (getcwd(path, sizeof(path)) == 0) rb_sys_fail(path) +#else +#define GETCWD(path) if (getwd(path) == 0) rb_sys_fail(path) +#endif + static VALUE dir_s_chdir(argc, argv, obj) int argc; VALUE *argv; VALUE obj; { - VALUE path; + VALUE path = Qnil; char *dist = ""; rb_secure(2); @@ -410,8 +435,18 @@ dir_s_chdir(argc, argv, obj) } } - if (chdir(dist) < 0) - rb_sys_fail(dist); + if (chdir_blocking > 0) + rb_warn("chdir during chdir block"); + + if (rb_block_given_p()) { + char cwd[MAXPATHLEN]; + + GETCWD(cwd); + chdir_blocking++; + dir_chdir(dist); + return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd); + } + dir_chdir(dist); return INT2FIX(0); } @@ -422,13 +457,7 @@ dir_s_getwd(dir) { char path[MAXPATHLEN]; -#ifdef HAVE_GETCWD - if (getcwd(path, sizeof(path)) == 0) rb_sys_fail(path); -#else - extern char *getwd(); - if (getwd(path) == 0) rb_sys_fail(path); -#endif - + GETCWD(path); return rb_tainted_str_new2(path); } @@ -775,7 +775,6 @@ static struct tag *prot_tag; _tag.frame = ruby_frame; \ _tag.iter = ruby_iter; \ _tag.prev = prot_tag; \ - _tag.retval = Qnil; \ _tag.scope = ruby_scope; \ _tag.tag = ptag; \ _tag.dst = 0; \ @@ -6332,7 +6331,7 @@ proc_eq(self, other) struct BLOCK *data, *data2; if (TYPE(other) != T_DATA) return Qfalse; - if (RDATA(other)->dmark != blk_mark) Qfalse; + if (RDATA(other)->dmark != (RUBY_DATA_FUNC)blk_mark) Qfalse; Data_Get_Struct(self, struct BLOCK, data); Data_Get_Struct(other, struct BLOCK, data2); if (data->tag == data2->tag) return Qtrue; @@ -182,8 +182,8 @@ char *rb_find_file _((char*)); void rb_gc_mark_locations _((VALUE*, VALUE*)); void rb_mark_tbl _((struct st_table*)); void rb_mark_hash _((struct st_table*)); -void rb_gc_mark_maybe(); -void rb_gc_mark(); +void rb_gc_mark_maybe _((void*)); +void rb_gc_mark _((void*)); void rb_gc_force_recycle _((VALUE)); void rb_gc _((void)); void rb_gc_call_finalizer_at_exit _((void)); @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.0" -#define RUBY_RELEASE_DATE "2001-03-14" +#define RUBY_RELEASE_DATE "2001-03-16" #define RUBY_VERSION_CODE 170 -#define RUBY_RELEASE_CODE 20010314 +#define RUBY_RELEASE_CODE 20010316 |