Skip to content

Commit

Permalink
Fix warnings for GCC v11.1 and Clang v11.1
Browse files Browse the repository at this point in the history
Signed-off-by: Remigiusz Kołłątaj <[email protected]>
  • Loading branch information
rkollataj authored and btaczala committed Jun 25, 2021
1 parent ffe0f22 commit 5730e79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
33 changes: 4 additions & 29 deletions src/dbcparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@ template <typename T> auto to_vector(const T& container) -> std::vector<typename
using namespace CANdb;
using strings = std::vector<std::string>;

std::string withLines(const std::string& dbcFile)
{

auto withDots = dbcFile;
withDots = StringUtils::replace_all(withDots, " ", "$");
withDots = StringUtils::replace_all(withDots, "\t", "[t]");
const strings split = StringUtils::split(withDots, "\n");
std::string buff;

int counter{ 1 };
for (const auto& line : split) {
buff += std::to_string(counter++) + std::string{ ": " } + line + std::string{ "\n" };
}

return buff;
}

// Changes \r\n to \n
std::string dos2unix(const std::string& data)
{
Expand All @@ -76,14 +59,6 @@ std::string dos2unix(const std::string& data)
return noWindowsShit;
}

std::string toUtf(const std::string& data)
{
return data;
// std::wstring_convert<std::codecvt_utf16<wchar_t>> converter;
// std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter2;
// return converter2.to_bytes(converter.from_bytes(data));
}

tl::expected<peg::parser, CANdb::ParserError> loadPegParser()
{
peg::parser pegParser;
Expand All @@ -105,10 +80,10 @@ CANdb::CanDbOrError parse(peg::parser& pegParser, const std::string& data)
}

const auto noTabsData = dos2unix(data);
const auto traceEnter = [](const peg::Ope& ope, const char* name, std::size_t, const peg::SemanticValues&,
const auto traceEnter = [](const peg::Ope&, const char* name, std::size_t, const peg::SemanticValues&,
const peg::Context&, const std::any&) { cdb_trace(" Parsing {} ", name); };
const auto traceLeave = [](const peg::Ope& ope, const char* s, std::size_t n, const peg::SemanticValues& sv,
const peg::Context& c, const std::any& dt, std::size_t) {};
const auto traceLeave = [](const peg::Ope&, const char*, std::size_t, const peg::SemanticValues&,
const peg::Context&, const std::any&, std::size_t) {};
pegParser.enable_trace(traceEnter, traceLeave);
strings phrases;
std::deque<std::string> idents, signs, sig_sign, ecu_tokens;
Expand Down Expand Up @@ -229,7 +204,7 @@ CANdb::CanDbOrError parse(peg::parser& pegParser, const std::string& data)
muxName = "";
};

pegParser["signal"] = [&idents, &numbers, &phrases, &signals, &signs, &sig_sign, &ecu_tokens, &mux, &muxNdx,
pegParser["signal"] = [&idents, &numbers, &phrases, &signals, &sig_sign, &ecu_tokens, &mux, &muxNdx,
&muxName](const peg::SemanticValues& sv) {
cdb_debug("Found signal {}", sv.token());

Expand Down
2 changes: 1 addition & 1 deletion src/parsererror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace CANdb {

const char* ParserErrorCategory::name() const noexcept { return "ParserError"; }
std::string ParserErrorCategory::message(int condition) const { return "ParserError"; }
std::string ParserErrorCategory::message(int) const { return "ParserError"; }

std::string ParserError::message() const { return _mess; }
ParserError make_error_code(ErrorType t, const std::string& msg) { return ParserError{ t, msg }; }
Expand Down
9 changes: 3 additions & 6 deletions src/parsererror.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ struct ParserErrorCategory : std::error_category {
};

struct ParserError {
ParserError(ErrorType t, const std::string& mess)
: _t(t)
, _mess(mess)
ParserError(ErrorType, const std::string& mess)
: _mess(mess)
{
}
ParserError(std::error_code ec)
: _t(ErrorType::StdErrorCode)
ParserError(std::error_code)
{
}

std::string message() const;

private:
ErrorType _t;
const std::string _mess;
};

Expand Down

0 comments on commit 5730e79

Please sign in to comment.