From f7bf34282cbb9883f6a69bf95c7635e28147572b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 9 Aug 2023 18:18:27 +0900 Subject: [PATCH] Remove frozen_string_literal pragmas from embedded runtime files --- Rakefile | 8 ++++++-- lib/racc/info.rb | 1 + lib/racc/parser.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index f1f3d90f..d4416d95 100644 --- a/Rakefile +++ b/Rakefile @@ -27,12 +27,16 @@ file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb', __FILE__] do |t| source = 'lib/racc/parser.rb' text = File.read(source) + text.sub!(/\A# *frozen[-_]string[-_]literal:.*\n/, '') text.gsub!(/^require '(.*)'$/) do - %[unless $".find {|p| p.end_with?('/#$1.rb')}\n$".push "\#{__dir__}/#$1.rb"\n#{File.read("lib/#{$1}.rb")}\nend\n] + 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] rescue $& end - open(t.name, 'wb') { |io| + File.open(t.name, 'wb') { |io| io.write(<<-eorb) module Racc PARSER_TEXT = <<'__end_of_file__' diff --git a/lib/racc/info.rb b/lib/racc/info.rb index b0fc9055..a6bd249c 100644 --- a/lib/racc/info.rb +++ b/lib/racc/info.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true #-- # # diff --git a/lib/racc/parser.rb b/lib/racc/parser.rb index ab1e5bcc..c4c74fae 100644 --- a/lib/racc/parser.rb +++ b/lib/racc/parser.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true #-- # Copyright (c) 1999-2006 Minero Aoki #