1
0
Fork 0

Erik Hofman:

This is the small code fix which is needed for the new options.xml file.
It is needed because otherwise the "--prop:name=value" is showed
incorrectly.

There is another problem though, when compiling with --without-logging
the help message isn't displayed at all! We *must* change that somehow.

Curt: good point, the SG_LOG()'s have been switched to cout's ...
This commit is contained in:
curt 2002-06-12 16:38:46 +00:00
parent a682823ada
commit 6800231cfa

View file

@ -1130,13 +1130,16 @@ fgUsage ()
SGPath opath( globals->get_fg_root() ); SGPath opath( globals->get_fg_root() );
opath.append( "options.xml" ); opath.append( "options.xml" );
SG_LOG( SG_GENERAL, SG_ALERT, "" ); cout << "" << endl;
try { try {
readProperties(opath.c_str(), &options_root); readProperties(opath.c_str(), &options_root);
} catch (const sg_exception &ex) { } catch (const sg_exception &ex) {
SG_LOG( SG_GENERAL, SG_ALERT, "Unable to read the help file." ); cout << "Unable to read the help file." << endl;
SG_LOG( SG_GENERAL, SG_ALERT, "Make sure the file options.xml is located in the FlightGear base directory." ); cout << "Make sure the file options.xml is located in the FlightGear base directory," << endl;
cout << "and the location of the base directory is specified bij setting $FG_ROOT or" << endl;
cout << "by adding --fg-root=path as a program argument." << endl;
exit(-1); exit(-1);
} }
@ -1149,7 +1152,7 @@ fgUsage ()
SGPropertyNode *usage = options->getNode("usage"); SGPropertyNode *usage = options->getNode("usage");
if (usage) { if (usage) {
SG_LOG( SG_GENERAL, SG_ALERT, "Usage: " << usage->getStringValue() ); cout << "Usage: " << usage->getStringValue() << endl;
} }
vector<SGPropertyNode_ptr>section = options->getChildren("section"); vector<SGPropertyNode_ptr>section = options->getChildren("section");
@ -1157,8 +1160,7 @@ fgUsage ()
SGPropertyNode *name = section[j]->getNode("name"); SGPropertyNode *name = section[j]->getNode("name");
if (name) { if (name) {
SG_LOG( SG_GENERAL, SG_ALERT, endl << name->getStringValue() cout << endl << name->getStringValue() << ":" << endl;
<< ":" );
} }
vector<SGPropertyNode_ptr>option = section[j]->getChildren("option"); vector<SGPropertyNode_ptr>option = section[j]->getChildren("option");
@ -1166,25 +1168,30 @@ fgUsage ()
SGPropertyNode *name = option[k]->getNode("name"); SGPropertyNode *name = option[k]->getNode("name");
SGPropertyNode *short_name = option[k]->getNode("short"); SGPropertyNode *short_name = option[k]->getNode("short");
SGPropertyNode *key = option[k]->getNode("key");
SGPropertyNode *arg = option[k]->getNode("arg"); SGPropertyNode *arg = option[k]->getNode("arg");
if (name) { if (name) {
string tmp = name->getStringValue(); string tmp = name->getStringValue();
if (short_name) { if (key){
tmp.append(", -"); tmp.append(":");
tmp.append(short_name->getStringValue()); tmp.append(key->getStringValue());
} }
if (arg) { if (arg) {
tmp.append("="); tmp.append("=");
tmp.append(arg->getStringValue()); tmp.append(arg->getStringValue());
} }
if (short_name) {
tmp.append(", -");
tmp.append(short_name->getStringValue());
}
char cstr[255]; char cstr[96];
if (tmp.size() <= 25) { if (tmp.size() <= 25) {
sprintf(cstr, " --%-27s", tmp.c_str()); snprintf(cstr, 96, " --%-27s", tmp.c_str());
} else { } else {
sprintf(cstr, "\n --%s\n%32c", tmp.c_str(), ' '); snprintf(cstr, 96, "\n --%s\n%32c", tmp.c_str(), ' ');
} }
string msg = cstr; string msg = cstr;
@ -1196,11 +1203,12 @@ fgUsage ()
(desc = option[k]->getNode("description", l, false)); (desc = option[k]->getNode("description", l, false));
l++ ) l++ )
{ {
sprintf(cstr, "\n%32c%s", ' ', desc->getStringValue()); snprintf(cstr, 96, "\n%32c%s", ' ',
desc->getStringValue());
msg += cstr; msg += cstr;
} }
} }
SG_LOG( SG_GENERAL, SG_ALERT, msg ); cout << msg << endl;
} }
} }
} }