everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] require Ruby 2.3+, support Ruby 3.1
@ 2022-01-20 18:34 Eric Wong
  2022-01-20 18:34 ` [PATCH 1/4] require Ruby 2.3+ Eric Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eric Wong @ 2022-01-20 18:34 UTC (permalink / raw)
  To: dtas-all

I figure most workstation and laptop users will have Ruby 2.3+
by now, since the Ruby core team doesn't even support 2.5.

In any case, old versions of dtas remain available for users of
old Rubies; but AFAIK dtas hardly has users atm and isn't likely
to gain more.

Psych 4.x (YAML) distributed with Ruby 3.1 breaks some subtle cases
for us so 4/4 fixes them.

Eric Wong (4):
  require Ruby 2.3+
  get rid of DTAS.dedupe_str wrapper
  move dtas-graph into script/, support Perl for dtas.sh
  use YAML.unsafe_load in Psych 4.x (Ruby 3.1+)

 bin/dtas-console                   |  4 ++--
 bin/dtas-msinkctl                  |  4 ++--
 bin/dtas-partstats                 | 12 +++---------
 bin/dtas-readahead                 | 11 +++++------
 bin/dtas-sinkedit                  |  7 +++----
 bin/dtas-sourceedit                |  7 +++----
 bin/dtas-splitfx                   |  6 +++---
 bin/dtas-tl                        |  4 ++--
 dtas.gemspec                       |  4 ++--
 dtas.sh                            |  7 ++++---
 lib/dtas.rb                        | 28 ++++++----------------------
 lib/dtas/compat_onenine.rb         | 17 -----------------
 lib/dtas/fadefx.rb                 |  4 ++--
 lib/dtas/mlib.rb                   | 12 +++++-------
 lib/dtas/partstats.rb              |  5 ++---
 lib/dtas/pipeline.rb               |  5 +----
 lib/dtas/player.rb                 |  4 ++--
 lib/dtas/player/client_handler.rb  |  6 +++---
 lib/dtas/process.rb                |  3 +--
 lib/dtas/rg_state.rb               |  4 ++--
 lib/dtas/source/av_ff_common.rb    |  6 +++---
 lib/dtas/source/sox.rb             |  6 +++---
 lib/dtas/source/splitfx.rb         |  4 ++--
 lib/dtas/spawn_fix.rb              | 10 ----------
 lib/dtas/state_file.rb             |  4 ++--
 lib/dtas/watchable/fiddle_ino.rb   |  4 ++--
 {perl => script}/dtas-graph        |  2 +-
 test/test_encoding.rb              |  4 ++--
 test/test_format_change.rb         |  4 ++--
 test/test_player_client_handler.rb |  4 ++--
 test/test_player_integration.rb    | 15 +++++++--------
 test/test_rg_integration.rb        | 18 +++++++++---------
 test/test_sink.rb                  |  4 ++--
 test/test_splitfx.rb               |  6 ++----
 test/test_tfx.rb                   |  4 ++--
 35 files changed, 94 insertions(+), 155 deletions(-)
 delete mode 100644 lib/dtas/compat_onenine.rb
 delete mode 100644 lib/dtas/spawn_fix.rb
 rename {perl => script}/dtas-graph (97%)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] require Ruby 2.3+
  2022-01-20 18:34 [PATCH 0/4] require Ruby 2.3+, support Ruby 3.1 Eric Wong
@ 2022-01-20 18:34 ` Eric Wong
  2022-01-20 18:34 ` [PATCH 2/4] get rid of DTAS.dedupe_str wrapper Eric Wong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2022-01-20 18:34 UTC (permalink / raw)
  To: dtas-all

This allows us to jettison a bunch of compatibility code since
we've started using Etc.nprocessors and String#- (uminus) in
more places.  The Ruby core team doesn't support <= 2.5, even.
---
 bin/dtas-partstats              | 12 +++---------
 bin/dtas-readahead              |  3 +--
 bin/dtas-sinkedit               |  3 +--
 bin/dtas-sourceedit             |  3 +--
 dtas.gemspec                    |  4 ++--
 lib/dtas.rb                     | 13 ++-----------
 lib/dtas/compat_onenine.rb      | 17 -----------------
 lib/dtas/partstats.rb           |  3 +--
 lib/dtas/pipeline.rb            |  5 +----
 lib/dtas/process.rb             |  3 +--
 lib/dtas/spawn_fix.rb           | 10 ----------
 test/test_player_integration.rb |  3 +--
 test/test_splitfx.rb            |  4 +---
 13 files changed, 15 insertions(+), 68 deletions(-)
 delete mode 100644 lib/dtas/compat_onenine.rb
 delete mode 100644 lib/dtas/spawn_fix.rb

diff --git a/bin/dtas-partstats b/bin/dtas-partstats
index 884a6d1..6a0c9d4 100755
--- a/bin/dtas-partstats
+++ b/bin/dtas-partstats
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 # TODO
@@ -8,17 +8,11 @@
 # - configurable output formatting
 # - Sequel/SQLite support
 require 'dtas/partstats'
+require 'etc'
 infile = ARGV[0] or abort "usage: #$0 INFILE"
 ps = DTAS::PartStats.new(infile)
 
-def nproc
-  require 'etc'
-  Etc.nprocessors
-rescue NoMethodError
-  `nproc 2>/dev/null || echo 2`.to_i
-end
-
-opts = { jobs: nproc }
+opts = { jobs: Etc.nprocessors }
 stats = ps.run(opts)
 
 headers = ps.key_idx.to_a
diff --git a/bin/dtas-readahead b/bin/dtas-readahead
index 3eedd86..a1971bd 100755
--- a/bin/dtas-readahead
+++ b/bin/dtas-readahead
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2015-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 #
@@ -18,7 +18,6 @@
 require 'dtas/process'
 
 include DTAS::Process
-include DTAS::SpawnFix
 trap(:CHLD) { DTAS::Process.reaper {} }
 trap(:INT) { exit(0) }
 trap(:TERM) { exit(0) }
diff --git a/bin/dtas-sinkedit b/bin/dtas-sinkedit
index 3393aac..8f96a97 100755
--- a/bin/dtas-sinkedit
+++ b/bin/dtas-sinkedit
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'optparse'
@@ -68,7 +68,6 @@
   buf = $stdin.read
   commit_update.call(buf)
 else
-  include DTAS::SpawnFix
   tmp = tmpyaml
   tmp_path = tmp.path
   do_update = lambda { commit_update.call(File.read(tmp_path)) }
diff --git a/bin/dtas-sourceedit b/bin/dtas-sourceedit
index 23362c2..e6603bf 100755
--- a/bin/dtas-sourceedit
+++ b/bin/dtas-sourceedit
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'optparse'
@@ -55,7 +55,6 @@
   buf = $stdin.read
   commit_update.call(buf)
 else
-  include DTAS::SpawnFix
   tmp = tmpyaml
   tmp_path = tmp.path
   do_update = lambda { commit_update.call(File.read(tmp_path)) }
diff --git a/dtas.gemspec b/dtas.gemspec
index 50ce370..e1bbb38 100644
--- a/dtas.gemspec
+++ b/dtas.gemspec
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2021 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 Gem::Specification.new do |s|
   manifest = File.read('.gem-manifest').split(/\n/)
@@ -12,5 +12,5 @@
   s.files = manifest
   s.homepage = 'https://80x24.org/dtas.git/about/'
   s.licenses = "GPL-3.0+"
-  s.required_ruby_version = '>= 1.9.3'
+  s.required_ruby_version = '>= 2.3'
 end
diff --git a/lib/dtas.rb b/lib/dtas.rb
index 1eac704..eb8f49d 100644
--- a/lib/dtas.rb
+++ b/lib/dtas.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 
@@ -9,15 +9,8 @@ module DTAS
   # try to use the monotonic clock in Ruby >= 2.1, it is immune to clock
   # offset adjustments and generates less garbage (Float vs Time object)
   # :stopdoc:
-  begin
+  def self.now # :nodoc:
     ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
-    def self.now # :nodoc:
-      ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
-    end
-  rescue NameError, NoMethodError
-    def self.now # :nodoc:
-      Time.now.to_f # Ruby <= 2.0
-    end
   end
 
   @null = nil
@@ -48,7 +41,5 @@ def self.dedupe_str(str)
   # :startdoc:
 end
 
-require_relative 'dtas/compat_onenine'
-require_relative 'dtas/spawn_fix'
 require_relative 'dtas/encoding'
 DTAS.extend(DTAS::Encoding)
diff --git a/lib/dtas/compat_onenine.rb b/lib/dtas/compat_onenine.rb
deleted file mode 100644
index b65ea50..0000000
--- a/lib/dtas/compat_onenine.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
-# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
-
-# Make Ruby 1.9.3 look like Ruby 2.0.0 to us
-# This exists for Debian wheezy users using the stock Ruby 1.9.3 install.
-# We'll drop this interface when Debian wheezy (7.0) becomes unsupported.
-class String # :nodoc:
-  def b # :nodoc:
-    dup.force_encoding(Encoding::BINARY)
-  end
-end unless String.method_defined?(:b)
-
-def IO # :nodoc:
-  def self.pipe # :nodoc:
-    super.each { |io| io.close_on_exec = true }
-  end
-end if RUBY_VERSION.to_f <= 1.9
diff --git a/lib/dtas/partstats.rb b/lib/dtas/partstats.rb
index 45eff34..8e9ee95 100644
--- a/lib/dtas/partstats.rb
+++ b/lib/dtas/partstats.rb
@@ -1,5 +1,5 @@
 # -*- encoding: binary -*-
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require_relative '../dtas'
@@ -11,7 +11,6 @@
 class DTAS::PartStats # :nodoc:
   CMD = 'sox "$INFILE" -n $TRIMFX $SOXFX stats $STATSOPTS'
   include DTAS::Process
-  include DTAS::SpawnFix
   attr_reader :key_idx
   attr_reader :key_width
 
diff --git a/lib/dtas/pipeline.rb b/lib/dtas/pipeline.rb
index eb2af89..1bebe87 100644
--- a/lib/dtas/pipeline.rb
+++ b/lib/dtas/pipeline.rb
@@ -1,12 +1,9 @@
-# Copyright (C) 2017-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require_relative '../dtas'
-require_relative 'spawn_fix'
 
 module DTAS::Pipeline # :nodoc:
-  include DTAS::SpawnFix
-
   # Process.spawn wrapper which supports running Proc-like objects in
   # a separate process, not just external commands.
   # Returns the pid of the spawned process
diff --git a/lib/dtas/process.rb b/lib/dtas/process.rb
index f93a8c4..d00716f 100644
--- a/lib/dtas/process.rb
+++ b/lib/dtas/process.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'io/wait'
@@ -11,7 +11,6 @@
 module DTAS::Process # :nodoc:
   PIDS = {}
   include DTAS::XS
-  include DTAS::SpawnFix
 
   def self.reaper
     begin
diff --git a/lib/dtas/spawn_fix.rb b/lib/dtas/spawn_fix.rb
deleted file mode 100644
index b586130..0000000
--- a/lib/dtas/spawn_fix.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
-# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
-# workaround for older Rubies: https://bugs.ruby-lang.org/issues/8770
-module DTAS::SpawnFix # :nodoc:
-  def spawn(*args)
-    super(*args)
-  rescue Errno::EINTR
-    retry
-  end if RUBY_VERSION.to_f <= 2.1
-end
diff --git a/test/test_player_integration.rb b/test/test_player_integration.rb
index d2e11cf..e933f7b 100644
--- a/test/test_player_integration.rb
+++ b/test/test_player_integration.rb
@@ -1,10 +1,9 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/player_integration'
 class TestPlayerIntegration < Testcase
   include PlayerIntegration
-  include DTAS::SpawnFix
 
   def test_cmd_rate
     env = ENV.to_hash.merge(@fmt.to_env)
diff --git a/test/test_splitfx.rb b/test/test_splitfx.rb
index b6ae01f..cacda66 100644
--- a/test/test_splitfx.rb
+++ b/test/test_splitfx.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'yaml'
@@ -7,8 +7,6 @@
 require_relative 'helper'
 
 class TestSplitfx < Testcase
-  include DTAS::SpawnFix
-
   def tmp_err(path)
     err = $stderr.dup
     $stderr.reopen(path, 'a')


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] get rid of DTAS.dedupe_str wrapper
  2022-01-20 18:34 [PATCH 0/4] require Ruby 2.3+, support Ruby 3.1 Eric Wong
  2022-01-20 18:34 ` [PATCH 1/4] require Ruby 2.3+ Eric Wong
@ 2022-01-20 18:34 ` Eric Wong
  2022-01-20 18:34 ` [PATCH 3/4] move dtas-graph into script/, support Perl for dtas.sh Eric Wong
  2022-01-20 18:34 ` [PATCH 4/4] use YAML.unsafe_load in Psych 4.x (Ruby 3.1+) Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2022-01-20 18:34 UTC (permalink / raw)
  To: dtas-all

Ruby 2.3+ supports String#@-, though it did not deduplicate
strings.  But 2.5 is already old at this point and most users
can be expected to have it.

This gives some memory regressions for Ruby <= 2.4 users,
but cuts down on the code we maintain and reduces bytecode
overhead for 2.5+ users.
---
 lib/dtas.rb                       | 13 -------------
 lib/dtas/fadefx.rb                |  4 ++--
 lib/dtas/mlib.rb                  | 12 +++++-------
 lib/dtas/partstats.rb             |  2 +-
 lib/dtas/player.rb                |  4 ++--
 lib/dtas/player/client_handler.rb |  6 +++---
 lib/dtas/rg_state.rb              |  4 ++--
 lib/dtas/source/av_ff_common.rb   |  6 +++---
 lib/dtas/source/sox.rb            |  6 +++---
 lib/dtas/watchable/fiddle_ino.rb  |  4 ++--
 10 files changed, 23 insertions(+), 38 deletions(-)

diff --git a/lib/dtas.rb b/lib/dtas.rb
index eb8f49d..477a176 100644
--- a/lib/dtas.rb
+++ b/lib/dtas.rb
@@ -25,19 +25,6 @@ def self.libc
       Fiddle.dlopen(nil)
     end
   end
-
-  # String#-@ will deduplicate strings when Ruby 2.5 is released (Dec 2017)
-  # https://bugs.ruby-lang.org/issues/13077
-  if RUBY_VERSION.to_f >= 2.5
-    def self.dedupe_str(str)
-      -str
-    end
-  else
-    # Ruby 2.1 - 2.4, noop for older Rubies
-    def self.dedupe_str(str)
-      eval "#{str.inspect}.freeze"
-    end
-  end
   # :startdoc:
 end
 
diff --git a/lib/dtas/fadefx.rb b/lib/dtas/fadefx.rb
index 7bccff8..0ec108c 100644
--- a/lib/dtas/fadefx.rb
+++ b/lib/dtas/fadefx.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require_relative '../dtas'
@@ -95,7 +95,7 @@ def fade_in_next_fx(format, tbeg, tlen)
   def parse!(str)
     return nil if str.empty?
     type = "t"
-    str.sub!(/\A([a-z])/, "") and type = DTAS.dedupe_str($1)
+    str.sub!(/\A([a-z])/, "") and type = -$1
     F.new(type, parse_time(str))
   end
 end
diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb
index eb7554a..f99ed6a 100644
--- a/lib/dtas/mlib.rb
+++ b/lib/dtas/mlib.rb
@@ -1,5 +1,5 @@
 # -*- encoding: utf-8 -*-
-# Copyright (C) 2015-2021 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 #
@@ -201,9 +201,7 @@ def load_tags
       tag_id = tag_map[x] and tag_map["#{x}number"] = tag_id
     end
     @tag_rmap = tag_map.invert.freeze
-    tag_map.merge!(Hash[*(tag_map.map { |k,v|
-      [DTAS.dedupe_str(k.upcase), v]
-    }.flatten!)])
+    tag_map.merge!(Hash[*(tag_map.map { |k,v| [-(k.upcase), v] }.flatten!)])
     @tag_map = tag_map.freeze
   end
 
@@ -421,7 +419,7 @@ def path_of(node, cache)
     return '/' if base == '' # root_node
     parent_id = node[:parent_id]
     base += '/' unless node[:tlen] >= 0
-    ppath = cache[parent_id] and return DTAS.dedupe_str("#{ppath}/#{base}")
+    ppath = cache[parent_id] and return -"#{ppath}/#{base}"
     parts = []
     begin
       node = @db[:nodes][id: node[:parent_id]]
@@ -429,9 +427,9 @@ def path_of(node, cache)
       parts.unshift node[:name]
     end while true
     parts.unshift('')
-    cache[parent_id] = DTAS.dedupe_str(parts.join('/'))
+    cache[parent_id] = -(parts.join('/'))
     parts << base
-    DTAS.dedupe_str(parts.join('/'))
+    -(parts.join('/'))
   end
 
   def emit_recurse(node, cache, cb)
diff --git a/lib/dtas/partstats.rb b/lib/dtas/partstats.rb
index 8e9ee95..061ff50 100644
--- a/lib/dtas/partstats.rb
+++ b/lib/dtas/partstats.rb
@@ -171,7 +171,7 @@ def parse_stats(stats, trim_part, buf)
       else
         next
       end
-      key = DTAS.dedupe_str($1)
+      key = -$1
       key_idx = @key_idx[key]
       parts = line.split(/\s+/)
       nshift.times { parts.shift } # remove stuff we don't need
diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb
index b39a2e7..ff7440f 100644
--- a/lib/dtas/player.rb
+++ b/lib/dtas/player.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'yaml'
@@ -168,7 +168,7 @@ def self.load(hash)
 
       if sinks = hash["sinks"]
         sinks.each do |sink_hsh|
-          sink_hsh['name'] = DTAS.dedupe_str(sink_hsh['name'])
+          sink_hsh['name'] = -sink_hsh['name']
           sink = DTAS::Sink.load(sink_hsh)
           sink.env = to_omap(sink.env)
           @sinks[sink.name] = sink
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb
index cf5442d..2914fe7 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require_relative '../xs'
@@ -135,7 +135,7 @@ def dpc_sink(io, msg)
       # or variable names.
       sink.valid_name?(name) or return io.emit("ERR sink name invalid")
 
-      sink.name = DTAS.dedupe_str(name)
+      sink.name = -name
       active_before = sink.active
       before = __sink_snapshot(sink)
 
@@ -144,7 +144,7 @@ def dpc_sink(io, msg)
         k, v = kv.split('=', 2)
         case k
         when %r{\Aenv\.([^=]+)\z}
-          sink.env[DTAS.dedupe_str($1)] = v
+          sink.env[$1] = v
         when %r{\Aenv#([^=]+)\z}
           v == nil or return io.emit("ERR unset env has no value")
           sink.env.delete($1)
diff --git a/lib/dtas/rg_state.rb b/lib/dtas/rg_state.rb
index d463bd8..9a44835 100644
--- a/lib/dtas/rg_state.rb
+++ b/lib/dtas/rg_state.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 #
@@ -72,7 +72,7 @@ def to_sox_gain(val)
     when 1 then return 'gain 192'
     else
       val.abs <= 0.00000001 and return
-      DTAS.dedupe_str(sprintf('gain %0.8f', val))
+      -sprintf('gain %0.8f', val)
     end
   end
 
diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb
index 6f92762..5299fdb 100644
--- a/lib/dtas/source/av_ff_common.rb
+++ b/lib/dtas/source/av_ff_common.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require_relative '../../dtas'
@@ -110,7 +110,7 @@ def av_ff_ok?
       f =~ /^duration=([\d\.]+)\s*$/nm and @duration = $1.to_f
       # TODO: multi-line/multi-value/repeated tags
       f.gsub!(/^TAG:([^=]+)=(.*)$/ni) { |_|
-        @comments[DTAS.dedupe_str($1.upcase)] = DTAS.dedupe_str($2)
+        @comments[$1.upcase] = -($2)
       }
     end
 
@@ -118,7 +118,7 @@ def av_ff_ok?
     s.scan(%r{^\[format\.tags\]\n(.*?)\n\n}m) do |_|
       f = $1.dup
       f.gsub!(/^([^=]+)=(.*)$/ni) { |_|
-        @comments[DTAS.dedupe_str($1.upcase)] = DTAS.dedupe_str($2)
+        @comments[$1.upcase] = -$2
       }
     end
     s.scan(%r{^\[format\]\n(.*?)\n\n}m) do |_|
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index 3a7fe7d..e38e23c 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 # encoding: binary
@@ -56,14 +56,14 @@ def mcache_lookup(infile)
         key = nil
         $1.split(/\n/n).each do |line|
           if line.sub!(/^([^=]+)=/ni, '')
-            key = DTAS.dedupe_str(DTAS.try_enc($1.upcase, enc))
+            key = DTAS.try_enc($1.upcase, enc)
           end
           (comments[key] ||= ''.b) << "#{line}\n" unless line.empty?
         end
         comments.each do |k,v|
           v.chomp!
           DTAS.try_enc(v, enc)
-          comments[k] = DTAS.dedupe_str(v)
+          comments[k] = v
         end
       end
       dst
diff --git a/lib/dtas/watchable/fiddle_ino.rb b/lib/dtas/watchable/fiddle_ino.rb
index e85fea1..b24bbf6 100644
--- a/lib/dtas/watchable/fiddle_ino.rb
+++ b/lib/dtas/watchable/fiddle_ino.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'fiddle'
@@ -53,7 +53,7 @@ def take(nonblock) # :nodoc:
           name.size == len or raise "short name #{name.inspect} != #{len}"
           name.sub!(/\0+\z/, '') or
             raise "missing: `\\0', inotify_event.name=#{name.inspect}"
-          name = DTAS.dedupe_str(name)
+          name = -name
         end
         ie = InotifyEvent.new(wd, mask, cookie, len, name)
         if event


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] move dtas-graph into script/, support Perl for dtas.sh
  2022-01-20 18:34 [PATCH 0/4] require Ruby 2.3+, support Ruby 3.1 Eric Wong
  2022-01-20 18:34 ` [PATCH 1/4] require Ruby 2.3+ Eric Wong
  2022-01-20 18:34 ` [PATCH 2/4] get rid of DTAS.dedupe_str wrapper Eric Wong
@ 2022-01-20 18:34 ` Eric Wong
  2022-01-20 18:34 ` [PATCH 4/4] use YAML.unsafe_load in Psych 4.x (Ruby 3.1+) Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2022-01-20 18:34 UTC (permalink / raw)
  To: dtas-all

"script/" is the standard location for Perl ExtUtils::MakeMaker-based
installations, so and we'll probably overload "lib" to support Perl
scripts.  This is another step in expanding our use of Perl5 and
avoiding the slow startup and API instability of Ruby.
---
 dtas.sh                     | 7 ++++---
 {perl => script}/dtas-graph | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename {perl => script}/dtas-graph (97%)

diff --git a/dtas.sh b/dtas.sh
index d3ea5e1..1ceca15 100755
--- a/dtas.sh
+++ b/dtas.sh
@@ -1,7 +1,8 @@
 #!/bin/sh -e
 # symlink this file to a directory in PATH to run dtas (or anything in bin/*)
 # without needing perms to install globally.  Used by "make symlink-install"
-p=$(realpath "$0" || readlink "$0") # neither is POSIX, but common
-p=$(dirname "$p") c=$(basename "$0") # both are POSIX
-exec ${RUBY-ruby} -I"$p"/lib "$p"/bin/"${c%.sh}" "$@"
+p=$(realpath "$0" || readlink "$0"); # neither is POSIX, but common
+p=$(dirname "$p") c=$(basename "$0"); c="${c%.sh}"
+if test -x "$p/bin/$c"; then exec ${RUBY-ruby} -I"$p"/lib "$p/bin/$c" "$@";
+else exec ${PERL-perl} -I"$p"/lib "$p/script/$c" "$@"; fi
 : this script is too short to copyright
diff --git a/perl/dtas-graph b/script/dtas-graph
similarity index 97%
rename from perl/dtas-graph
rename to script/dtas-graph
index 776485d..d918351 100755
--- a/perl/dtas-graph
+++ b/script/dtas-graph
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 #
 # Process visualizer which shows pipe connections between processes with


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] use YAML.unsafe_load in Psych 4.x (Ruby 3.1+)
  2022-01-20 18:34 [PATCH 0/4] require Ruby 2.3+, support Ruby 3.1 Eric Wong
                   ` (2 preceding siblings ...)
  2022-01-20 18:34 ` [PATCH 3/4] move dtas-graph into script/, support Perl for dtas.sh Eric Wong
@ 2022-01-20 18:34 ` Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2022-01-20 18:34 UTC (permalink / raw)
  To: dtas-all

Psych 4.x defaults to "nanny mode" to handle untrusted data.
This causes breakage with since YAML references (aliases)
emitted by dtas-player can't be handled by Psych clients under
Ruby 3.1.  Since dtas is single user and is a shell designed to
run arbitrary code, favor the new YAML.unsafe_load API which
behaves like the old YAML.load in Ruby <= 3.0.
---
 bin/dtas-console                   |  4 ++--
 bin/dtas-msinkctl                  |  4 ++--
 bin/dtas-readahead                 |  8 ++++----
 bin/dtas-sinkedit                  |  4 ++--
 bin/dtas-sourceedit                |  4 ++--
 bin/dtas-splitfx                   |  6 +++---
 bin/dtas-tl                        |  4 ++--
 lib/dtas.rb                        |  6 ++++++
 lib/dtas/source/splitfx.rb         |  4 ++--
 lib/dtas/state_file.rb             |  4 ++--
 test/test_encoding.rb              |  4 ++--
 test/test_format_change.rb         |  4 ++--
 test/test_player_client_handler.rb |  4 ++--
 test/test_player_integration.rb    | 12 ++++++------
 test/test_rg_integration.rb        | 18 +++++++++---------
 test/test_sink.rb                  |  4 ++--
 test/test_splitfx.rb               |  2 +-
 test/test_tfx.rb                   |  4 ++--
 18 files changed, 53 insertions(+), 47 deletions(-)

diff --git a/bin/dtas-console b/bin/dtas-console
index e02dda4..a519ba9 100755
--- a/bin/dtas-console
+++ b/bin/dtas-console
@@ -27,7 +27,7 @@
 w = DTAS::UNIXClient.new
 w.req_ok('watch')
 c = DTAS::UNIXClient.new
-cur = YAML.load(c.req('current'))
+cur = DTAS.yaml_load(c.req('current'))
 readable = [ se, w, $stdin ]
 set_title = (ENV['DISPLAY'] || ENV['WAYLAND_DISPLAY']) ? $stdout : nil
 
@@ -254,7 +254,7 @@ def may_fail(c, req, events)
         events << "#{Time.now.strftime(tfmt)} #{event}"
         # something happened, refresh current
         # we could be more intelligent here, maybe, but too much work.
-        cur = YAML.load(c.req('current'))
+        cur = DTAS.yaml_load(c.req('current'))
       when $stdin
         # keybindings taken from mplayer / vi
         case key = Curses.getch
diff --git a/bin/dtas-msinkctl b/bin/dtas-msinkctl
index 189738f..6fb3863 100755
--- a/bin/dtas-msinkctl
+++ b/bin/dtas-msinkctl
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'yaml'
@@ -29,7 +29,7 @@ def filter(c, player_sinks, key)
   rv = []
   player_sinks.each do |name|
     buf = c.req("sink cat #{name}")
-    sink = YAML.load(buf)
+    sink = DTAS.yaml_load(buf)
     rv << sink["name"] if sink[key]
   end
   rv
diff --git a/bin/dtas-readahead b/bin/dtas-readahead
index a1971bd..3f46b95 100755
--- a/bin/dtas-readahead
+++ b/bin/dtas-readahead
@@ -140,7 +140,7 @@ def do_open(path)
       when "---\n"
         buf << fp.read(fp.size - 4)
         Dir.chdir(File.dirname(path)) do
-          yml = YAML.load(buf)
+          yml = DTAS.yaml_load(buf)
           x = yml['infile'] and return File.open(File.expand_path(x).freeze)
         end
       end
@@ -155,7 +155,7 @@ def do_open(path)
   @todo_ra = @max_ra
   t0 = DTAS.now
   fp = nil
-  cur = YAML.load(c.req('current'))
+  cur = DTAS.yaml_load(c.req('current'))
   while @todo_ra > 0 && fp.nil?
     if current = cur['current']
       track = current['infile']
@@ -177,7 +177,7 @@ def do_open(path)
     end
 
     # queue has priority, work on it, first
-    queue = YAML.load(c.req('queue cat'))
+    queue = DTAS.yaml_load(c.req('queue cat'))
     while @todo_ra > 0 && track = queue.shift
       next unless track.kind_of?(String)
       fp = nil
@@ -209,7 +209,7 @@ def do_open(path)
       end
     end
     idx or break
-    cur = YAML.load(c.req('current'))
+    cur = DTAS.yaml_load(c.req('current'))
     current = cur['current'] or break
   end
   if current
diff --git a/bin/dtas-sinkedit b/bin/dtas-sinkedit
index 8f96a97..252270f 100755
--- a/bin/dtas-sinkedit
+++ b/bin/dtas-sinkedit
@@ -36,10 +36,10 @@
 
 buf = c.req(%W(sink cat #{name}))
 abort(buf) if buf =~ /\AERR/
-orig = YAML.load(buf)
+orig = DTAS.yaml_load(buf)
 
 commit_update = lambda do |buf|
-  sink = YAML.load(buf)
+  sink = DTAS.yaml_load(buf)
   cmd = %W(sink ed #{name})
   update_cmd_env(cmd, orig, sink)
 
diff --git a/bin/dtas-sourceedit b/bin/dtas-sourceedit
index e6603bf..1b3f4ee 100755
--- a/bin/dtas-sourceedit
+++ b/bin/dtas-sourceedit
@@ -36,10 +36,10 @@
 
 buf = c.req(%W(source cat #{name}))
 abort(buf) if buf =~ /\AERR/
-orig = YAML.load(buf)
+orig = DTAS.yaml_load(buf)
 
 commit_update = lambda do |buf|
-  source = YAML.load(buf)
+  source = DTAS.yaml_load(buf)
   cmd = %W(source ed #{name})
   update_cmd_env(cmd, orig, source)
 
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index 18ea0b4..05e71e5 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'yaml'
@@ -48,7 +48,7 @@
   when %r{\A(\w+)=(.*)\z}
     key, val = $1, $2
     # only one that makes sense is infile=another_file
-    overrides[key] = YAML.load(val)
+    overrides[key] = DTAS.yaml_load(val)
   when %r{\A(\w+)\.(\w+)=(.*)\z}
     # comments.ARTIST='blah'
     top, key, val = $1, $2, $3
@@ -63,5 +63,5 @@
 file = args.shift or abort usage
 target = args.shift || default_target
 splitfx = DTAS::SplitFX.new
-splitfx.import(YAML.load(File.read(file)), overrides)
+splitfx.import(DTAS.yaml_load(File.read(file)), overrides)
 splitfx.run(target, opts)
diff --git a/bin/dtas-tl b/bin/dtas-tl
index 988e726..c1af933 100755
--- a/bin/dtas-tl
+++ b/bin/dtas-tl
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 # encoding: binary
@@ -51,7 +51,7 @@ def do_edit(c)
   # jump to the line of the currently playing track if using vi or vim
   # Patches for other editors welcome: dtas-all@nongnu.org
   if ed =~ /vim?\z/
-    cur = YAML.load(c.req('current'))
+    cur = DTAS.yaml_load(c.req('current'))
     if tl = cur['tracklist']
       if pos = tl['pos']
         ed += " +#{pos + 1}"
diff --git a/lib/dtas.rb b/lib/dtas.rb
index 477a176..cb7c33d 100644
--- a/lib/dtas.rb
+++ b/lib/dtas.rb
@@ -25,6 +25,12 @@ def self.libc
       Fiddle.dlopen(nil)
     end
   end
+
+  # prevent breakage in Psych 4.x; we're a shell and designed to execute code
+  def self.yaml_load(buf)
+    require 'yaml'
+    YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(buf) : YAML.load(buf)
+  end
   # :startdoc:
 end
 
diff --git a/lib/dtas/source/splitfx.rb b/lib/dtas/source/splitfx.rb
index 11e4190..afeb6a3 100644
--- a/lib/dtas/source/splitfx.rb
+++ b/lib/dtas/source/splitfx.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'yaml'
@@ -36,7 +36,7 @@ def try(ymlfile, offset = nil, trim = nil)
 
     sfx = DTAS::SplitFX.new
     Dir.chdir(File.dirname(ymlfile)) do # ugh
-      @ymlhash = YAML.load(buf)
+      @ymlhash = DTAS.yaml_load(buf)
       @ymlhash['tracks'] ||= [ "t 0 default" ]
       sfx.import(@ymlhash)
       sfx.infile.replace(File.expand_path(sfx.infile))
diff --git a/lib/dtas/state_file.rb b/lib/dtas/state_file.rb
index eac3e2f..f16a866 100644
--- a/lib/dtas/state_file.rb
+++ b/lib/dtas/state_file.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'yaml'
@@ -14,7 +14,7 @@ def initialize(path, do_fsync = false)
   end
 
   def tryload
-    YAML.load(IO.binread(@path)) if File.readable?(@path)
+    DTAS.yaml_load(IO.binread(@path)) if File.readable?(@path)
   end
 
   def dump(obj, force_fsync = false)
diff --git a/test/test_encoding.rb b/test/test_encoding.rb
index 9ef6a25..666d185 100644
--- a/test/test_encoding.rb
+++ b/test/test_encoding.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/helper'
@@ -13,7 +13,7 @@ def test_encoding
   ARTIST: !binary |-
     RW5yaXF1ZSBSb2Ryw61ndWV6
 EOD
-    hash = YAML.load(data)
+    hash = DTAS.yaml_load(data)
     artist = DTAS.try_enc(hash['comments']['ARTIST'], Encoding::UTF_8)
     assert_equal 'Enrique Rodríguez', artist
   end
diff --git a/test/test_format_change.rb b/test/test_format_change.rb
index 95bb860..dc94f02 100644
--- a/test/test_format_change.rb
+++ b/test/test_format_change.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/player_integration'
@@ -26,7 +26,7 @@ def test_format_change
 
       Timeout.timeout(len) do
         begin
-          cur = YAML.load(s.req("current"))
+          cur = DTAS.yaml_load(s.req("current"))
         end while cur["sinks"] && sleep(0.01)
       end
 
diff --git a/test/test_player_client_handler.rb b/test/test_player_client_handler.rb
index 7ea8cc0..eee5e49 100644
--- a/test/test_player_client_handler.rb
+++ b/test/test_player_client_handler.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/helper'
@@ -71,7 +71,7 @@ def test_cat
     @sinks["default"] = sink
     dpc_sink(@io, %W(cat default))
     assert_equal 1, @io.size
-    hsh = YAML.load(@io[0])
+    hsh = DTAS.yaml_load(@io[0])
     assert_kind_of Hash, hsh
     assert_equal "default", hsh["name"]
     assert_match("dither -s", hsh["command"])
diff --git a/test/test_player_integration.rb b/test/test_player_integration.rb
index e933f7b..5059bd2 100644
--- a/test/test_player_integration.rb
+++ b/test/test_player_integration.rb
@@ -139,7 +139,7 @@ def test_sink_env
     Timeout.timeout(5) do
       begin
         yaml = s.req("current")
-        cur = YAML.load(yaml)
+        cur = DTAS.yaml_load(yaml)
       end while cur["sinks"] && sleep(0.01)
     end
 
@@ -166,7 +166,7 @@ def test_enq_head
     Timeout.timeout(len) do
       begin
         yaml = s.req("current")
-        cur = YAML.load(yaml)
+        cur = DTAS.yaml_load(yaml)
       end while cur["sinks"] && sleep(0.01)
     end
     assert(system("cmp", dump.path, expect.path),
@@ -195,13 +195,13 @@ def test_state_file
     state.close!
     s = client_socket
     s.req_ok(%W(state dump #{state_path}))
-    hash = YAML.load(IO.binread(state_path))
+    hash = DTAS.yaml_load(IO.binread(state_path))
     assert_equal @sock_path, hash["socket"]
     assert_equal "default", hash["sinks"][0]["name"]
 
     assert_equal "", IO.binread(@state_tmp.path)
     s.req_ok(%W(state dump))
-    orig = YAML.load(IO.binread(@state_tmp.path))
+    orig = DTAS.yaml_load(IO.binread(@state_tmp.path))
     assert_equal orig, hash
   ensure
     File.unlink(state_path)
@@ -216,11 +216,11 @@ def test_source_ed
     assert_equal "sox av ff splitfx", s.req("source ls")
 
     s.req_ok("source ed sox command=true")
-    sox = YAML.load(s.req("source cat sox"))
+    sox = DTAS.yaml_load(s.req("source cat sox"))
     assert_equal "true", sox["command"]
 
     s.req_ok("source ed sox command=")
-    sox = YAML.load(s.req("source cat sox"))
+    sox = DTAS.yaml_load(s.req("source cat sox"))
     assert_equal DTAS::Source::Sox::SOX_DEFAULTS["command"], sox["command"]
   end
 
diff --git a/test/test_rg_integration.rb b/test/test_rg_integration.rb
index efa0721..f274272 100644
--- a/test/test_rg_integration.rb
+++ b/test/test_rg_integration.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/player_integration'
@@ -39,7 +39,7 @@ def test_rg_changes_added
     yaml = cur = nil
     Timeout.timeout(5) do
       begin
-        cur = YAML.load(yaml = s.req("current"))
+        cur = DTAS.yaml_load(yaml = s.req("current"))
       end while cur["current_offset"] == 0 && sleep(0.01)
     end
 
@@ -55,7 +55,7 @@ def test_rg_changes_added
       Timeout.timeout(5) do
         begin
           yaml = s.req("current")
-          cur = YAML.load(yaml)
+          cur = DTAS.yaml_load(yaml)
         end while cur["current"]["env"]["RGFX"] !~ expect && sleep(0.01)
       end
       assert_match expect, cur["current"]["env"]["RGFX"]
@@ -67,27 +67,27 @@ def test_rg_changes_added
     check_gain.call(%r{gain 2\.5}, "track_peak")
 
     s.req_ok("rg preamp+=1")
-    rg = YAML.load(yaml = s.req("rg"))
+    rg = DTAS.yaml_load(yaml = s.req("rg"))
     assert_equal 1, rg["preamp"]
 
     s.req_ok("rg preamp-=1")
-    rg = YAML.load(yaml = s.req("rg"))
+    rg = DTAS.yaml_load(yaml = s.req("rg"))
     assert_nil rg["preamp"]
 
     s.req_ok("rg preamp=2")
-    rg = YAML.load(yaml = s.req("rg"))
+    rg = DTAS.yaml_load(yaml = s.req("rg"))
     assert_equal 2, rg["preamp"]
 
     s.req_ok("rg preamp-=0.3")
-    rg = YAML.load(yaml = s.req("rg"))
+    rg = DTAS.yaml_load(yaml = s.req("rg"))
     assert_equal 1.7, rg["preamp"]
 
     s.req_ok("rg preamp-=-0.3")
-    rg = YAML.load(yaml = s.req("rg"))
+    rg = DTAS.yaml_load(yaml = s.req("rg"))
     assert_equal 2.0, rg["preamp"]
 
     s.req_ok("rg preamp-=+0.3")
-    rg = YAML.load(yaml = s.req("rg"))
+    rg = DTAS.yaml_load(yaml = s.req("rg"))
     assert_equal 1.7, rg["preamp"]
 
     dethrottle_decoder(s)
diff --git a/test/test_sink.rb b/test/test_sink.rb
index 873fb3a..7214da6 100644
--- a/test/test_sink.rb
+++ b/test/test_sink.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/helper'
@@ -27,6 +27,6 @@ def test_name
   def test_inactive_load
     orig = { "active" => false }.freeze
     tmp = orig.to_yaml
-    assert_equal orig, YAML.load(tmp)
+    assert_equal orig, DTAS.yaml_load(tmp)
   end
 end
diff --git a/test/test_splitfx.rb b/test/test_splitfx.rb
index cacda66..e3bd19d 100644
--- a/test/test_splitfx.rb
+++ b/test/test_splitfx.rb
@@ -39,7 +39,7 @@ def assert_contains_stats(file)
   end
 
   def test_example
-    hash = YAML.load(File.read("examples/splitfx.sample.yml"))
+    hash = DTAS.yaml_load(File.read("examples/splitfx.sample.yml"))
     sfx = DTAS::SplitFX.new
     Dir.mktmpdir do |dir|
       Dir.chdir(dir) do
diff --git a/test/test_tfx.rb b/test/test_tfx.rb
index fa77ca5..51b1900 100644
--- a/test/test_tfx.rb
+++ b/test/test_tfx.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require './test/helper'
@@ -12,7 +12,7 @@ def rate
   end
 
   def test_example
-    ex = YAML.load(File.read("examples/tfx.sample.yml"))
+    ex = DTAS.yaml_load(File.read("examples/tfx.sample.yml"))
     effects = []
     ex["effects"].each do |line|
       words = Shellwords.split(line)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-20 23:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 18:34 [PATCH 0/4] require Ruby 2.3+, support Ruby 3.1 Eric Wong
2022-01-20 18:34 ` [PATCH 1/4] require Ruby 2.3+ Eric Wong
2022-01-20 18:34 ` [PATCH 2/4] get rid of DTAS.dedupe_str wrapper Eric Wong
2022-01-20 18:34 ` [PATCH 3/4] move dtas-graph into script/, support Perl for dtas.sh Eric Wong
2022-01-20 18:34 ` [PATCH 4/4] use YAML.unsafe_load in Psych 4.x (Ruby 3.1+) Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).