From b14b613cecf0552e40784b6f165865f230eeb0c8 Mon Sep 17 00:00:00 2001 From: Tyler Yankee Date: Wed, 19 Aug 2026 19:05:07 -0400 Subject: [PATCH] CPS: Use cmJSONState to read package JSON files This approach will be more portable. --- Source/cmPackageInfoReader.cxx | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/Source/cmPackageInfoReader.cxx b/Source/cmPackageInfoReader.cxx index a97a31fe51..abc89d701a 100644 --- a/Source/cmPackageInfoReader.cxx +++ b/Source/cmPackageInfoReader.cxx @@ -11,17 +11,16 @@ #include #include -#include #include #include -#include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include "cmCxxModuleMetadata.h" #include "cmExecutionStatus.h" #include "cmFileSet.h" #include "cmFileSetMetadata.h" +#include "cmJSONState.h" #include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" @@ -88,21 +87,9 @@ std::string GetRealDir(std::string const& path) Json::Value ReadJson(std::string const& fileName) { - // Open the specified file. - cmsys::ifstream file(fileName.c_str(), std::ios::in | std::ios::binary); - if (!file) { -#if JSONCPP_VERSION_HEXA < 0x01070300 - return Json::Value::null; -#else - return Json::Value::nullSingleton(); -#endif - } - - // Read file content and translate JSON. Json::Value data; - Json::CharReaderBuilder builder; - builder["collectComments"] = false; - if (!Json::parseFromStream(builder, file, &data, nullptr)) { + cmJSONState parseState(fileName, &data, cmJSONState::StrictMode::Relaxed); + if (!parseState.errors.empty()) { #if JSONCPP_VERSION_HEXA < 0x01070300 return Json::Value::null; #else