Gabriela Gibson wrote on Sat, Apr 06, 2013 at 13:01:52 +0100:
> On 4/2/13, Daniel Shahaf <danielsh_at_elego.de> wrote:
>> I'm not sure how to interpret a return value of (0,0) that's not
>> accompanied by an error flag (C errno!=0, or a Python exception). Is
>> that normal behaviour, a bug we should be working around in our code, or
>> an indication of a bug in our logic in the preceding lines?
> I took a look around a few distros, and in no case does this function
> return an error, to cater for dumb terminals if I understand this
> More info: http://en.wikipedia.org/wiki/POSIX_terminal_interface
So, in summary: the OS just forwards whatever its notion of window size
is, without sanity checking.
>> i.e., if (0,0) means "_get_term_width() was going 35mph in a school zone
>> at the time of the call to fcntl.ioctl()", we should fix that.
> _get_term_width()'s 'sin' is not checking for a sane minimum size, which
> is I think is a reasonable omission, because setting up a TERM with a
> claimed size of (0,0) isn't easily anticipated and we're only crashing
> svn and not aeroplanes :>
Actually just the test harness crashes. But isn't what you just said
a better fix? Rather than hard-code (0,0), sanity-check the width and
do something (fall back to 80, bail, ...) if it's less than $THRESHOLD?
Where $THRESHOLD is at least 1, but could reasonably be 7 (for "success"
or "failure") or more.
>> I'm not objected to it, but it's not clear to me what it gains either (shaves 100 syscalls
>> from a 'make check' run?).
> I agree, it's a a bit very picky to fix this, now that I think about it
> -- coding on muds gets you this reflexive habit lest you summon the lag
You should feel right at home with stefan2's work, then :-)
Received on 2013-04-06 19:15:50 CEST