1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

AK: Explicitly calculate length of char* when printing

This moves out the calculation of the char* out to the formatter.
Additionally, we now print (null) when a null pointer is passed.
This commit is contained in:
sin-ack 2022-07-11 19:59:54 +00:00 committed by Andreas Kling
parent 52d017c611
commit 6eecc65787
Notes: sideshowbarker 2024-07-18 04:38:32 +09:00
2 changed files with 9 additions and 2 deletions

View file

@ -275,8 +275,12 @@ void ArgsParser::print_usage_markdown(FILE* file, char const* argv0)
for (auto& opt : m_options) {
if (opt.hide_mode != OptionHideMode::None)
continue;
// FIXME: We allow opt.value_name to be empty even if the option
// requires an argument. This should be disallowed as it will
// currently display a blank name after the option.
if (opt.requires_argument)
out(file, " [{} {}]", opt.name_for_display(), opt.value_name);
out(file, " [{} {}]", opt.name_for_display(), opt.value_name ?: "");
else
out(file, " [{}]", opt.name_for_display());
}