From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- xpcom/string/nsTSubstring.cpp | 9 +++++++++ xpcom/string/nsTSubstring.h | 8 ++++++++ 2 files changed, 17 insertions(+) (limited to 'xpcom/string') diff --git a/xpcom/string/nsTSubstring.cpp b/xpcom/string/nsTSubstring.cpp index ae9fda73c8..cff2031422 100644 --- a/xpcom/string/nsTSubstring.cpp +++ b/xpcom/string/nsTSubstring.cpp @@ -1322,6 +1322,9 @@ int_type ToIntegerCommon(const nsTSubstring& aSrc, nsresult* aErrorCode, break; // clang-format on case '-': + if constexpr (!std::is_signed_v) { + return 0; + } negate = true; break; default: @@ -1389,6 +1392,12 @@ int32_t nsTSubstring::ToInteger(nsresult* aErrorCode, return ToIntegerCommon(*this, aErrorCode, aRadix); } +template +uint32_t nsTSubstring::ToUnsignedInteger(nsresult* aErrorCode, + uint32_t aRadix) const { + return ToIntegerCommon(*this, aErrorCode, aRadix); +} + /** * nsTSubstring::ToInteger64 */ diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h index 0b4022823f..622b931afb 100644 --- a/xpcom/string/nsTSubstring.h +++ b/xpcom/string/nsTSubstring.h @@ -382,6 +382,14 @@ class nsTSubstring : public mozilla::detail::nsTStringRepr { */ int32_t ToInteger(nsresult* aErrorCode, uint32_t aRadix = 10) const; + /** + * Perform string to uint conversion. + * @param aErrorCode will contain error if one occurs + * @param aRadix is the radix to use. Only 10 and 16 are supported. + * @return int rep of string value, and possible (out) error code + */ + uint32_t ToUnsignedInteger(nsresult* aErrorCode, uint32_t aRadix = 10) const; + /** * Perform string to 64-bit int conversion. * @param aErrorCode will contain error if one occurs -- cgit v1.2.3