* [PATCH] encoding: use CharlockHolmes properly on first run
@ 2020-09-29 2:31 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-09-29 2:31 UTC (permalink / raw)
To: dtas-all
Ruby case/when is not like C with fall-through, so we can't
rely on fall-through behavior to use CharlockHolmes to detect
legacy encodings.
---
lib/dtas/encoding.rb | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/lib/dtas/encoding.rb b/lib/dtas/encoding.rb
index dad54af..bbc6076 100644
--- a/lib/dtas/encoding.rb
+++ b/lib/dtas/encoding.rb
@@ -11,15 +11,14 @@ def self.extended(mod)
private
def try_enc_harder(str, enc, old) # :nodoc:
+ begin
+ require 'charlock_holmes'
+ @charlock_holmes = CharlockHolmes::EncodingDetector.new
+ rescue LoadError
+ @charlock_holmes = false
+ end if @charlock_holmes.nil?
+
case @charlock_holmes
- when nil
- begin
- require 'charlock_holmes'
- @charlock_holmes = CharlockHolmes::EncodingDetector.new
- rescue LoadError
- warn "`charlock_holmes` gem not available for encoding detection"
- @charlock_holmes = false
- end
when false
enc_fallback(str, enc, old)
else
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-29 2:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 2:31 [PATCH] encoding: use CharlockHolmes properly on first run Eric Wong
everything related to duct tape audio suite (dtas)
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://80x24.org/dtas-all
git clone --mirror http://ou63pmih66umazou.onion/dtas-all
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V1 dtas-all dtas-all/ https://80x24.org/dtas-all \
dtas-all@nongnu.org
public-inbox-index dtas-all
Example config snippet for mirrors.
Newsgroups are available over NNTP:
nntp://news.public-inbox.org/inbox.comp.audio.dtas
nntp://ou63pmih66umazou.onion/inbox.comp.audio.dtas
note: .onion URLs require Tor: https://www.torproject.org/
code repositories for the project(s) associated with this inbox:
../../../dtas.git
AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git