Dear tech@ readers,
On 11/21/15 13:20, Alessandro DE LAURENZIS wrote:
> Dear tech@,
>
> This is an attempt to solve a problem I previously reported [1] to
> misc@ (without receiving any feedback, so far).
[...]
> [1] http://marc.info/?l=openbsd-misc&m=144800414402238&w=2
>
my second attempt... I understand that the previous patch was wrong.
After digging into terminfo(5) man page, I think the problem could be
related to the if...then...else structures (%?...%t...%e...%t...%;)
Probably we should reset the parameter counter each time we change the
branch, proceeding "row by row" as per "infocmp -f" output.
The following patch could be a step forward in this direction, although
some corner cases might be uncovered:
--- /usr/src/usr.bin/tput/tput.c.orig Fri Jan 16 07:40:13 2015
+++ /usr/src/usr.bin/tput/tput.c Thu Dec 24 15:12:28 2015
@@ -190,10 +190,12 @@
process(char *cap, char *str, char **argv)
{
char *cp, *s, *nargv[9];
- int arg_need, popcount, i;
+ int arg_need, arg_need_p, popcount, popcount_p, i;
/* Count how many values we need for this capability. */
- for (cp = str, arg_need = popcount = 0; *cp != '\0'; cp++) {
+ for (cp = str,
+ arg_need = arg_need_p = popcount = popcount_p = 0;
+ *cp != '\0'; cp++) {
if (*cp == '%') {
switch (*++cp) {
case '%':
@@ -224,6 +226,17 @@
case '.':
case '+':
arg_need++;
+ break;
+ case '?':
+ case 'e':
+ arg_need_p = MAXIMUM(arg_need_p, arg_need);
+ arg_need=0;
+ popcount_p = MAXIMUM(popcount_p, popcount);
+ popcount=0;
+ break;
+ case ';':
+ arg_need = MAXIMUM(arg_need_p, arg_need);
+ popcount = MAXIMUM(popcount_p, popcount);
break;
default:
break;
I played a bit with it and I didn't observe any regression with TERM set to
"xterm", "xterm-color", "xterm-256color", "screen", "screen-256color" and
"wsvt25"; of course, both "tput setaf" and "tput setab" now work as expected.
Just let me know your view.
All the best
--
Alessandro DE LAURENZIS
[mailto:[email protected]]
LinkedIn: http://it.linkedin.com/in/delaurenzis