CVS commit: src/usr.bin/tput
Module Name:src Committed By: roy Date: Tue Feb 5 11:31:56 UTC 2013 Modified Files: src/usr.bin/tput: tput.c Log Message: Use putp(3) to output our strings. Fixes PR lib/47532 To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.25 src/usr.bin/tput/tput.c:1.26 --- src/usr.bin/tput/tput.c:1.25 Fri Jan 25 12:27:13 2013 +++ src/usr.bin/tput/tput.c Tue Feb 5 11:31:56 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tput.c,v 1.25 2013/01/25 12:27:13 roy Exp $ */ +/* $NetBSD: tput.c,v 1.26 2013/02/05 11:31:56 roy Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -__RCSID("$NetBSD: tput.c,v 1.25 2013/01/25 12:27:13 roy Exp $"); +__RCSID("$NetBSD: tput.c,v 1.26 2013/02/05 11:31:56 roy Exp $"); #endif /* not lint */ #include @@ -54,7 +54,6 @@ __RCSID("$NetBSD: tput.c,v 1.25 2013/01/ #include #include -static intoutc(int); static void usage(void) __dead; static char **process(const char *, const char *, char **); @@ -93,7 +92,7 @@ main(int argc, char **argv) if (!strcmp(p, "init")) { s = tigetstr("is1"); if (s != NULL) - tputs(s, 0, outc); + putp(s); p = "is2"; } break; @@ -107,7 +106,7 @@ main(int argc, char **argv) if (!strcmp(p, "reset")) { s = tigetstr("rs1"); if (s != NULL) - tputs(s, 0, outc); + putp(s); p = "rs2"; } break; @@ -181,17 +180,11 @@ process(const char *cap, const char *str /* And output */ #define p(i) (i <= nparams ? \ (piss[i - 1] ? (long)strs[i - 1] : nums[i - 1]) : 0) - puts(tparm(str, p(1), p(2), p(3), p(4), p(5), p(6), p(7), p(8), p(9))); + putp(tparm(str, p(1), p(2), p(3), p(4), p(5), p(6), p(7), p(8), p(9))); return argv; } -static int -outc(int c) -{ - return putchar(c); -} - static void usage(void) {
CVS commit: src/usr.bin/tput
Module Name:src Committed By: roy Date: Fri Jan 25 12:27:13 UTC 2013 Modified Files: src/usr.bin/tput: tput.c Log Message: If char * > long then print a suitable error when passing a string parameter. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.24 src/usr.bin/tput/tput.c:1.25 --- src/usr.bin/tput/tput.c:1.24 Fri Jan 25 12:12:30 2013 +++ src/usr.bin/tput/tput.c Fri Jan 25 12:27:13 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tput.c,v 1.24 2013/01/25 12:12:30 roy Exp $ */ +/* $NetBSD: tput.c,v 1.25 2013/01/25 12:27:13 roy Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -__RCSID("$NetBSD: tput.c,v 1.24 2013/01/25 12:12:30 roy Exp $"); +__RCSID("$NetBSD: tput.c,v 1.25 2013/01/25 12:27:13 roy Exp $"); #endif /* not lint */ #include @@ -145,6 +145,8 @@ process(const char *cap, const char *str "Unknown %% escape (%s) for capability `%s'"; static const char errnum[] = "Expected a numeric argument [%d] (%s) for capability `%s'"; + static const char errcharlong[] = + "Platform does not fit a string into a long for capability '%s'"; int i, nparams, piss[TPARM_MAX]; long nums[TPARM_MAX]; char *strs[TPARM_MAX], *tmp; @@ -160,9 +162,11 @@ process(const char *cap, const char *str for (i = 0; i < nparams; i++) { if (*++argv == NULL || *argv[0] == '\0') errx(2, errfew, nparams, cap); - if (piss[i]) + if (piss[i]) { + if (sizeof(char *) > sizeof(long) /* CONSTCOND */) +errx(2, errcharlong, cap); strs[i] = *argv; - else { + } else { errno = 0; nums[i] = strtol(*argv, &tmp, 0); if ((errno == ERANGE &&
CVS commit: src/usr.bin/tput
Module Name:src Committed By: roy Date: Fri Jan 25 12:12:30 UTC 2013 Modified Files: src/usr.bin/tput: tput.c Log Message: Remove debug accidently commited. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.23 src/usr.bin/tput/tput.c:1.24 --- src/usr.bin/tput/tput.c:1.23 Thu Jan 24 10:41:29 2013 +++ src/usr.bin/tput/tput.c Fri Jan 25 12:12:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tput.c,v 1.23 2013/01/24 10:41:29 roy Exp $ */ +/* $NetBSD: tput.c,v 1.24 2013/01/25 12:12:30 roy Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -__RCSID("$NetBSD: tput.c,v 1.23 2013/01/24 10:41:29 roy Exp $"); +__RCSID("$NetBSD: tput.c,v 1.24 2013/01/25 12:12:30 roy Exp $"); #endif /* not lint */ #include @@ -172,10 +172,6 @@ process(const char *cap, const char *str *tmp != '\0') errx(2, errnum, i + 1, *argv, cap); } - if (piss[i]) - printf ("str %d %s\n", i, strs[i]); - else - printf ("num %d %ld\n", i, nums[i]); } /* And output */
CVS commit: src/usr.bin/tput
Module Name:src Committed By: roy Date: Tue Oct 4 12:23:14 UTC 2011 Modified Files: src/usr.bin/tput: tput.c Log Message: Ensure we only pass cap names of one or two characters to tgetstr and friends so we don't mistakenly try and convert a terminfo code to a termcap code. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.21 src/usr.bin/tput/tput.c:1.22 --- src/usr.bin/tput/tput.c:1.21 Tue Oct 4 11:02:32 2011 +++ src/usr.bin/tput/tput.c Tue Oct 4 12:23:14 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tput.c,v 1.21 2011/10/04 11:02:32 roy Exp $ */ +/* $NetBSD: tput.c,v 1.22 2011/10/04 12:23:14 roy Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -__RCSID("$NetBSD: tput.c,v 1.21 2011/10/04 11:02:32 roy Exp $"); +__RCSID("$NetBSD: tput.c,v 1.22 2011/10/04 12:23:14 roy Exp $"); #endif /* not lint */ #include @@ -62,6 +62,7 @@ main(int argc, char **argv) int ch, exitval, n; char *term; const char *p, *s; + size_t pl; term = NULL; while ((ch = getopt(argc, argv, "T:")) != -1) @@ -109,17 +110,21 @@ main(int argc, char **argv) } break; } + pl = strlen(p); if (((s = tigetstr(p)) != NULL && s != (char *)-1) || - ((s = tgetstr(p, NULL)) != NULL)) + (pl <= 2 && (s = tgetstr(p, NULL)) != NULL)) argv = process(p, s, argv); - else if n = tigetnum(p)) != -1 && n != -2 )|| - (n = tgetnum(p)) != -1)) + else if n = tigetnum(p)) != -1 && n != -2 ) || + (pl <= 2 && (n = tgetnum(p)) != -1))) (void)printf("%d\n", n); else { exitval = tigetflag(p); - if (exitval == -1) -exitval = !tgetflag(p); - else + if (exitval == -1) { +if (pl <= 2) + exitval = !tgetflag(p); +else + exitval = 1; + } else exitval = !exitval; }
CVS commit: src/usr.bin/tput
Module Name:src Committed By: roy Date: Tue Oct 4 11:02:32 UTC 2011 Modified Files: src/usr.bin/tput: tput.c Log Message: tput now uses longname(3) to derive the terminal description instead of trying to parse it from termpcap. Fixes PR/43386. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/tput/tput.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tput/tput.c diff -u src/usr.bin/tput/tput.c:1.20 src/usr.bin/tput/tput.c:1.21 --- src/usr.bin/tput/tput.c:1.20 Wed Feb 3 15:34:46 2010 +++ src/usr.bin/tput/tput.c Tue Oct 4 11:02:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tput.c,v 1.20 2010/02/03 15:34:46 roy Exp $ */ +/* $NetBSD: tput.c,v 1.21 2011/10/04 11:02:32 roy Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)tput.c 8.3 (Berkeley) 4/28/95"; #endif -__RCSID("$NetBSD: tput.c,v 1.20 2010/02/03 15:34:46 roy Exp $"); +__RCSID("$NetBSD: tput.c,v 1.21 2011/10/04 11:02:32 roy Exp $"); #endif /* not lint */ #include @@ -53,7 +53,6 @@ __RCSID("$NetBSD: tput.c,v 1.20 2010/02/ #include static intoutc(int); -static void prlongname(char *); static void usage(void) __dead; static char **process(const char *, const char *, char **); @@ -61,7 +60,7 @@ int main(int argc, char **argv) { int ch, exitval, n; - char *term, tbuf[1024]; + char *term; const char *p, *s; term = NULL; @@ -97,7 +96,7 @@ main(int argc, char **argv) break; case 'l': if (!strcmp(p, "longname")) { -prlongname(tbuf); +(void)printf("%s\n", longname()); continue; } break; @@ -130,21 +129,6 @@ main(int argc, char **argv) return argv ? exitval : 2; } -static void -prlongname(char *buf) -{ - int savech; - char *p, *savep; - - for (p = buf; *p && *p != ':'; ++p) - continue; - savech = *(savep = p); - for (*p = '\0'; p >= buf && *p != '|'; --p) - continue; - (void)printf("%s\n", p + 1); - *savep = savech; -} - static char ** process(const char *cap, const char *str, char **argv) {
CVS commit: src/usr.bin/tput
Module Name:src Committed By: joerg Date: Fri May 14 01:58:07 UTC 2010 Modified Files: src/usr.bin/tput: tput.1 Log Message: Fix trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/tput/tput.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tput/tput.1 diff -u src/usr.bin/tput/tput.1:1.14 src/usr.bin/tput/tput.1:1.15 --- src/usr.bin/tput/tput.1:1.14 Wed Feb 3 15:34:46 2010 +++ src/usr.bin/tput/tput.1 Fri May 14 01:58:07 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: tput.1,v 1.14 2010/02/03 15:34:46 roy Exp $ +.\" $NetBSD: tput.1,v 1.15 2010/05/14 01:58:07 joerg Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -96,7 +96,7 @@ .It reset Reset the terminal (the .Xr terminfo 5 -.Dq rs1 , rs2 , rs3 +.Dq rs1 , rs2 , rs3 and .Dq rf sequence).