]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tinfo/lib_tparm.c
ncurses 5.9 - patch 20121215
[ncurses.git] / ncurses / tinfo / lib_tparm.c
1 /****************************************************************************
2  * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32  *     and: Thomas E. Dickey, 1996 on                                       *
33  ****************************************************************************/
34
35 /*
36  *      tparm.c
37  *
38  */
39
40 #include <curses.priv.h>
41
42 #include <ctype.h>
43 #include <tic.h>
44
45 MODULE_ID("$Id: lib_tparm.c,v 1.87 2012/10/27 21:28:21 tom Exp $")
46
47 /*
48  *      char *
49  *      tparm(string, ...)
50  *
51  *      Substitute the given parameters into the given string by the following
52  *      rules (taken from terminfo(5)):
53  *
54  *           Cursor addressing and other strings  requiring  parame-
55  *      ters in the terminal are described by a parameterized string
56  *      capability, with like escapes %x in  it.   For  example,  to
57  *      address  the  cursor, the cup capability is given, using two
58  *      parameters: the row and column to  address  to.   (Rows  and
59  *      columns  are  numbered  from  zero and refer to the physical
60  *      screen visible to the user, not to any  unseen  memory.)  If
61  *      the terminal has memory relative cursor addressing, that can
62  *      be indicated by
63  *
64  *           The parameter mechanism uses  a  stack  and  special  %
65  *      codes  to manipulate it.  Typically a sequence will push one
66  *      of the parameters onto the stack and then print it  in  some
67  *      format.  Often more complex operations are necessary.
68  *
69  *           The % encodings have the following meanings:
70  *
71  *           %%        outputs `%'
72  *           %c        print pop() like %c in printf()
73  *           %s        print pop() like %s in printf()
74  *           %[[:]flags][width[.precision]][doxXs]
75  *                     as in printf, flags are [-+#] and space
76  *                     The ':' is used to avoid making %+ or %-
77  *                     patterns (see below).
78  *
79  *           %p[1-9]   push ith parm
80  *           %P[a-z]   set dynamic variable [a-z] to pop()
81  *           %g[a-z]   get dynamic variable [a-z] and push it
82  *           %P[A-Z]   set static variable [A-Z] to pop()
83  *           %g[A-Z]   get static variable [A-Z] and push it
84  *           %l        push strlen(pop)
85  *           %'c'      push char constant c
86  *           %{nn}     push integer constant nn
87  *
88  *           %+ %- %* %/ %m
89  *                     arithmetic (%m is mod): push(pop() op pop())
90  *           %& %| %^  bit operations: push(pop() op pop())
91  *           %= %> %<  logical operations: push(pop() op pop())
92  *           %A %O     logical and & or operations for conditionals
93  *           %! %~     unary operations push(op pop())
94  *           %i        add 1 to first two parms (for ANSI terminals)
95  *
96  *           %? expr %t thenpart %e elsepart %;
97  *                     if-then-else, %e elsepart is optional.
98  *                     else-if's are possible ala Algol 68:
99  *                     %? c1 %t b1 %e c2 %t b2 %e c3 %t b3 %e c4 %t b4 %e b5 %;
100  *
101  *      For those of the above operators which are binary and not commutative,
102  *      the stack works in the usual way, with
103  *                      %gx %gy %m
104  *      resulting in x mod y, not the reverse.
105  */
106
107 NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0;
108
109 #define TPS(var) _nc_prescreen.tparm_state.var
110
111 #if NO_LEAKS
112 NCURSES_EXPORT(void)
113 _nc_free_tparm(void)
114 {
115     if (TPS(out_buff) != 0) {
116         FreeAndNull(TPS(out_buff));
117         TPS(out_size) = 0;
118         TPS(out_used) = 0;
119         FreeAndNull(TPS(fmt_buff));
120         TPS(fmt_size) = 0;
121     }
122 }
123 #endif
124
125 static NCURSES_INLINE void
126 get_space(size_t need)
127 {
128     need += TPS(out_used);
129     if (need > TPS(out_size)) {
130         TPS(out_size) = need * 2;
131         TYPE_REALLOC(char, TPS(out_size), TPS(out_buff));
132     }
133 }
134
135 static NCURSES_INLINE void
136 save_text(const char *fmt, const char *s, int len)
137 {
138     size_t s_len = strlen(s);
139     if (len > (int) s_len)
140         s_len = (size_t) len;
141
142     get_space(s_len + 1);
143
144     _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
145                 _nc_SLIMIT(TPS(out_size) - TPS(out_used))
146                 fmt, s);
147     TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
148 }
149
150 static NCURSES_INLINE void
151 save_number(const char *fmt, int number, int len)
152 {
153     if (len < 30)
154         len = 30;               /* actually log10(MAX_INT)+1 */
155
156     get_space((size_t) len + 1);
157
158     _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
159                 _nc_SLIMIT(TPS(out_size) - TPS(out_used))
160                 fmt, number);
161     TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
162 }
163
164 static NCURSES_INLINE void
165 save_char(int c)
166 {
167     if (c == 0)
168         c = 0200;
169     get_space((size_t) 1);
170     TPS(out_buff)[TPS(out_used)++] = (char) c;
171 }
172
173 static NCURSES_INLINE void
174 npush(int x)
175 {
176     if (TPS(stack_ptr) < STACKSIZE) {
177         TPS(stack)[TPS(stack_ptr)].num_type = TRUE;
178         TPS(stack)[TPS(stack_ptr)].data.num = x;
179         TPS(stack_ptr)++;
180     } else {
181         DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
182         _nc_tparm_err++;
183     }
184 }
185
186 static NCURSES_INLINE int
187 npop(void)
188 {
189     int result = 0;
190     if (TPS(stack_ptr) > 0) {
191         TPS(stack_ptr)--;
192         if (TPS(stack)[TPS(stack_ptr)].num_type)
193             result = TPS(stack)[TPS(stack_ptr)].data.num;
194     } else {
195         DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
196         _nc_tparm_err++;
197     }
198     return result;
199 }
200
201 static NCURSES_INLINE void
202 spush(char *x)
203 {
204     if (TPS(stack_ptr) < STACKSIZE) {
205         TPS(stack)[TPS(stack_ptr)].num_type = FALSE;
206         TPS(stack)[TPS(stack_ptr)].data.str = x;
207         TPS(stack_ptr)++;
208     } else {
209         DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(TPS(tparam_base))));
210         _nc_tparm_err++;
211     }
212 }
213
214 static NCURSES_INLINE char *
215 spop(void)
216 {
217     static char dummy[] = "";   /* avoid const-cast */
218     char *result = dummy;
219     if (TPS(stack_ptr) > 0) {
220         TPS(stack_ptr)--;
221         if (!TPS(stack)[TPS(stack_ptr)].num_type
222             && TPS(stack)[TPS(stack_ptr)].data.str != 0)
223             result = TPS(stack)[TPS(stack_ptr)].data.str;
224     } else {
225         DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(TPS(tparam_base))));
226         _nc_tparm_err++;
227     }
228     return result;
229 }
230
231 static NCURSES_INLINE const char *
232 parse_format(const char *s, char *format, int *len)
233 {
234     *len = 0;
235     if (format != 0) {
236         bool done = FALSE;
237         bool allowminus = FALSE;
238         bool dot = FALSE;
239         bool err = FALSE;
240         char *fmt = format;
241         int my_width = 0;
242         int my_prec = 0;
243         int value = 0;
244
245         *len = 0;
246         *format++ = '%';
247         while (*s != '\0' && !done) {
248             switch (*s) {
249             case 'c':           /* FALLTHRU */
250             case 'd':           /* FALLTHRU */
251             case 'o':           /* FALLTHRU */
252             case 'x':           /* FALLTHRU */
253             case 'X':           /* FALLTHRU */
254             case 's':
255                 *format++ = *s;
256                 done = TRUE;
257                 break;
258             case '.':
259                 *format++ = *s++;
260                 if (dot) {
261                     err = TRUE;
262                 } else {        /* value before '.' is the width */
263                     dot = TRUE;
264                     my_width = value;
265                 }
266                 value = 0;
267                 break;
268             case '#':
269                 *format++ = *s++;
270                 break;
271             case ' ':
272                 *format++ = *s++;
273                 break;
274             case ':':
275                 s++;
276                 allowminus = TRUE;
277                 break;
278             case '-':
279                 if (allowminus) {
280                     *format++ = *s++;
281                 } else {
282                     done = TRUE;
283                 }
284                 break;
285             default:
286                 if (isdigit(UChar(*s))) {
287                     value = (value * 10) + (*s - '0');
288                     if (value > 10000)
289                         err = TRUE;
290                     *format++ = *s++;
291                 } else {
292                     done = TRUE;
293                 }
294             }
295         }
296
297         /*
298          * If we found an error, ignore (and remove) the flags.
299          */
300         if (err) {
301             my_width = my_prec = value = 0;
302             format = fmt;
303             *format++ = '%';
304             *format++ = *s;
305         }
306
307         /*
308          * Any value after '.' is the precision.  If we did not see '.', then
309          * the value is the width.
310          */
311         if (dot)
312             my_prec = value;
313         else
314             my_width = value;
315
316         *format = '\0';
317         /* return maximum string length in print */
318         *len = (my_width > my_prec) ? my_width : my_prec;
319     }
320     return s;
321 }
322
323 #define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
324 #define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
325
326 /*
327  * Analyze the string to see how many parameters we need from the varargs list,
328  * and what their types are.  We will only accept string parameters if they
329  * appear as a %l or %s format following an explicit parameter reference (e.g.,
330  * %p2%s).  All other parameters are numbers.
331  *
332  * 'number' counts coarsely the number of pop's we see in the string, and
333  * 'popcount' shows the highest parameter number in the string.  We would like
334  * to simply use the latter count, but if we are reading termcap strings, there
335  * may be cases that we cannot see the explicit parameter numbers.
336  */
337 NCURSES_EXPORT(int)
338 _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount)
339 {
340     size_t len2;
341     int i;
342     int lastpop = -1;
343     int len;
344     int number = 0;
345     const char *cp = string;
346     static char dummy[] = "";
347
348     if (cp == 0)
349         return 0;
350
351     if ((len2 = strlen(cp)) > TPS(fmt_size)) {
352         TPS(fmt_size) = len2 + TPS(fmt_size) + 2;
353         TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
354         if (TPS(fmt_buff) == 0)
355             return 0;
356     }
357
358     memset(p_is_s, 0, sizeof(p_is_s[0]) * NUM_PARM);
359     *popcount = 0;
360
361     while ((cp - string) < (int) len2) {
362         if (*cp == '%') {
363             cp++;
364             cp = parse_format(cp, TPS(fmt_buff), &len);
365             switch (*cp) {
366             default:
367                 break;
368
369             case 'd':           /* FALLTHRU */
370             case 'o':           /* FALLTHRU */
371             case 'x':           /* FALLTHRU */
372             case 'X':           /* FALLTHRU */
373             case 'c':           /* FALLTHRU */
374                 if (lastpop <= 0)
375                     number++;
376                 lastpop = -1;
377                 break;
378
379             case 'l':
380             case 's':
381                 if (lastpop > 0)
382                     p_is_s[lastpop - 1] = dummy;
383                 ++number;
384                 break;
385
386             case 'p':
387                 cp++;
388                 i = (UChar(*cp) - '0');
389                 if (i >= 0 && i <= NUM_PARM) {
390                     lastpop = i;
391                     if (lastpop > *popcount)
392                         *popcount = lastpop;
393                 }
394                 break;
395
396             case 'P':
397                 ++number;
398                 ++cp;
399                 break;
400
401             case 'g':
402                 cp++;
403                 break;
404
405             case S_QUOTE:
406                 cp += 2;
407                 lastpop = -1;
408                 break;
409
410             case L_BRACE:
411                 cp++;
412                 while (isdigit(UChar(*cp))) {
413                     cp++;
414                 }
415                 break;
416
417             case '+':
418             case '-':
419             case '*':
420             case '/':
421             case 'm':
422             case 'A':
423             case 'O':
424             case '&':
425             case '|':
426             case '^':
427             case '=':
428             case '<':
429             case '>':
430                 lastpop = -1;
431                 number += 2;
432                 break;
433
434             case '!':
435             case '~':
436                 lastpop = -1;
437                 ++number;
438                 break;
439
440             case 'i':
441                 /* will add 1 to first (usually two) parameters */
442                 break;
443             }
444         }
445         if (*cp != '\0')
446             cp++;
447     }
448
449     if (number > NUM_PARM)
450         number = NUM_PARM;
451     return number;
452 }
453
454 static NCURSES_INLINE char *
455 tparam_internal(int use_TPARM_ARG, const char *string, va_list ap)
456 {
457     char *p_is_s[NUM_PARM];
458     TPARM_ARG param[NUM_PARM];
459     int popcount = 0;
460     int number;
461     int num_args;
462     int len;
463     int level;
464     int x, y;
465     int i;
466     const char *cp = string;
467     size_t len2;
468
469     if (cp == NULL)
470         return NULL;
471
472     TPS(out_used) = 0;
473     len2 = strlen(cp);
474
475     /*
476      * Find the highest parameter-number referred to in the format string.
477      * Use this value to limit the number of arguments copied from the
478      * variable-length argument list.
479      */
480     number = _nc_tparm_analyze(cp, p_is_s, &popcount);
481     if (TPS(fmt_buff) == 0)
482         return NULL;
483
484     if (number > NUM_PARM)
485         number = NUM_PARM;
486     if (popcount > NUM_PARM)
487         popcount = NUM_PARM;
488     num_args = max(popcount, number);
489
490     for (i = 0; i < num_args; i++) {
491         /*
492          * A few caps (such as plab_norm) have string-valued parms.
493          * We'll have to assume that the caller knows the difference, since
494          * a char* and an int may not be the same size on the stack.  The
495          * normal prototype for this uses 9 long's, which is consistent with
496          * our va_arg() usage.
497          */
498         if (p_is_s[i] != 0) {
499             p_is_s[i] = va_arg(ap, char *);
500             param[i] = 0;
501         } else if (use_TPARM_ARG) {
502             param[i] = va_arg(ap, TPARM_ARG);
503         } else {
504             param[i] = (TPARM_ARG) va_arg(ap, int);
505         }
506     }
507
508     /*
509      * This is a termcap compatibility hack.  If there are no explicit pop
510      * operations in the string, load the stack in such a way that
511      * successive pops will grab successive parameters.  That will make
512      * the expansion of (for example) \E[%d;%dH work correctly in termcap
513      * style, which means tparam() will expand termcap strings OK.
514      */
515     TPS(stack_ptr) = 0;
516     if (popcount == 0) {
517         popcount = number;
518         for (i = number - 1; i >= 0; i--) {
519             if (p_is_s[i])
520                 spush(p_is_s[i]);
521             else
522                 npush((int) param[i]);
523         }
524     }
525 #ifdef TRACE
526     if (USE_TRACEF(TRACE_CALLS)) {
527         for (i = 0; i < num_args; i++) {
528             if (p_is_s[i] != 0)
529                 save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
530             else
531                 save_number(", %d", (int) param[i], 0);
532         }
533         _tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
534         TPS(out_used) = 0;
535         _nc_unlock_global(tracef);
536     }
537 #endif /* TRACE */
538
539     while ((cp - string) < (int) len2) {
540         if (*cp != '%') {
541             save_char(UChar(*cp));
542         } else {
543             TPS(tparam_base) = cp++;
544             cp = parse_format(cp, TPS(fmt_buff), &len);
545             switch (*cp) {
546             default:
547                 break;
548             case '%':
549                 save_char('%');
550                 break;
551
552             case 'd':           /* FALLTHRU */
553             case 'o':           /* FALLTHRU */
554             case 'x':           /* FALLTHRU */
555             case 'X':           /* FALLTHRU */
556                 save_number(TPS(fmt_buff), npop(), len);
557                 break;
558
559             case 'c':           /* FALLTHRU */
560                 save_char(npop());
561                 break;
562
563             case 'l':
564                 save_number("%d", (int) strlen(spop()), 0);
565                 break;
566
567             case 's':
568                 save_text(TPS(fmt_buff), spop(), len);
569                 break;
570
571             case 'p':
572                 cp++;
573                 i = (UChar(*cp) - '1');
574                 if (i >= 0 && i < NUM_PARM) {
575                     if (p_is_s[i])
576                         spush(p_is_s[i]);
577                     else
578                         npush((int) param[i]);
579                 }
580                 break;
581
582             case 'P':
583                 cp++;
584                 if (isUPPER(*cp)) {
585                     i = (UChar(*cp) - 'A');
586                     TPS(static_vars)[i] = npop();
587                 } else if (isLOWER(*cp)) {
588                     i = (UChar(*cp) - 'a');
589                     TPS(dynamic_var)[i] = npop();
590                 }
591                 break;
592
593             case 'g':
594                 cp++;
595                 if (isUPPER(*cp)) {
596                     i = (UChar(*cp) - 'A');
597                     npush(TPS(static_vars)[i]);
598                 } else if (isLOWER(*cp)) {
599                     i = (UChar(*cp) - 'a');
600                     npush(TPS(dynamic_var)[i]);
601                 }
602                 break;
603
604             case S_QUOTE:
605                 cp++;
606                 npush(UChar(*cp));
607                 cp++;
608                 break;
609
610             case L_BRACE:
611                 number = 0;
612                 cp++;
613                 while (isdigit(UChar(*cp))) {
614                     number = (number * 10) + (UChar(*cp) - '0');
615                     cp++;
616                 }
617                 npush(number);
618                 break;
619
620             case '+':
621                 npush(npop() + npop());
622                 break;
623
624             case '-':
625                 y = npop();
626                 x = npop();
627                 npush(x - y);
628                 break;
629
630             case '*':
631                 npush(npop() * npop());
632                 break;
633
634             case '/':
635                 y = npop();
636                 x = npop();
637                 npush(y ? (x / y) : 0);
638                 break;
639
640             case 'm':
641                 y = npop();
642                 x = npop();
643                 npush(y ? (x % y) : 0);
644                 break;
645
646             case 'A':
647                 npush(npop() && npop());
648                 break;
649
650             case 'O':
651                 npush(npop() || npop());
652                 break;
653
654             case '&':
655                 npush(npop() & npop());
656                 break;
657
658             case '|':
659                 npush(npop() | npop());
660                 break;
661
662             case '^':
663                 npush(npop() ^ npop());
664                 break;
665
666             case '=':
667                 y = npop();
668                 x = npop();
669                 npush(x == y);
670                 break;
671
672             case '<':
673                 y = npop();
674                 x = npop();
675                 npush(x < y);
676                 break;
677
678             case '>':
679                 y = npop();
680                 x = npop();
681                 npush(x > y);
682                 break;
683
684             case '!':
685                 npush(!npop());
686                 break;
687
688             case '~':
689                 npush(~npop());
690                 break;
691
692             case 'i':
693                 if (p_is_s[0] == 0)
694                     param[0]++;
695                 if (p_is_s[1] == 0)
696                     param[1]++;
697                 break;
698
699             case '?':
700                 break;
701
702             case 't':
703                 x = npop();
704                 if (!x) {
705                     /* scan forward for %e or %; at level zero */
706                     cp++;
707                     level = 0;
708                     while (*cp) {
709                         if (*cp == '%') {
710                             cp++;
711                             if (*cp == '?')
712                                 level++;
713                             else if (*cp == ';') {
714                                 if (level > 0)
715                                     level--;
716                                 else
717                                     break;
718                             } else if (*cp == 'e' && level == 0)
719                                 break;
720                         }
721
722                         if (*cp)
723                             cp++;
724                     }
725                 }
726                 break;
727
728             case 'e':
729                 /* scan forward for a %; at level zero */
730                 cp++;
731                 level = 0;
732                 while (*cp) {
733                     if (*cp == '%') {
734                         cp++;
735                         if (*cp == '?')
736                             level++;
737                         else if (*cp == ';') {
738                             if (level > 0)
739                                 level--;
740                             else
741                                 break;
742                         }
743                     }
744
745                     if (*cp)
746                         cp++;
747                 }
748                 break;
749
750             case ';':
751                 break;
752
753             }                   /* endswitch (*cp) */
754         }                       /* endelse (*cp == '%') */
755
756         if (*cp == '\0')
757             break;
758
759         cp++;
760     }                           /* endwhile (*cp) */
761
762     get_space((size_t) 1);
763     TPS(out_buff)[TPS(out_used)] = '\0';
764
765     T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff))));
766     return (TPS(out_buff));
767 }
768
769 #if NCURSES_TPARM_VARARGS
770 #define tparm_varargs tparm
771 #else
772 #define tparm_proto tparm
773 #endif
774
775 NCURSES_EXPORT(char *)
776 tparm_varargs(NCURSES_CONST char *string,...)
777 {
778     va_list ap;
779     char *result;
780
781     _nc_tparm_err = 0;
782     va_start(ap, string);
783 #ifdef TRACE
784     TPS(tname) = "tparm";
785 #endif /* TRACE */
786     result = tparam_internal(TRUE, string, ap);
787     va_end(ap);
788     return result;
789 }
790
791 #if !NCURSES_TPARM_VARARGS
792 NCURSES_EXPORT(char *)
793 tparm_proto(NCURSES_CONST char *string,
794             TPARM_ARG a1,
795             TPARM_ARG a2,
796             TPARM_ARG a3,
797             TPARM_ARG a4,
798             TPARM_ARG a5,
799             TPARM_ARG a6,
800             TPARM_ARG a7,
801             TPARM_ARG a8,
802             TPARM_ARG a9)
803 {
804     return tparm_varargs(string, a1, a2, a3, a4, a5, a6, a7, a8, a9);
805 }
806 #endif /* NCURSES_TPARM_VARARGS */
807
808 NCURSES_EXPORT(char *)
809 tiparm(const char *string,...)
810 {
811     va_list ap;
812     char *result;
813
814     _nc_tparm_err = 0;
815     va_start(ap, string);
816 #ifdef TRACE
817     TPS(tname) = "tiparm";
818 #endif /* TRACE */
819     result = tparam_internal(FALSE, string, ap);
820     va_end(ap);
821     return result;
822 }