summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--array.c2
-rw-r--r--hash.c9
-rw-r--r--lib/cgi/session.rb10
-rw-r--r--numeric.c4
-rw-r--r--string.c24
6 files changed, 57 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f899bfd00..c2be85ca07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Nov 16 23:45:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (flo_divmod): protect float values from GC by
+ assignment to local variables. [ruby-dev:24873]
+
Tue Nov 16 16:30:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* {bcc32,win32,wince}/setup.mak (-epilogue-): remove config.h and
@@ -13,6 +18,18 @@ Tue Nov 16 11:19:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::options): use
Regexp conversion.
+Tue Nov 16 01:41:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_mod_check): frozen check should be separated.
+ [ruby-core:3742]
+
+ * array.c (rb_ary_update): pedantic check to detect
+ rb_ary_to_ary() to modify the receiver. [ruby-dev:24861]
+
+Mon Nov 15 13:50:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_justify): typo fixed. [ruby-dev:24851]
+
Mon Nov 15 11:50:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-mode.el (ruby-special-char-p, ruby-parse-partial): handle
@@ -344,6 +361,12 @@ Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ruby_cleanup): ruby_finalize_1 may cause exception,
should be wrapped by PUSH_TAG/POP_TAG(). [ruby-dev:24627]
+Thu Oct 28 08:42:02 2004 Tanaka Akira <akr@m17n.org>
+
+ * io.c (argf_forward): use ANSI style.
+ (argf_read): call argf_forward with argv argument.
+ [ruby-dev:24624]
+
Thu Oct 28 23:32:54 2004 akira yamada <akira@ruby-lang.org>
* ext/zlib/zlib.c (zstream_detach_input): resets klass of z->input if
diff --git a/array.c b/array.c
index 03647f81fd..a5772d55eb 100644
--- a/array.c
+++ b/array.c
@@ -957,7 +957,6 @@ rb_ary_update(ary, beg, len, rpl)
len = RARRAY(ary)->len - beg;
}
- rb_ary_modify(ary);
if (NIL_P(rpl)) {
rlen = 0;
}
@@ -965,6 +964,7 @@ rb_ary_update(ary, beg, len, rpl)
rpl = rb_ary_to_ary(rpl);
rlen = RARRAY(rpl)->len;
}
+ rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
len = beg + rlen;
diff --git a/hash.c b/hash.c
index fbf8d5d20d..b51cbdddce 100644
--- a/hash.c
+++ b/hash.c
@@ -1576,8 +1576,10 @@ rb_hash_update_block_i(key, value, hash)
/*
* call-seq:
- * hsh.merge!(other_hash) => hsh
- * hsh.update(other_hash) => hsh
+ * hsh.merge!(other_hash) => hsh
+ * hsh.update(other_hash) => hsh
+ * hsh.merge!(other_hash){|key, oldval, newval| block} => hsh
+ * hsh.update(other_hash){|key, oldval, newval| block} => hsh
*
* Adds the contents of <i>other_hash</i> to <i>hsh</i>, overwriting
* entries with duplicate keys with those from <i>other_hash</i>.
@@ -1603,7 +1605,8 @@ rb_hash_update(hash1, hash2)
/*
* call-seq:
- * hsh.merge(other_hash) -> a_hash
+ * hsh.merge(other_hash) -> a_hash
+ * hsh.merge(other_hash){|key, oldval, newval| block} -> a_hash
*
* Returns a new hash containing the contents of <i>other_hash</i> and
* the contents of <i>hsh</i>, overwriting entries in <i>hsh</i> with
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 9a49fdedc9..66ab8fd67e 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -159,7 +159,7 @@ class CGI
attr_reader :session_id
def Session::callback(dbman) #:nodoc:
- lambda{
+ Proc.new{
dbman[0].close unless dbman.empty?
}
end
@@ -351,17 +351,21 @@ class CGI
# on Unix systems).
# prefix:: the prefix to add to the session id when generating
# the filename for this session's FileStore file.
+ # Defaults to "cgi_sid_".
+ # suffix:: the prefix to add to the session id when generating
+ # the filename for this session's FileStore file.
# Defaults to the empty string.
#
# This session's FileStore file will be created if it does
# not exist, or opened if it does.
def initialize(session, option={})
dir = option['tmpdir'] || Dir::tmpdir
- prefix = option['prefix'] || ''
+ prefix = option['prefix'] || 'cgi_sid_'
+ suffix = option['suffix'] || ''
id = session.session_id
require 'digest/md5'
md5 = Digest::MD5.hexdigest(id)[0,16]
- @path = dir+"/"+prefix+md5
+ @path = dir+"/"+prefix+md5+suffix
unless File::exist? @path
@hash = {}
end
diff --git a/numeric.c b/numeric.c
index bbb279b7d5..cb176fe96b 100644
--- a/numeric.c
+++ b/numeric.c
@@ -730,7 +730,9 @@ flo_divmod(x, y)
return rb_num_coerce_bin(x, y);
}
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
- return rb_assoc_new(rb_float_new(div), rb_float_new(mod));
+ x = rb_float_new(div);
+ y = rb_float_new(mod);
+ return rb_assoc_new(x, y);
}
/*
diff --git a/string.c b/string.c
index 12f0474495..414de67b92 100644
--- a/string.c
+++ b/string.c
@@ -50,6 +50,15 @@ str_mod_check(s, p, len)
}
}
+static inline void
+str_frozen_check(s)
+ VALUE s;
+{
+ if (OBJ_FROZEN(s)) {
+ rb_raise(rb_eRuntimeError, "string frozen");
+ }
+}
+
static VALUE str_alloc _((VALUE));
static VALUE
str_alloc(klass)
@@ -1958,9 +1967,8 @@ rb_str_sub_bang(argc, argv, str)
rb_match_busy(match);
repl = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
- if (RSTRING(str)->ptr != p || RSTRING(str)->len != len) {
- rb_raise(rb_eRuntimeError, "string modified");
- }
+ str_mod_check(str, p, len);
+ str_frozen_check(str);
rb_backref_set(match);
}
else {
@@ -2080,6 +2088,7 @@ str_gsub(argc, argv, str, bang)
rb_match_busy(match);
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
str_mod_check(str, sp, slen);
+ str_frozen_check(str);
rb_backref_set(match);
}
else {
@@ -4458,11 +4467,12 @@ rb_str_justify(argc, argv, str, jflag)
width = NUM2LONG(w);
if (width < 0 || RSTRING(str)->len >= width) return rb_str_dup(str);
res = rb_str_new5(str, 0, width);
- if (argc == 0) {
+ if (argc == 2) {
StringValue(pad);
- if (RSTRING(pad)->len > 0) {
- f = RSTRING(pad)->ptr;
- flen = RSTRING(pad)->len;
+ f = RSTRING(pad)->ptr;
+ flen = RSTRING(pad)->len;
+ if (flen == 0) {
+ rb_raise(rb_eArgError, "zero width padding");
}
}
p = RSTRING(res)->ptr;