summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/util.cpp')
-rw-r--r--fpdfsdk/javascript/util.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 3338a3a126..7f0fe1eadb 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -70,40 +70,6 @@ const TbConvert TbConvertTable[] = {
#endif
};
-int ParseDataType(std::wstring* sFormat) {
- bool bPercent = false;
- for (size_t i = 0; i < sFormat->length(); ++i) {
- wchar_t c = (*sFormat)[i];
- if (c == L'%') {
- bPercent = true;
- continue;
- }
-
- if (bPercent) {
- if (c == L'c' || c == L'C' || c == L'd' || c == L'i' || c == L'o' ||
- c == L'u' || c == L'x' || c == L'X') {
- return UTIL_INT;
- }
- if (c == L'e' || c == L'E' || c == L'f' || c == L'g' || c == L'G') {
- return UTIL_DOUBLE;
- }
- if (c == L's' || c == L'S') {
- // Map s to S since we always deal internally
- // with wchar_t strings.
- (*sFormat)[i] = L'S';
- return UTIL_STRING;
- }
- if (c == L'.' || c == L'+' || c == L'-' || c == L'#' || c == L' ' ||
- std::iswdigit(c)) {
- continue;
- }
- break;
- }
- }
-
- return -1;
-}
-
} // namespace
util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
@@ -480,3 +446,37 @@ bool util::byteToChar(CJS_Runtime* pRuntime,
vRet = CJS_Value(pRuntime, wStr.c_str());
return true;
}
+
+int util::ParseDataType(std::wstring* sFormat) {
+ bool bPercent = false;
+ for (size_t i = 0; i < sFormat->length(); ++i) {
+ wchar_t c = (*sFormat)[i];
+ if (c == L'%') {
+ bPercent = true;
+ continue;
+ }
+
+ if (bPercent) {
+ if (c == L'c' || c == L'C' || c == L'd' || c == L'i' || c == L'o' ||
+ c == L'u' || c == L'x' || c == L'X') {
+ return UTIL_INT;
+ }
+ if (c == L'e' || c == L'E' || c == L'f' || c == L'g' || c == L'G') {
+ return UTIL_DOUBLE;
+ }
+ if (c == L's' || c == L'S') {
+ // Map s to S since we always deal internally
+ // with wchar_t strings.
+ (*sFormat)[i] = L'S';
+ return UTIL_STRING;
+ }
+ if (c == L'.' || c == L'+' || c == L'-' || c == L'#' || c == L' ' ||
+ std::iswdigit(c)) {
+ continue;
+ }
+ break;
+ }
+ }
+
+ return -1;
+}