summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-20 14:20:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-20 14:20:23 +0000
commite84e61852a4f3d8d7551d0eab3619916085fb557 (patch)
treec94e8da5b1a1cc1af831cf23288786153e509eb2
parentb6e0117285a918f4f2f3a350b8a648d2247d3d8e (diff)
downloadpdfium-e84e61852a4f3d8d7551d0eab3619916085fb557.tar.xz
c_str() calls not needed when writing to ostream
c_str() is a bit of a code smell, esp. since Byte/Wide strings know how to do this all by themselves. Change-Id: I9c86cee42c12a3f72ddb1d410a91cf25647d0ce6 Reviewed-on: https://pdfium-review.googlesource.com/35530 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp2
-rw-r--r--fxjs/cfxjse_formcalc_context_embeddertest.cpp116
3 files changed, 60 insertions, 60 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index ba8d03d7f9..80b121a572 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -391,7 +391,7 @@ void CPDF_PageContentGenerator::ProcessDefaultGraphics(
<< static_cast<int>(CFX_GraphStateData::LineCapButt) << " J "
<< static_cast<int>(CFX_GraphStateData::LineJoinMiter) << " j\n";
ByteString name = GetOrCreateDefaultGraphics();
- *buf << "/" << PDF_NameEncode(name).c_str() << " gs ";
+ *buf << "/" << PDF_NameEncode(name) << " gs ";
}
ByteString CPDF_PageContentGenerator::GetOrCreateDefaultGraphics() const {
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 379a8b999d..751a889b68 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -515,7 +515,7 @@ bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize) {
ByteString csBValue = pField->GetStringFor("V");
WideString csWValue = PDF_DecodeText(csBValue);
ByteString csValue_b = ByteString::FromUnicode(csWValue);
- fdfEncodedData << name_b.c_str() << "=" << csValue_b.c_str();
+ fdfEncodedData << name_b << "=" << csValue_b;
if (i != pFields->GetCount() - 1)
fdfEncodedData << "&";
}
diff --git a/fxjs/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/cfxjse_formcalc_context_embeddertest.cpp
index a227ac558d..58cb34b6d9 100644
--- a/fxjs/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/cfxjse_formcalc_context_embeddertest.cpp
@@ -89,8 +89,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Strings) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -385,8 +385,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DateFmt) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -447,8 +447,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, LocalDateFmt) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -469,8 +469,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_LocalTimeFmt) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -494,8 +494,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Num2Date) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString()) << "Program: " << tests[i].program;
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -518,8 +518,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Num2GMTime) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -538,8 +538,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Num2Time) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -596,8 +596,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, TimeFmt) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -819,8 +819,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Choose) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -929,8 +929,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Null) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
EXPECT_TRUE(Execute("Null() + 5"));
@@ -954,8 +954,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Ref) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -978,8 +978,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, UnitType) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1044,8 +1044,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Concat) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1069,8 +1069,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Decode) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1091,8 +1091,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Encode) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1111,8 +1111,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Format) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1131,8 +1131,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Left) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1171,8 +1171,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Lower) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1191,8 +1191,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Ltrim) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1210,8 +1210,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, DISABLED_Parse) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
EXPECT_TRUE(Execute("Parse(\"$9,999,999.99\", \"$1,234,567.89\")"));
@@ -1236,8 +1236,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Replace) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1256,8 +1256,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Right) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1276,8 +1276,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Rtrim) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1296,8 +1296,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Space) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1318,8 +1318,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Str) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1340,8 +1340,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Stuff) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1362,8 +1362,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Substr) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1392,8 +1392,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, Upper) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}
@@ -1418,8 +1418,8 @@ TEST_F(CFXJSE_FormCalcContextEmbedderTest, WordNum) {
CFXJSE_Value* value = GetValue();
EXPECT_TRUE(value->IsString());
EXPECT_STREQ(tests[i].result, value->ToString().c_str())
- << "Program: " << tests[i].program << " Result: '"
- << value->ToString().c_str() << "'";
+ << "Program: " << tests[i].program << " Result: '" << value->ToString()
+ << "'";
}
}