1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
/* define on IRIX to get posix compliant vsnprintf */
18
#define _XOPEN_SOURCE 500
21
#include <basestring_vsnprintf.h>
22
#include <my_config.h>
25
#define SNPRINTF_RETURN_TRUNC
26
#define snprintf _snprintf
27
#define vsnprintf _vsnprintf
31
basestring_snprintf(char *str, size_t size, const char *format, ...)
36
ret= basestring_vsnprintf(str, size, format, ap);
41
#ifdef SNPRINTF_RETURN_TRUNC
42
static char basestring_vsnprintf_buf[16*1024];
45
basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap)
49
#ifdef SNPRINTF_RETURN_TRUNC
50
return vsnprintf(basestring_vsnprintf_buf,
51
sizeof(basestring_vsnprintf_buf),
55
return vsnprintf(buf, 1, format, ap);
59
int ret= vsnprintf(str, size, format, ap);
60
#ifdef SNPRINTF_RETURN_TRUNC
61
if (ret == size-1 || ret == -1)
63
ret= vsnprintf(basestring_vsnprintf_buf,
64
sizeof(basestring_vsnprintf_buf),