From e77ddaf0d1d421da2f655832a45f237558e23115 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 17 Sep 2004 09:24:13 +0000 Subject: * array.c (rb_ary_delete): element comparison might change array size. [ruby-dev:24273] * parse.y: make ruby parser reentrant. merge ripper parser to the real one. this change makes ruby require bison. * file.c (rb_file_truncate): clear stdio buffer before truncating the file. [ruby-dev:24191] * ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF which might return singleton class. [ruby-dev:24202] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dir.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index c3301bc51f..d432b20b8d 100644 --- a/dir.c +++ b/dir.c @@ -1,4 +1,3 @@ - /********************************************************************** dir.c - @@ -687,6 +686,19 @@ dir_chdir(path) static int chdir_blocking = 0; static VALUE chdir_thread = Qnil; +struct chdir_data { + char *dist; + VALUE path; +}; + +static VALUE +chdir_yield(args) + struct chdir_data *args; +{ + dir_chdir(args->dist); + return rb_yield(args->path); +} + static VALUE chdir_restore(path) char *path; @@ -695,7 +707,6 @@ chdir_restore(path) if (chdir_blocking == 0) chdir_thread = Qnil; dir_chdir(path); - free(path); return Qnil; } @@ -767,11 +778,14 @@ dir_s_chdir(argc, argv, obj) if (rb_block_given_p()) { char *cwd = my_getcwd(); + struct chdir_data args; + chdir_blocking++; if (chdir_thread == Qnil) chdir_thread = rb_thread_current(); - dir_chdir(dist); - return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd); + args.dist = dist; + args.path = path; + return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)cwd); } dir_chdir(dist); -- cgit v1.2.3