diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-09-27 10:53:11 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-27 16:11:38 +0000 |
commit | 875e98c581952478f3a3ccef9b2f2e3ed06c5346 (patch) | |
tree | 8e0d7e032056bf4c73d6da43c0f3ce4eadb74dfd /fpdfsdk | |
parent | cc3a3ee3ebcc1baabdfa7ffca5876dbbfa3980c1 (diff) | |
download | pdfium-875e98c581952478f3a3ccef9b2f2e3ed06c5346.tar.xz |
Remove FX_STRSIZE and replace with size_t
BUG=pdfium:828
Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16
Reviewed-on: https://pdfium-review.googlesource.com/13230
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.h | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdf_sysfontinfo.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfdoc.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfedittext.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfppo.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/fpdftext.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/fpdfview.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/javascript/Document.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/javascript/PublicMethods.cpp | 58 | ||||
-rw-r--r-- | fpdfsdk/javascript/PublicMethods.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/util.cpp | 4 |
13 files changed, 60 insertions, 61 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index fd0dffadba..635655c033 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -442,7 +442,7 @@ bool CPDFSDK_InterForm::SubmitFields(const WideString& csDestination, bool bUrlEncoded) { ByteString textBuf = ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude); - FX_STRSIZE nBufSize = textBuf.GetLength(); + size_t nBufSize = textBuf.GetLength(); if (nBufSize == 0) return false; @@ -465,8 +465,7 @@ bool CPDFSDK_InterForm::SubmitFields(const WideString& csDestination, return true; } -bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, - FX_STRSIZE& nBufSize) { +bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize) { std::unique_ptr<CFDF_Document> pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); if (!pFDF) @@ -538,14 +537,14 @@ bool CPDFSDK_InterForm::SubmitForm(const WideString& sDestination, ByteString fdfBuffer = pFDFDoc->WriteToString(); - FX_STRSIZE nBufSize = fdfBuffer.GetLength(); - if (nBufSize == 0) + if (fdfBuffer.IsEmpty()) return false; - uint8_t* pLocalBuffer = FX_Alloc(uint8_t, nBufSize); - memcpy(pLocalBuffer, fdfBuffer.c_str(), nBufSize); + uint8_t* pLocalBuffer = FX_Alloc(uint8_t, fdfBuffer.GetLength()); + memcpy(pLocalBuffer, fdfBuffer.c_str(), fdfBuffer.GetLength()); uint8_t* pBuffer = pLocalBuffer; + size_t nBufSize = fdfBuffer.GetLength(); if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) { FX_Free(pLocalBuffer); return false; diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h index 76acaf9ebf..ae39913c4c 100644 --- a/fpdfsdk/cpdfsdk_interform.h +++ b/fpdfsdk/cpdfsdk_interform.h @@ -115,7 +115,7 @@ class CPDFSDK_InterForm : public IPDF_FormNotify { int BeforeFormImportData(CPDF_InterForm* pForm) override; void AfterFormImportData(CPDF_InterForm* pForm) override; - bool FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize); + bool FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize); int GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const; diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp index 67b9a08beb..f1f165afcb 100644 --- a/fpdfsdk/fpdf_sysfontinfo.cpp +++ b/fpdfsdk/fpdf_sysfontinfo.cpp @@ -171,7 +171,7 @@ static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis, auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); if (!pDefault->m_pFontInfo->GetFaceName(hFont, &name)) return 0; - if (name.GetLength() >= static_cast<FX_STRSIZE>(buf_size)) + if (name.GetLength() >= static_cast<size_t>(buf_size)) return name.GetLength() + 1; strncpy(buffer, name.c_str(), diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp index c3910b2883..c536c73254 100644 --- a/fpdfsdk/fpdfdoc.cpp +++ b/fpdfsdk/fpdfdoc.cpp @@ -103,7 +103,7 @@ FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { if (!pDoc) return nullptr; CPDF_BookmarkTree tree(pDoc); - FX_STRSIZE len = WideString::WStringLength(title); + size_t len = WideString::WStringLength(title); WideString encodedTitle = WideString::FromUTF16LE(title, len); std::set<CPDF_Dictionary*> visited; return FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict(); diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp index 2ac32b82a3..2a9ef53273 100644 --- a/fpdfsdk/fpdfedittext.cpp +++ b/fpdfsdk/fpdfedittext.cpp @@ -420,7 +420,7 @@ FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text) { if (!pTextObj) return false; - FX_STRSIZE len = WideString::WStringLength(text); + size_t len = WideString::WStringLength(text); WideString encodedText = WideString::FromUTF16LE(text, len); ByteString byteText; for (wchar_t wc : encodedText) { diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 65b0ae9852..3d821b601f 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -404,7 +404,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle, if (!pPageView) return; - FX_STRSIZE len = WideString::WStringLength(wsText); + size_t len = WideString::WStringLength(wsText); WideString wide_str_text = WideString::FromUTF16LE(wsText, len); pPageView->ReplaceSelection(wide_str_text); diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp index 153ae2e20c..3caba0e1e4 100644 --- a/fpdfsdk/fpdfppo.cpp +++ b/fpdfsdk/fpdfppo.cpp @@ -77,16 +77,16 @@ bool ParserPageRangeString(ByteString rangstring, return true; rangstring.Remove(' '); - FX_STRSIZE nLength = rangstring.GetLength(); + size_t nLength = rangstring.GetLength(); ByteString cbCompareString("0123456789-,"); - for (FX_STRSIZE i = 0; i < nLength; ++i) { + for (size_t i = 0; i < nLength; ++i) { if (!cbCompareString.Contains(rangstring[i])) return false; } ByteString cbMidRange; - FX_STRSIZE nStringFrom = 0; - pdfium::Optional<FX_STRSIZE> nStringTo = 0; + size_t nStringFrom = 0; + pdfium::Optional<size_t> nStringTo = 0; while (nStringTo < nLength) { nStringTo = rangstring.Find(',', nStringFrom); if (!nStringTo.has_value()) @@ -106,7 +106,7 @@ bool ParserPageRangeString(ByteString rangstring, return false; nMid = nMid.value() + 1; - FX_STRSIZE nEnd = cbMidRange.GetLength() - nMid.value(); + size_t nEnd = cbMidRange.GetLength() - nMid.value(); if (nEnd == 0) return false; diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp index 9742974c3a..ae6841febc 100644 --- a/fpdfsdk/fpdftext.cpp +++ b/fpdfsdk/fpdftext.cpp @@ -175,8 +175,8 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetText(FPDF_TEXTPAGE text_page, if (str.GetLength() <= 0) return 0; - if (str.GetLength() > static_cast<FX_STRSIZE>(count)) - str = str.Left(static_cast<FX_STRSIZE>(count)); + if (str.GetLength() > static_cast<size_t>(count)) + str = str.Left(static_cast<size_t>(count)); // UFT16LE_Encode doesn't handle surrogate pairs properly, so it is expected // the number of items to stay the same. @@ -256,11 +256,11 @@ FPDFText_FindStart(FPDF_TEXTPAGE text_page, CPDF_TextPageFind* textpageFind = new CPDF_TextPageFind(CPDFTextPageFromFPDFTextPage(text_page)); - FX_STRSIZE len = WideString::WStringLength(findwhat); + size_t len = WideString::WStringLength(findwhat); textpageFind->FindFirst(WideString::FromUTF16LE(findwhat, len), flags, start_index >= 0 - ? pdfium::Optional<FX_STRSIZE>(start_index) - : pdfium::Optional<FX_STRSIZE>()); + ? pdfium::Optional<size_t>(start_index) + : pdfium::Optional<size_t>()); return textpageFind; } diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index cb5edcf251..bbd60bdd59 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -240,7 +240,7 @@ size_t FPDF_FileHandlerContext::ReadBlock(void* buffer, size_t size) { return 0; FX_FILESIZE dwAvail = nSize - m_nCurPos; if (dwAvail < (FX_FILESIZE)size) - size = (size_t)dwAvail; + size = static_cast<size_t>(dwAvail); if (m_pFS->ReadBlock(m_pFS->clientData, (FPDF_DWORD)m_nCurPos, buffer, (FPDF_DWORD)size) == 0) { m_nCurPos += size; diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 0c611c1211..5d0f35c1bb 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -386,7 +386,7 @@ bool Document::mailForm(CJS_Runtime* pRuntime, if (sTextBuf.GetLength() == 0) return false; - FX_STRSIZE nBufSize = sTextBuf.GetLength(); + size_t nBufSize = sTextBuf.GetLength(); char* pMutableBuf = FX_Alloc(char, nBufSize); memcpy(pMutableBuf, sTextBuf.c_str(), nBufSize); @@ -1015,7 +1015,7 @@ bool Document::documentFileName(CJS_Runtime* pRuntime, return false; } WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath(); - FX_STRSIZE i = wsFilePath.GetLength(); + size_t i = wsFilePath.GetLength(); for (; i > 0; i--) { if (wsFilePath[i - 1] == L'\\' || wsFilePath[i - 1] == L'/') break; diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index c065bd0946..af4715987f 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -224,12 +224,12 @@ CJS_Array CJS_PublicMethods::AF_MakeArrayFromList(CJS_Runtime* pRuntime, } int CJS_PublicMethods::ParseStringInteger(const WideString& str, - FX_STRSIZE nStart, - FX_STRSIZE& nSkip, - FX_STRSIZE nMaxStep) { + size_t nStart, + size_t& nSkip, + size_t nMaxStep) { int nRet = 0; nSkip = 0; - for (FX_STRSIZE i = nStart, sz = str.GetLength(); i < sz; i++) { + for (size_t i = nStart, sz = str.GetLength(); i < sz; i++) { if (i - nStart > 10) break; @@ -247,11 +247,11 @@ int CJS_PublicMethods::ParseStringInteger(const WideString& str, } WideString CJS_PublicMethods::ParseStringString(const WideString& str, - FX_STRSIZE nStart, - FX_STRSIZE& nSkip) { + size_t nStart, + size_t& nSkip) { WideString swRet; nSkip = 0; - for (FX_STRSIZE i = nStart, sz = str.GetLength(); i < sz; i++) { + for (size_t i = nStart, sz = str.GetLength(); i < sz; i++) { wchar_t c = str[i]; if (!std::iswdigit(c)) break; @@ -276,10 +276,10 @@ double CJS_PublicMethods::ParseNormalDate(const WideString& value, int number[3]; - FX_STRSIZE nSkip = 0; - FX_STRSIZE nLen = value.GetLength(); - FX_STRSIZE nIndex = 0; - FX_STRSIZE i = 0; + size_t nSkip = 0; + size_t nLen = value.GetLength(); + size_t nIndex = 0; + size_t i = 0; while (i < nLen) { if (nIndex > 2) break; @@ -364,8 +364,8 @@ double CJS_PublicMethods::MakeRegularDate(const WideString& value, bool bExit = false; bool bBadFormat = false; - FX_STRSIZE i = 0; - FX_STRSIZE j = 0; + size_t i = 0; + size_t j = 0; while (i < format.GetLength()) { if (bExit) @@ -390,9 +390,9 @@ double CJS_PublicMethods::MakeRegularDate(const WideString& value, case 'M': case 's': case 't': { - FX_STRSIZE oldj = j; - FX_STRSIZE nSkip = 0; - FX_STRSIZE remaining = format.GetLength() - i - 1; + size_t oldj = j; + size_t nSkip = 0; + size_t remaining = format.GetLength() - i - 1; if (remaining == 0 || format[i + 1] != c) { switch (c) { @@ -626,10 +626,10 @@ WideString CJS_PublicMethods::MakeFormatDate(double dDate, int nMin = JS_GetMinFromTime(dDate); int nSec = JS_GetSecFromTime(dDate); - FX_STRSIZE i = 0; + size_t i = 0; while (i < format.GetLength()) { wchar_t c = format[i]; - FX_STRSIZE remaining = format.GetLength() - i - 1; + size_t remaining = format.GetLength() - i - 1; sPart = L""; switch (c) { case 'y': @@ -804,7 +804,7 @@ bool CJS_PublicMethods::AFNumber_Format(CJS_Runtime* pRuntime, } // Processing separator style - if (static_cast<FX_STRSIZE>(iDec2) < strValue.GetLength()) { + if (static_cast<size_t>(iDec2) < strValue.GetLength()) { if (iSepStyle == 2 || iSepStyle == 3) strValue.Replace(".", ","); @@ -946,7 +946,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime, const wchar_t cSep = iSepStyle < 2 ? L'.' : L','; bool bHasSep = wstrValue.Contains(cSep); - for (FX_STRSIZE i = 0; i < wstrChange.GetLength(); ++i) { + for (size_t i = 0; i < wstrChange.GetLength(); ++i) { if (wstrChange[i] == cSep) { if (bHasSep) { pEvent->Rc() = false; @@ -982,9 +982,9 @@ bool CJS_PublicMethods::AFNumber_Keystroke(CJS_Runtime* pRuntime, WideString wprefix = wstrValue.Left(pEvent->SelStart()); WideString wpostfix; if (pEvent->SelEnd() >= 0 && - static_cast<FX_STRSIZE>(pEvent->SelEnd()) < wstrValue.GetLength()) + static_cast<size_t>(pEvent->SelEnd()) < wstrValue.GetLength()) wpostfix = wstrValue.Right(wstrValue.GetLength() - - static_cast<FX_STRSIZE>(pEvent->SelEnd())); + static_cast<size_t>(pEvent->SelEnd())); val = wprefix + wstrChange + wpostfix; return true; } @@ -1410,7 +1410,7 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx( if (valEvent.IsEmpty()) return true; - FX_STRSIZE iIndexMask = 0; + size_t iIndexMask = 0; for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) { if (!maskSatisfied(valEvent[iIndexMask], wstrMask[iIndexMask])) break; @@ -1430,9 +1430,9 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx( return true; WideString wChange = wideChange; - FX_STRSIZE iIndexMask = pEvent->SelStart(); - FX_STRSIZE combined_len = valEvent.GetLength() + wChange.GetLength() + - pEvent->SelStart() - pEvent->SelEnd(); + size_t iIndexMask = pEvent->SelStart(); + size_t combined_len = valEvent.GetLength() + wChange.GetLength() + + pEvent->SelStart() - pEvent->SelEnd(); if (combined_len > wstrMask.GetLength()) { AlertIfPossible(pContext, JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str()); @@ -1447,7 +1447,7 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx( return true; } - for (FX_STRSIZE i = 0; i < wChange.GetLength(); ++i) { + for (size_t i = 0; i < wChange.GetLength(); ++i) { if (iIndexMask >= wstrMask.GetLength()) { AlertIfPossible(pContext, JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str()); @@ -1537,9 +1537,9 @@ bool CJS_PublicMethods::AFMergeChange(CJS_Runtime* pRuntime, prefix = L""; if (pEventHandler->SelEnd() >= 0 && - static_cast<FX_STRSIZE>(pEventHandler->SelEnd()) <= swValue.GetLength()) + static_cast<size_t>(pEventHandler->SelEnd()) <= swValue.GetLength()) postfix = swValue.Right(swValue.GetLength() - - static_cast<FX_STRSIZE>(pEventHandler->SelEnd())); + static_cast<size_t>(pEventHandler->SelEnd())); else postfix = L""; diff --git a/fpdfsdk/javascript/PublicMethods.h b/fpdfsdk/javascript/PublicMethods.h index 365df3e5dc..abce08b8a6 100644 --- a/fpdfsdk/javascript/PublicMethods.h +++ b/fpdfsdk/javascript/PublicMethods.h @@ -133,12 +133,12 @@ class CJS_PublicMethods : public CJS_Object { JS_STATIC_DECLARE_GLOBAL_FUN(); static int ParseStringInteger(const WideString& string, - FX_STRSIZE nStart, - FX_STRSIZE& nSkip, - FX_STRSIZE nMaxStep); + size_t nStart, + size_t& nSkip, + size_t nMaxStep); static WideString ParseStringString(const WideString& string, - FX_STRSIZE nStart, - FX_STRSIZE& nSkip); + size_t nStart, + size_t& nSkip); static double MakeRegularDate(const WideString& value, const WideString& format, bool* bWrongFormat); diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 3fe7a86dc2..c4b15685dd 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -297,8 +297,8 @@ static wchar_t TranslateCase(wchar_t input, CaseMode eMode) { WideString util::printx(const WideString& wsFormat, const WideString& wsSource) { WideString wsResult; - FX_STRSIZE iSourceIdx = 0; - FX_STRSIZE iFormatIdx = 0; + size_t iSourceIdx = 0; + size_t iFormatIdx = 0; CaseMode eCaseMode = kPreserveCase; bool bEscaped = false; while (iFormatIdx < wsFormat.GetLength()) { |