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:
parent
6f82a67fd0
commit
bf70582cf3
19 changed files with 130 additions and 23 deletions
18
ChangeLog
18
ChangeLog
|
@ -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
|
||||
|
|
1
MANIFEST
1
MANIFEST
|
@ -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
|
||||
|
|
5
array.c
5
array.c
|
@ -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
16
eval.c
|
@ -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);
|
||||
|
|
|
@ -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
21
hash.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Env.rb -- imports environment variables as global variables
|
||||
#
|
||||
# Env.rb -- imports environment variables as global variables, Perlish ;(
|
||||
# Usage:
|
||||
#
|
||||
# require 'Env'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# this is just a proof of concept toy.
|
||||
|
||||
class RegOr
|
||||
def initialize(re1, re2)
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
|
||||
#
|
||||
# --
|
||||
# this is obsolete; use getoptlong
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
$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:
|
||||
#
|
||||
|
|
2
object.c
2
object.c
|
@ -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
4
re.c
|
@ -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(®_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);
|
||||
|
|
3
regex.c
3
regex.c
|
@ -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) {
|
||||
|
|
|
@ -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
24
st.c
|
@ -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;\
|
||||
}\
|
||||
|
|
20
string.c
20
string.c
|
@ -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
|
||||
|
|
2
struct.c
2
struct.c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue