sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 1d675cacf246986d2bc98f035d6e50539e8ae69c
parent 31393dc61f6381b08b78a1b73e03d595ab72a577
Author: Scott Bonds <scott@ggr.com>
Date:   Tue, 16 Sep 2014 17:52:01 -0700

don't load libc and do setlocale() on OpenBSD

Diffstat:
M bin/sup | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -106,26 +106,28 @@ end
 ## ncurses.so that's been compiled against libncursesw. (note the w.) why
 ## this works, i have no idea. much like pretty much every aspect of
 ## dealing with curses.  cargo cult programming at its best.
-require 'dl/import'
 require 'rbconfig'
-module LibC
-  extend DL.const_defined?(:Importer) ? DL::Importer : DL::Importable
-  setlocale_lib = case RbConfig::CONFIG['arch']
-    when /darwin/; "libc.dylib"
-    when /cygwin/; "cygwin1.dll"
-    when /freebsd/; "libc.so.7"
-    else; "libc.so.6"
-  end
+unless RbConfig::CONFIG['arch'] =~ /openbsd/
+  require 'dl/import'
+  module LibC
+    extend DL.const_defined?(:Importer) ? DL::Importer : DL::Importable
+    setlocale_lib = case RbConfig::CONFIG['arch']
+      when /darwin/; "libc.dylib"
+      when /cygwin/; "cygwin1.dll"
+      when /freebsd/; "libc.so.7"
+      else; "libc.so.6"
+    end
 
-  debug "dynamically loading setlocale() from #{setlocale_lib}"
-  begin
-    dlload setlocale_lib
-    extern "void setlocale(int, const char *)"
-    debug "setting locale..."
-    LibC.setlocale(6, "")  # LC_ALL == 6
-  rescue RuntimeError => e
-    warn "cannot dlload setlocale(); ncurses wide character support probably broken."
-    warn "dlload error was #{e.class}: #{e.message}"
+    debug "dynamically loading setlocale() from #{setlocale_lib}"
+    begin
+      dlload setlocale_lib
+      extern "void setlocale(int, const char *)"
+      debug "setting locale..."
+      LibC.setlocale(6, "")  # LC_ALL == 6
+    rescue RuntimeError => e
+      warn "cannot dlload setlocale(); ncurses wide character support probably broken."
+      warn "dlload error was #{e.class}: #{e.message}"
+    end
   end
 end