[kwlug-disc] MKS - really the "lc" command
Steve Izma
sizma at golden.net
Tue Aug 2 20:48:23 EDT 2022
On Tue, Aug 02, 2022 at 08:13:00AM -0400, Doug Moen wrote:
> Subject: Re: [kwlug-disc] MKS - really the "lc" command
>
> I have the same problem, the lc output is not sensitive to
> terminal width.
>
> Here's the code that doesn't work:
> #ifdef TIOCGWINSZ
> if (isatty(1)) {
> struct winsize win;
> if (ioctl(1, TIOCGWINSZ, &win) != -1) {
> ncols = (win.ws_col == 0 ? 5 : (win.ws_col / COLUMNWIDTH));
> ncols = ncols ? ncols : 1; /* can't have 0 columns */
> }
> }
> #endif /* TIOGCWINSZ */
>
> Why doesn't it work?
> Because the #ifdef is failing. The program is not including the
> necessary header file.
> ...
> #include <sys/ioctl.h>
> #include <termios.h> /* TIOCGWINSZ on cygwin */
Thanks, Doug. Adding the extra includes worked. Much better.
-- Steve
--
Steve Izma
-
Home: 35 Locust St., Kitchener, Ontario, Canada N2H 1W6
E-mail: sizma at golden.net phone: 519-745-1313
cell (text only; not frequently checked): 519-998-2684
==
The most erroneous stories are those we think we know best – and
therefore never scrutinize or question.
-- Stephen Jay Gould, *Full House: The Spread of Excellence
from Plato to Darwin*, 1996
More information about the kwlug-disc
mailing list