* dir.c (dir_s_glob): supprt backslash escape of metacharacters

and delimiters.

* dir.c (remove_backslases): remove backslashes from path before
  calling stat(2).

* dir.c (dir_s_glob): call rb_yield directly (via push_pattern) if
  block is given to the method.

* dir.c (push_pattern): do not call rb_ary_push; yield directly.

* eval.c (blk_copy_prev): reduced ALLOC_N too much.

* eval.c (frame_dup): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-02-14 05:52:06 +00:00
Родитель 22765f2015
Коммит 8e5c3b23f2
35 изменённых файлов: 98 добавлений и 48 удалений

Просмотреть файл

@ -1,8 +1,34 @@
Wed Feb 14 00:44:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_s_glob): supprt backslash escape of metacharacters
and delimiters.
* dir.c (remove_backslases): remove backslashes from path before
calling stat(2).
* dir.c (dir_s_glob): call rb_yield directly (via push_pattern) if
block is given to the method.
* dir.c (push_pattern): do not call rb_ary_push; yield directly.
* eval.c (blk_copy_prev): reduced ALLOC_N too much.
* eval.c (frame_dup): ditto.
Tue Feb 13 23:05:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* dir.c (lstat): should use rb_sys_stat if lstat(2) is not
available.
Sun Feb 11 16:00:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* eval.c (stack_length): use __builtin_frame_address() only if
GCC and i386 CPU.
* gc.c (rb_gc, Init_stack): ditto.
* configure.in: add ac_cv_func_getpgrp_void=yes on DJGPP.
Tue Feb 13 08:43:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_ctl): do not call ioctl/fcntl for f2, if f and f2

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 6 09:46:12 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Jun 10 00:48:55 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Aug 10 15:05:44 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Aug 26 14:39:48 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

48
dir.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 5 09:51:01 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@ -557,10 +557,28 @@ extract_elem(path)
return extract_path(path, pend);
}
static void
remove_backslases(p)
char *p;
{
char *pend = p + strlen(p);
char *t = p;
while (p < pend) {
if (*p == '\\') {
*p++;
if (p == pend) break;
}
*t++ = *p++;
}
*t = '\0';
}
#ifndef S_ISDIR
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
void
rb_glob_helper(path, flag, func, arg)
char *path;
@ -572,6 +590,7 @@ rb_glob_helper(path, flag, func, arg)
char *p, *m;
if (!has_magic(path, 0)) {
remove_backslases(path);
if (rb_sys_stat(path, &st) == 0) {
(*func)(path, arg);
}
@ -694,7 +713,14 @@ push_pattern(path, ary)
char *path;
VALUE ary;
{
rb_ary_push(ary, rb_tainted_str_new2(path));
VALUE str = rb_tainted_str_new2(path);
if (ary) {
rb_ary_push(ary, str);
}
else {
rb_yield(str);
}
}
static void
@ -768,10 +794,12 @@ dir_s_glob(dir, str)
char buffer[MAXPATHLEN], *buf = buffer;
char *t;
int nest;
VALUE ary;
VALUE ary = 0;
Check_SafeStr(str);
ary = rb_ary_new();
if (!rb_block_given_p()) {
ary = rb_ary_new();
}
if (RSTRING(str)->len >= MAXPATHLEN)
buf = xmalloc(RSTRING(str)->len + 1);
@ -785,6 +813,10 @@ dir_s_glob(dir, str)
while (p < pend && !isdelim(*p)) {
if (*p == '{') nest+=2;
if (*p == '}') nest+=3;
if (*p == '\\') {
*t++ = *p++;
if (p == pend) break;
}
*t++ = *p++;
}
*t = '\0';
@ -798,14 +830,6 @@ dir_s_glob(dir, str)
}
if (buf != buffer)
free(buf);
if (rb_block_given_p()) {
long len = RARRAY(ary)->len;
VALUE *ptr = RARRAY(ary)->ptr;
while (len--) {
rb_yield(*ptr++);
}
}
return ary;
}

2
dln.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
dln.h
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Wed Jan 19 16:53:09 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
env.h
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Mon Jul 11 11:53:03 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

6
eval.c
Просмотреть файл

@ -6015,7 +6015,7 @@ blk_copy_prev(block)
while (block->prev) {
tmp = ALLOC_N(struct BLOCK, 1);
MEMCPY(tmp, block->prev, struct BLOCK, 1);
if (tmp->frame.argc > 0 && !(tmp->frame.flags & FRAME_MALLOC)) {
if (tmp->frame.argc > 0) {
tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
MEMCPY(tmp->frame.argv, block->prev->frame.argv, VALUE, tmp->frame.argc);
tmp->frame.flags |= FRAME_MALLOC;
@ -6035,11 +6035,11 @@ frame_dup(frame)
struct FRAME *tmp;
for (;;) {
if (frame->argc > 0 && !(frame->flags & FRAME_MALLOC)) {
if (frame->argc > 0) {
argv = ALLOC_N(VALUE, frame->argc);
MEMCPY(argv, frame->argv, VALUE, frame->argc);
frame->argv = argv;
frame->flags = FRAME_MALLOC;
frame->flags |= FRAME_MALLOC;
}
frame->tmp = 0; /* should not preserve tmp */
if (!frame->prev) break;

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Mon Jan 24 15:59:52 JST 1994
Copyright (C) 1995-1998 Yukihiro Matsumoto
Copyright (C) 1995-2001 Yukihiro Matsumoto
************************************************/

Просмотреть файл

@ -5,7 +5,7 @@
$Author$
created at: Mon Apr 7 18:53:05 JST 1997
Copyright (C) 1997-1998 Yukihiro Matsumoto
Copyright (C) 1997-2001 Yukihiro Matsumoto
************************************************/

Просмотреть файл

@ -5,7 +5,7 @@
$Author$
created at: Fri Aug 2 09:24:12 JST 1996
Copyright (C) 1995-1998 Yukihiro Matsumoto
Copyright (C) 1995-2001 Yukihiro Matsumoto
************************************************/
/* This module provides an interface to the RSA Data Security,

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri May 7 08:34:24 JST 1999
Copyright (C) 1995-1998 Yukihiro Matsumoto
Copyright (C) 1995-2001 Yukihiro Matsumoto
************************************************/

2
hash.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 22 18:51:18 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 16:01:58 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan

2
main.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 19 13:19:58 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Apr 27 16:30:01 JST 1995
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
math.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 25 14:12:56 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
node.h
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri May 28 15:14:02 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Aug 13 18:33:09 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
prec.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Jan 26 02:40:41 2000
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Dec 24 16:39:21 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Aug 19 17:46:47 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
re.h
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Sep 30 14:18:32 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Nov 12 16:47:09 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Wed Aug 16 01:15:38 JST 1995
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 20 10:13:44 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Mar 22 18:44:30 JST 1995
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
time.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Dec 28 14:31:59 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
util.c
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Fri Mar 10 17:22:34 JST 1995
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

2
util.h
Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Mar 9 11:55:53 JST 1995
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Tue Apr 19 23:55:15 JST 1994
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan

Просмотреть файл

@ -6,7 +6,7 @@
$Date$
created at: Thu Sep 30 20:08:01 JST 1993
Copyright (C) 1993-2000 Yukihiro Matsumoto
Copyright (C) 1993-2001 Yukihiro Matsumoto
**********************************************************************/
@ -40,6 +40,6 @@ ruby_show_version()
void
ruby_show_copyright()
{
printf("ruby - Copyright (C) 1993-2000 Yukihiro Matsumoto\n");
printf("ruby - Copyright (C) 1993-2001 Yukihiro Matsumoto\n");
exit(0);
}