mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
cmp: Replace uses of DeprecatedString
This commit is contained in:
parent
684af3d4d0
commit
f2ae25deee
Notes:
sideshowbarker
2024-07-16 21:10:51 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/f2ae25deee Pull-request: https://github.com/SerenityOS/serenity/pull/17793 Reviewed-by: https://github.com/krkk Reviewed-by: https://github.com/trflynn89
1 changed files with 10 additions and 8 deletions
|
@ -4,12 +4,13 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(DeprecatedString const& filename)
|
||||
static ErrorOr<NonnullOwnPtr<Core::BufferedFile>> open_file_or_stdin(StringView filename)
|
||||
{
|
||||
auto file = TRY(Core::File::open_file_or_standard_stream(filename, Core::File::OpenMode::Read));
|
||||
return TRY(Core::BufferedFile::create(move(file)));
|
||||
|
@ -21,8 +22,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(Core::System::pledge("stdio rpath"));
|
||||
|
||||
Core::ArgsParser parser;
|
||||
DeprecatedString filename1;
|
||||
DeprecatedString filename2;
|
||||
StringView filename1;
|
||||
StringView filename2;
|
||||
bool verbose = false;
|
||||
bool silent = false;
|
||||
|
||||
|
@ -58,14 +59,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln("{} {} differ: char {}, line {}", filename1, filename2, byte_number, line_number);
|
||||
};
|
||||
|
||||
auto report_eof = [&](auto& shorter_file_name) {
|
||||
auto report_eof = [&](auto& shorter_file_name) -> ErrorOr<void> {
|
||||
files_match = false;
|
||||
if (silent)
|
||||
return;
|
||||
return {};
|
||||
auto additional_info = verbose
|
||||
? DeprecatedString::formatted(" after byte {}", byte_number)
|
||||
: DeprecatedString::formatted(" after byte {}, line {}", byte_number, line_number);
|
||||
? TRY(String::formatted(" after byte {}", byte_number))
|
||||
: TRY(String::formatted(" after byte {}, line {}", byte_number, line_number));
|
||||
warnln("cmp: EOF on {}{}", shorter_file_name, additional_info);
|
||||
return {};
|
||||
};
|
||||
|
||||
while (true) {
|
||||
|
@ -76,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
break;
|
||||
|
||||
if (file1->is_eof() || file2->is_eof()) {
|
||||
report_eof(file1->is_eof() ? filename1 : filename2);
|
||||
TRY(report_eof(file1->is_eof() ? filename1 : filename2));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue