Fix non-standard assignment operator return types.
PiperOrigin-RevId: 254795741
Change-Id: I647ebf11588e2818f633f0a2b7ff30f24bb5f439
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/56871
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpvt_wordinfo.cpp b/core/fpdfdoc/cpvt_wordinfo.cpp
index 7712bcd..1e1556b 100644
--- a/core/fpdfdoc/cpvt_wordinfo.cpp
+++ b/core/fpdfdoc/cpvt_wordinfo.cpp
@@ -36,9 +36,9 @@
CPVT_WordInfo::~CPVT_WordInfo() {}
-void CPVT_WordInfo::operator=(const CPVT_WordInfo& word) {
+CPVT_WordInfo& CPVT_WordInfo::operator=(const CPVT_WordInfo& word) {
if (this == &word)
- return;
+ return *this;
Word = word.Word;
nCharset = word.nCharset;
@@ -46,4 +46,5 @@
fWordX = word.fWordX;
fWordY = word.fWordY;
fWordTail = word.fWordTail;
+ return *this;
}
diff --git a/core/fpdfdoc/cpvt_wordinfo.h b/core/fpdfdoc/cpvt_wordinfo.h
index 401b9a5..e23ab2c 100644
--- a/core/fpdfdoc/cpvt_wordinfo.h
+++ b/core/fpdfdoc/cpvt_wordinfo.h
@@ -15,7 +15,7 @@
CPVT_WordInfo(const CPVT_WordInfo& word);
~CPVT_WordInfo();
- void operator=(const CPVT_WordInfo& word);
+ CPVT_WordInfo& operator=(const CPVT_WordInfo& word);
uint16_t Word;
int32_t nCharset;
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 824ec85..a38dc15 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -189,58 +189,58 @@
ByteString::~ByteString() {}
-const ByteString& ByteString::operator=(const char* pStr) {
- if (!pStr || !pStr[0])
+ByteString& ByteString::operator=(const char* str) {
+ if (!str || !str[0])
clear();
else
- AssignCopy(pStr, strlen(pStr));
+ AssignCopy(str, strlen(str));
return *this;
}
-const ByteString& ByteString::operator=(ByteStringView bstrc) {
- if (bstrc.IsEmpty())
+ByteString& ByteString::operator=(ByteStringView str) {
+ if (str.IsEmpty())
clear();
else
- AssignCopy(bstrc.unterminated_c_str(), bstrc.GetLength());
+ AssignCopy(str.unterminated_c_str(), str.GetLength());
return *this;
}
-const ByteString& ByteString::operator=(const ByteString& that) {
+ByteString& ByteString::operator=(const ByteString& that) {
if (m_pData != that.m_pData)
m_pData = that.m_pData;
return *this;
}
-const ByteString& ByteString::operator=(ByteString&& that) {
+ByteString& ByteString::operator=(ByteString&& that) {
if (m_pData != that.m_pData)
m_pData = std::move(that.m_pData);
return *this;
}
-const ByteString& ByteString::operator+=(const char* pStr) {
- if (pStr)
- Concat(pStr, strlen(pStr));
+ByteString& ByteString::operator+=(const char* str) {
+ if (str)
+ Concat(str, strlen(str));
return *this;
}
-const ByteString& ByteString::operator+=(char ch) {
+ByteString& ByteString::operator+=(char ch) {
Concat(&ch, 1);
return *this;
}
-const ByteString& ByteString::operator+=(const ByteString& str) {
+ByteString& ByteString::operator+=(const ByteString& str) {
if (str.m_pData)
Concat(str.m_pData->m_String, str.m_pData->m_nDataLength);
return *this;
}
-const ByteString& ByteString::operator+=(ByteStringView str) {
+ByteString& ByteString::operator+=(ByteStringView str) {
if (!str.IsEmpty())
Concat(str.unterminated_c_str(), str.GetLength());
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 72d629a..d525050 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -131,15 +131,15 @@
bool operator<(ByteStringView str) const;
bool operator<(const ByteString& other) const;
- const ByteString& operator=(const char* str);
- const ByteString& operator=(ByteStringView bstrc);
- const ByteString& operator=(const ByteString& that);
- const ByteString& operator=(ByteString&& that);
+ ByteString& operator=(const char* str);
+ ByteString& operator=(ByteStringView str);
+ ByteString& operator=(const ByteString& that);
+ ByteString& operator=(ByteString&& that);
- const ByteString& operator+=(char ch);
- const ByteString& operator+=(const char* str);
- const ByteString& operator+=(const ByteString& str);
- const ByteString& operator+=(ByteStringView str);
+ ByteString& operator+=(char ch);
+ ByteString& operator+=(const char* str);
+ ByteString& operator+=(const ByteString& str);
+ ByteString& operator+=(ByteStringView str);
CharType operator[](const size_t index) const {
CHECK(IsValidIndex(index));
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index a071693..5bb36da 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -24,7 +24,7 @@
CFX_PTemplate(BaseType new_x, BaseType new_y) : x(new_x), y(new_y) {}
CFX_PTemplate(const CFX_PTemplate& other) : x(other.x), y(other.y) {}
- CFX_PTemplate operator=(const CFX_PTemplate& other) {
+ CFX_PTemplate& operator=(const CFX_PTemplate& other) {
if (this != &other) {
x = other.x;
y = other.y;
@@ -81,7 +81,7 @@
width = 0;
height = 0;
}
- CFX_STemplate operator=(const CFX_STemplate& other) {
+ CFX_STemplate& operator=(const CFX_STemplate& other) {
if (this != &other) {
width = other.width;
height = other.height;
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index a00ce2d..2340b14 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -385,58 +385,58 @@
WideString::~WideString() {}
-const WideString& WideString::operator=(const wchar_t* pStr) {
- if (!pStr || !pStr[0])
+WideString& WideString::operator=(const wchar_t* str) {
+ if (!str || !str[0])
clear();
else
- AssignCopy(pStr, wcslen(pStr));
+ AssignCopy(str, wcslen(str));
return *this;
}
-const WideString& WideString::operator=(WideStringView stringSrc) {
- if (stringSrc.IsEmpty())
+WideString& WideString::operator=(WideStringView str) {
+ if (str.IsEmpty())
clear();
else
- AssignCopy(stringSrc.unterminated_c_str(), stringSrc.GetLength());
+ AssignCopy(str.unterminated_c_str(), str.GetLength());
return *this;
}
-const WideString& WideString::operator=(const WideString& that) {
+WideString& WideString::operator=(const WideString& that) {
if (m_pData != that.m_pData)
m_pData = that.m_pData;
return *this;
}
-const WideString& WideString::operator=(WideString&& that) {
+WideString& WideString::operator=(WideString&& that) {
if (m_pData != that.m_pData)
m_pData = std::move(that.m_pData);
return *this;
}
-const WideString& WideString::operator+=(const wchar_t* pStr) {
- if (pStr)
- Concat(pStr, wcslen(pStr));
+WideString& WideString::operator+=(const wchar_t* str) {
+ if (str)
+ Concat(str, wcslen(str));
return *this;
}
-const WideString& WideString::operator+=(wchar_t ch) {
+WideString& WideString::operator+=(wchar_t ch) {
Concat(&ch, 1);
return *this;
}
-const WideString& WideString::operator+=(const WideString& str) {
+WideString& WideString::operator+=(const WideString& str) {
if (str.m_pData)
Concat(str.m_pData->m_String, str.m_pData->m_nDataLength);
return *this;
}
-const WideString& WideString::operator+=(WideStringView str) {
+WideString& WideString::operator+=(WideStringView str) {
if (!str.IsEmpty())
Concat(str.unterminated_c_str(), str.GetLength());
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index ec121ba..96bb3c4 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -111,15 +111,15 @@
bool IsValidIndex(size_t index) const { return index < GetLength(); }
bool IsValidLength(size_t length) const { return length <= GetLength(); }
- const WideString& operator=(const wchar_t* str);
- const WideString& operator=(WideStringView stringSrc);
- const WideString& operator=(const WideString& that);
- const WideString& operator=(WideString&& that);
+ WideString& operator=(const wchar_t* str);
+ WideString& operator=(WideStringView str);
+ WideString& operator=(const WideString& that);
+ WideString& operator=(WideString&& that);
- const WideString& operator+=(const wchar_t* str);
- const WideString& operator+=(wchar_t ch);
- const WideString& operator+=(const WideString& str);
- const WideString& operator+=(WideStringView str);
+ WideString& operator+=(const wchar_t* str);
+ WideString& operator+=(wchar_t ch);
+ WideString& operator+=(const WideString& str);
+ WideString& operator+=(WideStringView str);
bool operator==(const wchar_t* ptr) const;
bool operator==(WideStringView str) const;