Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Dec 5, 2000
1 parent b5ca10f commit c7d585c
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 156 deletions.
48 changes: 48 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@ Mon Dec 4 13:44:01 2000 WATANABE Hirofumi <eban@ruby-lang.org>

* lib/jcode.rb: consider multibyte. not /n.

Mon Dec 4 09:49:36 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* string.c (rb_str_inspect): output whole string contents. no more `...'

* string.c (rb_str_dump): should propagate taintness.

* hash.c (env_inspect): hash like human readable output.

* variable.c (rb_ivar_get): prohibiting instance variable access
is too much restriction.

* class.c (method_list): retrieving information should not be
restricted where $SAFE=4.

* class.c (rb_obj_singleton_methods): ditto.

* eval.c (rb_thread_priority): ditto.

* eval.c (rb_thread_local_aref): ditto.

* variable.c (rb_obj_instance_variables): ditto.

* variable.c (rb_mod_const_at): ditto.

* variable.c (rb_mod_class_variables): ditto.

* eval.c (rb_exec_end_proc): end_proc should be preserved.

Sat Dec 2 22:32:43 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_yield_0): || should accept exactly zero argument.

* parse.y (stmt): multiple right hand side for single assignment
(e.g. a = 1,2) is allowed.

Wed Nov 29 07:55:29 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* marshal.c (w_long): dumping long should be smaller than 32bit max.

* marshal.c (w_long): shorter long format for small integers(-123..122).

* marshal.c (r_long): ditto.

Tue Nov 28 18:10:51 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_mod_define_method): quick hack to implement
on-the-fly method definition. experimental.

Mon Nov 27 17:00:35 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_eval): should not redefine builtin classes/modules
Expand Down
11 changes: 7 additions & 4 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ Language Spec.
* Fixnum 0 as false ????
* discourage use of symbol variable (e.g. $/, etc.) in manual
* discourage use of Perlish features by giving warnings.
* `exception' method to be alternative for `$!'. ??
* non confusing in-block local variable (is it possible?)
+ remove scope by block
+ variables appears within block may have independent values.
* Regexp: make /o thread safe.
* decide if begin with rescue or ensure make do..while loop.

Hacking Interpreter

Expand All @@ -44,10 +45,11 @@ Hacking Interpreter
* scrambled script, or script filter
* setuid ruby
* performance tune for in-block (dynamic) local variables.
* generational GC ?
* generational GC
* give warnings to assign magic variables.
* export rb_io_{addstr,printf,puts,print}
* autoload should work with threads [ruby-talk:4589]
* remove stdio dependency from IOs.

Standard Libraries

Expand All @@ -73,7 +75,7 @@ Standard Libraries
- performance tune for String's non-bang methods.
- 'w' template for pack/unpack
- alternative for interator? => block_given?
- regex - /p (make obsolete), /m (new)
- regex - /p (made obsolete), /m (new)
- consistent /, %, divmod
- unbound method object
- integrate final.rb into the core.
Expand All @@ -92,6 +94,7 @@ 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).

Extension Libraries

Expand All @@ -115,4 +118,4 @@ Tools
Misc

- publish Ruby books
* publish Ruby books in English
- publish Ruby books in English
91 changes: 62 additions & 29 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "ruby.h"
#include "util.h"
#include "st.h"

VALUE rb_cArray;

Expand Down Expand Up @@ -1435,73 +1436,105 @@ rb_ary_diff(ary1, ary2)
return ary3;
}

static st_table*
ary_make_hash(ary1, ary2, func)
VALUE ary1, ary2;
int (*func)();
{
st_table *tbl = st_init_numtable();
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);
}
}
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);
}
}
}
return tbl;
}

static VALUE
rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
st_table *tbl = ary_make_hash(ary1, to_ary(ary2));
VALUE ary3 = rb_ary_new();
VALUE v;
long i;
int n;

ary2 = to_ary(ary2);
ary3 = rb_ary_new();
for (i=0; i<RARRAY(ary1)->len; i++) {
if (rb_ary_includes(ary2, RARRAY(ary1)->ptr[i])
&& !rb_ary_includes(ary3, RARRAY(ary1)->ptr[i])) {
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
v = RARRAY(ary1)->ptr[i];
if (st_delete(tbl, &v, &n)) {
if (n == 2) rb_ary_push(ary3, v);
}
}
st_free_table(tbl);

return ary3;
}

static VALUE
rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
VALUE ary3;
st_table *tbl;
VALUE ary3 = rb_ary_new();
VALUE v;
long i;

if (TYPE(ary2) != T_ARRAY) {
if (rb_ary_includes(ary1, ary2)) return ary1;
else return rb_ary_push(ary1, ary2);
}
ary2 = to_ary(ary2);
tbl = ary_make_hash(ary1, ary2);

ary3 = rb_ary_new();
for (i=0; i<RARRAY(ary1)->len; i++) {
if (!rb_ary_includes(ary3, RARRAY(ary1)->ptr[i]))
rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
v = RARRAY(ary1)->ptr[i];
if (st_delete(tbl, &v, 0)) {
rb_ary_push(ary3, v);
}
}
for (i=0; i<RARRAY(ary2)->len; i++) {
if (!rb_ary_includes(ary3, RARRAY(ary2)->ptr[i]))
rb_ary_push(ary3, RARRAY(ary2)->ptr[i]);
v = RARRAY(ary2)->ptr[i];
if (st_delete(tbl, &v, 0)) {
rb_ary_push(ary3, v);
}
}
st_free_table(tbl);

return ary3;
}

static VALUE
rb_ary_uniq_bang(ary)
VALUE ary;
{
VALUE *p, *q, *t, *end;
st_table *tbl = ary_make_hash(ary, 0);
VALUE *p, *q, *end;
VALUE v;

if (RARRAY(ary)->len == tbl->num_entries) {
st_free_table(tbl);
return Qnil;
}
rb_ary_modify(ary);
p = RARRAY(ary)->ptr;
end = p + RARRAY(ary)->len;

p = q = RARRAY(ary)->ptr;
end = p + RARRAY(ary)->len;
while (p < end) {
v = *p++;
q = t = p;
while (q < end) {
if (rb_equal(*q, v)) q++;
else *t++ = *q++;
if (st_delete(tbl, &v, 0)) {
*q++ = v;
}
end = t;
}
if (RARRAY(ary)->len == (end - RARRAY(ary)->ptr)) {
return Qnil;
}

RARRAY(ary)->len = (end - RARRAY(ary)->ptr);
RARRAY(ary)->len = (q - RARRAY(ary)->ptr);

return ary;
}
Expand Down
4 changes: 0 additions & 4 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,6 @@ method_list(mod, option, func)
VALUE klass;
VALUE *p, *q, *pend;

if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4)
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);
Expand Down Expand Up @@ -428,8 +426,6 @@ rb_obj_singleton_methods(obj)
VALUE klass;
VALUE *p, *q, *pend;

if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj))
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
klass = CLASS_OF(obj);
while (klass && FL_TEST(klass, FL_SINGLETON)) {
Expand Down
Loading

0 comments on commit c7d585c

Please sign in to comment.