summaryrefslogtreecommitdiffstats
path: root/xpcom/string
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /xpcom/string
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xpcom/string')
-rw-r--r--xpcom/string/nsTSubstring.cpp9
-rw-r--r--xpcom/string/nsTSubstring.h8
2 files changed, 17 insertions, 0 deletions
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<T>& aSrc, nsresult* aErrorCode,
break;
// clang-format on
case '-':
+ if constexpr (!std::is_signed_v<int_type>) {
+ return 0;
+ }
negate = true;
break;
default:
@@ -1389,6 +1392,12 @@ int32_t nsTSubstring<T>::ToInteger(nsresult* aErrorCode,
return ToIntegerCommon<T, int32_t>(*this, aErrorCode, aRadix);
}
+template <typename T>
+uint32_t nsTSubstring<T>::ToUnsignedInteger(nsresult* aErrorCode,
+ uint32_t aRadix) const {
+ return ToIntegerCommon<T, uint32_t>(*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
@@ -383,6 +383,14 @@ class nsTSubstring : public mozilla::detail::nsTStringRepr<T> {
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
* @param aRadix is the radix to use. Only 10 and 16 are supported.