This is the mail archive of the
cygwin
mailing list for the Cygwin project.
cygclang.dll breaks terminal output when used in Python bindings
- From: Jacob Niehus <jacob dot niehus at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 24 Oct 2014 13:43:18 -0700
- Subject: cygclang.dll breaks terminal output when used in Python bindings
- Authentication-results: sourceware.org; auth=none
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