[crux-devel] prt-get source code beautifying

Vitaly Sinilin vs at kp4.ru
Mon Aug 1 12:07:19 UTC 2016


Hi,

What is the reason to reset cout flags and fill character before each
line? It makes no difference to output on my system, but makes code
harder to read.

diff --git a/src/prtget.cpp b/src/prtget.cpp
index f22214c..5d94880 100644
--- a/src/prtget.cpp
+++ b/src/prtget.cpp
@@ -875,7 +875,6 @@ void PrtGet::printFormattedDiffLine(const string& name,
     cout <<  name;
 
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << versionInstalled;
 
     string locked = "";
@@ -883,7 +882,6 @@ void PrtGet::printFormattedDiffLine(const string& name,
         locked = "locked";
     }
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << versionPortsTree << locked << endl;
 }
 /*!
@@ -2044,7 +2042,6 @@ void PrtGet::printDepsLevel(int indent, const Package* package)
 
 void PrtGet::dumpConfig()
 {
-
     cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
     cout.fill( ' ' );
@@ -2055,58 +2052,40 @@ void PrtGet::dumpConfig()
         if ( m_parser->isAlternateConfigGiven() ) {
             fName = m_parser->alternateConfigFile();
         }
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Configuration file: " << fName << endl;
     }
 
     if (m_config->cacheFile() != "") {
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Cache file: " << m_config->cacheFile() << endl;
     }
     if (m_config->makeCommand() != "") {
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Make command file: " << m_config->makeCommand() << endl;
     }
     if (m_config->addCommand() != "") {
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Add command: " << m_config->addCommand() << endl;
     }
     if (m_config->removeCommand() != "") {
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Remove command: " << m_config->removeCommand() << endl;
     }
     if (m_config->runscriptCommand() != "") {
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Runscript command: " << m_config->runscriptCommand() << endl;
     }
 
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "Run scripts: " <<(m_config->runScripts() ? "yes" : "no" )
          << endl;
 
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "Keep higher version:" <<(m_config->preferHigher() ? "yes" : "no" )
          << endl;
 
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "Readme mode:  ";
     switch (m_config->readmeMode()) {
         case Configuration::VERBOSE_README:
@@ -2124,34 +2103,23 @@ void PrtGet::dumpConfig()
     cout << endl;
 
     if (m_config->logFilePattern() != "") {
-        cout.setf( ios::left, ios::adjustfield );
         cout.width( 20 );
-        cout.fill( ' ' );
         cout << "Log file: " << m_config->logFilePattern() << endl;
     }
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "  Write log: " << (m_config->writeLog() ? "yes" : "no" ) << endl;
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "  Append log: " <<(m_config->appendLog() ? "yes" : "no" ) << endl;
 
     cout << endl;
-    cout.setf( ios::left, ios::adjustfield );
+
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "Pkgmk settings:" << endl;
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "  Package dir: " << InstallTransaction::getPkgmkPackageDir() 
          << endl;
     
-    cout.setf( ios::left, ios::adjustfield );
     cout.width( 20 );
-    cout.fill( ' ' );
     cout << "  Compression mode: " 
          << InstallTransaction::getPkgmkCompressionMode() << endl;

-- 
Vitaly Sinilin <vs at kp4.ru>



More information about the crux-devel mailing list