From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Subject: [PATCH][lsvpd] "lscfg -vpl sysplaner0" ouptut alignment fix


lscfg -vpl sysplanar0 output:

     System VPD      :
	.......Product Specific.(RT)VSYS
	..................Flag FieldXXSV
	...............Brand KeywordP0
	Machine or Cabinet Serial Number.IBM,0206A38B0
	................Machine TypeIBM,9117-MMA
	.........Version of KeywordsipzSeries
	Physical Location: U9117.MMA.06A38B0

	CEC:
		.......Product Specific.(RT)VCEN
		........Device Specific.(BR)P0
		........Device Specific.(CI)9117-MMA 06A38B0
		Physical Location: U789D.001.DQD844T

Ideally output should be like below
	<label>....>Data>

This patch fixes above described alignment issue.

Reported-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
---
 src/output/lscfg.cpp |   41 +++++++++++++----------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)

Index: lsvpd-1.7.0/src/output/lscfg.cpp
===================================================================
--- lsvpd-1.7.0.orig/src/output/lscfg.cpp
+++ lsvpd-1.7.0/src/output/lscfg.cpp
@@ -142,6 +142,7 @@ bool contains( const vector<DataItem*>&
 
 void printField( const string& label, const string& data )
 {
+	cout << left;	// Append fill characters at the end.
 	cout << "        ";
 	cout << setfill( '.' ) << setw( 26 ) << label;
 	if( label.length( ) >= 26 )
@@ -467,22 +468,6 @@ void printVPD( Component* root )
 	}
 }
 
-void printPlatformField( const string& label, const string& data )
-{
-	cout << "       ";
-
-	if( label.length( ) >= 28 )
-	{
-		cout << label << ".";
-	}
-	else
-	{
-		cout << setfill( '.' ) << setw( 28 ) << label;
-	}
-
-	cout << data << endl;
-}
-
 void printPlatform( Component* root )
 {
 	if( root->getDescription( ).length( ) > 18 )
@@ -494,13 +479,13 @@ void printPlatform( Component* root )
 	cout << ":" << endl;
 
 	if( root->getRecordType( ) != "" )
-		printPlatformField( "Product Specific.(RT)", root->getRecordType( ) );
+		printField( "Product Specific.(RT)", root->getRecordType( ) );
 	if( root->getSerialNumber( ) != "" )
-		printPlatformField( root->getSerialNumberHN( ), root->getSerialNumber( ) );
+		printField( root->getSerialNumberHN( ), root->getSerialNumber( ) );
 	if(root->getFRU( ) != "" )
-		printPlatformField( root->getFRUHN( ), root->getFRU( ) );
+		printField( root->getFRUHN( ), root->getFRU( ) );
 	if( root->getPartNumber( ) != "" )
-		printPlatformField( root->getPartNumberHN( ), root->getPartNumber( ) );
+		printField( root->getPartNumberHN( ), root->getPartNumber( ) );
 
 	const vector<DataItem*> data = root->getDeviceSpecific( );
 	vector<DataItem*>::const_iterator i, end;
@@ -509,7 +494,7 @@ void printPlatform( Component* root )
 	{
 		label.str( "" );
 		label << (*i)->getHumanName( ) << ".(" << (*i)->getAC( ) << ")";
-		printPlatformField( label.str( ), (*i)->getValue( ) );
+		printField( label.str( ), (*i)->getValue( ) );
 	}
 
 	const vector<DataItem*> uData = root->getUserData( );
@@ -517,7 +502,7 @@ void printPlatform( Component* root )
 	{
 		label.str( "" );
 		label << (*i)->getHumanName( ) << ".(" << (*i)->getAC( ) << ")";
-		printPlatformField( label.str( ), (*i)->getValue( ) );
+		printField( label.str( ), (*i)->getValue( ) );
 	}
 
 	cout << "      Physical Location: " << root->getPhysicalLocation( ) <<
@@ -538,12 +523,12 @@ void printSpecific( System* root )
 	cout << "    Device Type:  " << root->getArch( ) << endl << endl;
 
 	cout << "      System VPD      :" << endl;
-	printPlatformField( "Product Specific.(RT)", root->getRecordType( ) );
-	printPlatformField( root->getFlagFieldHN( ), root->getFlagField( ) );
-	printPlatformField( root->getBrandHN( ), root->getBrand( ) );
-	printPlatformField( root->getSerial1HN( ), root->getSerial1( ) );
-	printPlatformField( root->getMachineTypeHN( ), root->getMachineType( ) );
-	printPlatformField( root->getKeywordVerHN( ), root->getKeywordVer( ) );
+	printField( "Product Specific.(RT)", root->getRecordType( ) );
+	printField( root->getFlagFieldHN( ), root->getFlagField( ) );
+	printField( root->getBrandHN( ), root->getBrand( ) );
+	printField( root->getSerial1HN( ), root->getSerial1( ) );
+	printField( root->getMachineTypeHN( ), root->getMachineType( ) );
+	printField( root->getKeywordVerHN( ), root->getKeywordVer( ) );
 	cout << "      Physical Location: " << root->getLocation( ) << endl <<
 		endl;
 
