1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:18:10 +00:00

LibCore: Rename identifiers that can clash with libc macros (#4127)

POSIX allows the default streams (stdin, stdout and stderr) to be
macros, which means that on such systems (musl libc is one) building
Lagom will fail due to the File::std*() names.

Also fix any files that use these identifiers.
This commit is contained in:
Érico Nogueira Rolim 2020-12-22 19:37:11 -03:00 committed by GitHub
parent abc98dea09
commit a8f0e489a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 13 deletions

View file

@ -241,7 +241,7 @@ static RefPtr<File> stdin_file;
static RefPtr<File> stdout_file; static RefPtr<File> stdout_file;
static RefPtr<File> stderr_file; static RefPtr<File> stderr_file;
NonnullRefPtr<File> File::stdin() NonnullRefPtr<File> File::standard_input()
{ {
if (!stdin_file) { if (!stdin_file) {
stdin_file = File::construct(); stdin_file = File::construct();
@ -250,7 +250,7 @@ NonnullRefPtr<File> File::stdin()
return *stdin_file; return *stdin_file;
} }
NonnullRefPtr<File> File::stdout() NonnullRefPtr<File> File::standard_output()
{ {
if (!stdout_file) { if (!stdout_file) {
stdout_file = File::construct(); stdout_file = File::construct();
@ -259,7 +259,7 @@ NonnullRefPtr<File> File::stdout()
return *stdout_file; return *stdout_file;
} }
NonnullRefPtr<File> File::stderr() NonnullRefPtr<File> File::standard_error()
{ {
if (!stderr_file) { if (!stderr_file) {
stderr_file = File::construct(); stderr_file = File::construct();

View file

@ -58,9 +58,9 @@ public:
}; };
bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescriptor); bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescriptor);
static NonnullRefPtr<File> stdin(); static NonnullRefPtr<File> standard_input();
static NonnullRefPtr<File> stdout(); static NonnullRefPtr<File> standard_output();
static NonnullRefPtr<File> stderr(); static NonnullRefPtr<File> standard_error();
private: private:
File(Object* parent = nullptr) File(Object* parent = nullptr)

View file

@ -128,14 +128,14 @@ public:
return Buffered<OutputFileStream> { file_result.value() }; return Buffered<OutputFileStream> { file_result.value() };
} }
static OutputFileStream stdout() static OutputFileStream standard_output()
{ {
return OutputFileStream { Core::File::stdout() }; return OutputFileStream { Core::File::standard_output() };
} }
static Buffered<OutputFileStream> stdout_buffered() static Buffered<OutputFileStream> stdout_buffered()
{ {
return Buffered<OutputFileStream> { Core::File::stdout() }; return Buffered<OutputFileStream> { Core::File::standard_output() };
} }
size_t write(ReadonlyBytes bytes) override size_t write(ReadonlyBytes bytes) override

View file

@ -44,6 +44,6 @@ int main()
return 1; return 1;
} }
auto engine = ChessEngine::construct(Core::File::stdin(), Core::File::stdout()); auto engine = ChessEngine::construct(Core::File::standard_input(), Core::File::standard_output());
return loop.exec(); return loop.exec();
} }

View file

@ -186,7 +186,7 @@ int main(int argc, char** argv)
}; };
if (!files.size() && !recursive) { if (!files.size() && !recursive) {
auto stdin_file = Core::File::stdin(); auto stdin_file = Core::File::standard_input();
for (;;) { for (;;) {
auto line = stdin_file->read_line(); auto line = stdin_file->read_line();
bool is_binary = line.bytes().contains_slow(0); bool is_binary = line.bytes().contains_slow(0);

View file

@ -41,7 +41,7 @@ int main(int argc, char** argv)
RefPtr<Core::File> file; RefPtr<Core::File> file;
if (!path) { if (!path) {
file = Core::File::stdin(); file = Core::File::standard_input();
} else { } else {
auto file_or_error = Core::File::open(path, Core::File::ReadOnly); auto file_or_error = Core::File::open(path, Core::File::ReadOnly);
if (file_or_error.is_error()) { if (file_or_error.is_error()) {

View file

@ -62,7 +62,7 @@ int main(int argc, char** argv)
} }
if (list || extract) { if (list || extract) {
auto file = Core::File::stdin(); auto file = Core::File::standard_input();
if (archive_file) { if (archive_file) {
auto maybe_file = Core::File::open(archive_file, Core::IODevice::OpenMode::ReadOnly); auto maybe_file = Core::File::open(archive_file, Core::IODevice::OpenMode::ReadOnly);