Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in echotc ?



On Mar 2, 11:10am, Clint Adams wrote:
} Subject: Re: Bug in echotc ?
}
} > echotc is broken.  I think it's still broken after this patch.
} 
} This is probably a bit more appropriate.
} 
}      else {
} +	/* This assumes arguments of <lines> <columns> for cap 'cm' */
}  	num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
} -	tputs(tgoto(t, num, atoi(*argv)), num, putraw);
} +	tputs(tgoto(t, num, atoi(*argv)), 1, putraw);
}      }

Hmm.
       The  tputs  routine  applies  padding  information  to the
       string str and outputs it.  The str  must  be  a  terminfo
       string  variable  or the return value from tparm, tgetstr,
       or tgoto.  affcnt is the number of lines affected, or 1 if
       not  applicable.   putc is a putchar-like routine to which
       the characters are passed, one at a time.

So it seems like what we really want is more like

	num = atoi(*argv);
	t = tgoto(t, (argv[1] ? atoi(argv[1]) : num), num);
	tputs(t, num, putraw);

Because atoi(*argv) is "the number of lines affected".  Except it isn't,
quite, because really the number of lines affected is the difference
between the current line and the target line.  So maybe 1 is the right
value to use for the second argument of tputs() after all.  Except if
this isn't a "cm" but rather a relative line-motion such as "DO" or "UP"
then ... maybe what we want is

	num = atoi(*argv);
	if (argct == 1)
	    tputs(tgoto(t, num, num), num, putraw);
        else
            tputs(tgoto(t, atoi(argv[1]), num), 1, putraw);

Except it's not clear *that* does the right thing with "LE" or "RI".
Gag.



Messages sorted by: Reverse Date, Date, Thread, Author