From 897c4b922f1fb50b942cda6cab0f4605f8afac3c Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Fri, 9 Jun 2017 14:20:26 -0400 Subject: Converting CFX_ByteTextBuf to ostringstream in fdpf_parser_decode.cpp. Bug: pdfium:731 Change-Id: I20c3d87dba91d1489794abb77afcd2d7e9db88fe Reviewed-on: https://pdfium-review.googlesource.com/6393 Reviewed-by: Lei Zhang Commit-Queue: Lei Zhang --- core/fpdfapi/parser/fpdf_parser_decode.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 3d7b9ffd59..a2ba203488 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -512,20 +513,20 @@ CFX_ByteString PDF_EncodeText(const CFX_WideString& str) { } CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) { - CFX_ByteTextBuf result; + std::ostringstream result; int srclen = src.GetLength(); if (bHex) { - result.AppendChar('<'); + result << '<'; for (int i = 0; i < srclen; i++) { char buf[2]; FXSYS_IntToTwoHexChars(src[i], buf); - result.AppendChar(buf[0]); - result.AppendChar(buf[1]); + result << buf[0]; + result << buf[1]; } - result.AppendChar('>'); - return result.MakeString(); + result << '>'; + return CFX_ByteString(result); } - result.AppendChar('('); + result << '('; for (int i = 0; i < srclen; i++) { uint8_t ch = src[i]; if (ch == 0x0a) { @@ -537,11 +538,11 @@ CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex) { continue; } if (ch == ')' || ch == '\\' || ch == '(') - result.AppendChar('\\'); - result.AppendChar(ch); + result << '\\'; + result << static_cast(ch); } - result.AppendChar(')'); - return result.MakeString(); + result << ')'; + return CFX_ByteString(result); } bool FlateEncode(const uint8_t* src_buf, -- cgit v1.2.3