summaryrefslogtreecommitdiff
path: root/ndb/src
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-10-21 16:26:53 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-10-21 16:26:53 +0000
commit277c84e2b12233624bdcc8f904bf86bbf9512e8e (patch)
tree4cce9c8f4b5a50c976e8abb3639660d3270d4ab6 /ndb/src
parent8a1488cd391d3448894021250f1de2de57f962ba (diff)
downloadmariadb-git-277c84e2b12233624bdcc8f904bf86bbf9512e8e.tar.gz
some platforms provide posix snprintf via special defined, these defines however cause problems elsewhere
so this is a way to only have to do this define in one file
Diffstat (limited to 'ndb/src')
-rw-r--r--ndb/src/common/util/BaseString.cpp28
-rw-r--r--ndb/src/common/util/Makefile.am2
-rw-r--r--ndb/src/common/util/basestring_vsnprintf.c9
3 files changed, 34 insertions, 5 deletions
diff --git a/ndb/src/common/util/BaseString.cpp b/ndb/src/common/util/BaseString.cpp
index 8b7df485f77..ac6038ffcfd 100644
--- a/ndb/src/common/util/BaseString.cpp
+++ b/ndb/src/common/util/BaseString.cpp
@@ -18,6 +18,10 @@
#include <ndb_global.h>
#include <BaseString.hpp>
+extern "C"
+int
+basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap);
+
BaseString::BaseString()
{
m_chr = new char[1];
@@ -127,14 +131,14 @@ BaseString::assfmt(const char *fmt, ...)
* when called as vsnprintf(NULL, 0, ...).
*/
va_start(ap, fmt);
- l = vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
+ l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap);
if(l > (int)m_len) {
delete[] m_chr;
m_chr = new char[l];
}
va_start(ap, fmt);
- vsnprintf(m_chr, l, fmt, ap);
+ basestring_vsnprintf(m_chr, l, fmt, ap);
va_end(ap);
m_len = strlen(m_chr);
return *this;
@@ -152,11 +156,11 @@ BaseString::appfmt(const char *fmt, ...)
* when called as vsnprintf(NULL, 0, ...).
*/
va_start(ap, fmt);
- l = vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
+ l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
va_end(ap);
char *tmp = new char[l];
va_start(ap, fmt);
- vsnprintf(tmp, l, fmt, ap);
+ basestring_vsnprintf(tmp, l, fmt, ap);
va_end(ap);
append(tmp);
delete[] tmp;
@@ -335,6 +339,22 @@ BaseString::trim(char * str, const char * delim){
return str;
}
+int
+BaseString::vsnprintf(char *str, size_t size, const char *format, va_list ap)
+{
+ return(basestring_vsnprintf(str, size, format, ap));
+}
+
+int
+BaseString::snprintf(char *str, size_t size, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ int ret= basestring_vsnprintf(str, size, format, ap);
+ va_end(ap);
+ return(ret);
+}
+
#ifdef TEST_BASE_STRING
diff --git a/ndb/src/common/util/Makefile.am b/ndb/src/common/util/Makefile.am
index efb249dd330..0235adae7c9 100644
--- a/ndb/src/common/util/Makefile.am
+++ b/ndb/src/common/util/Makefile.am
@@ -9,7 +9,7 @@ libgeneral_la_SOURCES = \
NdbSqlUtil.cpp new.cpp \
uucode.c random.c getarg.c version.c \
strdup.c strlcat.c strlcpy.c \
- ConfigValues.cpp ndb_init.c
+ ConfigValues.cpp ndb_init.c basestring_vsnprintf.c
include $(top_srcdir)/ndb/config/common.mk.am
include $(top_srcdir)/ndb/config/type_util.mk.am
diff --git a/ndb/src/common/util/basestring_vsnprintf.c b/ndb/src/common/util/basestring_vsnprintf.c
new file mode 100644
index 00000000000..65a92f6fa4b
--- /dev/null
+++ b/ndb/src/common/util/basestring_vsnprintf.c
@@ -0,0 +1,9 @@
+// define on IRIX to get posix complian vsnprintf
+#define _XOPEN_SOURCE 500
+#include <stdio.h>
+
+int
+basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap)
+{
+ return(vsnprintf(str, size, format, ap));
+}