aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flsupport.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-03-26 03:22:11 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-03-26 03:22:11 +0000
commit5b821a81fc7c9ed7decfe5575a867ab82464b0cc (patch)
tree9a5ad718cc024066d53f46937b32dacb64d97e4d /externals/grill/flext/source/flsupport.cpp
parent62a9baa7736d938b672a839b88f0bb4c8e511437 (diff)
""
svn path=/trunk/; revision=1480
Diffstat (limited to 'externals/grill/flext/source/flsupport.cpp')
-rw-r--r--externals/grill/flext/source/flsupport.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index cc300b95..c453aae2 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -18,6 +18,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <stdarg.h>
#include <new>
+#ifdef _MSC_VER
+#define vsnprintf _vsnprintf
+#define snprintf _snprintf
+#endif
+
const t_symbol *flext::sym_float = NULL;
const t_symbol *flext::sym_symbol = NULL;
const t_symbol *flext::sym_bang = NULL;
@@ -263,10 +268,9 @@ void flext::GetAString(const t_atom &a,char *buf,int szbuf)
#if FLEXT_SYS == FLEXT_SYS_PD
atom_string(const_cast<t_atom *>(&a),buf,szbuf);
#else
- // no checking for size here
- if(IsSymbol(a)) STD::sprintf(buf,GetString(a));
- else if(IsFloat(a)) STD::sprintf(buf,"%f",GetFloat(a));
- else if(IsInt(a)) STD::sprintf(buf,"%i",GetInt(a));
+ if(IsSymbol(a)) STD::strncpy(buf,GetString(a),szbuf);
+ else if(IsFloat(a)) STD::snprintf(buf,szbuf,"%f",GetFloat(a));
+ else if(IsInt(a)) STD::snprintf(buf,szbuf,"%i",GetInt(a));
else *buf = 0;
#endif
}
@@ -280,14 +284,14 @@ unsigned long flext::AtomHash(const t_atom &a)
#endif
}
-
void flext_root::post(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- char buf[1024]; // \TODO this is quite unsafe.....
- vsprintf(buf, fmt, ap);
+ char buf[1024];
+ vsnprintf(buf,sizeof buf,fmt, ap);
+ buf[sizeof buf-1] = 0; // in case of full buffer
::post(buf);
va_end(ap);
@@ -298,9 +302,10 @@ void flext_root::error(const char *fmt,...)
va_list ap;
va_start(ap, fmt);
- char buf[1024]; // \TODO this is quite unsafe.....
- STD::sprintf(buf,"error: ");
- vsprintf(buf+7, fmt, ap);
+ char buf[1024];
+ strcpy(buf,"error: ");
+ vsnprintf(buf+7,sizeof buf-7,fmt, ap);
+ buf[sizeof buf-1] = 0; // in case of full buffer
::post(buf);
va_end(ap);