Skip to content

Commit

Permalink
2000-02-23
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 23, 2000
1 parent 6f82a67 commit bf70582
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 23 deletions.
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Wed Feb 23 14:22:32 2000 Yukihiro Matsumoto <[email protected]>

* array.c (rb_ary_join): forgot to initialize a local variable
`taint'.

Tue Feb 22 07:40:55 2000 Yukihiro Matsumoto <[email protected]>

* re.c (Init_Regexp): renamed to MatchData, old name MatchingData
remain as alias.

Sat Feb 19 23:58:51 2000 Yukihiro Matsumoto <[email protected]>

* regex.c (re_match): pop_loop should not pop at forward jump.

Fri Feb 18 17:15:40 2000 Yukihiro Matsumoto <[email protected]>

* eval.c (method_clone): method objects are now clonable.

Fri Feb 18 00:27:34 2000 Yukihiro Matsumoto <[email protected]>

* variable.c (rb_shared_variable_declare): shared variable (aka
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -823,18 +823,21 @@ static VALUE
inspect_ary(ary)
VALUE ary;
{
int tainted = OBJ_TAINTED(ary);
long i = 0;
VALUE s, str;

str = rb_str_new2("[");

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;
}

Expand Down
16 changes: 16 additions & 0 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion ext/socket/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@
}
}
if (inet6 != 2 || inet4 != 2)
if (!(inet4 == 0 || inet4 == 2))
goto bad;
if (!(inet6 == 0 || inet6 == 2))
goto bad;
if (aitop)
Expand Down
21 changes: 20 additions & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Env.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Env.rb -- imports environment variables as global variables
#
# Env.rb -- imports environment variables as global variables, Perlish ;(
# Usage:
#
# require 'Env'
Expand Down
1 change: 1 addition & 0 deletions lib/eregex.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# this is just a proof of concept toy.

class RegOr
def initialize(re1, re2)
Expand Down
2 changes: 1 addition & 1 deletion lib/ftplib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion lib/getopts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
# this is obsolete; use getoptlong
#
#
#

$RCS_ID=%q$Header$
Expand Down
2 changes: 1 addition & 1 deletion lib/importenv.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# importenv.rb -- imports environment variables as global variables
# importenv.rb -- imports environment variables as global variables, Perlish ;(
#
# Usage:
#
Expand Down
2 changes: 2 additions & 0 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion re.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ rb_reg_desc(s, len, re)
}
}
}
OBJ_INFECT(str, re);
return str;
}

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 10 additions & 9 deletions sample/fib.pl
Original file line number Diff line number Diff line change
@@ -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 changes: 24 additions & 0 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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*
Expand All @@ -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);
Expand Down Expand Up @@ -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;\
}\
Expand Down
20 changes: 19 additions & 1 deletion string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bf70582

Please sign in to comment.