[cfe-commits] r70654 - in /cfe/trunk: lib/Frontend/TextDiagnosticPrinter.cpp tools/clang-cc/clang-cc.cpp
Douglas Gregor
dgregor at apple.com
Sat May 2 20:52:38 PDT 2009
Author: dgregor
Date: Sat May 2 22:52:38 2009
New Revision: 70654
URL: http://llvm.org/viewvc/llvm-project?rev=70654&view=rev
Log:
Respect the COLUMNS environment variable for word-wrapping (so we get
word-wrapping by default in Emacs; yay!). Thanks, Daniel.
Use LLVM's System layer rather than calling isatty() directly.
Fix a thinko in printing the indentation string that was causing some
weird output.
Modified:
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=70654&r1=70653&r2=70654&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sat May 2 22:52:38 2009
@@ -570,7 +570,8 @@
// This word does not fit on the current line, so wrap to the next
// line.
- OS << '\n' << IndentStr.begin();
+ OS << '\n';
+ OS.write(&IndentStr[0], Indentation);
OS.write(&Str[WordStart], WordLength);
Column = Indentation + WordLength;
Wrapped = true;
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=70654&r1=70653&r2=70654&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Sat May 2 22:52:38 2009
@@ -60,12 +60,12 @@
#include "llvm/Support/Timer.h"
#include "llvm/System/Host.h"
#include "llvm/System/Path.h"
+#include "llvm/System/Process.h"
#include "llvm/System/Signals.h"
#include <cstdlib>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-# include <sys/ioctl.h>
+#if HAVE_SYS_TYPES_H
# include <sys/types.h>
+# include <sys/ioctl.h>
#endif
using namespace clang;
@@ -1876,11 +1876,18 @@
/// \returns the width of the terminal (in characters), if there is a
/// terminal. If there is no terminal, returns 0.
static unsigned getTerminalWidth() {
-#if HAVE_UNISTD_H
+ // If COLUMNS is defined in the environment, wrap to that many columns.
+ if (const char *ColumnsStr = std::getenv("COLUMNS")) {
+ int Columns = atoi(ColumnsStr);
+ if (Columns > 0)
+ return Columns;
+ }
+
// Is this a terminal? If not, don't wrap by default.
- if (!isatty(/* Standard Error=*/2))
+ if (!llvm::sys::Process::StandardErrIsDisplayed())
return 0;
+#if HAVE_SYS_TYPES_H
// Try to determine the width of the terminal.
struct winsize ws;
unsigned Columns = 80; // A guess, in case the ioctl fails.
More information about the cfe-commits
mailing list