diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2020-10-09 20:50:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-13 19:30:17 +0000 |
commit | ff37b70553dbfd0b2aaeabb8a29c4d492507a9d3 (patch) | |
tree | 728b9266de70d79901eed31b0e39de0abc78cf24 /src/mongo/scripting | |
parent | bbe604a5b3f94f78a30a76941ea89c0ca5db14d2 (diff) | |
download | mongo-ff37b70553dbfd0b2aaeabb8a29c4d492507a9d3.tar.gz |
SERVER-50917 util/ctype.h to replace <cctype> & <ctype.h> funcs
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/engine.cpp | 15 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/bindata.cpp | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp index 42ccc5f7154..90f29d579cf 100644 --- a/src/mongo/scripting/engine.cpp +++ b/src/mongo/scripting/engine.cpp @@ -33,15 +33,17 @@ #include "mongo/scripting/engine.h" +#include <algorithm> #include <boost/filesystem/operations.hpp> -#include <cctype> +#include "mongo/base/string_data.h" #include "mongo/client/dbclient_base.h" #include "mongo/client/dbclient_cursor.h" #include "mongo/db/operation_context.h" #include "mongo/db/service_context.h" #include "mongo/logv2/log.h" #include "mongo/scripting/dbdirectclient_factory.h" +#include "mongo/util/ctype.h" #include "mongo/util/fail_point.h" #include "mongo/util/file.h" #include "mongo/util/text.h" @@ -207,8 +209,10 @@ void Scope::storedFuncMod(OperationContext* opCtx) { void Scope::validateObjectIdString(const string& str) { uassert(10448, "invalid object id: length", str.size() == 24); - for (size_t i = 0; i < str.size(); i++) - uassert(10430, "invalid object id: not hex", std::isxdigit(str.at(i))); + auto isAllHex = [](StringData s) { + return std::all_of(s.begin(), s.end(), [](char c) { return ctype::isXdigit(c); }); + }; + uassert(10430, "invalid object id: not hex", isAllHex(str)); } void Scope::loadStored(OperationContext* opCtx, bool ignoreNotConnected) { @@ -615,12 +619,13 @@ bool hasJSReturn(const string& code) { // return is at start OR preceded by space // AND return is not followed by digit or letter - return (x == 0 || isspace(code[x - 1])) && !(isalpha(code[x + 6]) || isdigit(code[x + 6])); + return (x == 0 || ctype::isSpace(code[x - 1])) && + !(ctype::isAlpha(code[x + 6]) || ctype::isDigit(code[x + 6])); } const char* jsSkipWhiteSpace(const char* raw) { while (raw[0]) { - while (isspace(*raw)) { + while (ctype::isSpace(*raw)) { ++raw; } if (raw[0] != '/' || raw[1] != '/') diff --git a/src/mongo/scripting/mozjs/bindata.cpp b/src/mongo/scripting/mozjs/bindata.cpp index f66e6064956..36c37700e20 100644 --- a/src/mongo/scripting/mozjs/bindata.cpp +++ b/src/mongo/scripting/mozjs/bindata.cpp @@ -31,7 +31,6 @@ #include "mongo/scripting/mozjs/bindata.h" -#include <cctype> #include <iomanip> #include "mongo/bson/bsonobjbuilder.h" |