summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-12 15:50:47 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-15 13:36:16 +0000
commitdc3a87c88da1ac710eadabeb2e5cf01aecb63f4b (patch)
tree26ddaea8a8521446a90531b8dd2281a4fdaec026 /xfa
parentef73cf5838ab3a902872d9fc57a90621cc3d7f21 (diff)
downloadpdfium-dc3a87c88da1ac710eadabeb2e5cf01aecb63f4b.tar.xz
Return unique_ptr from xfa lexer Scan() method
Change-Id: I7586194b59d2c8e28fc24b698ea93f4a2ab636e2 Reviewed-on: https://pdfium-review.googlesource.com/5474 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/fm2js/xfa_lexer.cpp15
-rw-r--r--xfa/fxfa/fm2js/xfa_lexer.h2
2 files changed, 9 insertions, 8 deletions
diff --git a/xfa/fxfa/fm2js/xfa_lexer.cpp b/xfa/fxfa/fm2js/xfa_lexer.cpp
index 44fa5150dc..e0511422a5 100644
--- a/xfa/fxfa/fm2js/xfa_lexer.cpp
+++ b/xfa/fxfa/fm2js/xfa_lexer.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/fm2js/xfa_lexer.h"
#include "core/fxcrt/fx_extension.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -132,13 +133,13 @@ CXFA_FMLexer::CXFA_FMLexer(const CFX_WideStringC& wsFormCalc,
CXFA_FMLexer::~CXFA_FMLexer() {}
CXFA_FMToken* CXFA_FMLexer::NextToken() {
- m_pToken.reset(Scan());
+ m_pToken = Scan();
return m_pToken.get();
}
-CXFA_FMToken* CXFA_FMLexer::Scan() {
+std::unique_ptr<CXFA_FMToken> CXFA_FMLexer::Scan() {
uint16_t ch = 0;
- CXFA_FMToken* p = new CXFA_FMToken(m_uCurrentLine);
+ auto p = pdfium::MakeUnique<CXFA_FMToken>(m_uCurrentLine);
if (!XFA_FMDChar::isValid(m_ptr)) {
ch = XFA_FMDChar::get(m_ptr);
Error(kFMErrUnsupportedChar, ch);
@@ -173,7 +174,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
case '"': {
const wchar_t* pTemp = 0;
p->m_type = TOKstring;
- iRet = String(p, m_ptr, pTemp);
+ iRet = String(p.get(), m_ptr, pTemp);
m_ptr = pTemp;
return p;
}
@@ -189,7 +190,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
case '9': {
p->m_type = TOKnumber;
const wchar_t* pTemp = 0;
- iRet = Number(p, m_ptr, pTemp);
+ iRet = Number(p.get(), m_ptr, pTemp);
m_ptr = pTemp;
if (iRet)
Error(kFMErrBadSuffixNumber);
@@ -317,7 +318,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
p->m_type = TOKnumber;
const wchar_t* pTemp = 0;
XFA_FMDChar::dec(m_ptr);
- iRet = Number(p, m_ptr, pTemp);
+ iRet = Number(p.get(), m_ptr, pTemp);
m_ptr = pTemp;
if (iRet)
Error(kFMErrBadSuffixNumber);
@@ -337,7 +338,7 @@ CXFA_FMToken* CXFA_FMLexer::Scan() {
break;
default: {
const wchar_t* pTemp = 0;
- iRet = Identifiers(p, m_ptr, pTemp);
+ iRet = Identifiers(p.get(), m_ptr, pTemp);
m_ptr = pTemp;
if (!iRet)
p->m_type = IsKeyword(p->m_wstring);
diff --git a/xfa/fxfa/fm2js/xfa_lexer.h b/xfa/fxfa/fm2js/xfa_lexer.h
index 100f757dc0..7968b78217 100644
--- a/xfa/fxfa/fm2js/xfa_lexer.h
+++ b/xfa/fxfa/fm2js/xfa_lexer.h
@@ -123,7 +123,7 @@ class CXFA_FMLexer {
bool HasError() const;
private:
- CXFA_FMToken* Scan();
+ std::unique_ptr<CXFA_FMToken> Scan();
const wchar_t* m_ptr;
uint32_t m_uCurrentLine;