mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibLine: Convert strings to time_t using signed conversion methods
The time_t type itself is signed, and the result of this conversion is always stored as time_t, so let's not use to_uint<>.
This commit is contained in:
parent
d4ecdf3ced
commit
a67ad665b1
Notes:
sideshowbarker
2024-07-17 18:49:10 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/a67ad665b1 Pull-request: https://github.com/SerenityOS/serenity/pull/16522
@ -259,7 +259,7 @@ bool Editor::load_history(DeprecatedString const& path)
|
||||
auto hist = StringView { data.data(), data.size() };
|
||||
for (auto& str : hist.split_view("\n\n"sv)) {
|
||||
auto it = str.find("::"sv).value_or(0);
|
||||
auto time = str.substring_view(0, it).to_uint<time_t>().value_or(0);
|
||||
auto time = str.substring_view(0, it).to_int<time_t>().value_or(0);
|
||||
auto string = str.substring_view(it == 0 ? it : it + 2);
|
||||
m_history.append({ string, time });
|
||||
}
|
||||
@ -320,7 +320,7 @@ bool Editor::save_history(DeprecatedString const& path)
|
||||
file->line_begin(), file->line_end(), m_history.begin(), m_history.end(), final_history,
|
||||
[](StringView str) {
|
||||
auto it = str.find("::"sv).value_or(0);
|
||||
auto time = str.substring_view(0, it).to_uint<time_t>().value_or(0);
|
||||
auto time = str.substring_view(0, it).to_int<time_t>().value_or(0);
|
||||
auto string = str.substring_view(it == 0 ? it : it + 2);
|
||||
return HistoryEntry { string, time };
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user