summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--MANIFEST1
-rw-r--r--array.c5
-rw-r--r--eval.c16
-rw-r--r--ext/socket/extconf.rb4
-rw-r--r--hash.c21
-rw-r--r--lib/Env.rb3
-rw-r--r--lib/eregex.rb1
-rw-r--r--lib/ftplib.rb2
-rw-r--r--lib/getopts.rb2
-rw-r--r--lib/importenv.rb2
-rw-r--r--object.c2
-rw-r--r--re.c4
-rw-r--r--regex.c3
-rw-r--r--sample/fib.pl19
-rw-r--r--st.c24
-rw-r--r--string.c20
-rw-r--r--struct.c2
-rw-r--r--version.h4
19 files changed, 130 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d04f68..5e0c182 100644
--- a/ChangeLog
+++ b/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
diff --git a/MANIFEST b/MANIFEST
index 7793e60..1237134 100644
--- a/MANIFEST
+++ b/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
diff --git a/array.c b/array.c
index 7172baa..56957e3 100644
--- a/array.c
+++ b/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;
}
diff --git a/eval.c b/eval.c
index b913680..d789545 100644
--- a/eval.c
+++ b/eval.c
@@ -5958,6 +5958,21 @@ rb_obj_method(obj, vid)
}
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;
VALUE *argv;
@@ -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);
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index b7aee1c..6a2937b 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -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)
diff --git a/hash.c b/hash.c
index ea42674..bfef46b 100644
--- a/hash.c
+++ b/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;
}
diff --git a/lib/Env.rb b/lib/Env.rb
index b3ee3ba..7101b84 100644
--- a/lib/Env.rb
+++ b/lib/Env.rb
@@ -1,5 +1,4 @@
-# Env.rb -- imports environment variables as global variables
-#
+# Env.rb -- imports environment variables as global variables, Perlish ;(
# Usage:
#
# require 'Env'
diff --git a/lib/eregex.rb b/lib/eregex.rb
index 384d531..cc7a7f6 100644
--- a/lib/eregex.rb
+++ b/lib/eregex.rb
@@ -1,3 +1,4 @@
+# this is just a proof of concept toy.
class RegOr
def initialize(re1, re2)
diff --git a/lib/ftplib.rb b/lib/ftplib.rb
index 0b90749..4cb1b75 100644
--- a/lib/ftplib.rb
+++ b/lib/ftplib.rb
@@ -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'
diff --git a/lib/getopts.rb b/lib/getopts.rb
index 5b9562d..b513f89 100644
--- a/lib/getopts.rb
+++ b/lib/getopts.rb
@@ -6,8 +6,8 @@
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
+# this is obsolete; use getoptlong
#
-#
#
$RCS_ID=%q$Header$
diff --git a/lib/importenv.rb b/lib/importenv.rb
index 10b2891..fcf306a 100644
--- a/lib/importenv.rb
+++ b/lib/importenv.rb
@@ -1,4 +1,4 @@
-# importenv.rb -- imports environment variables as global variables
+# importenv.rb -- imports environment variables as global variables, Perlish ;(
#
# Usage:
#
diff --git a/object.c b/object.c
index 572c740..13d3db8 100644
--- a/object.c
+++ b/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;
}
diff --git a/re.c b/re.c
index 2685eac..72fae47 100644
--- a/re.c
+++ b/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(&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);
diff --git a/regex.c b/regex.c
index 0ee2b06..60e23e0 100644
--- a/regex.c
+++ b/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) {
diff --git a/sample/fib.pl b/sample/fib.pl
index c559376..945a492 100644
--- a/sample/fib.pl
+++ b/sample/fib.pl
@@ -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";
diff --git a/st.c b/st.c
index 08651d0..9789cc7 100644
--- a/st.c
+++ b/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;\
}\
diff --git a/string.c b/string.c
index e48a1ec..1040b7c 100644
--- a/string.c
+++ b/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
diff --git a/struct.c b/struct.c
index 2fd7690..d345a19 100644
--- a/struct.c
+++ b/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;
}
diff --git a/version.h b/version.h
index f06993d..4dcdb68 100644
--- a/version.h
+++ b/version.h
@@ -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