diff options
author | Dave Reisner <dreisner@archlinux.org> | 2014-06-21 08:44:01 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-06-29 11:04:17 +1000 |
commit | 357b9a24a96478b7bcaaea8633f8f6a519f8903c (patch) | |
tree | 28cdc687d3a12ab389d36758e828d17c1c13dde5 /src/pacman/callback.c | |
parent | 07647d3d43d418f9efcf7c83a2079b9b673a7bfa (diff) | |
download | pacman-357b9a24a96478b7bcaaea8633f8f6a519f8903c.tar.xz |
cache terminal size, add SIGWINCH handler to reset
Refactoring getcols, yet again. We do the following:
1) Introduce a static global in src/pacman/util.c
2) getcols always prefers this cached value, but will derive it from
the COLUMNS environment var, the characteristics of stdout, or a sane
default (in that order).
3) Introduce a SIGWINCH signal handler to reset the cached value,
meaning we only call ioctl when we don't know the value.
On my machine, pacman -Syy goes from ~4300 ioctl calls to 3.
Diffstat (limited to 'src/pacman/callback.c')
-rw-r--r-- | src/pacman/callback.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 9cde1de7..6be20eca 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -424,7 +424,7 @@ void cb_question(alpm_question_t *question) "The following package cannot be upgraded due to unresolvable dependencies:\n", "The following packages cannot be upgraded due to unresolvable dependencies:\n", count)); - list_display(" ", namelist, getcols(fileno(stdout))); + list_display(" ", namelist, getcols()); printf("\n"); q->skip = noyes(_n( "Do you want to skip the above package for this upgrade?", @@ -494,7 +494,7 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent, int len, wclen, wcwid, padwid; wchar_t *wcstr; - const unsigned short cols = getcols(fileno(stdout)); + const unsigned short cols = getcols(); if(config->noprogressbar || cols == 0) { return; @@ -664,7 +664,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) const char *rate_label, *xfered_label; int file_percent = 0, total_percent = 0; - const unsigned short cols = getcols(fileno(stdout)); + const unsigned short cols = getcols(); if(config->noprogressbar || cols == 0 || file_total == -1) { if(file_xfered == 0) { |