aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tinfo/lib_tparm.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2001-05-17 08:21:06 +0000
committerPeter Wemm <peter@FreeBSD.org>2001-05-17 08:21:06 +0000
commit7a69bbfb278952228c9aa1eca241e65fcdef425e (patch)
treee83b2ef47811e687a6c54035c9af6d4a2b7f14e1 /contrib/ncurses/ncurses/tinfo/lib_tparm.c
parent18259542b2f8fa7e3f76f4bb0dd37995dfd424aa (diff)
downloadsrc-7a69bbfb278952228c9aa1eca241e65fcdef425e.tar.gz
src-7a69bbfb278952228c9aa1eca241e65fcdef425e.zip
Import ncurses-5.2-20010512 onto the vendor branch
Obtained from: ftp://dickey.his.com/ncurses/
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=76726
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo/lib_tparm.c')
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tparm.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/lib_tparm.c b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
index 6a8ca1f0419a..e62b824e5bc6 100644
--- a/contrib/ncurses/ncurses/tinfo/lib_tparm.c
+++ b/contrib/ncurses/ncurses/tinfo/lib_tparm.c
@@ -42,7 +42,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.47 2000/10/04 00:57:13 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.52 2001/03/11 15:12:48 tom Exp $")
/*
* char *
@@ -114,8 +114,11 @@ typedef struct {
bool num_type;
} stack_frame;
+NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0;
+
static stack_frame stack[STACKSIZE];
static int stack_ptr;
+static const char *tparam_base = "";
#ifdef TRACE
static const char *tname;
@@ -126,7 +129,7 @@ static size_t out_size;
static size_t out_used;
#if NO_LEAKS
-void
+NCURSES_EXPORT(void)
_nc_free_tparm(void)
{
if (out_buff != 0) {
@@ -195,6 +198,9 @@ npush(int x)
stack[stack_ptr].num_type = TRUE;
stack[stack_ptr].data.num = x;
stack_ptr++;
+ } else {
+ DEBUG(2, ("npush: stack overflow: %s", _nc_visbuf(tparam_base)));
+ _nc_tparm_err++;
}
}
@@ -206,6 +212,9 @@ npop(void)
stack_ptr--;
if (stack[stack_ptr].num_type)
result = stack[stack_ptr].data.num;
+ } else {
+ DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(tparam_base)));
+ _nc_tparm_err++;
}
return result;
}
@@ -217,6 +226,9 @@ spush(char *x)
stack[stack_ptr].num_type = FALSE;
stack[stack_ptr].data.str = x;
stack_ptr++;
+ } else {
+ DEBUG(2, ("spush: stack overflow: %s", _nc_visbuf(tparam_base)));
+ _nc_tparm_err++;
}
}
@@ -229,6 +241,9 @@ spop(void)
stack_ptr--;
if (!stack[stack_ptr].num_type && stack[stack_ptr].data.str != 0)
result = stack[stack_ptr].data.str;
+ } else {
+ DEBUG(2, ("spop: stack underflow: %s", _nc_visbuf(tparam_base)));
+ _nc_tparm_err++;
}
return result;
}
@@ -286,7 +301,7 @@ parse_format(const char *s, char *format, int *len)
}
break;
default:
- if (isdigit(*s)) {
+ if (isdigit(CharOf(*s))) {
value = (value * 10) + (*s - '0');
if (value > 10000)
err = TRUE;
@@ -501,7 +516,7 @@ tparam_internal(const char *string, va_list ap)
if (*string != '%') {
save_char(*string);
} else {
- string++;
+ tparam_base = string++;
string = parse_format(string, format, &len);
switch (*string) {
default:
@@ -717,20 +732,21 @@ tparam_internal(const char *string, va_list ap)
string++;
} /* endwhile (*string) */
- if (out_buff == 0 && (out_buff = typeCalloc(char, 1)) == NULL)
- return (NULL);
+ get_space(1);
out_buff[out_used] = '\0';
T((T_RETURN("%s"), _nc_visbuf(out_buff)));
return (out_buff);
}
-char *
-tparm(NCURSES_CONST char *string,...)
+NCURSES_EXPORT(char *)
+tparm
+(NCURSES_CONST char *string,...)
{
va_list ap;
char *result;
+ _nc_tparm_err = 0;
va_start(ap, string);
#ifdef TRACE
tname = "tparm";