From a8aaf568578332d669aa7892c689bbff16f21c6f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 23 Jul 2021 07:22:07 +0300 Subject: cam: options: Restore std::cerr adjustment field The std::cerr adjustment is set to std::left to print the usage text. Restore it to its original value when done, to avoid affecting the caller. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/cam/options.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/cam/options.cpp') diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 33bc512e..4f7e8691 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -453,7 +453,7 @@ void KeyValueParser::usage(int indent) argument += "]"; } - std::cerr << std::setw(indent) << std::left << argument; + std::cerr << std::setw(indent) << argument; for (const char *help = option.help, *end = help; end;) { end = strchr(help, '\n'); @@ -994,7 +994,12 @@ void OptionsParser::usage() std::cerr << "Options:" << std::endl; + std::ios_base::fmtflags f(std::cerr.flags()); + std::cerr << std::left; + usageOptions(options_, indent); + + std::cerr.flags(f); } void OptionsParser::usageOptions(const std::list