aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-09-20 11:47:04 +0000
committerRoy Marples <roy@marples.name>2007-09-20 11:47:04 +0000
commitccced38428aac90cfda37b5570011dae10389d7c (patch)
treec8aac71128611c02e0575a489ce7545cd9ba2765
parentc1cd1da59567d4f489d000cfdbc4faba31baf83b (diff)
libeinfo now works out the number of columns from stdout rather than stdin, #188506.
-rw-r--r--ChangeLog5
-rw-r--r--src/libeinfo.c8
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e1b5f529..1b4307ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
+ 20 Sep 2007; Roy Marples <uberlord@gentoo.org>:
+
+ libeinfo now works out the number of columns from stdout rather than
+ stdin, #188506.
+
19 Sep 2007; Roy Marples <uberlord@gentoo.org>:
Added the checkown applet based on the work by Renato Caldas, #192682
diff --git a/src/libeinfo.c b/src/libeinfo.c
index 489b3469..77517c83 100644
--- a/src/libeinfo.c
+++ b/src/libeinfo.c
@@ -173,17 +173,17 @@ static bool colour_terminal (void)
return (false);
}
-static int get_term_columns (void)
+static int get_term_columns (FILE *stream)
{
#if defined(TIOCGSIZE) /* BSD */
struct ttysize ts;
- if (ioctl(0, TIOCGSIZE, &ts) == 0)
+ if (ioctl(fileno (stream), TIOCGSIZE, &ts) == 0)
return (ts.ts_cols);
#elif defined(TIOCGWINSZ) /* Linux */
struct winsize ws;
- if (ioctl(0, TIOCGWINSZ, &ws) == 0)
+ if (ioctl(fileno (stream), TIOCGWINSZ, &ws) == 0)
return (ws.ws_col);
#endif
@@ -473,7 +473,7 @@ static void _eend (FILE *fp, int col, einfo_color_t color, const char *msg)
if (! msg)
return;
- cols = get_term_columns () - (strlen (msg) + 5);
+ cols = get_term_columns (fp) - (strlen (msg) + 5);
/* cons25 is special - we need to remove one char, otherwise things
* do not align properly at all. */