0

[libphonenumber] snprintf isn't generally in the std:: namespace

Due to some relatively common gnu-isms, one can often use snprintf by
calling std::snprintf.  It's not necessarily proper to do so, though,
and the ARM toolchain used on Chromium OS does not support it.

BUG=None
TEST=unit tests

R=georgey

Review URL: http://codereview.chromium.org/7277083

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91437 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
cmasone@chromium.org
2011-07-03 01:42:00 +00:00
parent f9019858c3
commit a3d727da44
3 changed files with 26 additions and 3 deletions
third_party/libphonenumber

@ -18,8 +18,8 @@ Additional files, not in the original library:
libphonenumber.gyp
README.chromium
Until the changes are upstreamed library is included directly, with a patch
in patches/version277.patch applied.
Until the changes are upstreamed library is included directly, with patches
in patches/version277.patch and patches/version277a.patch applied.
The folders included in our repository for now are
cpp/

@ -17,6 +17,8 @@
#ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#include <stdio.h>
#include <string>
#include "logger.h"
@ -48,7 +50,7 @@ struct ConvertToString<int> {
#if defined(OS_WIN)
_itoa_s(n, buffer, sizeof(buffer), 10);
#else
std::snprintf(buffer, sizeof(buffer), "%d", n);
snprintf(buffer, sizeof(buffer), "%d", n);
#endif
return string(buffer);
}

@ -0,0 +1,21 @@
diff -Naur src-orig/default_logger.h src/default_logger.h
--- src-orig/default_logger.h 2011-07-02 16:27:58.000000000 -0700
+++ src/default_logger.h 2011-07-02 16:28:29.000000000 -0700
@@ -17,6 +17,8 @@
#ifndef I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
#define I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
+#include <stdio.h>
+
#include <string>
#include "logger.h"
@@ -45,7 +47,7 @@
struct ConvertToString<int> {
static inline string DoWork(const int& n) {
char buffer[16];
- std::snprintf(buffer, sizeof(buffer), "%d", n);
+ snprintf(buffer, sizeof(buffer), "%d", n);
return string(buffer);
}
};