[前][次][番号順一覧][スレッド一覧]

ruby-changes:59753

From: Jeremy <ko1@a...>
Date: Mon, 20 Jan 2020 17:48:24 +0900 (JST)
Subject: [ruby-changes:59753] 9f99760daf (master): Get rid of use of special variables

https://git.ruby-lang.org/ruby.git/commit/?id=9f99760daf

From 9f99760dafac6eaa53287470b8ff59b1be0bf6d6 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Mon, 20 Jan 2020 16:53:31 +0900
Subject: Get rid of use of special variables

Use `"\n"` and `IO#fileno` instead of `$/` and `$.` respectively.
[Feature #14240]

diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
index 7639a90..b838a78 100644
--- a/ext/ripper/tools/preproc.rb
+++ b/ext/ripper/tools/preproc.rb
@@ -45,7 +45,7 @@ def prelude(f, out) https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/preproc.rb#L45
   while line = f.gets
     case line
     when /\A%%/
-      out << '%%' << $/
+      out << "%%\n"
       return
     when /\A%token/
       out << line.sub(/<\w+>/, '<val>')
@@ -79,15 +79,15 @@ def grammar(f, out) https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/preproc.rb#L79
   while line = f.gets
     case line
     when %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
-      out << DSL.new($2, ($1 || "").split(",")).generate << $/
+      out << DSL.new($2, ($1 || "").split(",")).generate << "\n"
     when %r</\*%%%\*/>
-      out << '#if 0' << $/
+      out << "#if 0\n"
     when %r</\*%>
-      out << '#endif' << $/
+      out << "#endif\n"
     when %r<%\*/>
-      out << $/
+      out << "\n"
     when /\A%%/
-      out << '%%' << $/
+      out << "%%\n"
       return
     else
       out << line
diff --git a/template/encdb.h.tmpl b/template/encdb.h.tmpl
index 06afb5d..b3bd545 100644
--- a/template/encdb.h.tmpl
+++ b/template/encdb.h.tmpl
@@ -58,7 +58,7 @@ encdirs.each do |encdir| https://github.com/ruby/ruby/blob/trunk/template/encdb.h.tmpl#L58
           else
             name = $1
           end
-          check_duplication(defs, $1, fn, $.)
+          check_duplication(defs, $1, fn, f.lineno)
           next if BUILTIN_ENCODINGS[name]
           encodings << $1
           count += 1
@@ -71,18 +71,18 @@ encdirs.each do |encdir| https://github.com/ruby/ruby/blob/trunk/template/encdb.h.tmpl#L71
           when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
             raise ArgumentError,
             '%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
-              [fn, $., $2, $1] unless defs[$2.upcase]
+              [fn, f.lineno, $2, $1] unless defs[$2.upcase]
             count += 1
           when /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
             raise ArgumentError,
             '%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
-              [fn, $., $2, $1] unless defs[$2.upcase]
+              [fn, f.lineno, $2, $1] unless defs[$2.upcase]
           when /^ENC_DUMMY\w*\(\s*"([^"]+)"/
             count += 1
           else
             next
           end
-          check_duplication(defs, $1, fn, $.)
+          check_duplication(defs, $1, fn, f.lineno)
           lines << line.sub(/;.*/m, "").chomp + ";" if line
         end
       end
diff --git a/template/transdb.h.tmpl b/template/transdb.h.tmpl
index 16565dd..990a863 100644
--- a/template/transdb.h.tmpl
+++ b/template/transdb.h.tmpl
@@ -44,9 +44,9 @@ transdirs.each do |transdir| https://github.com/ruby/ruby/blob/trunk/template/transdb.h.tmpl#L44
           from_to = "%s to %s" % [$1, $2]
           if converters[from_to]
             raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
-            [path, $., from_to, *converters[from_to].values_at(3, 4)]
+            [path, f.lineno, from_to, *converters[from_to].values_at(3, 4)]
           else
-            converters[from_to] = [$1, $2, fn[0..-3], path, $.]
+            converters[from_to] = [$1, $2, fn[0..-3], path, f.lineno]
             converter_list << from_to
           end
         end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]