git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-02-23 05:23:12 +00:00
Родитель 6f82a67fd0
Коммит bf70582cf3
19 изменённых файлов: 130 добавлений и 23 удалений

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

@ -1,3 +1,21 @@
Wed Feb 23 14:22:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* array.c (rb_ary_join): forgot to initialize a local variable
`taint'.
Tue Feb 22 07:40:55 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* re.c (Init_Regexp): renamed to MatchData, old name MatchingData
remain as alias.
Sat Feb 19 23:58:51 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_match): pop_loop should not pop at forward jump.
Fri Feb 18 17:15:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (method_clone): method objects are now clonable.
Fri Feb 18 00:27:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp> Fri Feb 18 00:27:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* variable.c (rb_shared_variable_declare): shared variable (aka * variable.c (rb_shared_variable_declare): shared variable (aka

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

@ -89,7 +89,6 @@ lib/Env.rb
lib/README lib/README
lib/base64.rb lib/base64.rb
lib/cgi.rb lib/cgi.rb
lib/cgi-lib.rb
lib/complex.rb lib/complex.rb
lib/date.rb lib/date.rb
lib/date2.rb lib/date2.rb

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

@ -669,7 +669,7 @@ rb_ary_join(ary, sep)
VALUE ary, sep; VALUE ary, sep;
{ {
long i; long i;
int taint; int taint = 0;
VALUE result, tmp; VALUE result, tmp;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0); if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
@ -823,6 +823,7 @@ static VALUE
inspect_ary(ary) inspect_ary(ary)
VALUE ary; VALUE ary;
{ {
int tainted = OBJ_TAINTED(ary);
long i = 0; long i = 0;
VALUE s, str; VALUE s, str;
@ -830,11 +831,13 @@ inspect_ary(ary)
for (i=0; i<RARRAY(ary)->len; i++) { for (i=0; i<RARRAY(ary)->len; i++) {
s = rb_inspect(RARRAY(ary)->ptr[i]); s = rb_inspect(RARRAY(ary)->ptr[i]);
tainted = OBJ_TAINTED(s);
if (i > 0) rb_str_cat(str, ", ", 2); if (i > 0) rb_str_cat(str, ", ", 2);
rb_str_cat(str, RSTRING(s)->ptr, RSTRING(s)->len); rb_str_cat(str, RSTRING(s)->ptr, RSTRING(s)->len);
} }
rb_str_cat(str, "]", 1); rb_str_cat(str, "]", 1);
if (tainted) OBJ_TAINT(str);
return str; return str;
} }

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

@ -5957,6 +5957,21 @@ rb_obj_method(obj, vid)
return method; return method;
} }
static VALUE
method_clone(self)
VALUE self;
{
VALUE clone;
struct METHOD *orig, *data;
Data_Get_Struct(self, struct METHOD, orig);
clone = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,data);
CLONESETUP(clone, self);
*data = *orig;
return clone;
}
static VALUE static VALUE
method_call(argc, argv, method) method_call(argc, argv, method)
int argc; int argc;
@ -6094,6 +6109,7 @@ Init_Proc()
rb_cMethod = rb_define_class("Method", rb_cObject); rb_cMethod = rb_define_class("Method", rb_cObject);
rb_undef_method(CLASS_OF(rb_cMethod), "new"); rb_undef_method(CLASS_OF(rb_cMethod), "new");
rb_define_method(rb_cMethod, "clone", method_clone, 0);
rb_define_method(rb_cMethod, "call", method_call, -1); rb_define_method(rb_cMethod, "call", method_call, -1);
rb_define_method(rb_cMethod, "[]", method_call, -1); rb_define_method(rb_cMethod, "[]", method_call, -1);
rb_define_method(rb_cMethod, "arity", method_arity, 0); rb_define_method(rb_cMethod, "arity", method_arity, 0);

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

@ -244,7 +244,9 @@ main()
} }
} }
if (inet6 != 2 || inet4 != 2) if (!(inet4 == 0 || inet4 == 2))
goto bad;
if (!(inet6 == 0 || inet6 == 2))
goto bad; goto bad;
if (aitop) if (aitop)

21
hash.c
Просмотреть файл

@ -89,7 +89,23 @@ rb_any_hash(a)
break; break;
case T_STRING: case T_STRING:
#if 0
hval = rb_str_hash(a); hval = rb_str_hash(a);
#else
{
register const char *p = RSTRING(a)->ptr;
register int len = RSTRING(a)->len;
register unsigned int h = 0, g;
while (len--) {
h = ( h << 4 ) + *p++;
if ( g = h & 0xF0000000 )
h ^= g >> 24;
h &= ~g;
}
hval = h;
}
#endif
break; break;
default: default:
@ -648,9 +664,11 @@ inspect_i(key, value, str)
} }
str2 = rb_inspect(key); str2 = rb_inspect(key);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len); rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
rb_str_cat(str, "=>", 2); rb_str_cat(str, "=>", 2);
str2 = rb_inspect(value); str2 = rb_inspect(value);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len); rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
return ST_CONTINUE; return ST_CONTINUE;
} }
@ -664,7 +682,8 @@ inspect_hash(hash)
str = rb_str_new2("{"); str = rb_str_new2("{");
st_foreach(RHASH(hash)->tbl, inspect_i, str); st_foreach(RHASH(hash)->tbl, inspect_i, str);
rb_str_cat(str, "}", 1); rb_str_cat(str, "}", 1);
OBJ_INFECT(str, hash);
return str; return str;
} }

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

@ -1,5 +1,4 @@
# Env.rb -- imports environment variables as global variables # Env.rb -- imports environment variables as global variables, Perlish ;(
#
# Usage: # Usage:
# #
# require 'Env' # require 'Env'

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

@ -1,3 +1,4 @@
# this is just a proof of concept toy.
class RegOr class RegOr
def initialize(re1, re2) def initialize(re1, re2)

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

@ -2,7 +2,7 @@
# ftplib.rb # ftplib.rb
# #
$stderr.puts 'Warning: ftplib.rb is obsolute: use net/ftp' $stderr.puts 'Warning: ftplib.rb is obsolete: use net/ftp'
require 'net/ftp' require 'net/ftp'

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

@ -6,8 +6,8 @@
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.) # by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
# #
# -- # --
# this is obsolete; use getoptlong
# #
#
# #
$RCS_ID=%q$Header$ $RCS_ID=%q$Header$

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

@ -1,4 +1,4 @@
# importenv.rb -- imports environment variables as global variables # importenv.rb -- imports environment variables as global variables, Perlish ;(
# #
# Usage: # Usage:
# #

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

@ -168,6 +168,7 @@ inspect_i(id, value, str)
rb_str_cat(str, "=", 1); rb_str_cat(str, "=", 1);
str2 = rb_inspect(value); str2 = rb_inspect(value);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len); rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
return ST_CONTINUE; return ST_CONTINUE;
} }
@ -178,6 +179,7 @@ inspect_obj(obj, str)
{ {
st_foreach(ROBJECT(obj)->iv_tbl, inspect_i, str); st_foreach(ROBJECT(obj)->iv_tbl, inspect_i, str);
rb_str_cat(str, ">", 1); rb_str_cat(str, ">", 1);
OBJ_INFECT(str, obj);
return str; return str;
} }

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

@ -268,6 +268,7 @@ rb_reg_desc(s, len, re)
} }
} }
} }
OBJ_INFECT(str, re);
return str; return str;
} }
@ -1298,7 +1299,8 @@ Init_Regexp()
rb_global_variable(&reg_cache); rb_global_variable(&reg_cache);
rb_cMatch = rb_define_class("MatchingData", rb_cObject); rb_cMatch = rb_define_class("MatchData", rb_cObject);
rb_define_global_const("MatchingData", rb_cMatch);
rb_undef_method(CLASS_OF(rb_cMatch), "new"); rb_undef_method(CLASS_OF(rb_cMatch), "new");
rb_define_method(rb_cMatch, "clone", match_clone, 0); rb_define_method(rb_cMatch, "clone", match_clone, 0);

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

@ -4194,9 +4194,10 @@ re_match(bufp, string_arg, size, pos, regs)
case jump: case jump:
p1++; p1++;
EXTRACT_NUMBER_AND_INCR (mcnt, p1); EXTRACT_NUMBER_AND_INCR (mcnt, p1);
if (mcnt >= 0) break; /* should be backward jump */
p1 += mcnt; p1 += mcnt;
if (p1 >= pend) break;
if (( is_a_jump_n && (enum regexpcode)*p1 == succeed_n) || if (( is_a_jump_n && (enum regexpcode)*p1 == succeed_n) ||
(!is_a_jump_n && (enum regexpcode)*p1 == on_failure_jump)) { (!is_a_jump_n && (enum regexpcode)*p1 == on_failure_jump)) {
if (failed_paren) { if (failed_paren) {

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

@ -1,10 +1,11 @@
sub fib { sub fib {
local($n)=@_; my($n)=@_;
if( $n<2 ){ if ($n<2) {
return $n; return $n;
} { }
return &fib($n-2)+&fib($n-1) else {
} return fib($n-2)+fib($n-1);
} }
}
print &fib(20), "\n"; print fib(20), "\n";

24
st.c
Просмотреть файл

@ -111,6 +111,7 @@ new_size(size)
{ {
int i, newsize; int i, newsize;
#if 0
for (i = 0, newsize = MINSIZE; for (i = 0, newsize = MINSIZE;
i < sizeof(primes)/sizeof(primes[0]); i < sizeof(primes)/sizeof(primes[0]);
i++, newsize <<= 1) i++, newsize <<= 1)
@ -119,6 +120,23 @@ new_size(size)
} }
/* Ran out of polynomials */ /* Ran out of polynomials */
return -1; /* should raise exception */ return -1; /* should raise exception */
#else
for (i=3; i<31; i++) {
if ((1<<i) > size) return 1<<i;
}
return -1;
#endif
}
static int collision = 0;
static int init_st = 0;
static void
stat_col()
{
FILE *f = fopen("/tmp/col", "w");
fprintf(f, "collision: %d\n", collision);
fclose(f);
} }
st_table* st_table*
@ -128,6 +146,11 @@ st_init_table_with_size(type, size)
{ {
st_table *tbl; st_table *tbl;
if (init_st == 0) {
init_st = 1;
atexit(stat_col);
}
size = new_size(size); /* round up to prime number */ size = new_size(size); /* round up to prime number */
tbl = alloc(st_table); tbl = alloc(st_table);
@ -198,6 +221,7 @@ st_free_table(table)
bin_pos = hash_val%(table)->num_bins;\ bin_pos = hash_val%(table)->num_bins;\
ptr = (table)->bins[bin_pos];\ ptr = (table)->bins[bin_pos];\
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\ if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
collision++;\
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\ while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
ptr = ptr->next;\ ptr = ptr->next;\
}\ }\

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

@ -421,6 +421,7 @@ rb_str_hash(str)
register char *p = RSTRING(str)->ptr; register char *p = RSTRING(str)->ptr;
register int key = 0; register int key = 0;
#if 0
if (ruby_ignorecase) { if (ruby_ignorecase) {
while (len--) { while (len--) {
key = key*65599 + toupper(*p); key = key*65599 + toupper(*p);
@ -433,6 +434,20 @@ rb_str_hash(str)
p++; p++;
} }
} }
#else
if (ruby_ignorecase) {
while (len--) {
key = key*33 + toupper(*p);
p++;
}
}
else {
while (len--) {
key = key*33 + *p++;
}
}
key = key + (key>>5);
#endif
return key; return key;
} }
@ -1354,6 +1369,7 @@ rb_str_inspect(str)
char buf[STRMAX]; char buf[STRMAX];
char *p, *pend; char *p, *pend;
char *b; char *b;
VALUE inspect;
p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len; p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;
b = buf; b = buf;
@ -1430,7 +1446,9 @@ rb_str_inspect(str)
} }
} }
*b++ = '"'; *b++ = '"';
return rb_str_new(buf, b - buf); inspect = rb_str_new(buf, b - buf);
OBJ_INFECT(inspect, str);
return inspect;
} }
static VALUE static VALUE

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

@ -376,8 +376,10 @@ inspect_struct(s)
rb_str_cat(str, "=", 1); rb_str_cat(str, "=", 1);
str2 = rb_inspect(RSTRUCT(s)->ptr[i]); str2 = rb_inspect(RSTRUCT(s)->ptr[i]);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len); rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
} }
rb_str_cat(str, ">", 1); rb_str_cat(str, ">", 1);
OBJ_INFECT(str, s);
return str; return str;
} }

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

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.2" #define RUBY_VERSION "1.5.2"
#define RUBY_RELEASE_DATE "2000-02-18" #define RUBY_RELEASE_DATE "2000-02-23"
#define RUBY_VERSION_CODE 152 #define RUBY_VERSION_CODE 152
#define RUBY_RELEASE_CODE 20000218 #define RUBY_RELEASE_CODE 20000223