diff options
author | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
commit | 9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch) | |
tree | c97037f398d714665aefccb6eb54d0969ad7030c /core/src/fpdftext/unicodenormalization.cpp | |
parent | 780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff) | |
download | pdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz |
XFA: clang-format all pdfium code.
No behavior change.
Generated by:
find . -name '*.cpp' -o -name '*.h' | \
grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \
xargs ../../buildtools/mac/clang-format -i
Then manually merged https://codereview.chromium.org/1269223002/
See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion.
BUG=none
Diffstat (limited to 'core/src/fpdftext/unicodenormalization.cpp')
-rw-r--r-- | core/src/fpdftext/unicodenormalization.cpp | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/core/src/fpdftext/unicodenormalization.cpp b/core/src/fpdftext/unicodenormalization.cpp index 468900c7d8..446c6940eb 100644 --- a/core/src/fpdftext/unicodenormalization.cpp +++ b/core/src/fpdftext/unicodenormalization.cpp @@ -12,65 +12,60 @@ extern const FX_WCHAR g_UnicodeData_Normalization_Map2[]; extern const FX_WCHAR g_UnicodeData_Normalization_Map3[]; extern const FX_WCHAR g_UnicodeData_Normalization_Map4[]; const FX_WCHAR* g_UnicodeData_Normalization_Maps[5] = { - NULL, - g_UnicodeData_Normalization_Map1, - g_UnicodeData_Normalization_Map2, - g_UnicodeData_Normalization_Map3, - g_UnicodeData_Normalization_Map4 -}; -FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst) -{ - wch = wch & 0xFFFF; - FX_WCHAR wFind = g_UnicodeData_Normalization[wch]; - if (!wFind) { - if (pDst) { - *pDst = wch; - } - return 1; - } - if(wFind >= 0x8000) { - wch = wFind - 0x8000; - wFind = 1; - } else { - wch = wFind & 0x0FFF; - wFind >>= 12; - } - const FX_WCHAR* pMap = g_UnicodeData_Normalization_Maps[wFind]; - if (pMap == g_UnicodeData_Normalization_Map4) { - pMap = g_UnicodeData_Normalization_Map4 + wch; - wFind = (FX_WCHAR)(*pMap ++); - } else { - pMap += wch; - } + NULL, g_UnicodeData_Normalization_Map1, g_UnicodeData_Normalization_Map2, + g_UnicodeData_Normalization_Map3, g_UnicodeData_Normalization_Map4}; +FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst) { + wch = wch & 0xFFFF; + FX_WCHAR wFind = g_UnicodeData_Normalization[wch]; + if (!wFind) { if (pDst) { - FX_WCHAR n = wFind; - while (n --) { - *pDst ++ = *pMap ++; - } + *pDst = wch; } - return (FX_STRSIZE)wFind; -} -FX_STRSIZE FX_WideString_GetNormalization(const CFX_WideStringC& wsSrc, FX_WCHAR* pDst) -{ - FX_STRSIZE nCount = 0; - for (FX_STRSIZE len = 0; len < wsSrc.GetLength(); len ++) { - FX_WCHAR wch = wsSrc.GetAt(len); - if(pDst) { - nCount += FX_Unicode_GetNormalization(wch, pDst + nCount); - } else { - nCount += FX_Unicode_GetNormalization(wch, pDst); - } + return 1; + } + if (wFind >= 0x8000) { + wch = wFind - 0x8000; + wFind = 1; + } else { + wch = wFind & 0x0FFF; + wFind >>= 12; + } + const FX_WCHAR* pMap = g_UnicodeData_Normalization_Maps[wFind]; + if (pMap == g_UnicodeData_Normalization_Map4) { + pMap = g_UnicodeData_Normalization_Map4 + wch; + wFind = (FX_WCHAR)(*pMap++); + } else { + pMap += wch; + } + if (pDst) { + FX_WCHAR n = wFind; + while (n--) { + *pDst++ = *pMap++; } - return nCount; + } + return (FX_STRSIZE)wFind; } -FX_STRSIZE FX_WideString_GetNormalization(const CFX_WideStringC& wsSrc, CFX_WideString &wsDst) -{ - FX_STRSIZE nLen = FX_WideString_GetNormalization(wsSrc, (FX_WCHAR*)NULL); - if (!nLen) { - return 0; +FX_STRSIZE FX_WideString_GetNormalization(const CFX_WideStringC& wsSrc, + FX_WCHAR* pDst) { + FX_STRSIZE nCount = 0; + for (FX_STRSIZE len = 0; len < wsSrc.GetLength(); len++) { + FX_WCHAR wch = wsSrc.GetAt(len); + if (pDst) { + nCount += FX_Unicode_GetNormalization(wch, pDst + nCount); + } else { + nCount += FX_Unicode_GetNormalization(wch, pDst); } - FX_WCHAR* pBuf = wsDst.GetBuffer(nLen); - FX_WideString_GetNormalization(wsSrc, pBuf); - wsDst.ReleaseBuffer(nLen); - return nLen; + } + return nCount; +} +FX_STRSIZE FX_WideString_GetNormalization(const CFX_WideStringC& wsSrc, + CFX_WideString& wsDst) { + FX_STRSIZE nLen = FX_WideString_GetNormalization(wsSrc, (FX_WCHAR*)NULL); + if (!nLen) { + return 0; + } + FX_WCHAR* pBuf = wsDst.GetBuffer(nLen); + FX_WideString_GetNormalization(wsSrc, pBuf); + wsDst.ReleaseBuffer(nLen); + return nLen; } |