Skip to content

Commit

Permalink
changes for build in far2l
Browse files Browse the repository at this point in the history
  • Loading branch information
ctapmex committed Aug 24, 2024
1 parent a5f01cd commit 213698d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/colorer/cregexp/cregexp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "colorer/cregexp/cregexp.h"

#include <cstring>

StackElem* CRegExp::RegExpStack {nullptr};
int CRegExp::RegExpStack_Size {0};
Expand Down
13 changes: 7 additions & 6 deletions src/colorer/parsers/ParserFactoryImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ void ParserFactory::Impl::loadCatalog(const UnicodeString* catalog_path)
if (!catalog_path || catalog_path->isEmpty()) {
logger->debug("loadCatalog for empty path");

auto env = Environment::getOSVariable("COLORER_CATALOG");
auto env = colorer::Environment::getOSVariable("COLORER_CATALOG");
if (!env || env->isEmpty()) {
throw ParserFactoryException("Can't find suitable catalog.xml for parse.");
}
base_catalog_path = Environment::normalizePath(env.get());
base_catalog_path = colorer::Environment::normalizePath(env.get());
}
else {
logger->debug("loadCatalog for {0}", *catalog_path);
base_catalog_path = Environment::normalizePath(catalog_path);
base_catalog_path = colorer::Environment::normalizePath(catalog_path);
}

parseCatalog(*base_catalog_path);
Expand All @@ -45,7 +45,7 @@ void ParserFactory::Impl::loadHrcPath(const UnicodeString& location)
try {
logger->debug("try load '{0}'", location);
if (XmlInputSource::isFileURI(*base_catalog_path, &location)) {
auto files = Environment::getFilesFromPath(base_catalog_path.get(), &location, ".hrc");
auto files = colorer::Environment::getFilesFromPath(base_catalog_path.get(), &location, ".hrc");
for (auto& file : files) {
loadHrc(file, nullptr);
}
Expand Down Expand Up @@ -84,7 +84,8 @@ void ParserFactory::Impl::parseCatalog(const UnicodeString& catalog_path)
}
}

[[maybe_unused]] std::vector<UnicodeString> ParserFactory::Impl::enumHrdClasses()
[[maybe_unused]]
std::vector<UnicodeString> ParserFactory::Impl::enumHrdClasses()
{
std::vector<UnicodeString> result;
result.reserve(hrd_nodes.size());
Expand Down Expand Up @@ -162,7 +163,7 @@ void ParserFactory::Impl::fillMapper(const UnicodeString& classID, const Unicode
const UnicodeString* name_id;
const UnicodeString name_default(HrdNameDefault);
if (nameID == nullptr) {
auto hrd = Environment::getOSVariable("COLORER_HRD");
auto hrd = colorer::Environment::getOSVariable("COLORER_HRD");
if (hrd) {
name_id = hrd.get();
}
Expand Down
4 changes: 3 additions & 1 deletion src/colorer/utils/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#else
#include <regex>
#endif

namespace colorer {
fs::path Environment::to_filepath(const UnicodeString* str)
{
#ifdef _WINDOWS
Expand Down Expand Up @@ -141,3 +141,5 @@ bool Environment::isRegularFile(const UnicodeString* basePath, const UnicodeStri
fullPath = clear_path.u16string().c_str();
return fs::is_regular_file(clear_path);
}

} // namespace colorer
2 changes: 2 additions & 0 deletions src/colorer/utils/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace fs = ghc::filesystem;
namespace fs = std::filesystem;
#endif
#include <vector>
namespace colorer {

class Environment
{
Expand All @@ -26,4 +27,5 @@ class Environment
static bool isRegularFile(const UnicodeString* basePath, const UnicodeString* relPath, UnicodeString& fullPath);
};

} // namespace colorer
#endif // COLORER_ENVIRONMENT_H
4 changes: 3 additions & 1 deletion src/colorer/viewer/TextLinesStore.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "colorer/viewer/TextLinesStore.h"
#include <cstring>
#include "colorer/Exception.h"
#include "colorer/io/InputSource.h"

Expand Down Expand Up @@ -34,7 +35,8 @@ void TextLinesStore::loadFile(const UnicodeString* inFileName, bool tab2spaces)
memcpy(&stdin_array[stdin_array.size() - read_len], &line[0], read_len * sizeof(char));
}
file = Encodings::toUnicodeString(stdin_array.data(), (int32_t) stdin_array.size());
} else {
}
else {
this->fileName = std::make_unique<UnicodeString>(*inFileName);
colorer::InputSource* is = colorer::InputSource::newInstance(inFileName);

Expand Down
7 changes: 4 additions & 3 deletions src/colorer/xml/libxml2/LibXmlInputSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LibXmlInputSource
explicit LibXmlInputSource(const UnicodeString* path, const UnicodeString* base = nullptr)
{
UnicodeString full_path;
if (Environment::isRegularFile(base, path, full_path)) {
if (colorer::Environment::isRegularFile(base, path, full_path)) {
sourcePath = full_path;
// file is not open yet, only after makeStream
}
Expand All @@ -25,12 +25,13 @@ class LibXmlInputSource
return LibXmlInputSource(&relPath, &sourcePath);
}

[[nodiscard]] UnicodeString& getPath()
[[nodiscard]]
UnicodeString& getPath()
{
return sourcePath;
}

private:
private:
UnicodeString sourcePath;
};

Expand Down

0 comments on commit 213698d

Please sign in to comment.