mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_s_sysopen): preserve path in the buffer allocated by
ALLOCA_N() to prevent modification. [ruby-dev:24438] * io.c (rb_io_mode_flags): preserve append mode flag. [ruby-dev:24436] * io.c (rb_io_modenum_mode): do not use external output buffer. * string.c (rb_str_justify): differ pointer retrieval to prevent padding string modification. [ruby-dev:24434] * range.c (range_each_func): allow func to terminate loop by returning RANGE_EACH_BREAK. * range.c (member_i): use RANGE_EACH_BREAK. [ruby-talk:114959] * marshal.c (r_byte): retrieve pointer from string value for each time. [ruby-dev:24404] * marshal.c (r_bytes0): ditto. * enum.c (sort_by_i): re-entrance check added. [ruby-dev:24399] * io.c (io_read): should freeze all reading buffer. [ruby-dev:24400] * string.c (rb_str_sum): should use bignums when bits is greater than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395] * eval.c (specific_eval): defer pointer retrieval to prevent unsafe sourcefile string modification. [ruby-dev:24382] * eval.c (specific_eval): defer pointer retrieval to prevent unsafe sourcefile string modification. [ruby-dev:24382] * string.c (rb_str_sum): wrong cast caused wrong result. [ruby-dev:24385] * enum.c (enum_sort_by): hide temporary array from ObjectSpace.each_object. [ruby-dev:24386] * string.c (rb_str_sum): check was done with false pointer. [ruby-dev:24383] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
16d052477b
commit
f433be6d9c
10 changed files with 220 additions and 169 deletions
|
@ -99,11 +99,13 @@ class PStore
|
|||
content = nil
|
||||
unless read_only
|
||||
file = File.open(@filename, File::RDWR | File::CREAT)
|
||||
file.binmode
|
||||
file.flock(File::LOCK_EX)
|
||||
commit_new(file) if FileTest.exist?(new_file)
|
||||
content = file.read()
|
||||
else
|
||||
file = File.open(@filename, File::RDONLY)
|
||||
file.binmode
|
||||
file.flock(File::LOCK_SH)
|
||||
content = (File.read(new_file) rescue file.read())
|
||||
end
|
||||
|
@ -132,6 +134,7 @@ class PStore
|
|||
content = dump(@table)
|
||||
if !md5 || size != content.size || md5 != Digest::MD5.digest(content)
|
||||
File.open(tmp_file, "w") {|t|
|
||||
t.binmode
|
||||
t.write(content)
|
||||
}
|
||||
File.rename(tmp_file, new_file)
|
||||
|
@ -166,6 +169,7 @@ class PStore
|
|||
f.rewind
|
||||
new_file = @filename + ".new"
|
||||
File.open(new_file) do |nf|
|
||||
nf.binmode
|
||||
FileUtils.copy_stream(nf, f)
|
||||
end
|
||||
File.unlink(new_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue