1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (proc_save_safe_level, proc_get_safe_level,

proc_set_safe_level): save/restore safe level 1..4.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-10-09 08:43:39 +00:00
parent 0b2e94b2ab
commit dd3eed4f08
2 changed files with 10 additions and 34 deletions

View file

@ -1,3 +1,8 @@
Thu Oct 9 17:43:36 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (proc_save_safe_level, proc_get_safe_level,
proc_set_safe_level): save/restore safe level 1..4.
Thu Oct 9 15:45:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Thu Oct 9 15:45:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (uv_to_utf8): change message to "out of range", since * pack.c (uv_to_utf8): change message to "out of range", since

39
eval.c
View file

@ -6866,57 +6866,28 @@ rb_f_binding(self)
return bind; return bind;
} }
#define PROC_T3 FL_USER1 #define PROC_TSHIFT (FL_USHIFT+1)
#define PROC_T4 FL_USER2 #define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
#define PROC_TMAX (FL_USER1|FL_USER2)
#define PROC_TMASK (FL_USER1|FL_USER2)
static void static void
proc_save_safe_level(data) proc_save_safe_level(data)
VALUE data; VALUE data;
{ {
if (OBJ_TAINTED(data)) { FL_SET(data, (ruby_safe_level << PROC_TSHIFT) & PROC_TMASK);
switch (ruby_safe_level) {
case 3:
FL_SET(data, PROC_T3);
break;
case 4:
FL_SET(data, PROC_T4);
break;
default:
if (ruby_safe_level > 4) {
FL_SET(data, PROC_TMAX);
}
break;
}
}
} }
static int static int
proc_get_safe_level(data) proc_get_safe_level(data)
VALUE data; VALUE data;
{ {
if (OBJ_TAINTED(data)) { return (RBASIC(data)->flags & PROC_TMASK) >> PROC_TSHIFT;
switch (RBASIC(data)->flags & PROC_TMASK) {
case PROC_T3:
return 3;
case PROC_T4:
return 4;
case PROC_TMAX:
return 5;
}
return 3;
}
return 0;
} }
static void static void
proc_set_safe_level(data) proc_set_safe_level(data)
VALUE data; VALUE data;
{ {
if (OBJ_TAINTED(data)) { ruby_safe_level = proc_get_safe_level(data);
ruby_safe_level = proc_get_safe_level(data);
}
} }
static VALUE static VALUE