[BusyBox] [patch] auto width

Vladimir N. Oleynik dzo at simtreas.ru
Wed Mar 24 10:15:00 UTC 2004


Brian,

> I've noticed a bug in the "autowidth" feature more, and is probably in
> others.  The call to the function get_terminal_width_height() passes
> in a file descriptor but that file descriptor is never used, instead
> the ioctl() is called with 0.  In more_main() the call to
> get_terminal_width_height() passes 0 as the file descriptor instead of
> fileno(cin).  This isn't a problem when you more a file (e.g. "more
> /etc/passwd") but when you pipe a file to it (e.g. "cat /etc/passwd |
> more") the size of the terminal cannot be determined because file
> descriptor 0 is not a terminal.  The fix is simple, I've attached a
> patch for more.c and get_terminal_width_height.c.

Ok. Last patch reduce 73 bytes for compensate (and over) your changes ;-)

Comments:
Added cin_fileno variable, auto setted to 0 from BSS and have "eq" stdin
descriptor if isatty(stout)==0, removed global variable FILE* cin.
Removed default setting to terminal_width/terminal_height, this used
only from main() and setted after call get_terminal_width_height()
always correct.
Variable please_display_more_prompt changed to bits logic, have size reducing.


--w
vodz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: last_patch130.gz
Type: application/x-tar
Size: 1345 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20040324/03ba8c4c/attachment.tar 


More information about the busybox mailing list