Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.vs/
/build/
/prefix/
/linux-build/
Expand Down
17 changes: 16 additions & 1 deletion include/ifc/abstract-sgraph.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <concepts>
#include <string_view>
#include <type_traits>
#include <array>
#include <algorithm>

#include <ifc/underlying.hxx>
#include <ifc/basic-types.hxx>
Expand Down Expand Up @@ -3544,7 +3546,20 @@ namespace ifc {

// -- exception type in case of an invalid partition name
struct InvalidPartitionName {
std::string_view name;
explicit InvalidPartitionName(std::string_view partition_name)
{
partition_name = partition_name.substr(0, partition_name_buffer.size() - 1);
std::copy(partition_name.begin(), partition_name.end(), partition_name_buffer.begin());
partition_name_buffer[partition_name.length()] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partition_name is already sized in such a way that the last byte in the buffer stays the way it was initiliazed, which is 0. This line is unnecessary.

}

const char* partition_name() const noexcept
{
return partition_name_buffer.data();
}

private:
std::array<char, 64> partition_name_buffer;
};

// Retrieve a partition summary based on the partition's name.
Expand Down
10 changes: 7 additions & 3 deletions src/ifc-printer/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ void translate_exception()
{
std::cerr << "ifc architecture mismatch\n";
}
catch(ifc::error_condition::UnexpectedVisitor& e)
catch (const ifc::InvalidPartitionName& e)
{
std::cerr << "invalid partition name: " << e.partition_name() << '\n';
}
catch (ifc::error_condition::UnexpectedVisitor& e)
{
std::cerr << "visit unexpected " << e.category << ": "
<< e.sort << '\n';
}
catch (const char* message)
catch (const std::exception& e)
{
std::cerr << "caught: " << message;
std::cerr << "caught std exception: " << e.what();
}
catch (...)
{
Expand Down
3 changes: 1 addition & 2 deletions src/ifc-reader/reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace ifc {

Reader::Reader(const ifc::InputIfc& ifc_) : ifc(ifc_)
{
if (not ifc.header())
throw "file not found";
IFCASSERT(ifc.header());
read_table_of_contents();
}

Expand Down