зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1362194 - part 1 - add a fallible CopyASCIItoUTF16 function; r=mccr8
We already have all the machinery to expose a function like this, we just need to write it.
This commit is contained in:
Родитель
38846a0f8f
Коммит
f6465f98b9
|
@ -87,9 +87,20 @@ LossyCopyUTF16toASCII(const nsAString& aSource, nsACString& aDest)
|
||||||
|
|
||||||
void
|
void
|
||||||
CopyASCIItoUTF16(const nsACString& aSource, nsAString& aDest)
|
CopyASCIItoUTF16(const nsACString& aSource, nsAString& aDest)
|
||||||
|
{
|
||||||
|
if (!CopyASCIItoUTF16(aSource, aDest, mozilla::fallible)) {
|
||||||
|
// Note that this may wildly underestimate the allocation that failed, as
|
||||||
|
// we report the length of aSource as UTF-16 instead of UTF-8.
|
||||||
|
aDest.AllocFailed(aDest.Length() + aSource.Length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CopyASCIItoUTF16(const nsACString& aSource, nsAString& aDest,
|
||||||
|
const mozilla::fallible_t& aFallible)
|
||||||
{
|
{
|
||||||
aDest.Truncate();
|
aDest.Truncate();
|
||||||
AppendASCIItoUTF16(aSource, aDest);
|
return AppendASCIItoUTF16(aSource, aDest, aFallible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -35,6 +35,8 @@ Distance(const nsReadingIterator<char>& aStart,
|
||||||
|
|
||||||
void LossyCopyUTF16toASCII(const nsAString& aSource, nsACString& aDest);
|
void LossyCopyUTF16toASCII(const nsAString& aSource, nsACString& aDest);
|
||||||
void CopyASCIItoUTF16(const nsACString& aSource, nsAString& aDest);
|
void CopyASCIItoUTF16(const nsACString& aSource, nsAString& aDest);
|
||||||
|
MOZ_MUST_USE bool CopyASCIItoUTF16(const nsACString& aSource, nsAString& aDest,
|
||||||
|
const mozilla::fallible_t&);
|
||||||
|
|
||||||
void LossyCopyUTF16toASCII(const char16ptr_t aSource, nsACString& aDest);
|
void LossyCopyUTF16toASCII(const char16ptr_t aSource, nsACString& aDest);
|
||||||
void CopyASCIItoUTF16(const char* aSource, nsAString& aDest);
|
void CopyASCIItoUTF16(const char* aSource, nsAString& aDest);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче