summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-11-10 18:43:33 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-10 18:43:33 +0000
commit414af463d5504e456dc6a7f8ec7950fe1c55e393 (patch)
tree2cf1a8564b530627f435ba41b8af29eb18d69d63 /core
parenta8caf1c23a8376705d8cb08500d82aa6e948a082 (diff)
downloadpdfium-414af463d5504e456dc6a7f8ec7950fe1c55e393.tar.xz
[Merge M63] Revert cleanup of IsHyphen and reimplement
The original version of this code was landed in https://pdfium-review.googlesource.com/c/pdfium/+/13690/. A corner case has been found that breaks. In this CL I have reverted the changes in IsHyphen and implemented a less aggressive cleanup that I have tested works as expected. TBR=dsinclair@chromium.org BUG=chromium:781804 Change-Id: I3b36f420834081fdd9e1ae17efc234b561b4df41 Reviewed-on: https://pdfium-review.googlesource.com/17950 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-on: https://pdfium-review.googlesource.com/18330 Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdftext/cpdf_textpage.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 82778b1658..0a7a39fff5 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -1218,25 +1218,29 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode(
}
bool CPDF_TextPage::IsHyphen(wchar_t curChar) const {
- WideStringView curText;
- if (!m_TempTextBuf.IsEmpty())
- curText = m_TempTextBuf.AsStringView();
- else if (!m_TextBuf.IsEmpty())
+ WideStringView curText = m_TempTextBuf.AsStringView();
+ if (curText.IsEmpty())
curText = m_TextBuf.AsStringView();
- else
- return false;
- curText = curText.TrimmedRight(0x20);
- if (curText.GetLength() < 2)
+ if (curText.IsEmpty())
return false;
- // Extracting the last 2 characters, since they are all that matter
- curText = curText.Right(2);
- if (!IsHyphenCode(curText.Last()))
- return false;
+ auto iter = curText.rbegin();
+ for (; iter != curText.rend() && *iter == 0x20; iter++) {
+ // Do nothing
+ }
- if (FXSYS_iswalpha(curText.First() && FXSYS_iswalnum(curChar)))
- return true;
+ if (iter != curText.rend()) {
+ if (!IsHyphenCode(*iter))
+ return false;
+ iter++;
+ if (FXSYS_iswalpha(*iter) && FXSYS_iswalpha(*iter))
+ return true;
+ } else {
+ iter--;
+ if (!IsHyphenCode(*iter))
+ return false;
+ }
const PAGECHAR_INFO* preInfo;
if (!m_TempCharList.empty())