On Tuesday 20 July 2010 05:08, Denys Vlasenko wrote:
> On Tuesday 20 July 2010 03:19, Rob Landley wrote:
> > > http://busybox.net/downloads/fixes-1.17.0/busybox-1.17.0-ask_terminal.patch
> > >
> > > This patch will make e.g. hush to query window width using ESC [ 6 n
> > > only if ioctl(TIOCGWINSZ) fails or returns bogus value of 0.
> > >
> > > You need to not only confirm that it builds, but also try it
> > > on the serial line and let me know whether it actually
> > > does the trick. It may fail to work if ctl(TIOCGWINSZ) on the serial
> > > line lies, that is, returns some invented nonzero width and height
> > > and doesnt indicate the error.
> >
> > Ok, let's see....
> >
> > Nope, vi still thinks it's 80x25. (Which is odd because
> > CONFIG_FEATURE_VI_ASK_TERMINAL is enabled.)
> >
> > Let's see... the ioctl is returning 0 (success) but leaving win.ws_row and
> > win.ws_col at 0 if they were initialized to 0. And your code is washing
> > that
> > through:
> >
> > static int wh_helper(int value, int def_val, const char *env_name, int *err)
> > {
> > if (value == 0) {
> > char *s = getenv(env_name);
> > if (s) {
> > value = atoi(s);
> > /* If LINES/COLUMNS are set, pretent that there is
> > * no error getting w/h, this prevents some ugly
> > * cursor tricks by our callers */
> > *err = 0;
> ** note that this *err = 0 thing happens _only_
> if LINES/COLUMNS are overridded in environment.
> > }
> > }
> > if (value <= 1 || value >= 30000)
> > value = def_val;
> > return value;
> > }
> >
> > Which is helpfully overwriting those 0 values with a default value.
>
> Hmmm, it should be a bug then, but I don't see where:
>
> int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned
> *height)
> {
> struct winsize win;
> int err;
>
> win.ws_row = 0;
> win.ws_col = 0;
> err = ioctl(fd, TIOCGWINSZ, &win) != 0 || win.ws_row == 0;
> ** we get err = 1 here, since win.ws_row == 0
> if (height)
> *height = wh_helper(win.ws_row, 24, "LINES", &err);
> if (width)
> *width = wh_helper(win.ws_col, 80, "COLUMNS", &err);
> ** and here wh_helper() should NOT reset err to 0, unless you have
> $COLUMNS defined in environment.
> return err;
> ** we return 1
> }
>
> ...
>
> static void win_changed(int nsig)
> {
> int sv_errno = errno;
> unsigned width;
> IF_FEATURE_EDITING_ASK_TERMINAL(S.unknown_width =)
> get_terminal_width_height(0, &width, NULL);
> ** and here S.unknown_width should be set to 1
> cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
> if (nsig == SIGWINCH)
> signal(SIGWINCH, win_changed); /* rearm ourself */
> errno = sv_errno;
> }
>
> Apparently it doesn't happen. Where is my mistake?
Ah, FEATURE_**VI**_ASK_TERMINAL. I thought you test it with shell...
FEATURE_VI_ASK_TERMINAL case is similar:
# if ENABLE_FEATURE_VI_ASK_TERMINAL
if (!G.get_rowcol_error)
G.get_rowcol_error =
# endif
get_terminal_width_height(STDIN_FILENO, &columns,
&rows);
I need to know whether here G.get_rowcol_error gets set to 1,
and if not, why... can you take a look?
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox