зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1197316 - Remove PR_snprintf calls in xpcom/. r=froydnj
This commit is contained in:
Родитель
7833654240
Коммит
ba173ae5e4
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include "nsSupportsPrimitives.h"
|
||||
#include "nsMemory.h"
|
||||
#include "prprf.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/Snprintf.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -239,9 +240,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRUint8Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 8;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%u", (uint16_t)mData);
|
||||
char buf[8];
|
||||
snprintf_literal(buf, "%u", (unsigned int)mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -285,9 +285,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRUint16Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 8;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%u", (int)mData);
|
||||
char buf[8];
|
||||
snprintf_literal(buf, "%u", (unsigned int)mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -331,9 +330,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRUint32Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 16;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%lu", mData);
|
||||
char buf[16];
|
||||
snprintf_literal(buf, "%u", mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -377,9 +375,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRUint64Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 32;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%llu", mData);
|
||||
char buf[32];
|
||||
snprintf_literal(buf, "%llu", mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -423,9 +420,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRTimeImpl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 32;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%llu", mData);
|
||||
char buf[32];
|
||||
snprintf_literal(buf, "%" PRIu64, mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -517,9 +513,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRInt16Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 8;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%d", mData);
|
||||
char buf[8];
|
||||
snprintf_literal(buf, "%d", (int)mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -563,9 +558,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRInt32Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 16;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%ld", mData);
|
||||
char buf[16];
|
||||
snprintf_literal(buf, "%d", mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -609,9 +603,8 @@ NS_IMETHODIMP
|
|||
nsSupportsPRInt64Impl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 32;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%lld", mData);
|
||||
char buf[32];
|
||||
snprintf_literal(buf, "%" PRId64, mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -655,9 +648,8 @@ NS_IMETHODIMP
|
|||
nsSupportsFloatImpl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 32;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%f", (double)mData);
|
||||
char buf[32];
|
||||
snprintf_literal(buf, "%f", (double)mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -701,9 +693,8 @@ NS_IMETHODIMP
|
|||
nsSupportsDoubleImpl::ToString(char** aResult)
|
||||
{
|
||||
NS_ASSERTION(aResult, "Bad pointer");
|
||||
static const int size = 32;
|
||||
char buf[size];
|
||||
PR_snprintf(buf, size, "%f", mData);
|
||||
char buf[32];
|
||||
snprintf_literal(buf, "%f", mData);
|
||||
|
||||
*aResult = (char*)nsMemory::Clone(buf, (strlen(buf) + 1) * sizeof(char));
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsID.h"
|
||||
#include "prprf.h"
|
||||
#include "nsMemory.h"
|
||||
#include "mozilla/Snprintf.h"
|
||||
|
||||
void nsID::Clear()
|
||||
{
|
||||
|
@ -111,11 +111,11 @@ nsID::ToString() const
|
|||
char* res = (char*)NS_Alloc(NSID_LENGTH);
|
||||
|
||||
if (res) {
|
||||
PR_snprintf(res, NSID_LENGTH, gIDFormat,
|
||||
m0, (uint32_t)m1, (uint32_t)m2,
|
||||
(uint32_t)m3[0], (uint32_t)m3[1], (uint32_t)m3[2],
|
||||
(uint32_t)m3[3], (uint32_t)m3[4], (uint32_t)m3[5],
|
||||
(uint32_t)m3[6], (uint32_t)m3[7]);
|
||||
snprintf(res, NSID_LENGTH, gIDFormat,
|
||||
m0, (uint32_t)m1, (uint32_t)m2,
|
||||
(uint32_t)m3[0], (uint32_t)m3[1], (uint32_t)m3[2],
|
||||
(uint32_t)m3[3], (uint32_t)m3[4], (uint32_t)m3[5],
|
||||
(uint32_t)m3[6], (uint32_t)m3[7]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -123,11 +123,11 @@ nsID::ToString() const
|
|||
void
|
||||
nsID::ToProvidedString(char (&aDest)[NSID_LENGTH]) const
|
||||
{
|
||||
PR_snprintf(aDest, NSID_LENGTH, gIDFormat,
|
||||
m0, (uint32_t)m1, (uint32_t)m2,
|
||||
(uint32_t)m3[0], (uint32_t)m3[1], (uint32_t)m3[2],
|
||||
(uint32_t)m3[3], (uint32_t)m3[4], (uint32_t)m3[5],
|
||||
(uint32_t)m3[6], (uint32_t)m3[7]);
|
||||
snprintf_literal(aDest, gIDFormat,
|
||||
m0, (uint32_t)m1, (uint32_t)m2,
|
||||
(uint32_t)m3[0], (uint32_t)m3[1], (uint32_t)m3[2],
|
||||
(uint32_t)m3[3], (uint32_t)m3[4], (uint32_t)m3[5],
|
||||
(uint32_t)m3[6], (uint32_t)m3[7]);
|
||||
}
|
||||
|
||||
#endif // XPCOM_GLUE_AVOID_NSPR
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <string.h>
|
||||
#include "prdtoa.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "prprf.h"
|
||||
#include "mozilla/Snprintf.h"
|
||||
#include "prmem.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsTextFormatter.h"
|
||||
|
@ -406,7 +406,8 @@ cvt_f(SprintfState* aState, double aDouble, int aWidth, int aPrec,
|
|||
}
|
||||
}
|
||||
*bufp++ = exp;
|
||||
PR_snprintf(bufp, bufsz - (bufp - buf), "%+03d", decpt - 1);
|
||||
|
||||
snprintf(bufp, bufsz - (bufp - buf), "%+03d", decpt - 1);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
|
@ -458,7 +459,7 @@ cvt_f(SprintfState* aState, double aDouble, int aWidth, int aPrec,
|
|||
}
|
||||
}
|
||||
*bufp++ = exp;
|
||||
PR_snprintf(bufp, bufsz - (bufp - buf), "%+03d", decpt - 1);
|
||||
snprintf(bufp, bufsz - (bufp - buf), "%+03d", decpt - 1);
|
||||
} else {
|
||||
if (decpt < 1) {
|
||||
*bufp++ = '0';
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "nsJSPrincipals.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "prprf.h"
|
||||
#ifdef MOZ_THREADSTACKHELPER_NATIVE
|
||||
#include "shared-libraries.h"
|
||||
#endif
|
||||
|
@ -21,6 +20,7 @@
|
|||
#include "mozilla/Scoped.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/MemoryChecking.h"
|
||||
#include "mozilla/Snprintf.h"
|
||||
|
||||
#ifdef MOZ_THREADSTACKHELPER_NATIVE
|
||||
#include "google_breakpad/processor/call_stack.h"
|
||||
|
@ -464,12 +464,12 @@ ThreadStackHelper::GetNativeStack(Stack& aStack)
|
|||
char buffer[0x100];
|
||||
size_t len = 0;
|
||||
if (!frame.function_name.empty()) {
|
||||
len = PR_snprintf(buffer, sizeof(buffer), "%s:%s",
|
||||
module_name, frame.function_name.c_str());
|
||||
len = snprintf_literal(buffer, "%s:%s",
|
||||
module_name, frame.function_name.c_str());
|
||||
} else {
|
||||
len = PR_snprintf(buffer, sizeof(buffer), "%s:0x%p",
|
||||
module_name, (intptr_t)
|
||||
(frame.instruction - frame.module->base_address()));
|
||||
len = snprintf_literal(buffer, "%s:0x%p", module_name,
|
||||
(intptr_t)(frame.instruction -
|
||||
frame.module->base_address()));
|
||||
}
|
||||
if (len) {
|
||||
aStack.AppendViaBuffer(buffer, len);
|
||||
|
@ -619,7 +619,7 @@ ThreadStackHelper::AppendJSEntry(const volatile StackEntry* aEntry,
|
|||
}
|
||||
}
|
||||
|
||||
size_t len = PR_snprintf(buffer, sizeof(buffer), "%s:%u", basename, lineno);
|
||||
size_t len = snprintf_literal(buffer, "%s:%u", basename, lineno);
|
||||
if (len < sizeof(buffer)) {
|
||||
if (mStackToFill->IsSameAsEntry(aPrevLabel, buffer)) {
|
||||
return aPrevLabel;
|
||||
|
|
Загрузка…
Ссылка в новой задаче