diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-09-28 18:35:57 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-09-28 18:35:57 -0500 |
commit | 4ef88103f74a3a6e8e36ae9eff80f641e20bd1a1 (patch) | |
tree | 4dc098488ea087de82b1edccdc89853c6b04c891 /source | |
parent | b6967c8a9190efa4e9128850fa723fe3ea3140f7 (diff) |
Fix string catenate error.
Diffstat (limited to 'source')
-rw-r--r-- | source/fud_directory.cpp | 7 | ||||
-rw-r--r-- | source/fud_string.cpp | 12 |
2 files changed, 12 insertions, 7 deletions
diff --git a/source/fud_directory.cpp b/source/fud_directory.cpp index 99f3600..6df5bcc 100644 --- a/source/fud_directory.cpp +++ b/source/fud_directory.cpp @@ -29,7 +29,10 @@ struct Stat : public CStat {}; Result<DirectoryEntry, FudStatus> DirectoryEntry::fromStat(const String& name, const Stat& statBuffer) { using RetType = Result<DirectoryEntry, FudStatus>; - static_assert(std::is_same_v<decltype(statBuffer.st_size), long>); + static_assert(std::is_same_v<decltype(statBuffer.st_ino), unsigned long>); + static_assert(sizeof(decltype(statBuffer.st_ino)) <= sizeof(size_t)); + + static_assert(std::is_same_v<decltype(statBuffer.st_size), signed long>); static_assert(sizeof(decltype(statBuffer.st_size)) <= sizeof(size_t)); static_assert(std::is_same_v<decltype(statBuffer.st_nlink), unsigned long>); @@ -71,7 +74,7 @@ Result<DirectoryEntry, FudStatus> DirectoryEntry::fromStat(const String& name, c } return RetType::okay( - DirectoryEntry{name, size, static_cast<size_t>(statBuffer.st_nlink), statBuffer.st_mtime, entryType}); + DirectoryEntry{name, statBuffer.st_ino, size, static_cast<size_t>(statBuffer.st_nlink), statBuffer.st_mtime, entryType}); } Directory::Directory(String name) : m_name{name} diff --git a/source/fud_string.cpp b/source/fud_string.cpp index 52d6b8f..97acb52 100644 --- a/source/fud_string.cpp +++ b/source/fud_string.cpp @@ -16,6 +16,7 @@ */ #include "fud_string.hpp" + #include "fud_assert.hpp" namespace fud { @@ -115,7 +116,8 @@ String& String::operator=(const String& rhs) return *this; } -String& String::operator=(String&& rhs) { +String& String::operator=(String&& rhs) +{ m_length = rhs.m_length; m_capacity = rhs.m_capacity; if (rhs.isLarge()) { @@ -287,7 +289,7 @@ String String::catenate(const String& rhs) const auto* destPtr = output.data(); auto status = copyMem(destPtr, m_capacity, data(), length()); fudAssert(status == FudStatus::Success); - status = copyMem(destPtr + length(), m_capacity, rhs.data(), rhs.length()); + status = copyMem(destPtr + length(), output.m_capacity - length(), rhs.data(), rhs.length()); fudAssert(status == FudStatus::Success); static_cast<void>(status); fudAssert(output.nullTerminate() == FudStatus::Success); @@ -295,7 +297,8 @@ String String::catenate(const String& rhs) const return output; } -bool String::compare(const String& rhs) const { +bool String::compare(const String& rhs) const +{ if (!valid() || !rhs.valid()) { return false; } @@ -304,8 +307,7 @@ bool String::compare(const String& rhs) const { return false; } - if (isLarge() && data() == rhs.data()) - { + if (isLarge() && data() == rhs.data()) { return true; } |