Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 376d118

Browse files
authored
Merge pull request #659 from t-b/remove-fallback-snprintf-implementation
Remove fallback snprintf implementation
2 parents 40aecac + 8f2218e commit 376d118

File tree

6 files changed

+9
-1076
lines changed

6 files changed

+9
-1076
lines changed

log4tango/config/check_snprintf.cpp

Lines changed: 0 additions & 6 deletions
This file was deleted.

log4tango/config/config.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ LOG4TANGO_CHECK_COMPILER_FEATURE("config/check_sstream.cpp" SSTREAM)
5353
#namespace
5454
LOG4TANGO_CHECK_COMPILER_FEATURE("config/check_namespace.cpp" NAMESPACES)
5555

56-
#snprintf
57-
LOG4TANGO_CHECK_COMPILER_FEATURE("config/check_snprintf.cpp" SNPRINTF)
58-
5956
#check types
6057
check_type_size(int64_t INT64_SIZE)
6158
if(WIN32)

log4tango/config/config.h.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
/* define if the compiler implements namespaces */
2323
#cmakedefine LOG4TANGO_HAVE_NAMESPACES
2424

25-
/* define if the C library has snprintf */
26-
#cmakedefine LOG4TANGO_HAVE_SNPRINTF
27-
2825
/* define if the compiler has stringstream */
2926
#cmakedefine LOG4TANGO_HAVE_SSTREAM
3027

@@ -77,4 +74,4 @@
7774
#cmakedefine __darwin__
7875

7976
/* If we're running on FreeBSD */
80-
#cmakedefine __freebsd__
77+
#cmakedefine __freebsd__

log4tango/include/log4tango/config-win32.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ typedef __int64 int64_t;
8484
# define LOG4TANGO_HAVE_SSTREAM 1
8585
#endif
8686

87-
/* define if the C library has snprintf */
88-
#ifndef LOG4TANGO_HAVE_SNPRINTF
89-
# define LOG4TANGO_HAVE_SNPRINTF 1
90-
#endif
91-
9287
/* define to get around problems with ERROR in windows.h */
9388
#ifndef LOG4TANGO_FIX_ERROR_COLLISION
9489
# define LOG4TANGO_FIX_ERROR_COLLISION 1

log4tango/src/StringUtil.cpp

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//
44
// Copyright (C) : 2000 - 2002
55
// LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6-
// Bastiaan Bakker. All rights reserved.
7-
//
6+
// Bastiaan Bakker. All rights reserved.
7+
//
88
// 2004,2005,2006,2007,2008,2009,2010,2011,2012
99
// Synchrotron SOLEIL
1010
// L'Orme des Merisiers
@@ -16,12 +16,12 @@
1616
// it under the terms of the GNU Lesser General Public License as published by
1717
// the Free Software Foundation, either version 3 of the License, or
1818
// (at your option) any later version.
19-
//
19+
//
2020
// Log4tango is distributed in the hope that it will be useful,
2121
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2222
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2323
// GNU Lesser General Public License for more details.
24-
//
24+
//
2525
// You should have received a copy of the GNU Lesser General Public License
2626
// along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
2727

@@ -32,47 +32,30 @@
3232
#if defined(_MSC_VER)
3333
#define VSNPRINTF _vsnprintf
3434
#else
35-
#ifdef LOG4TANGO_HAVE_SNPRINTF
3635
#define VSNPRINTF vsnprintf
37-
#else
38-
/* use alternative snprintf() from http://www.ijs.si/software/snprintf/ */
39-
40-
#define HAVE_SNPRINTF
41-
#define PREFER_PORTABLE_SNPRINTF
42-
43-
#include <stdlib.h>
44-
#include <stdarg.h>
45-
46-
extern "C" {
47-
#include "snprintf.c"
48-
}
49-
50-
#define VSNPRINTF portable_vsnprintf
51-
52-
#endif // LOG4TANGO_HAVE_SNPRINTF
5336
#endif // _MSC_VER
5437

5538
namespace log4tango {
5639

5740
std::string StringUtil::vform(const char* format, va_list args) {
5841
size_t size = 1024;
5942
char* buffer = new char[size];
60-
43+
6144
while (1) {
6245
int n = VSNPRINTF(buffer, size, format, args);
63-
46+
6447
// If that worked, return a string.
6548
if ((n > -1) && (static_cast<size_t>(n) < size)) {
6649
std::string s(buffer);
6750
delete [] buffer;
6851
return s;
6952
}
70-
53+
7154
// Else try again with more space.
7255
size = (n > -1) ?
7356
n + 1 : // ISO/IEC 9899:1999
7457
size * 2; // twice the old size
75-
58+
7659
delete [] buffer;
7760
buffer = new char[size];
7861
}

0 commit comments

Comments
 (0)