Dear tech@ readers,
On Thu 24/12/2015 15:58, Alessandro DE LAURENZIS wrote:
[...]
> 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.
I didn't receive any feedback so far, meaning either xterm 256-color
usage is barely used in our community or my approach in fixing tput is
completely wrong.
Nevertheless, I'm still trying to improve the patch; this time, I
realized that popcount is not actually involved into the parameter
counting process, so no need to reset it:
--- /usr/src/usr.bin/tput/tput.c.orig Fri Jan 16 07:40:13 2015
+++ /usr/src/usr.bin/tput/tput.c Fri Dec 25 14:39:32 2015
@@ -190,10 +190,10 @@
process(char *cap, char *str, char **argv)
{
char *cp, *s, *nargv[9];
- int arg_need, popcount, i;
+ int arg_need, arg_need_p, popcount, 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 = 0; *cp != '\0'; cp++)
{
if (*cp == '%') {
switch (*++cp) {
case '%':
@@ -224,6 +224,14 @@
case '.':
case '+':
arg_need++;
+ break;
+ case '?':
+ case 'e':
+ arg_need_p = MAXIMUM(arg_need_p, arg_need);
+ arg_need=0;
+ break;
+ case ';':
+ arg_need = MAXIMUM(arg_need_p, arg_need);
break;
default:
break;
--
Alessandro DE LAURENZIS
[mailto:[email protected]]
LinkedIn: http://it.linkedin.com/in/delaurenzis