Mercurial > hg > octave-avbm
changeset 4485:bd3cfa59eb61
[project @ 2003-08-21 20:29:34 by jwe]
author | jwe |
---|---|
date | Thu, 21 Aug 2003 20:29:34 +0000 |
parents | 468ddfbce2e2 |
children | 6ceba1f351fb |
files | src/ChangeLog src/utils.cc |
diffstat | 2 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-08-21 John W. Eaton <jwe@bevo.che.wisc.edu> + + * utils.cc (octave_vsnprintf): Copy va_list to avoid using more + than once. + 2003-08-07 John W. Eaton <jwe@bevo.che.wisc.edu> * utils.cc (octave_vsnprintf): Call octave_raw_vsnprintf instead
--- a/src/utils.cc +++ b/src/utils.cc @@ -950,6 +950,14 @@ octave_throw_interrupt_exception (); \ BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_2 +#if defined __GNUC__ && defined __va_copy +#define SAVE_ARGS(saved_args, args) __va_copy (saved_args, args) +#elif defined va_copy +#define SAVE_ARGS(saved_args, args) va_copy (saved_args, args) +#else +#define SAVE_ARGS(saved_args, args) saved_args = args +#endif + char * octave_vsnprintf (const char *fmt, va_list args) { @@ -973,6 +981,13 @@ #if defined (HAVE_C99_VSNPRINTF) + // Note that the caller is responsible for calling va_end on args. + // We will do it for saved_args. + + va_list saved_args; + + SAVE_ARGS (saved_args, args); + BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_FOR_VSNPRINTF; nchars = octave_raw_vsnprintf (buf, size, fmt, args); @@ -991,19 +1006,27 @@ { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_FOR_VSNPRINTF; - octave_raw_vsnprintf (buf, size, fmt, args); + octave_raw_vsnprintf (buf, size, fmt, saved_args); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } } + va_end (saved_args); + #else while (1) { + va_list saved_args; + + SAVE_ARGS (saved_args, args); + BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE_FOR_VSNPRINTF; - nchars = octave_raw_vsnprintf (buf, size, fmt, args); + nchars = octave_raw_vsnprintf (buf, size, fmt, saved_args); + + va_end (saved_args); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE;