diff options
author | Greg Clayton <gclayton@apple.com> | 2014-02-05 17:57:57 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2014-02-05 17:57:57 +0000 |
commit | 340b0309b59b8222d7f39e425848075422560c76 (patch) | |
tree | 8fcd9680e57fbba1e223c8bab28cb3bdb1556d62 /lldb/source/Host/common/File.cpp | |
parent | 9b8aa38e454f9035fed9ef683afbe05a141e3297 (diff) | |
download | bcm5719-llvm-340b0309b59b8222d7f39e425848075422560c76.tar.gz bcm5719-llvm-340b0309b59b8222d7f39e425848075422560c76.zip |
Fixed an issue where "command source" would not do the right thing:
- empty lines in init files would repeat previous command and cause errors to be displayed
- all options to control showing the command, its output, if it should stop on error or continue, weren't being obeyed.
llvm-svn: 200860
Diffstat (limited to 'lldb/source/Host/common/File.cpp')
-rw-r--r-- | lldb/source/Host/common/File.cpp | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index ab61b393c54..dcb272ab5df 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -13,7 +13,9 @@ #include <fcntl.h> #include <limits.h> #include <stdarg.h> +#include <stdio.h> #include <sys/stat.h> +#include <sys/ioctl.h> #ifdef _WIN32 #include "lldb/Host/windows/windows.h" @@ -78,7 +80,9 @@ File::File(const char *path, uint32_t options, uint32_t permissions) : m_stream (kInvalidStream), m_options (), m_own_stream (false), - m_own_descriptor (false) + m_own_descriptor (false), + m_is_interactive (eLazyBoolCalculate), + m_is_real_terminal (eLazyBoolCalculate) { Open (path, options, permissions); } @@ -90,7 +94,10 @@ File::File (const FileSpec& filespec, m_stream (kInvalidStream), m_options (0), m_own_stream (false), - m_own_descriptor (false) + m_own_descriptor (false), + m_is_interactive (eLazyBoolCalculate), + m_is_real_terminal (eLazyBoolCalculate) + { if (filespec) { @@ -103,7 +110,9 @@ File::File (const File &rhs) : m_stream (kInvalidStream), m_options (0), m_own_stream (false), - m_own_descriptor (false) + m_own_descriptor (false), + m_is_interactive (eLazyBoolCalculate), + m_is_real_terminal (eLazyBoolCalculate) { Duplicate (rhs); } @@ -371,6 +380,8 @@ File::Close () m_options = 0; m_own_stream = false; m_own_descriptor = false; + m_is_interactive = eLazyBoolCalculate; + m_is_real_terminal = eLazyBoolCalculate; return error; } @@ -866,3 +877,41 @@ File::ConvertOpenOptionsForPOSIXOpen (uint32_t open_options) return mode; } + +void +File::CalculateInteractiveAndTerminal () +{ + const int fd = GetDescriptor(); + if (fd >= 0) + { + m_is_interactive = eLazyBoolNo; + m_is_real_terminal = eLazyBoolNo; + if (isatty(fd)) + { + m_is_interactive = eLazyBoolYes; + struct winsize window_size; + if (::ioctl (fd, TIOCGWINSZ, &window_size) == 0) + { + if (window_size.ws_col > 0) + m_is_real_terminal = eLazyBoolYes; + } + } + } +} + +bool +File::GetIsInteractive () +{ + if (m_is_interactive == eLazyBoolCalculate) + CalculateInteractiveAndTerminal (); + return m_is_interactive == eLazyBoolYes; +} + +bool +File::GetIsRealTerminal () +{ + if (m_is_real_terminal == eLazyBoolCalculate) + CalculateInteractiveAndTerminal(); + return m_is_real_terminal == eLazyBoolYes; +} + |