mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_provided): extension should be guessed using
rb_find_file_noext(). * eval.c (rb_f_require): should call rb_feature_p() after extension completion. * eval.c (rb_eval): add CHECK_INTS before next, redo, retry to avoid potential uninterruptable infinite loop. * file.c (rb_file_s_expand_path): use CharNext() to expand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
980f816479
commit
0abedcd807
3 changed files with 69 additions and 15 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,12 +1,40 @@
|
|||
Fri Jul 27 18:07:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_provided): extension should be guessed using
|
||||
rb_find_file_noext().
|
||||
|
||||
* eval.c (rb_f_require): should call rb_feature_p() after
|
||||
extension completion.
|
||||
|
||||
Fri Jul 27 16:25:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_eval): add CHECK_INTS before next, redo, retry to
|
||||
avoid potential uninterruptable infinite loop.
|
||||
|
||||
Thu Jul 26 11:27:12 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* file.c (rb_find_file_noext, rb_find_file): fix tilde expansion
|
||||
problem.
|
||||
|
||||
Wed Jul 25 17:54:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* file.c (rb_file_s_expand_path): use CharNext() to expand.
|
||||
|
||||
Wed Jul 25 17:16:26 2001 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* intern.h: add some missing function prototypes.
|
||||
|
||||
Wed Jul 25 15:50:05 2001 Guy Decoux <decoux@moulon.inra.fr>
|
||||
|
||||
* file.c (rb_file_s_expand_path): should not expand "." and ".."
|
||||
not following dirsep.
|
||||
|
||||
Wed Jul 25 12:15:32 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* file.c (rb_find_file_noext): should update f by expanded path.
|
||||
|
||||
* file.c (rb_find_file): ditto.
|
||||
|
||||
Tue Jul 24 23:10:47 2001 Nobuyoshi.Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* file.c (strrdirsep): multi-byte pathname and DOSish separater
|
||||
|
|
18
eval.c
18
eval.c
|
@ -2398,6 +2398,7 @@ rb_eval(self, n)
|
|||
break;
|
||||
|
||||
case NODE_NEXT:
|
||||
CHECK_INTS;
|
||||
if (node->nd_stts) {
|
||||
return_value(avalue_to_svalue(rb_eval(self, node->nd_stts)));
|
||||
}
|
||||
|
@ -2408,10 +2409,12 @@ rb_eval(self, n)
|
|||
break;
|
||||
|
||||
case NODE_REDO:
|
||||
CHECK_INTS;
|
||||
JUMP_TAG(TAG_REDO);
|
||||
break;
|
||||
|
||||
case NODE_RETRY:
|
||||
CHECK_INTS;
|
||||
JUMP_TAG(TAG_RETRY);
|
||||
break;
|
||||
|
||||
|
@ -5385,7 +5388,14 @@ int
|
|||
rb_provided(feature)
|
||||
const char *feature;
|
||||
{
|
||||
return rb_feature_p(feature, Qfalse);
|
||||
VALUE f = rb_str_new2(feature);
|
||||
|
||||
if (strrchr(feature, '.') == 0) {
|
||||
if (rb_find_file_noext(&f) == 0) {
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
return rb_feature_p(RSTRING(f)->ptr, Qfalse);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5413,8 +5423,6 @@ rb_f_require(obj, fname)
|
|||
volatile int safe = ruby_safe_level;
|
||||
|
||||
SafeStringValue(fname);
|
||||
if (rb_feature_p(RSTRING(fname)->ptr, Qtrue))
|
||||
return Qfalse;
|
||||
ext = strrchr(RSTRING(fname)->ptr, '.');
|
||||
if (ext) {
|
||||
if (strcmp(".rb", ext) == 0) {
|
||||
|
@ -5480,6 +5488,8 @@ rb_f_require(obj, fname)
|
|||
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
|
||||
|
||||
load_dyna:
|
||||
if (rb_feature_p(RSTRING(feature)->ptr, Qfalse))
|
||||
return Qfalse;
|
||||
rb_provide_feature(feature);
|
||||
{
|
||||
int volatile old_vmode = scope_vmode;
|
||||
|
@ -5500,6 +5510,8 @@ rb_f_require(obj, fname)
|
|||
return Qtrue;
|
||||
|
||||
load_rb:
|
||||
if (rb_feature_p(RSTRING(feature)->ptr, Qtrue))
|
||||
return Qfalse;
|
||||
ruby_safe_level = 0;
|
||||
rb_provide_feature(feature);
|
||||
/* loading ruby library should be serialized. */
|
||||
|
|
38
file.c
38
file.c
|
@ -1332,7 +1332,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
VALUE *argv;
|
||||
{
|
||||
VALUE fname, dname;
|
||||
char *s, *p;
|
||||
char *s, *p, *sbeg, *b;
|
||||
char buf[MAXPATHLEN+2];
|
||||
char *bend = buf + sizeof(buf) - 2;
|
||||
int tainted;
|
||||
|
@ -1340,7 +1340,7 @@ rb_file_s_expand_path(argc, argv)
|
|||
rb_scan_args(argc, argv, "11", &fname, &dname);
|
||||
|
||||
tainted = OBJ_TAINTED(fname);
|
||||
s = StringValuePtr(fname);
|
||||
s = sbeg = StringValuePtr(fname);
|
||||
p = buf;
|
||||
if (s[0] == '~') {
|
||||
if (isdirsep(s[1]) || s[1] == '\0') {
|
||||
|
@ -1360,10 +1360,13 @@ rb_file_s_expand_path(argc, argv)
|
|||
struct passwd *pwPtr;
|
||||
s++;
|
||||
#endif
|
||||
b = s;
|
||||
while (*s && !isdirsep(*s)) {
|
||||
*p++ = *s++;
|
||||
if (p >= bend) goto toolong;
|
||||
s = CharNext(s);
|
||||
}
|
||||
if (p + (s-b) >= bend) goto toolong;
|
||||
memcpy(p, b, s-b);
|
||||
p += s-b;
|
||||
*p = '\0';
|
||||
#ifdef HAVE_PWD_H
|
||||
pwPtr = getpwnam(buf);
|
||||
|
@ -1381,10 +1384,13 @@ rb_file_s_expand_path(argc, argv)
|
|||
#if defined DOSISH
|
||||
/* skip drive letter */
|
||||
else if (ISALPHA(s[0]) && s[1] == ':' && isdirsep(s[2])) {
|
||||
b = s;
|
||||
while (*s && !isdirsep(*s)) {
|
||||
*p++ = *s++;
|
||||
if (p >= bend) goto toolong;
|
||||
s = CharNext(s);
|
||||
}
|
||||
if (p + (s-b) >= bend) goto toolong;
|
||||
memcpy(p, b, s-b);
|
||||
p += s-b;
|
||||
}
|
||||
#endif
|
||||
else if (!isdirsep(*s)) {
|
||||
|
@ -1411,10 +1417,10 @@ rb_file_s_expand_path(argc, argv)
|
|||
}
|
||||
*p = '/';
|
||||
|
||||
for ( ; *s; s++) {
|
||||
while (*s) {
|
||||
switch (*s) {
|
||||
case '.':
|
||||
if (*(s+1)) {
|
||||
if (*(s+1) && (s == sbeg || isdirsep(*(s - 1)))) {
|
||||
switch (*++s) {
|
||||
case '.':
|
||||
if (*(s+1) == '\0' || isdirsep(*(s+1))) {
|
||||
|
@ -1441,6 +1447,9 @@ rb_file_s_expand_path(argc, argv)
|
|||
*++p = '.'; *++p = *s; break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*++p = '.';
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
#if defined DOSISH
|
||||
|
@ -1448,9 +1457,14 @@ rb_file_s_expand_path(argc, argv)
|
|||
#endif
|
||||
if (!isdirsep(*p)) *++p = '/'; break;
|
||||
default:
|
||||
*++p = *s;
|
||||
if (p >= bend) goto toolong;
|
||||
b = s;
|
||||
s = CharNext(s);
|
||||
p = CharNext(p);
|
||||
if (p + (s-b) >= bend) goto toolong;
|
||||
memcpy(p, b, s-b);
|
||||
continue;
|
||||
}
|
||||
s = CharNext(s);
|
||||
}
|
||||
|
||||
/* Place a \0 at end. If path ends with a "/", delete it */
|
||||
|
@ -2278,7 +2292,7 @@ rb_find_file_noext(filep)
|
|||
if (rb_safe_level() >= 2 && OBJ_TAINTED(fname)) {
|
||||
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
|
||||
}
|
||||
f = STR2CSTR(fname);
|
||||
f = StringValuePtr(fname);
|
||||
*filep = fname;
|
||||
}
|
||||
|
||||
|
@ -2329,7 +2343,7 @@ rb_find_file(path)
|
|||
if (rb_safe_level() >= 2 && OBJ_TAINTED(path)) {
|
||||
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
|
||||
}
|
||||
f = STR2CSTR(path);
|
||||
f = StringValuePtr(path);
|
||||
}
|
||||
|
||||
#if defined(__MACOS__) || defined(riscos)
|
||||
|
|
Loading…
Reference in a new issue