summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-06-09 14:20:26 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-09 21:30:50 +0000
commit897c4b922f1fb50b942cda6cab0f4605f8afac3c (patch)
tree37587a503953043c62d3dd418d6a2cb6593d018c /core/fpdfapi/parser
parent262cf4665df3811ec6e68de48566dfa746609c66 (diff)
downloadpdfium-897c4b922f1fb50b942cda6cab0f4605f8afac3c.tar.xz
Converting CFX_ByteTextBuf to ostringstream in fdpf_parser_decode.cpp.chromium/3126
Bug: pdfium:731 Change-Id: I20c3d87dba91d1489794abb77afcd2d7e9db88fe Reviewed-on: https://pdfium-review.googlesource.com/6393 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp23
1 files changed, 12 insertions, 11 deletions
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 <limits.h>
#include <algorithm>
+#include <sstream>
#include <utility>
#include <vector>
@@ -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<char>(ch);
}
- result.AppendChar(')');
- return result.MakeString();
+ result << ')';
+ return CFX_ByteString(result);
}
bool FlateEncode(const uint8_t* src_buf,