delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/10/24/16:43:57

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:from:date:message-id:subject:to
:content-type; q=dns; s=default; b=at21bwR7XZr3lzdnaoG7mg8S8FCjb
zwBKxMoIW4uZSpWpjpS0yq+RT510MnsktDnZRN5pC/OriU7RArvIWZbt6tj+JhtJ
//ORg0mI5uVIivG855fz82oIz09x3hgV7S1q3ap7ggkF+tJ/czarulPDw+OARwir
W21Y10dlZkDRiU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:from:date:message-id:subject:to
:content-type; s=default; bh=54A6mN3bIWUnSFwo+hLOidRbAHI=; b=HJM
ZjuNtnA3nQxTqk1AdgDFWqLo5qyv8EgMqS9KUlg4kTSSD/v/Zc01a272aP5hhvNr
SgCKSMz4SO2Udhf/iHcBYfbnbEZY4CUPqEhxiLec7f+LeFyFaWmh12Fdyq0x+Quz
UtLubIA1G7U95PRMg1ayQ3uJtMeTn3AbA4Ij1DPQ=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ob0-f175.google.com
X-Received: by 10.202.183.70 with SMTP id h67mr5215764oif.19.1414183418235; Fri, 24 Oct 2014 13:43:38 -0700 (PDT)
MIME-Version: 1.0
From: Jacob Niehus <jacob DOT niehus AT gmail DOT com>
Date: Fri, 24 Oct 2014 13:43:18 -0700
Message-ID: <CACvCDBp9DstQR87zPWjz+FD=S3Ob4M7f5+28om+u_O+WCtqj8Q@mail.gmail.com>
Subject: cygclang.dll breaks terminal output when used in Python bindings
To: cygwin AT cygwin DOT com

I use a Vim plugin called clang_complete for C/C++ code completion which
interfaces with Clang using Clang's python bindings. After updating Cygwin,
the terminal output of Vim is garbled as soon as the plugin uses the Clang
Python bindings.

I tracked down the exact revision (188615) of LLVM/Clang which cause the
problem and the diff for that revision is at the bottom of this message.
Basically it changes the way it looks up terminal capabilities in such a way
that it think Cygwin can't display colors which causes it to change terminal
output settings.

I was able to fix the problem by installing the libncurses-devel package and
recompiling LLVM/Clang. Should libncurses-devel be a dependency of libclang or
is there another way to fix this problem?

Thanks,
Jacob Niehus

--- lib/Support/Unix/Process.inc        (revision 188614)
+++ lib/Support/Unix/Process.inc        (revision 188615)
@@ -240,10 +240,12 @@
 }

 #ifdef HAVE_TERMINFO
-// We manually declare these two extern functions because finding the correct
+// We manually declare these extern functions because finding the correct
 // headers from various terminfo, curses, or other sources is harder than
 // writing their specs down.
 extern "C" int setupterm(char *term, int filedes, int *errret);
+extern "C" struct term *set_curterm(struct term *termp);
+extern "C" int del_curterm(struct term *termp);
 extern "C" int tigetnum(char *capname);
 #endif

@@ -272,7 +274,15 @@
   //
   // The 'tigetnum' routine returns -2 or -1 on errors, and might return 0 if
   // the terminfo says that no colors are supported.
-  if (tigetnum(const_cast<char *>("colors")) > 0)
+  bool HasColors = tigetnum(const_cast<char *>("colors")) > 0;
+
+  // Now extract the structure allocated by setupterm and free its memory
+  // through a really silly dance.
+  struct term *termp = set_curterm((struct term *)0);
+  (void)del_curterm(termp); // Drop any errors here.
+
+  // Return true if we found a color capabilities for the current terminal.
+  if (HasColors)
     return true;
 #endif

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019