1
1

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.
Этот коммит содержится в:
Jeff Squyres 2009-05-28 16:15:06 +00:00
родитель 590fbcff6c
Коммит 07c7a7a255
2 изменённых файлов: 28 добавлений и 6 удалений

Просмотреть файл

@ -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
**************************************************************************

Просмотреть файл

@ -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;