1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-01-27 08:08:39 +00:00
parent ceb8031b6b
commit 1f25ed85a9
13 changed files with 346 additions and 326 deletions

View file

@ -1,3 +1,11 @@
Wed Jan 27 03:16:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* variable.c (rb_mod_const_at): can't list constants of the
untainted objects in safe mode.
* class.c (method_list): can't list methods of untainted objects
in safe mode.
Tue Jan 26 02:40:41 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
* prec.c: Precision support for numbers.

View file

@ -2,13 +2,12 @@ SHELL = /bin/sh
#### Start of system configuration section. ####
MAJOR= @MAJOR@
MINOR= @MINOR@
MAJOR= @MAJOR@
MINOR= @MINOR@
TEENY= @TEENY@
RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
srcdir = @srcdir@
VPATH = @srcdir@:@srcdir@/missing
@ -32,7 +31,6 @@ binsuffix = @binsuffix@
#### End of system configuration section. ####
LIBRUBY_A = @LIBRUBY_A@
LIBRUBY_SO = @LIBRUBY_SO@
LIBRUBY_ALIASES= @LIBRUBY_ALIASES@

View file

@ -365,6 +365,8 @@ method_list(mod, option, func)
VALUE klass;
VALUE *p, *q, *pend;
if (rb_safe_level() >= 4 && !FL_TEST(mod, FL_TAINT))
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
for (klass = mod; klass; klass = RCLASS(klass)->super) {
st_foreach(RCLASS(klass)->m_tbl, func, ary);
@ -426,6 +428,8 @@ rb_obj_singleton_methods(obj)
VALUE klass;
VALUE *p, *q, *pend;
if (rb_safe_level() >= 4 && !FL_TEST(obj, FL_TAINT))
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
klass = CLASS_OF(obj);
while (klass && FL_TEST(klass, FL_SINGLETON)) {

440
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,10 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ruby.h)
MAJOR=1
MINOR=3
TEENY=1
rb_version=`grep RUBY_VERSION $srcdir/version.h`
MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
TEENY=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)"'`
AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
@ -572,14 +573,14 @@ if test "$fat_binary" = yes ; then
CFLAGS="$CFLAGS $ARCH_FLAG"
fi
LIBRUBY_A='libruby.a'
LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
LIBRUBY='$(LIBRUBY_A)'
LIBRUBYARG='$(LIBRUBY_A)'
SOLIBS=
if test "$host_os" = "beos"; then
CFLAGS="$CFLAGS -relax_pointers"
LIBRUBY='$(LIBRUBY_SO)'
LIBRUBYARG='-lruby'
LIBRUBYARG='-l$(RUBY_INSTALL_NAME)'
SOLIBS='-lnet'
echo creating ruby.def
case "$host_cpu" in
@ -593,21 +594,19 @@ if test "$host_os" = "beos"; then
esac
fi
AC_SUBST(LIBSUFFIX)
LIBRUBY_SO='libruby.so.$(MAJOR).$(MINOR).$(TEENY)'
LIBRUBY_ALIASES='libruby.so'
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
if test "$enable_shared" = 'yes'; then
LIBRUBY='$(LIBRUBY_SO)'
LIBRUBYARG='-L./ -lruby'
LIBRUBYARG='-L./ -l$(RUBY_INSTALL_NAME)'
CFLAGS="$CFLAGS $CCDLFLAGS"
case "$host_os" in
freebsd2*|sunos4*)
LIBRUBY_ALIASES='libruby.so.$(MAJOR).$(MINOR) libruby.so'
freebsd2*|sunos4*|linux*)
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
;;
hpux*)
LIBRUBY_SO='libruby.sl.$(MAJOR).$(MINOR).$(TEENY)'
LIBRUBY_ALIASES='libruby.sl.$(MAJOR).$(MINOR) libruby.sl'
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
;;
*)
;;
@ -628,7 +627,7 @@ case "$host_os" in
;;
esac
AC_SUBST(RUBY_INSTALL_NAME)
AC_SUBST(LIBRUBY_A)
AC_SUBST(LIBRUBY_SO)
AC_SUBST(LIBRUBY_ALIASES)
@ -644,6 +643,7 @@ ri_suffix=
test "$program_suffix" != NONE &&
ri_suffix=$program_suffix
LIBSUFFIX=$ri_suffix
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
AC_DEFINE_UNQUOTED(RUBY_LIB, "${prefix}/lib/${RUBY_INSTALL_NAME}")
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${prefix}/lib/${RUBY_INSTALL_NAME}/site_ruby")

134
eval.c
View file

@ -207,9 +207,9 @@ rb_alias(klass, name, def)
}
body = orig->nd_body;
if (nd_type(body) == NODE_FBODY) { /* was alias */
body = body->nd_head;
def = body->nd_mid;
origin = body->nd_orig;
body = body->nd_head;
}
st_insert(RCLASS(klass)->m_tbl, name,
@ -633,22 +633,33 @@ static VALUE ruby_wrapper; /* security wrapper */
ruby_scope = _scope; \
scope_vmode = SCOPE_PUBLIC;
#ifdef USE_THREAD
#define SCOPE_DONT_RECYCLE FL_USER2
static void scope_dup(struct SCOPE *);
#define POP_SCOPE() \
if (ruby_scope->flag == SCOPE_ALLOCA) {\
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) {\
scope_dup(ruby_scope);\
FL_SET(_old, SCOPE_DONT_RECYCLE);\
}\
else {\
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE)) {\
FL_SET(_old, SCOPE_DONT_RECYCLE);\
}\
else {\
if (ruby_scope->flag == SCOPE_ALLOCA) {\
ruby_scope->local_vars = 0;\
ruby_scope->local_tbl = 0;\
if (ruby_scope != top_scope)\
rb_gc_force_recycle((VALUE)ruby_scope);\
}\
else {\
ruby_scope->flag |= SCOPE_NOSTACK;\
}\
}\
ruby_scope = _old;\
scope_vmode = _vmode;\
}
#else /* not USE_THREAD */
#define POP_SCOPE() \
if (ruby_scope->flag == SCOPE_ALLOCA) {\
ruby_scope->local_vars = 0;\
ruby_scope->local_tbl = 0;\
if (ruby_scope != top_scope)\
rb_gc_force_recycle((VALUE)ruby_scope);\
}\
else {\
ruby_scope->flag |= SCOPE_NOSTACK;\
@ -656,6 +667,7 @@ static void scope_dup(struct SCOPE *);
ruby_scope = _old;\
scope_vmode = _vmode;\
}
#endif /* USE_THREAD */
static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
@ -1128,6 +1140,10 @@ rb_eval_cmd(cmd, arg)
val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
#ifdef USE_THREAD
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(saved_scope, SCOPE_DONT_RECYCLE);
#endif
ruby_scope = saved_scope;
safe_level = safe;
POP_TAG();
@ -3168,8 +3184,10 @@ rb_yield_0(val, self, klass)
POP_VARS();
ruby_block = block;
ruby_frame = ruby_frame->prev;
#ifdef USE_THREAD
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(old_scope, SCOPE_DONT_RECYCLE);
#endif
ruby_scope = old_scope;
if (state) JUMP_TAG(state);
return result;
@ -3684,14 +3702,12 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
break;
}
#if 0
if ((++tick & 0x3ff) == 0) {
CHECK_INTS; /* better than nothing */
if (stack_length() > STACK_LEVEL_MAX) {
rb_raise(rb_eSysStackError, "stack level too deep");
}
}
#endif
PUSH_ITER(itr);
PUSH_FRAME();
@ -4181,8 +4197,10 @@ eval(self, src, scope, file, line)
rb_in_eval--;
if (!NIL_P(scope)) {
ruby_frame = ruby_frame->prev;
#ifdef USE_THREAD
if (FL_TEST(ruby_scope, SCOPE_DONT_RECYCLE))
FL_SET(old_scope, SCOPE_DONT_RECYCLE);
#endif
ruby_scope = old_scope;
ruby_block = old_block;
ruby_calling_block = old_call_block;
@ -4313,7 +4331,8 @@ static VALUE
yield_under(under, self)
VALUE under, self;
{
rb_secure(4);
if (rb_safe_level() >= 4 && !FL_TEST(self, FL_TAINT))
rb_raise(rb_eSecurityError, "Insecure: can't eval");
return exec_under(yield_under_i, under, self);
}
@ -6573,41 +6592,42 @@ rb_thread_abort_exc_set(thread, val)
return val;
}
#define THREAD_ALLOC(th) {\
th = ALLOC(struct thread);\
\
th->status = 0;\
th->result = 0;\
th->rb_errinfo = Qnil;\
\
th->stk_ptr = 0;\
th->stk_len = 0;\
th->stk_max = 0;\
th->wait_for = 0;\
th->fd = 0;\
th->delay = 0.0;\
th->join = 0;\
\
th->frame = 0;\
th->scope = 0;\
th->klass = 0;\
th->dyna_vars = 0;\
th->block = 0;\
th->iter = 0;\
th->tag = 0;\
th->rb_errinfo = 0;\
th->last_status = 0;\
th->last_line = 0;\
th->last_match = 0;\
th->abort = 0;\
}
static thread_t
rb_thread_alloc(klass)
VALUE klass;
{
thread_t th;
th = ALLOC(struct thread);
th->status = THREAD_RUNNABLE;
th->status = 0;
th->result = 0;
th->rb_errinfo = Qnil;
th->stk_ptr = 0;
th->stk_len = 0;
th->stk_max = 0;
th->wait_for = 0;
th->fd = 0;
th->delay = 0.0;
th->join = 0;
th->frame = 0;
th->scope = 0;
th->klass = 0;
th->wrapper = 0;
th->dyna_vars = 0;
th->block = 0;
th->iter = 0;
th->tag = 0;
th->rb_errinfo = 0;
th->last_status = 0;
th->last_line = 0;
th->last_match = 0;
th->abort = 0;
THREAD_ALLOC(th);
th->thread = Data_Wrap_Struct(klass, thread_mark, thread_free, th);
if (curr_thread) {
@ -7030,35 +7050,9 @@ rb_callcc(self)
VALUE self;
{
volatile VALUE cont;
thread_t th = ALLOC(struct thread);
th->status = THREAD_RUNNABLE;
th->status = 0;
th->result = 0;
th->rb_errinfo = Qnil;
th->stk_ptr = 0;
th->stk_len = 0;
th->stk_max = 0;
th->wait_for = 0;
th->fd = 0;
th->delay = 0.0;
th->join = 0;
th->frame = 0;
th->scope = 0;
th->klass = 0;
th->dyna_vars = 0;
th->block = 0;
th->iter = 0;
th->tag = 0;
th->rb_errinfo = 0;
th->last_status = 0;
th->last_line = 0;
th->last_match = 0;
th->abort = 0;
thread_t th;
THREAD_ALLOC(th);
th->thread = cont = Data_Wrap_Struct(rb_cContinuation, thread_mark,
thread_free, th);

View file

@ -272,7 +272,7 @@ def create_makefile(target)
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir
end
$srcdir = $top_srcdir + "/ext/" + target
$srcdir = $top_srcdir + "/ext/" + $mdir
mfile = open("Makefile", "w")
mfile.printf "\
SHELL = /bin/sh

View file

@ -2,7 +2,7 @@
# tkscrollbox.rb - Tk Listbox with Scrollbar
# as an example of Composite Widget
# $Date$
# by Yukihiro Matsumoto <matz@caelum.co.jp>
# by Yukihiro Matsumoto <matz@netlab.co.jp>
require 'tk.rb'

6
gc.c
View file

@ -598,7 +598,8 @@ rb_gc_mark(ptr)
break;
case T_SCOPE:
if (obj->as.scope.local_vars) {
if (obj->as.scope.local_vars &&
obj->as.scope.flag != SCOPE_ALLOCA) {
int n = obj->as.scope.local_tbl[0]+1;
VALUE *vars = &obj->as.scope.local_vars[-1];
@ -807,7 +808,8 @@ obj_free(obj)
return; /* no need to free iv_tbl */
case T_SCOPE:
if (RANY(obj)->as.scope.local_vars) {
if (RANY(obj)->as.scope.local_vars &&
RANY(obj)->as.scope.flag != SCOPE_ALLOCA) {
VALUE *vars = RANY(obj)->as.scope.local_vars-1;
if (vars[0] == 0)
free(RANY(obj)->as.scope.local_tbl);

View file

@ -37,12 +37,13 @@ end
pwd = Dir.pwd
Dir.chdir libdir
if File.exist? CONFIG["LIBRUBY_SO"]
for alias in [CONFIG["LIBRUBY_SO"]]
if File.exist? alias
File.delete alias
for link in CONFIG["LIBRUBY_ALIASES"].split
if File.exist? link
File.delete link
end
File.symlink CONFIG["LIBRUBY_SO"], alias
print "link #{CONFIG['LIBRUBY_SO']} -> #{alias}\n"
File.symlink CONFIG["LIBRUBY_SO"], link
print "link #{CONFIG['LIBRUBY_SO']} -> #{link}\n"
end
end
Dir.chdir pwd
File.makedirs "#{destdir}#{pkglibdir}", true
@ -58,7 +59,7 @@ File.makedirs(archdir,true)
for f in Dir["*.h"]
File.install f, "#{destdir}#{archdir}", 0644, true
end
File.install "libruby.a", "#{destdir}#{archdir}", 0644, true
File.install CONFIG['LIBRUBY_A'], "#{destdir}#{archdir}", 0644, true
File.makedirs "#{destdir}#{mandir}", true
File.install "ruby.1", "#{destdir}#{mandir}", 0644, true

View file

@ -1330,20 +1330,23 @@ fix_step(from, to, step)
if (!FIXNUM_P(to) || !FIXNUM_P(step))
return int_step(from, to, step);
i = FIX2LONG(from);
end = FIX2LONG(to);
diff = FIX2LONG(step);
if (diff == 0) {
rb_raise(rb_eArgError, "step cannot be 0");
}
else if (diff > 0) {
for (i=FIX2LONG(from); i <= end; i+=diff) {
if (diff > 0) {
while (i <= end) {
rb_yield(INT2FIX(i));
i += diff;
}
}
else {
for (i=FIX2LONG(from); i >= end; i+=diff) {
while (i >= end) {
rb_yield(INT2FIX(i));
i += diff;
}
}
return from;

View file

@ -716,9 +716,11 @@ generic_ivar_set(obj, id, val)
VALUE val;
{
st_table *tbl;
int special = Qfalse;
if (rb_special_const_p(obj)) {
special_generic_ivar = 1;
special = Qtrue;
}
if (!generic_iv_tbl) {
generic_iv_tbl = st_init_numtable();
@ -824,6 +826,8 @@ rb_ivar_get(obj, id)
{
VALUE val;
if (!FL_TEST(obj, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't access instance variable");
switch (TYPE(obj)) {
case T_OBJECT:
case T_CLASS:
@ -849,13 +853,13 @@ rb_ivar_set(obj, id, val)
ID id;
VALUE val;
{
if (!FL_TEST(obj, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable");
switch (TYPE(obj)) {
case T_OBJECT:
case T_CLASS:
case T_MODULE:
case T_FILE:
if (rb_safe_level() >= 4 && !FL_TEST(obj, FL_TAINT))
rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable");
if (!ROBJECT(obj)->iv_tbl) ROBJECT(obj)->iv_tbl = st_init_numtable();
st_insert(ROBJECT(obj)->iv_tbl, id, val);
break;
@ -907,6 +911,8 @@ rb_obj_instance_variables(obj)
{
VALUE ary;
if (!FL_TEST(obj, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
switch (TYPE(obj)) {
case T_OBJECT:
case T_CLASS:
@ -938,6 +944,8 @@ rb_obj_remove_instance_variable(obj, name)
VALUE val = Qnil;
ID id = rb_to_id(name);
if (!FL_TEST(obj, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable");
if (!rb_is_instance_id(id)) {
rb_raise(rb_eNameError, "`%s' is not an instance variable",
rb_id2name(id));
@ -1080,6 +1088,8 @@ VALUE
rb_mod_const_at(mod, ary)
VALUE mod, ary;
{
if (!FL_TEST(mod, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
if (RCLASS(mod)->iv_tbl) {
st_foreach(RCLASS(mod)->iv_tbl, const_i, ary);
}
@ -1163,7 +1173,7 @@ rb_const_set(klass, id, val)
ID id;
VALUE val;
{
if (rb_safe_level() >= 4 && !FL_TEST(klass, FL_TAINT))
if (!FL_TEST(klass, FL_TAINT) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't set constant");
if (!RCLASS(klass)->iv_tbl) {
RCLASS(klass)->iv_tbl = st_init_numtable();

View file

@ -1,2 +1,2 @@
#define RUBY_VERSION "1.3.1"
#define VERSION_DATE "99/01/20"
#define VERSION_DATE "99/01/27"