Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions log4tango/config/check_snprintf.cpp

This file was deleted.

3 changes: 0 additions & 3 deletions log4tango/config/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ LOG4TANGO_CHECK_COMPILER_FEATURE("config/check_sstream.cpp" SSTREAM)
#namespace
LOG4TANGO_CHECK_COMPILER_FEATURE("config/check_namespace.cpp" NAMESPACES)

#snprintf
LOG4TANGO_CHECK_COMPILER_FEATURE("config/check_snprintf.cpp" SNPRINTF)

#check types
check_type_size(int64_t INT64_SIZE)
if(WIN32)
Expand Down
5 changes: 1 addition & 4 deletions log4tango/config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
/* define if the compiler implements namespaces */
#cmakedefine LOG4TANGO_HAVE_NAMESPACES

/* define if the C library has snprintf */
#cmakedefine LOG4TANGO_HAVE_SNPRINTF

/* define if the compiler has stringstream */
#cmakedefine LOG4TANGO_HAVE_SSTREAM

Expand Down Expand Up @@ -77,4 +74,4 @@
#cmakedefine __darwin__

/* If we're running on FreeBSD */
#cmakedefine __freebsd__
#cmakedefine __freebsd__
5 changes: 0 additions & 5 deletions log4tango/include/log4tango/config-win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ typedef __int64 int64_t;
# define LOG4TANGO_HAVE_SSTREAM 1
#endif

/* define if the C library has snprintf */
#ifndef LOG4TANGO_HAVE_SNPRINTF
# define LOG4TANGO_HAVE_SNPRINTF 1
#endif

/* define to get around problems with ERROR in windows.h */
#ifndef LOG4TANGO_FIX_ERROR_COLLISION
# define LOG4TANGO_FIX_ERROR_COLLISION 1
Expand Down
33 changes: 8 additions & 25 deletions log4tango/src/StringUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//
// Copyright (C) : 2000 - 2002
// LifeLine Networks BV (www.lifeline.nl). All rights reserved.
// Bastiaan Bakker. All rights reserved.
//
// Bastiaan Bakker. All rights reserved.
//
// 2004,2005,2006,2007,2008,2009,2010,2011,2012
// Synchrotron SOLEIL
// L'Orme des Merisiers
Expand All @@ -16,12 +16,12 @@
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// Log4tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -32,47 +32,30 @@
#if defined(_MSC_VER)
#define VSNPRINTF _vsnprintf
#else
#ifdef LOG4TANGO_HAVE_SNPRINTF
#define VSNPRINTF vsnprintf
#else
/* use alternative snprintf() from http://www.ijs.si/software/snprintf/ */

#define HAVE_SNPRINTF
#define PREFER_PORTABLE_SNPRINTF

#include <stdlib.h>
#include <stdarg.h>

extern "C" {
#include "snprintf.c"
}

#define VSNPRINTF portable_vsnprintf

#endif // LOG4TANGO_HAVE_SNPRINTF
#endif // _MSC_VER

namespace log4tango {

std::string StringUtil::vform(const char* format, va_list args) {
size_t size = 1024;
char* buffer = new char[size];

while (1) {
int n = VSNPRINTF(buffer, size, format, args);

// If that worked, return a string.
if ((n > -1) && (static_cast<size_t>(n) < size)) {
std::string s(buffer);
delete [] buffer;
return s;
}

// Else try again with more space.
size = (n > -1) ?
n + 1 : // ISO/IEC 9899:1999
size * 2; // twice the old size

delete [] buffer;
buffer = new char[size];
}
Expand Down
Loading