Skip to content

Commit

Permalink
* dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016).
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Mar 16, 2001
1 parent 7f74a38 commit b842d5f
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 23 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions README.jp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ Public License)
�������ܥץ������˴ޤޤ��¾�κ�Ԥˤ�륳���ɤϡ���
�줾��κ�Ԥΰո��ˤ�����¤��ä������礬����ޤ���

����Ū�ˤ�gc.c(����)��util.c(����)��st.[ch]��regex.[ch]
����� ./missing�ǥ��쥯�ȥ겼�Υե����뷲���������ޤ���
���줾������۾��ʤɤ��դ��Ƥϳƥե�����򻲾Ȥ��Ƥ�
��������
����Ū�ˤ�util.c(����)��st.[ch]��regex.[ch] �����
./missing�ǥ��쥯�ȥ겼�Υե����뷲���������ޤ������줾
������۾��ʤɤ��դ��Ƥϳƥե�����򻲾Ȥ��Ƥ���������

5. �ܥץ������ؤ����ϤȤʤ륹����ץȤ���ӡ��ܥץ�����
�फ��ν��Ϥθ������ܥץ������κ�ԤǤϤʤ������줾
Expand Down
49 changes: 39 additions & 10 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b842d5f

Please sign in to comment.