[PATCH v2 2/7] Add "help news"
Tom Tromey
tom@tromey.com
Sun Jul 5 15:59:00 GMT 2020
>>>>> "Christian" == Christian Biesinger via Gdb-patches <gdb-patches@sourceware.org> writes:
Christian> On Tue, Jun 23, 2020 at 8:20 AM Tom Tromey <tom@tromey.com> wrote:
>> +static void
>> +help_news (struct ui_file *stream)
>> +{
>> + std::string news_name = std::string (gdb_datadir) + SLASH_STRING + "NEWS";
>> + gdb_file_up news_file = gdb_fopen_cloexec (news_name.c_str (), "r");
>> + if (news_file == nullptr)
>> + perror_with_name (_("could not open the NEWS file"));
>> +
>> + char buffer[1024];
>> + size_t offset = 0;
>> + while (true)
>> + {
>> + size_t nbytes = fread (&buffer[offset], 1, sizeof (buffer) - offset,
>> + news_file.get ());
Christian> Why not use read_entire_file from your other patch?
The NEWS file seems large-ish, and I figured the normal thing for users
would be to use the pager to view the top, then stop reading.
Tom
More information about the Gdb-patches
mailing list