From 07c7a7a25590fe728fb518680dc397f58ae47c81 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 28 May 2009 16:15:06 +0000 Subject: [PATCH] Make ompi_info behave a bit better if STL decides not to play with 0 length string constructors. Print a developer warning if we have a too-long field (in developer builds only). This commit was SVN r21315. --- ompi/tools/ompi_info/help-ompi_info.txt | 10 ++++++++++ ompi/tools/ompi_info/output.cc | 24 ++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ompi/tools/ompi_info/help-ompi_info.txt b/ompi/tools/ompi_info/help-ompi_info.txt index 7a9d06cac0..0637189998 100644 --- a/ompi/tools/ompi_info/help-ompi_info.txt +++ b/ompi/tools/ompi_info/help-ompi_info.txt @@ -10,6 +10,7 @@ # University of Stuttgart. All rights reserved. # Copyright (c) 2004-2005 The Regents of the University of California. # All rights reserved. +# Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -33,3 +34,12 @@ show this message to an Open MPI wizard: Source line number: %d Aborting... +# +[developer warning: field too long] +************************************************************************** +*** DEVELOPER WARNING: A field in ompi_info output is too long and +*** will appear poorly in the prettyprint output. +*** +*** Value: "%s" +*** Max length: %d +************************************************************************** diff --git a/ompi/tools/ompi_info/output.cc b/ompi/tools/ompi_info/output.cc index 78b02c92ba..2a0abee8c6 100644 --- a/ompi/tools/ompi_info/output.cc +++ b/ompi/tools/ompi_info/output.cc @@ -41,6 +41,8 @@ #include "ompi/tools/ompi_info/ompi_info.h" +#include "opal/util/show_help.h" + using namespace std; using namespace ompi_info; @@ -187,12 +189,22 @@ void ompi_info::out(const string& pretty_message, const string &plain_message, int value) { if (ompi_info::pretty) { - string spaces(OMPI_max(centerpoint - pretty_message.length(), 0), ' '); - if (!pretty_message.empty()) { - cout << spaces << pretty_message << ": " << value << endl; - } else { - cout << spaces << " " << value << endl; - } + if (centerpoint > pretty_message.length()) { + string spaces(centerpoint - pretty_message.length(), ' '); + cout << spaces; + } +#if OPAL_ENABLE_DEBUG + else { + opal_show_help("help-ompi_info.txt", + "developer warning: field too long", false, + pretty_message.c_str(), centerpoint); + } +#endif + if (!pretty_message.empty()) { + cout << pretty_message << ": " << value << endl; + } else { + cout << " " << value << endl; + } } else { if (!plain_message.empty()) { cout << plain_message << ":" << value << endl;