Fri Jan 25 12:30:06 2013 UTC ()
For platforms where we cannot fit a char * into a long, return NULL
and set errno to ENOTSUPP.


(roy)
diff -r1.8 -r1.9 src/lib/libterminfo/terminfo.3
diff -r1.12 -r1.13 src/lib/libterminfo/tparm.c

cvs diff -r1.8 -r1.9 src/lib/libterminfo/terminfo.3 (expand / switch to unified diff)

--- src/lib/libterminfo/terminfo.3 2011/10/04 11:01:14 1.8
+++ src/lib/libterminfo/terminfo.3 2013/01/25 12:30:05 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: terminfo.3,v 1.8 2011/10/04 11:01:14 roy Exp $ 1.\" $NetBSD: terminfo.3,v 1.9 2013/01/25 12:30:05 roy Exp $
2.\" 2.\"
3.\" Copyright (c) 2009, 2011 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation 6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Roy Marples. 7.\" by Roy Marples.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17.\" 17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE. 28.\" POSSIBILITY OF SUCH DAMAGE.
29.\" 29.\"
30.Dd October 4, 2011 30.Dd January 25, 2013
31.Dt TERMINFO 3 31.Dt TERMINFO 3
32.Os 32.Os
33.Sh NAME 33.Sh NAME
34.Nm setupterm , 34.Nm setupterm ,
35.Nm set_curterm , 35.Nm set_curterm ,
36.Nm del_curterm , 36.Nm del_curterm ,
37.Nm termname , 37.Nm termname ,
38.Nm longname , 38.Nm longname ,
39.Nm tigetflag , 39.Nm tigetflag ,
40.Nm tigetnum , 40.Nm tigetnum ,
41.Nm tigetstr , 41.Nm tigetstr ,
42.Nm tparm , 42.Nm tparm ,
43.Nm tputs , 43.Nm tputs ,
@@ -177,26 +177,32 @@ The @@ -177,26 +177,32 @@ The
177function returns a string decoded from 177function returns a string decoded from
178.Va cm 178.Va cm
179with the parameters 179with the parameters
180.Va p1 180.Va p1
181\&... 181\&...
182.Va p9 182.Va p9
183applied. 183applied.
184Some capabilities require string parameters and only platforms that can fit 184Some capabilities require string parameters and only platforms that can fit
185a 185a
186.Vt char * 186.Vt char *
187pointer inside a 187pointer inside a
188.Vt long 188.Vt long
189can use them. 189can use them.
 190For platforms which don't support this,
 191.Dv NULL
 192is returned and
 193.Va errno
 194is set to
 195.Er ENOTSUPP .
190The string encoding and parameter application is described in 196The string encoding and parameter application is described in
191.Xr terminfo 5 . 197.Xr terminfo 5 .
192.Pp 198.Pp
193The 199The
194.Fn tputs 200.Fn tputs
195function applies padding information to the string 201function applies padding information to the string
196.Va cp ; 202.Va cp ;
197.Va affcnt 203.Va affcnt
198gives the number of lines affected by the operation, 204gives the number of lines affected by the operation,
199or 1 if this is not applicable; 205or 1 if this is not applicable;
200.Va outc 206.Va outc
201is a function which is called by each character in turn. 207is a function which is called by each character in turn.
202The external variable 208The external variable

cvs diff -r1.12 -r1.13 src/lib/libterminfo/tparm.c (expand / switch to unified diff)

--- src/lib/libterminfo/tparm.c 2013/01/24 10:41:28 1.12
+++ src/lib/libterminfo/tparm.c 2013/01/25 12:30:05 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tparm.c,v 1.12 2013/01/24 10:41:28 roy Exp $ */ 1/* $NetBSD: tparm.c,v 1.13 2013/01/25 12:30:05 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009, 2011, 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2009, 2011, 2013 The NetBSD Foundation, Inc.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Roy Marples. 7 * by Roy Marples.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -18,27 +18,27 @@ @@ -18,27 +18,27 @@
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31__RCSID("$NetBSD: tparm.c,v 1.12 2013/01/24 10:41:28 roy Exp $"); 31__RCSID("$NetBSD: tparm.c,v 1.13 2013/01/25 12:30:05 roy Exp $");
32#include <sys/param.h> 32#include <sys/param.h>
33 33
34#include <assert.h> 34#include <assert.h>
35#include <ctype.h> 35#include <ctype.h>
36#include <errno.h> 36#include <errno.h>
37#include <stdarg.h> 37#include <stdarg.h>
38#include <stdio.h> 38#include <stdio.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <string.h> 40#include <string.h>
41#include <term_private.h> 41#include <term_private.h>
42#include <term.h> 42#include <term.h>
43 43
44#define LONG_STR_MAX ((CHAR_BIT * sizeof(long)) / 3) 44#define LONG_STR_MAX ((CHAR_BIT * sizeof(long)) / 3)
@@ -213,32 +213,45 @@ _ti_tiparm(TERMINAL *term, const char *s @@ -213,32 +213,45 @@ _ti_tiparm(TERMINAL *term, const char *s
213 if (term->_buflen == 0) { 213 if (term->_buflen == 0) {
214 term->_buf = malloc(BUFINC); 214 term->_buf = malloc(BUFINC);
215 if (term->_buf == NULL) 215 if (term->_buf == NULL)
216 return NULL; 216 return NULL;
217 term->_buflen = BUFINC; 217 term->_buflen = BUFINC;
218 } 218 }
219 219
220 memset(&piss, 0, sizeof(piss)); 220 memset(&piss, 0, sizeof(piss));
221 max = _ti_parm_analyse(str, piss, TPARM_MAX); 221 max = _ti_parm_analyse(str, piss, TPARM_MAX);
222 222
223 /* Put our parameters into variables */ 223 /* Put our parameters into variables */
224 memset(&params, 0, sizeof(params)); 224 memset(&params, 0, sizeof(params));
225 for (l = 0; l < max; l++) { 225 for (l = 0; l < max; l++) {
226 if (piss[l]) 226 if (piss[l]) {
227 params[l].string = va_arg(parms, char *); 227 if (va_long) {
228 else if (va_long) 228 /* This only works if char * fits into a long
229 params[l].num = va_arg(parms, long); 229 * on this platform. */
230 else 230 if (sizeof(char *) <= sizeof(long)/*CONSTCOND*/)
231 params[l].num = (long)va_arg(parms, int); 231 params[l].string =
 232 (char *)va_arg(parms, long);
 233 else {
 234 errno = ENOTSUP;
 235 return NULL;
 236 }
 237 } else
 238 params[l].string = va_arg(parms, char *);
 239 } else {
 240 if (va_long)
 241 params[l].num = va_arg(parms, long);
 242 else
 243 params[l].num = (long)va_arg(parms, int);
 244 }
232 } 245 }
233 246
234 memset(&stack, 0, sizeof(stack)); 247 memset(&stack, 0, sizeof(stack));
235 while ((c = *str++) != '\0') { 248 while ((c = *str++) != '\0') {
236 if (c != '%' || (c = *str++) == '%') { 249 if (c != '%' || (c = *str++) == '%') {
237 if (c == '\0') 250 if (c == '\0')
238 break; 251 break;
239 if (ochar(term, c) == 0) 252 if (ochar(term, c) == 0)
240 return NULL; 253 return NULL;
241 continue; 254 continue;
242 } 255 }
243 256
244 /* Handle formatting. */ 257 /* Handle formatting. */