Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb', 'lib/racc/info.rb', __F
lib = $1
code = File.read("lib/#{lib}.rb")
code.sub!(/\A(?:#.*\n)+/, '')
%[unless $".find {|p| p.end_with?('/#{lib}.rb')}\n$".push "\#{__dir__}/#{lib}.rb"\n#{code}\nend\n]
%[unless $".find {|p| p.tr('\\\\', '/').end_with?('/#{lib}.rb')}\n$".push "\#{__dir__}/#{lib}.rb"\n#{code}\nend\n]
rescue
$&
end
Expand Down
2 changes: 1 addition & 1 deletion lib/racc/parserfilegenerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def runtime_source

def embed_library(src)
line %[###### #{src.filename} begin]
line %[unless $".find {|p| p.end_with?('/#{src.filename}')}]
line %[unless $".find {|p| p.tr('\\\\', '/').end_with?('/#{src.filename}')}]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense if File::ALT_SEPARATOR is nil?

line %[$".push "\#{__dir__}/#{src.filename}"]
put src, @params.convert_line?
line %[end]
Expand Down
12 changes: 11 additions & 1 deletion test/test_parser_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ module Racc
class TestRaccParserText < TestCase
def test_parser_text_require
assert_not_match(/^require/, Racc::PARSER_TEXT)
assert_in_out_err(%W[-I#{LIB_DIR} -rracc/parser-text -e$:.clear -eeval(Racc::PARSER_TEXT)])
ruby "-I#{LIB_DIR}", "-rracc/parser-text", "-e", "$:.clear", "-e", "eval(Racc::PARSER_TEXT)", quiet: true
end

def test_parser_text_require_with_backslash_loaded_feature
ruby "-I#{LIB_DIR}", "-rracc/parser-text", "-e", <<~'RUBY', quiet: true
require 'racc/info'
$".map! do |feature|
feature.end_with?('/racc/info.rb') ? 'C:\\tmp\\racc\\info.rb' : feature
end
eval(Racc::PARSER_TEXT)
RUBY
end
end
end
11 changes: 11 additions & 0 deletions test/test_racc_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ def test_echk_y
assert_exec 'echk.y', quiet: true
end

def test_echk_y_with_backslash_loaded_feature
assert_compile 'echk.y', '-E'
assert_debugfile 'echk.y', []
ruby "-I#{LIB_DIR}", "-rracc/parser", "-e", <<~'RUBY', "#{@TAB_DIR}/echk", quiet: true
$".map! do |feature|
feature.end_with?('/racc/parser.rb') ? 'C:\\tmp\\racc\\parser.rb' : feature
end
load ARGV.shift
RUBY
end

def test_err_y
assert_compile 'err.y'
assert_debugfile 'err.y', []
Expand Down