summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-21 03:41:45 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-21 03:41:45 +0000
commit9910feef4fc251419dc31cd2e022f81375bcad23 (patch)
tree3fabd7a3d793d999f1f4e116a9e95ad1adcb582d
parent98e25a542aec760aed724bd7152ba86a96b3eeb8 (diff)
* gc.c (id2ref): sometimes confused symbol and reference.
* dir.c (glob_helper): breaks loop after calling recusive glob_helper; all wild cards should be consumed; no need for further match. * dir.c (dir_s_glob): gives warning if no match found. * object.c (sym_inspect): did allocate extra byte space. * marshal.c (shortlen): shortlen should return number of bytes written. * eval.c (ev_const_defined): need not to check if cbase->nd_class is rb_cObject. * eval.c (ev_const_get): ditto. * time.c (time_zone): return "UTC" for UTC time objects. * eval.c (THREAD_ALLOC): flags should be initialized. * signal.c (rb_f_kill): should use FIX2INT, not FIX2UINT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog38
-rw-r--r--dir.c60
-rw-r--r--eval.c8
-rw-r--r--ext/socket/socket.c2
-rw-r--r--file.c12
-rw-r--r--gc.c8
-rw-r--r--lib/debug.rb2
-rw-r--r--lib/find.rb2
-rw-r--r--marshal.c2
-rw-r--r--object.c2
-rw-r--r--ruby.h4
-rw-r--r--signal.c2
-rw-r--r--time.c3
-rw-r--r--version.h4
14 files changed, 100 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index e3bf47b4f5..ebe58b7351 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,12 +6,50 @@ Wed Mar 21 08:05:35 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* win32/win32.c: ditto.
+Wed Mar 21 01:26:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (id2ref): sometimes confused symbol and reference.
+
Tue Mar 20 23:09:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* win32/win32.c (win32_stat): UNC support.
* dir.c (extract_path): fix "./*" problem.
+Tue Mar 20 15:10:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): breaks loop after calling recusive
+ glob_helper; all wild cards should be consumed; no need for
+ further match.
+
+ * dir.c (dir_s_glob): gives warning if no match found.
+
+Tue Mar 20 14:13:45 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * object.c (sym_inspect): did allocate extra byte space.
+
+Mon Mar 19 19:14:47 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * marshal.c (shortlen): shortlen should return number of bytes
+ written.
+
+Mon Mar 19 16:52:23 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (ev_const_defined): need not to check if cbase->nd_class
+ is rb_cObject.
+
+ * eval.c (ev_const_get): ditto.
+
+Mon Mar 19 17:11:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_zone): return "UTC" for UTC time objects.
+
+Mon Mar 19 16:27:32 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (THREAD_ALLOC): flags should be initialized.
+
+ * signal.c (rb_f_kill): should use FIX2INT, not FIX2UINT.
+
Mon Mar 19 10:55:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (glob_helper): replace lstat() by stat() to follow symlink
diff --git a/dir.c b/dir.c
index 560e2cd924..acd1fa506c 100644
--- a/dir.c
+++ b/dir.c
@@ -62,7 +62,7 @@ char *strchr _((char*,char));
#include <ctype.h>
#ifndef HAVE_LSTAT
-#define lstat stat
+#define lstat rb_sys_stat
#endif
#define FNM_NOESCAPE 0x01
@@ -610,8 +610,6 @@ remove_backslashes(p)
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
-#define GLOB_RECURSIVE 0x10
-
static void
glob_helper(path, flag, func, arg)
char *path;
@@ -624,10 +622,10 @@ glob_helper(path, flag, func, arg)
if (!has_magic(path, 0)) {
remove_backslashes(path);
- if (stat(path, &st) == 0) {
+ if (rb_sys_stat(path, &st) == 0) {
(*func)(path, arg);
}
- else if (!(flag & GLOB_RECURSIVE)) {
+ else if (errno != ENOENT) {
/* In case stat error is other than ENOENT and
we may want to know what is wrong. */
rb_sys_warning(path);
@@ -655,8 +653,8 @@ glob_helper(path, flag, func, arg)
else dir = base;
magic = extract_elem(p);
- if (stat(dir, &st) < 0) {
- rb_sys_warning(dir);
+ if (rb_sys_stat(dir, &st) < 0) {
+ if (errno != ENOENT) rb_sys_warning(dir);
free(base);
break;
}
@@ -665,7 +663,7 @@ glob_helper(path, flag, func, arg)
recursive = 1;
buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
sprintf(buf, "%s%s", base, *base ? m : m+1);
- glob_helper(buf, flag|GLOB_RECURSIVE, func, arg);
+ glob_helper(buf, flag, func, arg);
free(buf);
}
dirp = opendir(dir);
@@ -693,13 +691,13 @@ glob_helper(path, flag, func, arg)
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name);
if (lstat(buf, &st) < 0) {
- rb_sys_warning(buf);
+ if (errno != ENOENT) rb_sys_warning(buf);
continue;
}
if (S_ISDIR(st.st_mode)) {
strcat(buf, "/**");
strcat(buf, m);
- glob_helper(buf, flag|GLOB_RECURSIVE, func, arg);
+ glob_helper(buf, flag, func, arg);
}
free(buf);
continue;
@@ -721,25 +719,28 @@ glob_helper(path, flag, func, arg)
closedir(dirp);
free(base);
free(magic);
- while (link) {
- if (stat(link->path, &st) == 0) {
- if (S_ISDIR(st.st_mode)) {
- int len = strlen(link->path);
- int mlen = strlen(m);
- char *t = ALLOC_N(char, len+mlen+1);
-
- sprintf(t, "%s%s", link->path, m);
- glob_helper(t, flag|GLOB_RECURSIVE, func, arg);
- free(t);
+ if (link) {
+ while (link) {
+ if (rb_sys_stat(link->path, &st) == 0) {
+ if (S_ISDIR(st.st_mode)) {
+ int len = strlen(link->path);
+ int mlen = strlen(m);
+ char *t = ALLOC_N(char, len+mlen+1);
+
+ sprintf(t, "%s%s", link->path, m);
+ glob_helper(t, flag, func, arg);
+ free(t);
+ }
+ tmp = link;
+ link = link->next;
+ free(tmp->path);
+ free(tmp);
+ }
+ else {
+ rb_sys_warning(link->path);
}
- tmp = link;
- link = link->next;
- free(tmp->path);
- free(tmp);
- }
- else {
- rb_sys_warning(link->path);
}
+ break;
}
}
p = m;
@@ -756,7 +757,7 @@ rb_glob(path, func, arg)
}
void
-rb_iglob(path, func, arg)
+rb_globi(path, func, arg)
char *path;
void (*func)();
VALUE arg;
@@ -886,6 +887,9 @@ dir_s_glob(dir, str)
}
if (buf != buffer)
free(buf);
+ if (ary && RARRAY(ary)->len == 0) {
+ rb_warning("no matches found: %s", RSTRING(str)->ptr);
+ }
return ary;
}
diff --git a/eval.c b/eval.c
index 46a361116b..fd7c3dde30 100644
--- a/eval.c
+++ b/eval.c
@@ -1428,7 +1428,7 @@ ev_const_defined(cref, id, self)
{
NODE *cbase = cref;
- while (cbase && cbase->nd_clss != rb_cObject) {
+ while (cbase) {
struct RClass *klass = RCLASS(cbase->nd_clss);
if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id);
@@ -1449,7 +1449,7 @@ ev_const_get(cref, id, self)
NODE *cbase = cref;
VALUE result;
- while (cbase && cbase->nd_clss != rb_cObject) {
+ while (cbase) {
struct RClass *klass = RCLASS(cbase->nd_clss);
if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id);
@@ -1467,7 +1467,7 @@ rb_mod_nesting()
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();
- while (cbase && cbase->nd_clss != rb_cObject) {
+ while (cbase) {
rb_ary_push(ary, cbase->nd_clss);
cbase = cbase->nd_next;
}
@@ -1480,7 +1480,7 @@ rb_mod_s_constants()
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();
- while (cbase && cbase->nd_clss != rb_cObject) {
+ while (cbase) {
rb_mod_const_at(cbase->nd_clss, ary);
cbase = cbase->nd_next;
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 1e3611394d..668b332054 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1828,7 +1828,7 @@ sock_s_getservbyaname(argc, argv)
port = strtoul(s, &end, 0);
if (*end != '\0') {
- rb_raise(rb_eSocket, "no such servce %s/%s", s, proto);
+ rb_raise(rb_eSocket, "no such service %s/%s", s, proto);
}
}
diff --git a/file.c b/file.c
index d24f6297c1..dcc1c1e89b 100644
--- a/file.c
+++ b/file.c
@@ -313,7 +313,7 @@ rb_stat(file, st)
#if defined DJGPP
if (RSTRING(file)->len == 0) return -1;
#endif
- return stat(RSTRING(file)->ptr, st);
+ return rb_sys_stat(RSTRING(file)->ptr, st);
}
static VALUE
@@ -323,7 +323,7 @@ rb_file_s_stat(obj, fname)
struct stat st;
Check_SafeStr(fname);
- if (stat(RSTRING(fname)->ptr, &st) == -1) {
+ if (rb_sys_stat(RSTRING(fname)->ptr, &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
return stat_new(&st);
@@ -419,7 +419,7 @@ eaccess(path, mode)
struct stat st;
static int euid = -1;
- if (stat(path, &st) < 0) return (-1);
+ if (rb_sys_stat(path, &st) < 0) return (-1);
if (euid == -1)
euid = geteuid ();
@@ -721,7 +721,7 @@ check3rdbyte(file, mode)
{
struct stat st;
- if (stat(file, &st) < 0) return Qfalse;
+ if (rb_sys_stat(file, &st) < 0) return Qfalse;
if (st.st_mode & mode) return Qtrue;
return Qfalse;
}
@@ -2115,7 +2115,7 @@ path_check_1(path)
return path_check_1(buf);
}
for (;;) {
- if (stat(path, &st) == 0 && (st.st_mode & 002)) {
+ if (rb_sys_stat(path, &st) == 0 && (st.st_mode & 002)) {
if (p) *p = '/';
return 0;
}
@@ -2234,7 +2234,7 @@ rb_find_file(file)
}
path = dln_find_file(file, path);
- if (path && stat(path, &st) == 0) {
+ if (path && rb_sys_stat(path, &st) == 0) {
return path;
}
return 0;
diff --git a/gc.c b/gc.c
index f97899cefd..56dddc5d5a 100644
--- a/gc.c
+++ b/gc.c
@@ -42,7 +42,7 @@ void rb_io_fptr_finalize _((struct OpenFile*));
# if defined(HAVE_ALLOCA_H)
# include <alloca.h>
# elif !defined(alloca)
-char *alloca();
+void *alloca();
# endif
#endif /* __GNUC__ */
@@ -1294,11 +1294,13 @@ id2ref(obj, id)
rb_secure(4);
p0 = ptr = NUM2UINT(id);
- if (FIXNUM_P(ptr)) return (VALUE)ptr;
- if (SYMBOL_P(ptr)) return (VALUE)ptr;
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
if (ptr == Qnil) return Qnil;
+ if (FIXNUM_P(ptr)) return (VALUE)ptr;
+ if (SYMBOL_P(ptr) && rb_id2name(SYM2ID((VALUE)ptr)) != 0) {
+ return (VALUE)ptr;
+ }
ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
if (!is_pointer_to_heap(ptr)) {
diff --git a/lib/debug.rb b/lib/debug.rb
index 220b68d2c9..9e777952ad 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -535,7 +535,7 @@ Commands
cat[ch] <an Exception> set catchpoint to an exception
b[reak] list breakpoints
cat[ch] show catchpoint
- del[ele][ nnn] delete some or all breakpoints
+ del[ete][ nnn] delete some or all breakpoints
disp[lay] <expression> add expression into display expression list
undisp[lay][ nnn] delete one particular or all display expressions
c[ont] run until program ends or hit breakpoint
diff --git a/lib/find.rb b/lib/find.rb
index b220018b6b..3c16533794 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -32,7 +32,7 @@ module Find
d.close
end
end
- rescue Errno::ENOENT
+ rescue Errno::ENOENT, Errno::EACCES
end
end
end
diff --git a/marshal.c b/marshal.c
index 35ceee9aa0..284d4e0fe8 100644
--- a/marshal.c
+++ b/marshal.c
@@ -46,7 +46,7 @@ shortlen(len, ds)
num = SHORTDN(num);
offset++;
}
- return len*sizeof(BDIGIT)/sizeof(short) - offset;
+ return (len - 1)*sizeof(BDIGIT)/sizeof(short) + offset;
}
#define SHORTLEN(x) shortlen((x),d)
#endif
diff --git a/object.c b/object.c
index 071dfb1bab..8bb1d29e68 100644
--- a/object.c
+++ b/object.c
@@ -512,7 +512,7 @@ sym_inspect(sym)
char *name;
name = rb_id2name(SYM2ID(sym));
- str = rb_str_new(0, strlen(name)+2);
+ str = rb_str_new(0, strlen(name)+1);
RSTRING(str)->ptr[0] = ':';
strcpy(RSTRING(str)->ptr+1, name);
return str;
diff --git a/ruby.h b/ruby.h
index a9f9c11503..ff7edf6c55 100644
--- a/ruby.h
+++ b/ruby.h
@@ -592,6 +592,10 @@ rb_special_const_p(VALUE obj)
static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
#endif
+#ifndef rb_sys_stat
+#define rb_sys_stat stat
+#endif
+
#if defined(__cplusplus)
} /* extern "C" { */
#endif
diff --git a/signal.c b/signal.c
index b9c5d66979..5222dc7400 100644
--- a/signal.c
+++ b/signal.c
@@ -252,7 +252,7 @@ rb_f_kill(argc, argv)
else {
for (i=1; i<argc; i++) {
Check_Type(argv[i], T_FIXNUM);
- if (kill(FIX2UINT(argv[i]), sig) < 0)
+ if (kill(FIX2INT(argv[i]), sig) < 0)
rb_sys_fail(0);
}
}
diff --git a/time.c b/time.c
index 1b18859bcc..a06f1abf2a 100644
--- a/time.c
+++ b/time.c
@@ -841,6 +841,9 @@ time_zone(time)
time_get_tm(time, tobj->gmt);
}
+ if (tobj->gmt == 1) {
+ return rb_str_new2("UTC");
+ }
#if defined(HAVE_TM_ZONE)
return rb_str_new2(tobj->tm.tm_zone);
#elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT)
diff --git a/version.h b/version.h
index ca886e9717..5791b1bc85 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.0"
-#define RUBY_RELEASE_DATE "2001-03-20"
+#define RUBY_RELEASE_DATE "2001-03-21"
#define RUBY_VERSION_CODE 170
-#define RUBY_RELEASE_CODE 20010320
+#define RUBY_RELEASE_CODE 20010321