X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_tparm.c;h=7e5b3f2a4fa91782ac91ab980ed52ff6b4d76414;hp=53205d1711bf06fb86c563edc4433e959ee9e995;hb=e2dee48666d83c609f7ecced6203ecfdc94e36aa;hpb=03f728e5bb3630a54fffc4a2ff2f8dbfcce9088e diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c index 53205d17..7e5b3f2a 100644 --- a/ncurses/tinfo/lib_tparm.c +++ b/ncurses/tinfo/lib_tparm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2013 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 * @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$Id: lib_tparm.c,v 1.84 2011/10/22 15:48:47 tom Exp $") +MODULE_ID("$Id: lib_tparm.c,v 1.89 2013/09/28 20:46:56 tom Exp $") /* * char * @@ -107,6 +107,7 @@ MODULE_ID("$Id: lib_tparm.c,v 1.84 2011/10/22 15:48:47 tom Exp $") NCURSES_EXPORT_VAR(int) _nc_tparm_err = 0; #define TPS(var) _nc_prescreen.tparm_state.var +#define popcount _nc_popcount /* workaround for NetBSD 6.0 defect */ #if NO_LEAKS NCURSES_EXPORT(void) @@ -128,9 +129,7 @@ get_space(size_t need) need += TPS(out_used); if (need > TPS(out_size)) { TPS(out_size) = need * 2; - TPS(out_buff) = typeRealloc(char, TPS(out_size), TPS(out_buff)); - if (TPS(out_buff) == 0) - _nc_err_abort(MSG_NO_MEMORY); + TYPE_REALLOC(char, TPS(out_size), TPS(out_buff)); } } @@ -143,7 +142,9 @@ save_text(const char *fmt, const char *s, int len) 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)); } @@ -155,7 +156,9 @@ save_number(const char *fmt, int number, int len) 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)); } @@ -559,7 +562,7 @@ tparam_internal(int use_TPARM_ARG, const char *string, va_list ap) break; case 'l': - save_number("%d", (int) strlen(spop()), 0); + npush((int) strlen(spop())); break; case 's':