summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-16 08:30:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-16 08:30:09 +0000
commitb842d5f571bb67206c0083f31df16aefcf43f7c1 (patch)
tree3019fbaf784a9ab4e0a25a0bb6f41009d10730ea
parent7f74a38b72626051f1f6013b627f8662b2ead3a7 (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--ChangeLog4
-rw-r--r--README5
-rw-r--r--README.jp7
-rw-r--r--dir.c49
-rw-r--r--eval.c3
-rw-r--r--intern.h4
-rw-r--r--version.h4
7 files changed, 53 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 2151e4d71c..81c6715649 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Mar 15 01:28:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016).
+
Fri Mar 16 17:14:17 2001 Akinori MUSHA <knu@iDaemons.org>
* configure.in: Set SOLIBS properly for all ELF and
diff --git a/README b/README
index 97d940f4cf..fa3d670c26 100644
--- a/README
+++ b/README
@@ -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
diff --git a/README.jp b/README.jp
index 566fbcdac4..05c6dc85ab 100644
--- a/README.jp
+++ b/README.jp
@@ -178,10 +178,9 @@ Public License)または以下に示す条件で本プログラムを再配布で
だし,本プログラムに含まれる他の作者によるコードは,そ
れぞれの作者の意向による制限が加えられる場合があります.
- 具体的にはgc.c(一部),util.c(一部),st.[ch],regex.[ch]
- および ./missingディレクトリ下のファイル群が該当します.
- それぞれの配布条件などに付いては各ファイルを参照してく
- ださい.
+ 具体的にはutil.c(一部),st.[ch],regex.[ch] および
+ ./missingディレクトリ下のファイル群が該当します.それぞ
+ れの配布条件などに付いては各ファイルを参照してください.
5. 本プログラムへの入力となるスクリプトおよび,本プログラ
ムからの出力の権利は本プログラムの作者ではなく,それぞ
diff --git a/dir.c b/dir.c
index 87cc64d176..9e0b2cf28f 100644
--- a/dir.c
+++ b/dir.c
@@ -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);
}
diff --git a/eval.c b/eval.c
index 5d2f0016fe..93881002de 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/intern.h b/intern.h
index b83c077b67..e3fec0967e 100644
--- a/intern.h
+++ b/intern.h
@@ -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));
diff --git a/version.h b/version.h
index f48838e690..8c22079a86 100644
--- a/version.h
+++ b/version.h
@@ -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