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

2000-02-23

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
parent 6f82a67fd0
commit bf70582cf3
19 changed files with 130 additions and 23 deletions

View file

@ -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>
* variable.c (rb_shared_variable_declare): shared variable (aka

View file

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

View file

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

16
eval.c
View file

@ -5957,6 +5957,21 @@ rb_obj_method(obj, vid)
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
method_call(argc, argv, method)
int argc;
@ -6094,6 +6109,7 @@ Init_Proc()
rb_cMethod = rb_define_class("Method", rb_cObject);
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, "[]", method_call, -1);
rb_define_method(rb_cMethod, "arity", method_arity, 0);

View file

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

21
hash.c
View file

@ -89,7 +89,23 @@ rb_any_hash(a)
break;
case T_STRING:
#if 0
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;
default:
@ -648,9 +664,11 @@ inspect_i(key, value, str)
}
str2 = rb_inspect(key);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
rb_str_cat(str, "=>", 2);
str2 = rb_inspect(value);
rb_str_cat(str, RSTRING(str2)->ptr, RSTRING(str2)->len);
OBJ_INFECT(str, str2);
return ST_CONTINUE;
}
@ -664,7 +682,8 @@ inspect_hash(hash)
str = rb_str_new2("{");
st_foreach(RHASH(hash)->tbl, inspect_i, str);
rb_str_cat(str, "}", 1);
OBJ_INFECT(str, hash);
return str;
}

View file

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

View file

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

View file

@ -2,7 +2,7 @@
# 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'

View file

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

View file

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

View file

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

4
re.c
View file

@ -268,6 +268,7 @@ rb_reg_desc(s, len, re)
}
}
}
OBJ_INFECT(str, re);
return str;
}
@ -1298,7 +1299,8 @@ Init_Regexp()
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_define_method(rb_cMatch, "clone", match_clone, 0);

View file

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

View file

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

24
st.c
View file

@ -111,6 +111,7 @@ new_size(size)
{
int i, newsize;
#if 0
for (i = 0, newsize = MINSIZE;
i < sizeof(primes)/sizeof(primes[0]);
i++, newsize <<= 1)
@ -119,6 +120,23 @@ new_size(size)
}
/* Ran out of polynomials */
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*
@ -128,6 +146,11 @@ st_init_table_with_size(type, size)
{
st_table *tbl;
if (init_st == 0) {
init_st = 1;
atexit(stat_col);
}
size = new_size(size); /* round up to prime number */
tbl = alloc(st_table);
@ -198,6 +221,7 @@ st_free_table(table)
bin_pos = hash_val%(table)->num_bins;\
ptr = (table)->bins[bin_pos];\
if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) {\
collision++;\
while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
ptr = ptr->next;\
}\

View file

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

View file

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

View file

@ -1,4 +1,4 @@
#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_RELEASE_CODE 20000218
#define RUBY_RELEASE_CODE 20000223