From 556ed22496d650bd0b13b6c163be9814637970ae Mon Sep 17 00:00:00 2001 From: Carbo Kuo Date: Fri, 2 Aug 2024 23:42:09 -0400 Subject: [PATCH] Add back Config::NewFromFile with one argument to maintain the ABI compatibility. It was changed in v1.1.8. --- src/Config.cpp | 4 ++++ src/Config.hpp | 6 ++++-- src/SimpleConverter.cpp | 2 +- src/tools/CommandLine.cpp | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Config.cpp b/src/Config.cpp index eee6e067b..a8392b1e9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -222,6 +222,10 @@ Config::Config() : internal(new ConfigInternal()) {} Config::~Config() { delete reinterpret_cast(internal); } +ConverterPtr Config::NewFromFile(const std::string& fileName) { + return NewFromFile(fileName, std::vector{}, nullptr); +} + ConverterPtr Config::NewFromFile(const std::string& fileName, const std::vector& paths, const char* argv0) { diff --git a/src/Config.hpp b/src/Config.hpp index 1737d01bd..6b744b9aa 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -37,9 +37,11 @@ class OPENCC_EXPORT Config { ConverterPtr NewFromString(const std::string& json, const std::vector& paths); + ConverterPtr NewFromFile(const std::string& fileName); + ConverterPtr NewFromFile(const std::string& fileName, - const std::vector& paths = {}, - const char* argv0 = nullptr); + const std::vector& paths, + const char* argv0); private: void* internal; diff --git a/src/SimpleConverter.cpp b/src/SimpleConverter.cpp index 7b24ac654..b179751d9 100644 --- a/src/SimpleConverter.cpp +++ b/src/SimpleConverter.cpp @@ -55,7 +55,7 @@ struct InternalData { paths_with_runfiles.push_back( bazel_runfiles->Rlocation("_main/data/dictionary")); return new InternalData( - config.NewFromFile(configFileName, paths_with_runfiles)); + config.NewFromFile(configFileName, paths_with_runfiles, argv0)); } #endif return new InternalData(config.NewFromFile(configFileName, paths, argv0)); diff --git a/src/tools/CommandLine.cpp b/src/tools/CommandLine.cpp index e029d3d36..568d1bbfd 100644 --- a/src/tools/CommandLine.cpp +++ b/src/tools/CommandLine.cpp @@ -197,7 +197,7 @@ int main(int argc, const char* argv[]) { outputFileName = Optional(outputArg.getValue()); noFlush = true; } - converter = config.NewFromFile(configFileName, pathArg.getValue()); + converter = config.NewFromFile(configFileName, pathArg.getValue(), argv[0]); bool lineByLine = inputFileName.IsNull(); if (lineByLine) { ConvertLineByLine();