summaryrefslogtreecommitdiff
path: root/lib/rdoc
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-30 22:44:04 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-12-01 02:36:20 +0900
commitc87b3ee671581594b60ae7cac05a053b1c12f3b9 (patch)
tree6fac310707f63fa2400f5748fed0e51c62c5d552 /lib/rdoc
parentd752cf7601adbe4bc2dc658effc2f61563a7dfb7 (diff)
[ruby/rdoc] Use Tempfile
https://github.com/ruby/rdoc/commit/0b9dde5ab4
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6835
Diffstat (limited to 'lib/rdoc')
-rw-r--r--lib/rdoc/rd/block_parser.rb11
1 files changed, 4 insertions, 7 deletions
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