/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+// NOLINTNEXTLINE(bugprone-reserved-identifier)
#define _SCL_SECURE_NO_WARNINGS
#include "cmStringCommand.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
-#include "cmProperty.h"
#include "cmRange.h"
#include "cmStringAlgorithms.h"
#include "cmStringReplaceHelper.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmUuid.h"
+#include "cmValue.h"
namespace {
bool HandleHashCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
-#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
status.SetError(
cmStrCat(args[0], " requires an output variable and an input string"));
return true;
}
return false;
-#else
- status.SetError(cmStrCat(args[0], " not available during bootstrap"));
- return false;
-#endif
}
bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
std::string::size_type hexIndex = 0;
for (auto const& c : instr) {
- sprintf(&output[hexIndex], "%.2x", static_cast<unsigned char>(c) & 0xFF);
+ snprintf(&output[hexIndex], 3, "%.2x",
+ static_cast<unsigned char>(c) & 0xFF);
hexIndex += 2;
}
status.GetMakefile().ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
- if (!re.compile(regex.c_str())) {
+ if (!re.compile(regex)) {
std::string e =
"sub-command REGEX, mode MATCH failed to compile regex \"" + regex +
"\".";
status.GetMakefile().ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
- if (!re.compile(regex.c_str())) {
+ if (!re.compile(regex)) {
std::string e =
"sub-command REGEX, mode MATCHALL failed to compile regex \"" + regex +
"\".";
size_t length = stringValue.size();
char buffer[1024];
- sprintf(buffer, "%d", static_cast<int>(length));
+ snprintf(buffer, sizeof(buffer), "%d", static_cast<int>(length));
status.GetMakefile().AddDefinition(variableName, buffer);
return true;
const std::string& variable = args[1];
std::string value = cmJoin(cmMakeRange(args).advance(2), std::string());
- cmProp oldValue = status.GetMakefile().GetDefinition(variable);
+ cmValue oldValue = status.GetMakefile().GetDefinition(variable);
if (oldValue) {
value += *oldValue;
}
const std::string& Args::PopFront(cm::string_view error)
{
- if (empty()) {
+ if (this->empty()) {
throw json_error({ error });
}
- const std::string& res = *begin();
- advance(1);
+ const std::string& res = *this->begin();
+ this->advance(1);
return res;
}
const std::string& Args::PopBack(cm::string_view error)
{
- if (empty()) {
+ if (this->empty()) {
throw json_error({ error });
}
- const std::string& res = *(end() - 1);
- retreat(1);
+ const std::string& res = *(this->end() - 1);
+ this->retreat(1);
return res;
}
Json::ArrayIndex index = static_cast<Json::ArrayIndex>(lindex);
if (index >= max) {
cmAlphaNum sizeStr{ max };
- throw json_error({ "expected an index less then "_s, sizeStr.View(),
+ throw json_error({ "expected an index less than "_s, sizeStr.View(),
" got '"_s, str, "'"_s },
progress);
}
}
}
return *search;
-};
+}
Json::Value ReadJson(const std::string& jsonstr)
{
mode != "EQUAL"_s) {
throw json_error(
{ "got an invalid mode '"_s, mode,
- "', expected one of GET, GET_ARRAY, TYPE, MEMBER, MEMBERS,"
- " LENGTH, REMOVE, SET, EQUAL"_s });
+ "', expected one of GET, TYPE, MEMBER, LENGTH, REMOVE, SET, "
+ " EQUAL"_s });
}
const auto& jsonstr = args.PopFront("missing json string argument"_s);