|
From: Ethan M. <merritt@u.washington.edu> - 2011-10-06 23:34:48
|
On Thursday, October 06, 2011 04:22:52 pm Ethan Merritt wrote:
> On Thursday, October 06, 2011 03:46:13 pm Hans-Bernhard Br�ker wrote:
> > On 06.10.2011 10:01, Shigeharu TAKENO wrote:
> >
> > > I saw that gnuplot.exe of CVS version compiled by VC++ reports
> > [...]
> > > foo = sprintf("%40d %40d %40d %40d %40d %40d",1,2,3,4,5,6)
> > > ^
> > > "stringvar.dem", line 59: undefined value
> >
> > For what it's worth: this program doesn't appear in gnuplot.exe compiled
> > by Open Watcom.
> >
> > > The gnuplot show no erorr message for the command
> > >
> > > foo = sprintf("%83d",1)
> > >
> > > but it show the same error message above for the command
> > >
> > > foo = sprintf("%84d",1)
> >
> > This doesn't cause problem either.
> >
> > The root of the problem appears to be the buffer size computation and
> > subsequent realloc()ation in f_sprintf(). The number 84 is magic
> > because it's 84 plus the length of the format string "%84d". Go figure.
>
> The problem occurs when the platform/compiler does not support snprintf.
> f_sprintf() has:
>
> #ifdef HAVE_SNPRINTF
> /* Use the format to print next arg */
> ... this code works fine ...
> #else
> /* FIXME - this is bad; we should dummy up an snprintf equivalent */
> ... this code triggers a buffer overflow if the format width is too large
> #endif
Some Googling suggests that VC++ may work if you do
#define snprintf _snprintf
This would have to go in some header or configuration file,
along with HAVE_SNPRINTF.
--
Ethan A Merritt
Biomolecular Structure Center, K-428 Health Sciences Bldg
University of Washington, Seattle 98195-7742
|