Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions libuuu/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
#include <sys/stat.h>
#include <thread>

#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>

static CmdMap g_cmd_map;
static CmdObjCreateMap g_cmd_create_map;
Expand Down Expand Up @@ -237,21 +238,17 @@ int get_string_in_square_brackets(string &cmd, string &context)
uint32_t str_to_uint(string &str)
{
uint32_t val = 0;
const char * start = str.substr(0).c_str();
char * endPtr = const_cast<char*>(start);
std::stringstream ss;
if (str.size() > 2 &&
str.substr(0, 2).compare("0x") == 0)
{
val = strtoul(start+2, &endPtr, 16);
ss << std::hex << str.substr(2);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's problem do you try to fix? the function should be the same

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't know why but the old code fail to convert on x86_64 latest ubuntu.... and well c++ conversion function are more robust than the strtoul legacy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It pass ubuntu 18.08 at auto build system.

else
{
val = strtoul(start, &endPtr, 10);
}
if (start == endPtr)
{
throw ("Trying to convert non numeric value to int");
ss << std::dec << str;
}
ss >> val;
return val;
}

Expand Down