Skip to content

Commit

Permalink
SERVER-10601 --> remove parseLL() function definition and use in numb…
Browse files Browse the repository at this point in the history
…erlong.cpp
  • Loading branch information
tkaye407 committed Jun 12, 2017
1 parent 7aecd45 commit d86fe12
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
6 changes: 5 additions & 1 deletion src/mongo/scripting/mozjs/numberlong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <boost/optional.hpp>
#include <js/Conversions.h>

#include "mongo/base/parse_number.h"
#include "mongo/scripting/mozjs/implscope.h"
#include "mongo/scripting/mozjs/objectwrapper.h"
#include "mongo/scripting/mozjs/valuereader.h"
Expand Down Expand Up @@ -170,7 +171,10 @@ void NumberLongInfo::construct(JSContext* cx, JS::CallArgs args) {
// For string values we call strtoll because we expect non-number string
// values to fail rather than return 0 (which is the behavior of ToInt64).
std::string str = ValueWriter(cx, arg).toString();
numLong = parseLL(str.c_str());

// Call parseNumberFromStringWithBase() function to convert string to a number
Status status = parseNumberFromStringWithBase(str, 10, &numLong);
uassert(ErrorCodes::BadValue, "could not convert string to long long", status.isOK());
} else {
numLong = ValueWriter(cx, arg).toInt64();
}
Expand Down
21 changes: 0 additions & 21 deletions src/mongo/util/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,6 @@ bool isValidUTF8(const char* s) {
return true;
}

long long parseLL(const char* n) {
long long ret;
uassert(13307, "cannot convert empty string to long long", *n != 0);
#if !defined(_WIN32)
char* endPtr = 0;
errno = 0;
ret = strtoll(n, &endPtr, 10);
uassert(13305, "could not convert string to long long", *endPtr == 0 && errno == 0);
#else
size_t endLen = 0;
try {
ret = stoll(n, &endLen, 10);
} catch (...) {
endLen = 0;
}
uassert(13306, "could not convert string to long long", endLen != 0 && n[endLen] == 0);
#endif // !defined(_WIN32)
return ret;
}


#if defined(_WIN32)

std::string toUtf8String(const std::wstring& wide) {
Expand Down
4 changes: 0 additions & 4 deletions src/mongo/util/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ class StringSplitter {
bool isValidUTF8(const char* s);
bool isValidUTF8(const std::string& s);

// expect that n contains a base ten number and nothing else after it
// NOTE win version hasn't been tested directly
long long parseLL(const char* n);

#if defined(_WIN32)

std::string toUtf8String(const std::wstring& wide);
Expand Down

0 comments on commit d86fe12

Please sign in to comment.