diff options
author | Craig Earls <enderw88@gmail.com> | 2014-11-07 18:21:13 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2014-11-07 18:21:13 -0700 |
commit | af15887ecb32cdacea8a0a487f8b94dd81f98383 (patch) | |
tree | cccfad949f3a2511bc0ef5071b818503290b9842 /src | |
parent | 1bd67755fa3127d80b7534d15f1f9de1b477c19a (diff) | |
parent | 62e1354e0bb9bef2efaed14e3543199880026491 (diff) | |
download | fork-ledger-af15887ecb32cdacea8a0a487f8b94dd81f98383.tar.gz fork-ledger-af15887ecb32cdacea8a0a487f8b94dd81f98383.tar.bz2 fork-ledger-af15887ecb32cdacea8a0a487f8b94dd81f98383.zip |
Merge branch 'master' of https://github.com/ledger/ledger
Diffstat (limited to 'src')
-rw-r--r-- | src/report.cc | 7 | ||||
-rw-r--r-- | src/select.cc | 7 | ||||
-rw-r--r-- | src/system.hh.in | 5 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc index 7bb79bd1..a05a57d9 100644 --- a/src/report.cc +++ b/src/report.cc @@ -181,10 +181,17 @@ void report_t::normalize_options(const string& verb) } long cols = 0; +#if HAVE_IOCTL + struct winsize ws; +#endif if (HANDLED(columns_)) cols = lexical_cast<long>(HANDLER(columns_).value); else if (const char * columns = std::getenv("COLUMNS")) cols = lexical_cast<long>(columns); +#if HAVE_IOCTL + else if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1) + cols = ws.ws_col; +#endif else cols = 80L; diff --git a/src/select.cc b/src/select.cc index 45ae34be..a9e943ab 100644 --- a/src/select.cc +++ b/src/select.cc @@ -145,10 +145,17 @@ value_t select_command(call_scope_t& args) string thus_far = ""; std::size_t cols = 0; +#if HAVE_IOCTL + struct winsize ws; +#endif if (report.HANDLED(columns_)) cols = lexical_cast<std::size_t>(report.HANDLER(columns_).value); else if (const char * columns_env = std::getenv("COLUMNS")) cols = lexical_cast<std::size_t>(columns_env); +#if HAVE_IOCTL + else if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1) + cols = ws.ws_col; +#endif else cols = 80; diff --git a/src/system.hh.in b/src/system.hh.in index eaee14dc..67a218da 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -63,6 +63,7 @@ #define HAVE_REALPATH @HAVE_REALPATH@ #define HAVE_GETPWUID @HAVE_GETPWUID@ #define HAVE_GETPWNAM @HAVE_GETPWNAM@ +#define HAVE_IOCTL @HAVE_IOCTL@ #define HAVE_ISATTY @HAVE_ISATTY@ #define HAVE_UNIX_PIPES @HAVE_UNIX_PIPES@ @@ -151,6 +152,10 @@ typedef std::ostream::pos_type ostream_pos_type; #include <pwd.h> #endif +#if HAVE_IOCTL +#include <sys/ioctl.h> +#endif + #if HAVE_UNIX_PIPES #include <sys/types.h> #include <sys/wait.h> |