public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cygclang.dll breaks terminal output when used in Python bindings
@ 2014-10-24 20:43 Jacob Niehus
  2014-10-26 20:22 ` Jacob Niehus
  0 siblings, 1 reply; 2+ messages in thread
From: Jacob Niehus @ 2014-10-24 20:43 UTC (permalink / raw)
  To: cygwin

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

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

* Re: cygclang.dll breaks terminal output when used in Python bindings
  2014-10-24 20:43 cygclang.dll breaks terminal output when used in Python bindings Jacob Niehus
@ 2014-10-26 20:22 ` Jacob Niehus
  0 siblings, 0 replies; 2+ messages in thread
From: Jacob Niehus @ 2014-10-26 20:22 UTC (permalink / raw)
  To: cygwin

> 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?

I must have been confused about which version I was compiling when I wrote
this. libncurses doesn't seem to make a difference. I was able to solve the
problem using --enable-terminfo=no for the configure script or
-DLLVM_ENABLE_TERMINFO=OFF with cmake which I tested on three different
computers. Now the question is: should that option be set when compiling
libclang for distribution with Cygwin?

--
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

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

end of thread, other threads:[~2014-10-26 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-24 20:43 cygclang.dll breaks terminal output when used in Python bindings Jacob Niehus
2014-10-26 20:22 ` Jacob Niehus

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).