/****************************************************************************
- * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.79 2010/01/16 16:47:46 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.86 2012/02/22 22:40:24 tom Exp $")
/*
* char *
get_space(s_len + 1);
- (void) sprintf(TPS(out_buff) + TPS(out_used), fmt, s);
+ _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
+ _nc_SLIMIT(TPS(out_size) - TPS(out_used))
+ fmt, s);
TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
}
if (len < 30)
len = 30; /* actually log10(MAX_INT)+1 */
- get_space((unsigned) len + 1);
+ get_space((size_t) len + 1);
- (void) sprintf(TPS(out_buff) + TPS(out_used), fmt, number);
+ _nc_SPRINTF(TPS(out_buff) + TPS(out_used),
+ _nc_SLIMIT(TPS(out_size) - TPS(out_used))
+ fmt, number);
TPS(out_used) += strlen(TPS(out_buff) + TPS(out_used));
}
{
if (c == 0)
c = 0200;
- get_space(1);
+ get_space((size_t) 1);
TPS(out_buff)[TPS(out_used)++] = (char) c;
}
}
static NCURSES_INLINE char *
-tparam_internal(bool use_TPARM_ARG, const char *string, va_list ap)
+tparam_internal(int use_TPARM_ARG, const char *string, va_list ap)
{
char *p_is_s[NUM_PARM];
TPARM_ARG param[NUM_PARM];
- int popcount;
+ int popcount = 0;
int number;
+ int num_args;
int len;
int level;
int x, y;
if (TPS(fmt_buff) == 0)
return NULL;
- for (i = 0; i < max(popcount, number); i++) {
+ if (number > NUM_PARM)
+ number = NUM_PARM;
+ if (popcount > NUM_PARM)
+ popcount = NUM_PARM;
+ num_args = max(popcount, number);
+
+ for (i = 0; i < num_args; i++) {
/*
* A few caps (such as plab_norm) have string-valued parms.
* We'll have to assume that the caller knows the difference, since
*/
if (p_is_s[i] != 0) {
p_is_s[i] = va_arg(ap, char *);
+ param[i] = 0;
} else if (use_TPARM_ARG) {
param[i] = va_arg(ap, TPARM_ARG);
} else {
if (p_is_s[i])
spush(p_is_s[i]);
else
- npush(param[i]);
+ npush((int) param[i]);
}
}
#ifdef TRACE
if (USE_TRACEF(TRACE_CALLS)) {
- for (i = 0; i < popcount; i++) {
+ for (i = 0; i < num_args; i++) {
if (p_is_s[i] != 0)
save_text(", %s", _nc_visbuf(p_is_s[i]), 0);
else
- save_number(", %d", param[i], 0);
+ save_number(", %d", (int) param[i], 0);
}
_tracef(T_CALLED("%s(%s%s)"), TPS(tname), _nc_visbuf(cp), TPS(out_buff));
TPS(out_used) = 0;
if (p_is_s[i])
spush(p_is_s[i]);
else
- npush(param[i]);
+ npush((int) param[i]);
}
break;
cp++;
} /* endwhile (*cp) */
- get_space(1);
+ get_space((size_t) 1);
TPS(out_buff)[TPS(out_used)] = '\0';
T((T_RETURN("%s"), _nc_visbuf(TPS(out_buff))));