mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 592009. Fix AppendPrintf to support more than 31 characters. r=bsmedberg
We can use vsmprintf to have the formatting code do the allocation for us.
This commit is contained in:
parent
6591011663
commit
d976bd144d
@ -387,35 +387,34 @@ class nsTSubstring_CharT
|
||||
|
||||
void AppendASCII( const char* data, size_type length = size_type(-1) ) { ReplaceASCII(mLength, 0, data, length); }
|
||||
|
||||
// AppendPrintf truncates output to 31 ASCII characters
|
||||
void AppendPrintf( const char* format, ... );
|
||||
void AppendInt( PRInt32 aInteger )
|
||||
{ AppendPrintf( "%d", aInteger ); }
|
||||
{ AppendPrintf31( "%d", aInteger ); }
|
||||
void AppendInt( PRInt32 aInteger, int aRadix )
|
||||
{
|
||||
const char *fmt = aRadix == 10 ? "%d" : aRadix == 8 ? "%o" : "%x";
|
||||
AppendPrintf( fmt, aInteger );
|
||||
AppendPrintf31( fmt, aInteger );
|
||||
}
|
||||
void AppendInt( PRUint32 aInteger )
|
||||
{ AppendPrintf( "%u", aInteger ); }
|
||||
{ AppendPrintf31( "%u", aInteger ); }
|
||||
void AppendInt( PRUint32 aInteger, int aRadix )
|
||||
{
|
||||
const char *fmt = aRadix == 10 ? "%u" : aRadix == 8 ? "%o" : "%x";
|
||||
AppendPrintf( fmt, aInteger );
|
||||
AppendPrintf31( fmt, aInteger );
|
||||
}
|
||||
void AppendInt( PRInt64 aInteger )
|
||||
{ AppendPrintf( "%lld", aInteger ); }
|
||||
{ AppendPrintf31( "%lld", aInteger ); }
|
||||
void AppendInt( PRInt64 aInteger, int aRadix )
|
||||
{
|
||||
const char *fmt = aRadix == 10 ? "%lld" : aRadix == 8 ? "%llo" : "%llx";
|
||||
AppendPrintf( fmt, aInteger );
|
||||
AppendPrintf31( fmt, aInteger );
|
||||
}
|
||||
void AppendInt( PRUint64 aInteger )
|
||||
{ AppendPrintf( "%llu", aInteger ); }
|
||||
{ AppendPrintf31( "%llu", aInteger ); }
|
||||
void AppendInt( PRUint64 aInteger, int aRadix )
|
||||
{
|
||||
const char *fmt = aRadix == 10 ? "%llu" : aRadix == 8 ? "%llo" : "%llx";
|
||||
AppendPrintf( fmt, aInteger );
|
||||
AppendPrintf31( fmt, aInteger );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -427,6 +426,8 @@ class nsTSubstring_CharT
|
||||
{ DoAppendFloat(aFloat, 15); }
|
||||
private:
|
||||
void NS_FASTCALL DoAppendFloat( double aFloat, int digits );
|
||||
// AppendPrintf31 truncates output to 31 ASCII characters
|
||||
void AppendPrintf31( const char* format, ... );
|
||||
public:
|
||||
|
||||
// AppendLiteral must ONLY be applied to an actual literal string.
|
||||
|
@ -735,7 +735,7 @@ nsTSubstring_CharT::StripChars( const char_type* aChars, PRUint32 aOffset )
|
||||
mLength = to - mData;
|
||||
}
|
||||
|
||||
void nsTSubstring_CharT::AppendPrintf( const char* format, ...)
|
||||
void nsTSubstring_CharT::AppendPrintf31( const char* format, ...)
|
||||
{
|
||||
char buf[32];
|
||||
va_list ap;
|
||||
@ -745,6 +745,17 @@ void nsTSubstring_CharT::AppendPrintf( const char* format, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void nsTSubstring_CharT::AppendPrintf( const char* format, ...)
|
||||
{
|
||||
char *buf;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
buf = PR_vsmprintf(format, ap);
|
||||
AppendASCII(buf);
|
||||
PR_smprintf_free(buf);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
/* hack to make sure we define Modified_cnvtf only once */
|
||||
#ifdef CharT_is_PRUnichar
|
||||
|
Loading…
Reference in New Issue
Block a user