Commit 9d7c3cee authored by unknown's avatar unknown

Fix for snprintf

parent a803c36b
......@@ -222,8 +222,6 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_PERROR
#define HAVE_VFPRINT
#define HAVE_SNPRINTF
#define _snprintf snprintf
#define HAVE_CHSIZE /* System has chsize() function */
#define HAVE_RENAME /* Have rename() as function */
#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
......@@ -248,6 +246,11 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_ALLOCA
#define HAVE_COMPRESS
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
#define _snprintf snprintf
#endif
#ifdef _MSC_VER
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
#define HAVE_ANSI_INCLUDE
......
......@@ -501,7 +501,8 @@ void Field_decimal::store(double nr)
fyllchar = zerofill ? (char) '0' : (char) ' ';
#ifdef HAVE_SNPRINTF_
snprintf(buff,sizeof(buff), "%.*f",(int) dec,nr);
buff[sizeof(buff)-1]=0; // Safety
snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr);
#else
sprintf(buff,"%.*f",dec,nr);
#endif
......@@ -2075,7 +2076,8 @@ String *Field_double::val_str(String *val_buffer,
*to++= *pos++;
#else
#ifdef HAVE_SNPRINTF
snprintf(to,to_length,"%.*f",dec,nr);
buff[to_length-1]=0; // Safety
snprintf(to,to_length-1,"%.*f",dec,nr);
#else
sprintf(to,"%.*f",dec,nr);
#endif
......
......@@ -359,7 +359,8 @@ void field_real::add()
else
{
#ifdef HAVE_SNPRINTF
snprintf(buff, sizeof(buff), "%-.*f", (int) decs, num);
buff[sizeof(buff)-1]=0; // Safety
snprintf(buff, sizeof(buff)-1, "%-.*f", (int) decs, num);
#else
sprintf(buff, "%-.*f", (int) decs, num);
#endif
......
......@@ -186,7 +186,8 @@ bool String::set(double num,uint decimals)
return FALSE;
#else
#ifdef HAVE_SNPRINTF
snprintf(buff,sizeof(buff), "%.*f",(int) decimals,num);
buff[sizeof(buff)-1]=0; // Safety
snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
#else
sprintf(buff,"%.*f",(int) decimals,num);
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment