summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-11-22 09:14:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-11-22 09:14:24 +0000
commite2d384d628c8e4bd59300844e9111645d1070d5a (patch)
treecce3e69dea4b7f93481a4cdc5d16c61558cfa546 /file.c
parent8347974c9fd6fcfd6af8d06f5c8ceca3bce76057 (diff)
* file.c (rb_find_file_ext): should not terminate searching with
empty path, just ignore. * dir.c: remove <sys/parm.h> inclusion. * compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): check using rb_cmpint(). * error.c (init_syserr): remove sys_nerr dependency. * numeric.c (num_cmp): added to satisfy Comparable assumption. * eval.c (rb_add_method): "initialize" should be public if it is a singleton method. * regex.c (re_match): avoid dereferencing if size == 0. (ruby-bugs-ja:PR#360) * time.c (time_cmp): should return nil if an operand is not a number nor time. (ruby-bugs-ja:PR#359) * file.c (rb_stat_cmp): should return nil if an operand is not File::Stat. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/file.c b/file.c
index 565de7c2b6..04af8db766 100644
--- a/file.c
+++ b/file.c
@@ -34,7 +34,8 @@ int flock _((int, int));
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
-#else
+#endif
+#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
@@ -158,7 +159,7 @@ rb_stat_cmp(self, other)
else
return INT2FIX(1);
}
- rb_raise(rb_eTypeError, "operand is not File::Stat");
+ return Qnil;
}
static VALUE
@@ -1436,7 +1437,7 @@ rb_file_s_expand_path(argc, argv)
if (!dir) {
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `%s'", s);
}
- BUFCHECK (strlen(dir) > buflen);
+ BUFCHECK(strlen(dir) > buflen);
strcpy(buf, dir);
p = buf + strlen(dir);
s++;
@@ -1451,7 +1452,7 @@ rb_file_s_expand_path(argc, argv)
while (*s && !isdirsep(*s)) {
s = CharNext(s);
}
- BUFCHECK (p + (s-b) >= pend);
+ BUFCHECK(p + (s-b) >= pend);
memcpy(p, b, s-b);
p += s-b;
*p = '\0';
@@ -1461,7 +1462,7 @@ rb_file_s_expand_path(argc, argv)
endpwent();
rb_raise(rb_eArgError, "user %s doesn't exist", buf);
}
- BUFCHECK (strlen(pwPtr->pw_dir) > buflen);
+ BUFCHECK(strlen(pwPtr->pw_dir) > buflen);
strcpy(buf, pwPtr->pw_dir);
p = buf + strlen(pwPtr->pw_dir);
endpwent();
@@ -1475,7 +1476,7 @@ rb_file_s_expand_path(argc, argv)
while (*s && !isdirsep(*s)) {
s = CharNext(s);
}
- BUFCHECK (p + (s-b) >= pend);
+ BUFCHECK(p + (s-b) >= pend);
memcpy(p, b, s-b);
p += s-b;
}
@@ -1484,7 +1485,7 @@ rb_file_s_expand_path(argc, argv)
if (!NIL_P(dname)) {
dname = rb_file_s_expand_path(1, &dname);
if (OBJ_TAINTED(dname)) tainted = 1;
- BUFCHECK (RSTRING(dname)->len > buflen);
+ BUFCHECK(RSTRING(dname)->len > buflen);
memcpy(buf, RSTRING(dname)->ptr, RSTRING(dname)->len);
p += RSTRING(dname)->len;
}
@@ -1492,7 +1493,7 @@ rb_file_s_expand_path(argc, argv)
char *dir = my_getcwd();
tainted = 1;
- BUFCHECK (strlen(dir) > buflen);
+ BUFCHECK(strlen(dir) > buflen);
strcpy(buf, dir);
free(dir);
p = &buf[strlen(buf)];
@@ -1502,7 +1503,7 @@ rb_file_s_expand_path(argc, argv)
else {
while (*s && isdirsep(*s)) {
*p++ = '/';
- BUFCHECK (p >= pend);
+ BUFCHECK(p >= pend);
s++;
}
if (p > buf && *s) p--;
@@ -1548,7 +1549,7 @@ rb_file_s_expand_path(argc, argv)
case '\\':
#endif
if (s > b) {
- BUFCHECK (p + (s-b+1) >= pend);
+ BUFCHECK(p + (s-b+1) >= pend);
memcpy(++p, b, s-b);
p += s-b;
*p = '/';
@@ -1562,7 +1563,7 @@ rb_file_s_expand_path(argc, argv)
}
if (s > b) {
- BUFCHECK (p + (s-b) >= pend);
+ BUFCHECK(p + (s-b) >= pend);
memcpy(++p, b, s-b);
p += s-b;
}
@@ -2476,7 +2477,7 @@ rb_find_file_ext(filep, ext)
VALUE str = RARRAY(rb_load_path)->ptr[i];
SafeStringValue(str);
- if (RSTRING(str)->len == 0) return 0;
+ if (RSTRING(str)->len == 0) continue;
path = RSTRING(str)->ptr;
for (j=0; ext[j]; j++) {
fname = rb_str_dup(*filep);