|
@@ -3495,7 +3495,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
|
|
|
|
|
|
|
|
// Chip Model Name
|
|
// Chip Model Name
|
|
|
this->ChipID.ModelName =
|
|
this->ChipID.ModelName =
|
|
|
- this->ExtractValueFromCpuInfoFile(buffer, "model name").c_str();
|
|
|
|
|
|
|
+ this->ExtractValueFromCpuInfoFile(buffer, "model name");
|
|
|
|
|
|
|
|
// L1 Cache size
|
|
// L1 Cache size
|
|
|
// Different architectures may show different names for the caches.
|
|
// Different architectures may show different names for the caches.
|
|
@@ -4613,7 +4613,7 @@ std::string SystemInformationImplementation::ExtractValueFromSysCtl(
|
|
|
std::string SystemInformationImplementation::RunProcess(
|
|
std::string SystemInformationImplementation::RunProcess(
|
|
|
std::vector<const char*> args)
|
|
std::vector<const char*> args)
|
|
|
{
|
|
{
|
|
|
- std::string buffer = "";
|
|
|
|
|
|
|
+ std::string buffer;
|
|
|
|
|
|
|
|
// Run the application
|
|
// Run the application
|
|
|
kwsysProcess* gp = kwsysProcess_New();
|
|
kwsysProcess* gp = kwsysProcess_New();
|
|
@@ -4668,11 +4668,7 @@ std::string SystemInformationImplementation::RunProcess(
|
|
|
std::string SystemInformationImplementation::ParseValueFromKStat(
|
|
std::string SystemInformationImplementation::ParseValueFromKStat(
|
|
|
const char* arguments)
|
|
const char* arguments)
|
|
|
{
|
|
{
|
|
|
- std::vector<const char*> args;
|
|
|
|
|
- args.clear();
|
|
|
|
|
- args.push_back("kstat");
|
|
|
|
|
- args.push_back("-p");
|
|
|
|
|
-
|
|
|
|
|
|
|
+ std::vector<std::string> args_string;
|
|
|
std::string command = arguments;
|
|
std::string command = arguments;
|
|
|
size_t start = std::string::npos;
|
|
size_t start = std::string::npos;
|
|
|
size_t pos = command.find(' ', 0);
|
|
size_t pos = command.find(' ', 0);
|
|
@@ -4691,35 +4687,35 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!inQuotes) {
|
|
if (!inQuotes) {
|
|
|
- std::string arg = command.substr(start + 1, pos - start - 1);
|
|
|
|
|
|
|
+ args_string.push_back(command.substr(start + 1, pos - start - 1));
|
|
|
|
|
+ std::string& arg = args_string.back();
|
|
|
|
|
|
|
|
// Remove the quotes if any
|
|
// Remove the quotes if any
|
|
|
- size_t quotes = arg.find('"');
|
|
|
|
|
- while (quotes != std::string::npos) {
|
|
|
|
|
- arg.erase(quotes, 1);
|
|
|
|
|
- quotes = arg.find('"');
|
|
|
|
|
- }
|
|
|
|
|
- args.push_back(arg.c_str());
|
|
|
|
|
|
|
+ arg.erase(std::remove(arg.begin(), arg.end(), '"'), arg.end());
|
|
|
start = pos;
|
|
start = pos;
|
|
|
}
|
|
}
|
|
|
pos = command.find(' ', pos + 1);
|
|
pos = command.find(' ', pos + 1);
|
|
|
}
|
|
}
|
|
|
- std::string lastArg = command.substr(start + 1, command.size() - start - 1);
|
|
|
|
|
- args.push_back(lastArg.c_str());
|
|
|
|
|
|
|
+ args_string.push_back(command.substr(start + 1, command.size() - start - 1));
|
|
|
|
|
|
|
|
|
|
+ std::vector<const char*> args;
|
|
|
|
|
+ args.reserve(3 + args_string.size());
|
|
|
|
|
+ args.push_back("kstat");
|
|
|
|
|
+ args.push_back("-p");
|
|
|
|
|
+ for (size_t i = 0; i < args_string.size(); ++i) {
|
|
|
|
|
+ args.push_back(args_string[i].c_str());
|
|
|
|
|
+ }
|
|
|
args.push_back(KWSYS_NULLPTR);
|
|
args.push_back(KWSYS_NULLPTR);
|
|
|
|
|
|
|
|
std::string buffer = this->RunProcess(args);
|
|
std::string buffer = this->RunProcess(args);
|
|
|
|
|
|
|
|
- std::string value = "";
|
|
|
|
|
|
|
+ std::string value;
|
|
|
for (size_t i = buffer.size() - 1; i > 0; i--) {
|
|
for (size_t i = buffer.size() - 1; i > 0; i--) {
|
|
|
if (buffer[i] == ' ' || buffer[i] == '\t') {
|
|
if (buffer[i] == ' ' || buffer[i] == '\t') {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
if (buffer[i] != '\n' && buffer[i] != '\r') {
|
|
if (buffer[i] != '\n' && buffer[i] != '\r') {
|
|
|
- std::string val = value;
|
|
|
|
|
- value = buffer[i];
|
|
|
|
|
- value += val;
|
|
|
|
|
|
|
+ value.insert(0u, 1, buffer[i]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return value;
|
|
return value;
|