git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-12-08 07:10:38 +00:00
Родитель a721bd628e
Коммит 2322a13127
14 изменённых файлов: 95 добавлений и 50 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Fri Dec 8 10:44:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_mod_remove_cvar): Module#remove_class_variable
added.
Thu Dec 7 17:35:51 2000 Shugo Maeda <shugo@ruby-lang.org>
* eval.c (stack_length): don't use __builtin_frame_address() on alpha.
@ -8,6 +13,17 @@ Wed Dec 6 18:07:13 2000 WATANABE Hirofumi <eban@ruby-lang.org>
* eval.c (rb_mod_define_method): avoid VC4.0 warnings.
Wed Dec 6 13:38:08 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_and): tuning, make hash from shorter operand.
Wed Dec 6 01:28:50 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
* gc.c (rb_gc): __builtin_frame_address() should not be used on
MacOS X.
* gc.c (Init_stack): ditto.
Mon Dec 4 13:44:01 2000 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/jcode.rb: consider multibyte. not /n.

Просмотреть файл

@ -237,7 +237,7 @@ win32.@OBJEXT@: $(srcdir)/win32/win32.c
###
parse.@OBJEXT@: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
###
array.@OBJEXT@: array.c ruby.h config.h defines.h intern.h
array.@OBJEXT@: array.c ruby.h config.h defines.h intern.h st.h
bignum.@OBJEXT@: bignum.c ruby.h config.h defines.h intern.h
class.@OBJEXT@: class.c ruby.h config.h defines.h intern.h node.h st.h
compar.@OBJEXT@: compar.c ruby.h config.h defines.h intern.h

6
ToDo
Просмотреть файл

@ -94,7 +94,11 @@ Standard Libraries
* Process::waitall [ruby-talk:4557]
* synchronized method - synchronized{...}, synchronized :foo, :bar
* move Time::times to Process.
* Module#define_method which takes a name and a body (block, proc or method).
- Module#define_method which takes a name and a body (block, proc or method).
* IO#for_fd in general
* Array#&, Array#| to allow duplication. ???
- fork_and_kill_other_threads.
* way to specify immortal (fork endurance) thread.
Extension Libraries

55
array.c
Просмотреть файл

@ -1436,49 +1436,45 @@ rb_ary_diff(ary1, ary2)
return ary3;
}
static st_table*
static VALUE
ary_make_hash(ary1, ary2, func)
VALUE ary1, ary2;
int (*func)();
{
st_table *tbl = st_init_numtable();
VALUE hash = rb_hash_new();
int i, n;
for (i=0; i<RARRAY(ary1)->len; i++) {
if (!st_lookup(tbl, RARRAY(ary1)->ptr[i], &n)) {
st_add_direct(tbl, RARRAY(ary1)->ptr[i], 0);
}
rb_hash_aset(hash, RARRAY(ary1)->ptr[i], Qtrue);
}
if (ary2) {
for (i=0; i<RARRAY(ary2)->len; i++) {
if (st_lookup(tbl, RARRAY(ary2)->ptr[i], &n)) {
st_insert(tbl, RARRAY(ary2)->ptr[i], 2);
}
else {
st_add_direct(tbl, RARRAY(ary2)->ptr[i], 1);
}
rb_hash_aset(hash, RARRAY(ary2)->ptr[i], Qtrue);
}
}
return tbl;
return hash;
}
static VALUE
rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
st_table *tbl = ary_make_hash(ary1, to_ary(ary2));
VALUE hash;
VALUE ary3 = rb_ary_new();
VALUE v;
long i;
int n;
ary2 = to_ary(ary2);
if (RARRAY(ary1)->len < RARRAY(ary2)->len) { /* swap */
VALUE tmp = ary1; ary1 = ary2; ary2 = tmp;
}
hash = ary_make_hash(ary2, 0);
for (i=0; i<RARRAY(ary1)->len; i++) {
v = RARRAY(ary1)->ptr[i];
if (st_delete(tbl, &v, &n)) {
if (n == 2) rb_ary_push(ary3, v);
VALUE v = RARRAY(ary1)->ptr[i];
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
rb_ary_push(ary3, v);
}
}
st_free_table(tbl);
return ary3;
}
@ -1487,27 +1483,26 @@ static VALUE
rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
st_table *tbl;
VALUE hash;
VALUE ary3 = rb_ary_new();
VALUE v;
long i;
ary2 = to_ary(ary2);
tbl = ary_make_hash(ary1, ary2);
hash = ary_make_hash(ary1, ary2);
for (i=0; i<RARRAY(ary1)->len; i++) {
v = RARRAY(ary1)->ptr[i];
if (st_delete(tbl, &v, 0)) {
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
rb_ary_push(ary3, v);
}
}
for (i=0; i<RARRAY(ary2)->len; i++) {
v = RARRAY(ary2)->ptr[i];
if (st_delete(tbl, &v, 0)) {
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
rb_ary_push(ary3, v);
}
}
st_free_table(tbl);
return ary3;
}
@ -1516,21 +1511,19 @@ static VALUE
rb_ary_uniq_bang(ary)
VALUE ary;
{
st_table *tbl = ary_make_hash(ary, 0);
VALUE hash = ary_make_hash(ary, 0);
VALUE *p, *q, *end;
VALUE v;
if (RARRAY(ary)->len == tbl->num_entries) {
st_free_table(tbl);
if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) {
return Qnil;
}
rb_ary_modify(ary);
rb_ary_modify(ary);
p = q = RARRAY(ary)->ptr;
end = p + RARRAY(ary)->len;
while (p < end) {
v = *p++;
if (st_delete(tbl, &v, 0)) {
VALUE v = *p++;
if (st_delete(RHASH(hash)->tbl, &v, 0)) {
*q++ = v;
}
}

2
eval.c
Просмотреть файл

@ -4037,7 +4037,7 @@ stack_length(p)
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__) && !defined(__alpha__)
# if defined(__GNUC__) && !defined(__alpha__) && !defined(__APPLE__)
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);

4
gc.c
Просмотреть файл

@ -925,7 +925,7 @@ rb_gc()
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__) && !defined(__alpha__)
# if defined(__GNUC__) && !defined(__alpha__) && !defined(__APPLE__)
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);
@ -1005,7 +1005,7 @@ Init_stack(addr)
#if defined(__human68k__)
extern void *_SEND;
rb_gc_stack_start = _SEND;
#elif defined(__GNUC__) && !defined(__alpha__)
#elif defined(__GNUC__) && !defined(__alpha__) && !defined(__APPLE__)
rb_gc_stack_start = __builtin_frame_address(2);
#else
VALUE start;

Просмотреть файл

@ -371,11 +371,12 @@ void rb_const_assign _((VALUE, ID, VALUE));
VALUE rb_mod_constants _((VALUE));
void rb_autoload_load _((ID));
void rb_cvar_declare _((VALUE, ID, VALUE));
int rb_cvar_defined _((VALUE, ID));
VALUE rb_cvar_defined _((VALUE, ID));
void rb_cvar_set _((VALUE, ID, VALUE));
VALUE rb_cvar_get _((VALUE, ID));
VALUE rb_cvar_singleton _((VALUE));
VALUE rb_mod_class_variables _((VALUE));
VALUE rb_mod_remove_cvar _((VALUE, VALUE));
/* version.c */
void ruby_show_version _((void));
void ruby_show_copyright _((void));

Просмотреть файл

@ -29,6 +29,9 @@ class Tempfile < SimpleDelegator
end
def initialize(basename, tmpdir=ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp')
if $SAFE > 0 and tmpdir.tainted?
tmpdir = '/tmp'
end
umask = File.umask(0177)
begin
n = 0

Просмотреть файл

@ -1203,6 +1203,7 @@ Init_Object()
rb_define_private_method(rb_cModule, "remove_const", rb_mod_remove_const, 1);
rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1);
rb_define_method(rb_cModule, "class_variables", rb_mod_class_variables, 0);
rb_define_private_method(rb_cModule, "remove_class_variable", rb_mod_remove_cvar, 1);
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);

Просмотреть файл

@ -1225,33 +1225,34 @@ rb_const_defined(klass, id)
}
static void
mod_av_set(klass, id, val, dest, once)
mod_av_set(klass, id, val, isconst)
VALUE klass;
ID id;
VALUE val;
char *dest;
int once;
int isconst;
{
char *dest = isconst ? "constant" : "class variable";
if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest);
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
if (!RCLASS(klass)->iv_tbl) {
RCLASS(klass)->iv_tbl = st_init_numtable();
}
else if (once && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
else if (isconst && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
rb_warn("already initialized %s %s", dest, rb_id2name(id));
}
st_insert(RCLASS(klass)->iv_tbl, id, val);
}
void
rb_const_set(klass, id, val)
VALUE klass;
ID id;
VALUE val;
{
mod_av_set(klass, id, val, "constant", Qtrue);
mod_av_set(klass, id, val, Qtrue);
}
void
@ -1377,7 +1378,7 @@ rb_cvar_declare(klass, id, val)
tmp = RCLASS(tmp)->super;
}
mod_av_set(klass, id, val, "class variable", Qfalse);
mod_av_set(klass, id, val, Qfalse);
}
VALUE
@ -1401,7 +1402,7 @@ rb_cvar_get(klass, id)
return Qnil; /* not reached */
}
int
VALUE
rb_cvar_defined(klass, id)
VALUE klass;
ID id;
@ -1485,6 +1486,32 @@ rb_mod_class_variables(obj)
return ary;
}
VALUE
rb_mod_remove_cvar(mod, name)
VALUE mod, name;
{
ID id = rb_to_id(name);
VALUE val;
if (!rb_is_class_id(id)) {
rb_raise(rb_eNameError, "wrong class variable name %s", name);
}
if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't remove class variable");
if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
if (RCLASS(mod)->iv_tbl && st_delete(ROBJECT(mod)->iv_tbl, &id, &val)) {
return val;
}
if (rb_cvar_defined(mod, id)) {
rb_raise(rb_eNameError, "cannot remove %s for %s",
rb_id2name(id), rb_class2name(mod));
}
rb_raise(rb_eNameError, "class variable %s not defined for %s",
rb_id2name(id), rb_class2name(mod));
return Qnil; /* not reached */
}
VALUE
rb_iv_get(obj, name)
VALUE obj;

Просмотреть файл

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.2"
#define RUBY_RELEASE_DATE "2000-12-05"
#define RUBY_RELEASE_DATE "2000-12-08"
#define RUBY_VERSION_CODE 162
#define RUBY_RELEASE_CODE 20001205
#define RUBY_RELEASE_CODE 20001208

Просмотреть файл

@ -29,7 +29,7 @@ AUTOCONF = autoconf
prefix = /usr
CFLAGS = -nologo -DNT=1 -Zi -O2b2x -G5
CFLAGS = -nologo -DNT=1 -Zi -MD -O2b2x -G5
CPPFLAGS = -I$(srcdir) -I$(srcdir)/missing
LDFLAGS = $(CFLAGS) -Fm
XLDFLAGS =

Просмотреть файл

@ -1,5 +1,5 @@
s%@SHELL@%%g
s%@CFLAGS@%-nologo -DNT=1 -Zi -O2b2x -G5%g
s%@CFLAGS@%-nologo -DNT=1 -Zi -MD -O2b2x -G5%g
s%@CPPFLAGS@%%g
s%@CXXFLAGS@%%g
s%@FFLAGS@%%g

Просмотреть файл

@ -1767,7 +1767,7 @@ myfddup (int fd)
void
myfdclose(FILE *fp)
{
#if !defined __MINGW32__
#if !defined MSVCRT_THREADS
_free_osfhnd(fileno(fp));
#endif
fclose(fp);