Rename FX_atof() and FX_ftoa().
FX_atof() is really StringToFloat(), whereas atof() is string-to-double.
Rename FX_ftoa() as well for consistency.
Change-Id: I628f17425b9235d7b2a86411c6f24956fc2a080a
Reviewed-on: https://pdfium-review.googlesource.com/c/46430
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_psengine.cpp b/core/fpdfapi/page/cpdf_psengine.cpp
index b1e32f8..0de5652 100644
--- a/core/fpdfapi/page/cpdf_psengine.cpp
+++ b/core/fpdfapi/page/cpdf_psengine.cpp
@@ -170,7 +170,7 @@
if (pFound != std::end(kPsOpNames) && pFound->name == word)
m_Operators.push_back(pdfium::MakeUnique<CPDF_PSOP>(pFound->op));
else
- m_Operators.push_back(pdfium::MakeUnique<CPDF_PSOP>(FX_atof(word)));
+ m_Operators.push_back(pdfium::MakeUnique<CPDF_PSOP>(StringToFloat(word)));
}
CPDF_PSEngine::CPDF_PSEngine() = default;
diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp
index 5db3ff7..c822b8e 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance.cpp
@@ -63,7 +63,7 @@
if (FindTagParamFromStart(&syntax, "Tf", 2)) {
csFontNameTag = ByteString(syntax.GetWord());
csFontNameTag.Delete(0, 1);
- *fFontSize = FX_atof(syntax.GetWord());
+ *fFontSize = StringToFloat(syntax.GetWord());
}
return {PDF_NameDecode(csFontNameTag.AsStringView())};
}
@@ -77,20 +77,20 @@
CPDF_SimpleParser syntax(m_csDA.AsStringView().span());
if (FindTagParamFromStart(&syntax, "g", 1)) {
- fc[0] = FX_atof(syntax.GetWord());
+ fc[0] = StringToFloat(syntax.GetWord());
return {CFX_Color::kGray};
}
if (FindTagParamFromStart(&syntax, "rg", 3)) {
- fc[0] = FX_atof(syntax.GetWord());
- fc[1] = FX_atof(syntax.GetWord());
- fc[2] = FX_atof(syntax.GetWord());
+ fc[0] = StringToFloat(syntax.GetWord());
+ fc[1] = StringToFloat(syntax.GetWord());
+ fc[2] = StringToFloat(syntax.GetWord());
return {CFX_Color::kRGB};
}
if (FindTagParamFromStart(&syntax, "k", 4)) {
- fc[0] = FX_atof(syntax.GetWord());
- fc[1] = FX_atof(syntax.GetWord());
- fc[2] = FX_atof(syntax.GetWord());
- fc[3] = FX_atof(syntax.GetWord());
+ fc[0] = StringToFloat(syntax.GetWord());
+ fc[1] = StringToFloat(syntax.GetWord());
+ fc[2] = StringToFloat(syntax.GetWord());
+ fc[3] = StringToFloat(syntax.GetWord());
return {CFX_Color::kCMYK};
}
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index fe09f7a..660f376 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -76,7 +76,7 @@
// static
ByteString ByteString::FormatFloat(float d) {
char buf[32];
- return ByteString(buf, FX_ftoa(d, buf));
+ return ByteString(buf, FloatToString(d, buf));
}
// static
diff --git a/core/fxcrt/cfx_widetextbuf.cpp b/core/fxcrt/cfx_widetextbuf.cpp
index 3d7da32..c2af175 100644
--- a/core/fxcrt/cfx_widetextbuf.cpp
+++ b/core/fxcrt/cfx_widetextbuf.cpp
@@ -50,7 +50,7 @@
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) {
char buf[32];
- size_t len = FX_ftoa((float)f, buf);
+ size_t len = FloatToString((float)f, buf);
ExpandBuf(len * sizeof(wchar_t));
wchar_t* str = reinterpret_cast<wchar_t*>(m_pBuffer.get() + m_DataSize);
for (size_t i = 0; i < len; i++) {
diff --git a/core/fxcrt/fx_number.cpp b/core/fxcrt/fx_number.cpp
index 68d5bd9..6c6e551 100644
--- a/core/fxcrt/fx_number.cpp
+++ b/core/fxcrt/fx_number.cpp
@@ -31,7 +31,7 @@
if (strc.Contains('.')) {
m_bInteger = false;
m_bSigned = true;
- m_FloatValue = FX_atof(strc);
+ m_FloatValue = StringToFloat(strc);
return;
}
diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp
index 944f467..64bcd77 100644
--- a/core/fxcrt/fx_string.cpp
+++ b/core/fxcrt/fx_string.cpp
@@ -48,7 +48,7 @@
} // namespace
-float FX_atof(const ByteStringView& strc) {
+float StringToFloat(const ByteStringView& strc) {
if (strc.IsEmpty())
return 0.0;
@@ -87,11 +87,11 @@
return bNegative ? -value : value;
}
-float FX_atof(const WideStringView& wsStr) {
- return FX_atof(FX_UTF8Encode(wsStr).c_str());
+float StringToFloat(const WideStringView& wsStr) {
+ return StringToFloat(FX_UTF8Encode(wsStr).c_str());
}
-size_t FX_ftoa(float d, char* buf) {
+size_t FloatToString(float d, char* buf) {
buf[0] = '0';
buf[1] = '\0';
if (d == 0.0f) {
diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h
index 670aa4d..8d93150 100644
--- a/core/fxcrt/fx_string.h
+++ b/core/fxcrt/fx_string.h
@@ -19,8 +19,8 @@
ByteString FX_UTF8Encode(const WideStringView& wsStr);
WideString FX_UTF8Decode(const ByteStringView& bsStr);
-float FX_atof(const ByteStringView& str);
-float FX_atof(const WideStringView& wsStr);
-size_t FX_ftoa(float f, char* buf);
+float StringToFloat(const ByteStringView& str);
+float StringToFloat(const WideStringView& wsStr);
+size_t FloatToString(float f, char* buf);
#endif // CORE_FXCRT_FX_STRING_H_
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index f199996..a8209e2 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -917,11 +917,11 @@
}
}
- int nDay = FX_atof(wsArray[2].AsStringView());
- int nHour = FX_atof(wsArray[3].AsStringView());
- int nMin = FX_atof(wsArray[4].AsStringView());
- int nSec = FX_atof(wsArray[5].AsStringView());
- int nYear = FX_atof(wsArray[7].AsStringView());
+ int nDay = StringToFloat(wsArray[2].AsStringView());
+ int nHour = StringToFloat(wsArray[3].AsStringView());
+ int nMin = StringToFloat(wsArray[4].AsStringView());
+ int nSec = StringToFloat(wsArray[5].AsStringView());
+ int nYear = StringToFloat(wsArray[7].AsStringView());
double dRet = FX_MakeDate(FX_MakeDay(nYear, nMonth - 1, nDay),
FX_MakeTime(nHour, nMin, nSec, 0));
if (std::isnan(dRet))
@@ -1297,7 +1297,7 @@
WideString trimmed = pFormField->GetValue();
trimmed.TrimRight();
trimmed.TrimLeft();
- dTemp = FX_atof(trimmed.AsStringView());
+ dTemp = StringToFloat(trimmed.AsStringView());
break;
}
case FormFieldType::kPushButton:
@@ -1312,7 +1312,7 @@
WideString trimmed = pFormCtrl->GetExportValue();
trimmed.TrimRight();
trimmed.TrimLeft();
- dTemp = FX_atof(trimmed.AsStringView());
+ dTemp = StringToFloat(trimmed.AsStringView());
break;
}
break;
@@ -1321,7 +1321,7 @@
WideString trimmed = pFormField->GetValue();
trimmed.TrimRight();
trimmed.TrimLeft();
- dTemp = FX_atof(trimmed.AsStringView());
+ dTemp = StringToFloat(trimmed.AsStringView());
}
break;
default: