diff options
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/PublicMethods.cpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 08d5cb707c..c030d6cad2 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -222,16 +222,10 @@ CFX_WideString CJS_PublicMethods::StrLTrim(FX_LPCWSTR pStr) CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr) { FX_LPCWSTR p = pStr; - while (*p) p++; - p--; - if (p >= pStr) - { - while (*p && *p == L' ') p--; - p++; - return CFX_WideString(pStr,p-pStr); - } - return L""; + while (p > pStr && *(p - 1) == L' ') p--; + + return CFX_WideString(pStr, p - pStr); } CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) @@ -243,22 +237,16 @@ CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) { while (*pStr && *pStr == ' ') pStr++; - return pStr; + return pStr; } CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) { FX_LPCSTR p = pStr; - while (*p) p++; - p--; - if (p >= pStr) - { - while (*p && *p == ' ') p--; - p++; - return CFX_ByteString(pStr,p-pStr); - } - return ""; + while (p > pStr && *(p - 1) == L' ') p--; + + return CFX_ByteString(pStr,p-pStr); } CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr) |