NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/39883 (tput support for setaf terminfo sequence is broken)



The following reply was made to PR bin/39883; it has been noted by GNATS.

From: jnemeth%CornerstoneService.ca@localhost (John Nemeth)
To: David Holland <dholland-bugs%netbsd.org@localhost>, 
gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/39883 (tput support for setaf terminfo sequence is broken)
Date: Tue, 1 Jun 2010 20:51:21 -0700

 On May 29,  7:41pm, David Holland wrote:
 } On Mon, Mar 15, 2010 at 02:00:08AM +0000, John Nemeth wrote:
 }  >  } I suppose tput should exit 1 when asked for an unknown capability
 }  >  } though; would fixing that be sufficient?
 }  >  
 }  >       That would be sufficient.  I seem to recall more discussion
 }  >  on the issue, but I guess it was on a mailing list.  I think the
 }  >  idea was that if somebody asked for a capability more then two
 }  >  letters long that tput would exit with an error.  The problem was
 }  >  that tgetstr() simply truncated to two characters, so "setaf" became
 }  >  "se" (standout end).
 } 
 } Like this? It seems to do the trick.
 } 
 } Index: tput.c
 } ===================================================================
 } RCS file: /cvsroot/src/usr.bin/tput/tput.c,v
 } retrieving revision 1.19
 } diff -u -p -r1.19 tput.c
 } --- tput.c   21 Jul 2008 14:19:27 -0000      1.19
 } +++ tput.c   29 May 2010 19:39:38 -0000
 } @@ -105,7 +105,9 @@ main(int argc, char **argv)
 }                      break;
 }              }
 }              cptr = buf;
 } -            if (tgetstr(p, &cptr))
 } +            if (strlen(p) > 2)
 } +                    exitval = 1;
 
      This would simply mean that the user asked for a capabilty
 that the terminal doesn't have.  This may or may not be true.
 "exitval = 2;" would probably be better since that would indicate
 that the user did something wrong.  We may even want to consider
 something like:
 
 exit(2, "this program only supports termcap capabilities, not terminfo");
 
 } +            else if (tgetstr(p, &cptr))
 }                      argv = process(p, buf, argv);
 }              else if ((n = tgetnum(p)) != -1)
 }                      (void)printf("%d\n", n);
 } 
 }-- End of excerpt from David Holland
 


Home | Main Index | Thread Index | Old Index