From c87b3ee671581594b60ae7cac05a053b1c12f3b9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 30 Nov 2022 22:44:04 +0900 Subject: [ruby/rdoc] Use Tempfile https://github.com/ruby/rdoc/commit/0b9dde5ab4 --- lib/rdoc/rd/block_parser.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'lib/rdoc/rd') diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb index eb7d46925b..1241f81762 100644 --- a/lib/rdoc/rd/block_parser.rb +++ b/lib/rdoc/rd/block_parser.rb @@ -18,8 +18,6 @@ class BlockParser < Racc::Parser # :stopdoc: -TMPFILE = ["rdtmp", $$, 0] - MARK_TO_LEVEL = { '=' => 1, '==' => 2, @@ -148,11 +146,10 @@ def next_token # :nodoc: if @tree.filter[@in_part].mode == :rd # if output is RD formatted subtree = parse_subtree(part_out.to_a) else # if output is target formatted - basename = TMPFILE.join('.') - TMPFILE[-1] += 1 - tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w") - tmpfile.print(part_out) - tmpfile.close + basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile| + tmpfile.print(part_out) + File.basename(tmpfile.path) + end subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"]) end @in_part = nil -- cgit v1.2.3