convert llvm-ar and llvm-ranlib to raw_ostream from iostreams.

Patch by Danil Malyshev!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120341 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-11-29 23:02:20 +00:00
parent 75579f739f
commit 424a04ec4e
2 changed files with 23 additions and 26 deletions

View File

@@ -18,11 +18,10 @@
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
#include <iostream>
#include <algorithm> #include <algorithm>
#include <iomanip>
#include <memory> #include <memory>
#include <fstream> #include <fstream>
using namespace llvm; using namespace llvm;
@@ -335,12 +334,12 @@ bool buildPaths(bool checkExistence, std::string* ErrMsg) {
// printSymbolTable - print out the archive's symbol table. // printSymbolTable - print out the archive's symbol table.
void printSymbolTable() { void printSymbolTable() {
std::cout << "\nArchive Symbol Table:\n"; outs() << "\nArchive Symbol Table:\n";
const Archive::SymTabType& symtab = TheArchive->getSymbolTable(); const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end(); for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
I != E; ++I ) { I != E; ++I ) {
unsigned offset = TheArchive->getFirstFileOffset() + I->second; unsigned offset = TheArchive->getFirstFileOffset() + I->second;
std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n"; outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
} }
} }
@@ -365,10 +364,10 @@ bool doPrint(std::string* ErrMsg) {
continue; continue;
if (Verbose) if (Verbose)
std::cout << "Printing " << I->getPath().str() << "\n"; outs() << "Printing " << I->getPath().str() << "\n";
unsigned len = I->getSize(); unsigned len = I->getSize();
std::cout.write(data, len); outs().write(data, len);
} else { } else {
countDown--; countDown--;
} }
@@ -382,17 +381,17 @@ bool doPrint(std::string* ErrMsg) {
void void
printMode(unsigned mode) { printMode(unsigned mode) {
if (mode & 004) if (mode & 004)
std::cout << "r"; outs() << "r";
else else
std::cout << "-"; outs() << "-";
if (mode & 002) if (mode & 002)
std::cout << "w"; outs() << "w";
else else
std::cout << "-"; outs() << "-";
if (mode & 001) if (mode & 001)
std::cout << "x"; outs() << "x";
else else
std::cout << "-"; outs() << "-";
} }
// doDisplayTable - Implement the 't' operation. This function prints out just // doDisplayTable - Implement the 't' operation. This function prints out just
@@ -411,22 +410,22 @@ doDisplayTable(std::string* ErrMsg) {
// FIXME: Output should be this format: // FIXME: Output should be this format:
// Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile // Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile
if (I->isBitcode()) if (I->isBitcode())
std::cout << "b"; outs() << "b";
else if (I->isCompressed()) else if (I->isCompressed())
std::cout << "Z"; outs() << "Z";
else else
std::cout << " "; outs() << " ";
unsigned mode = I->getMode(); unsigned mode = I->getMode();
printMode((mode >> 6) & 007); printMode((mode >> 6) & 007);
printMode((mode >> 3) & 007); printMode((mode >> 3) & 007);
printMode(mode & 007); printMode(mode & 007);
std::cout << " " << std::setw(4) << I->getUser(); outs() << " " << format("%4u", I->getUser());
std::cout << "/" << std::setw(4) << I->getGroup(); outs() << "/" << format("%4u", I->getGroup());
std::cout << " " << std::setw(8) << I->getSize(); outs() << " " << format("%8u", I->getSize());
std::cout << " " << std::setw(20) << I->getModTime().str().substr(4); outs() << " " << format("%20s", I->getModTime().str().substr(4).c_str());
std::cout << " " << I->getPath().str() << "\n"; outs() << " " << I->getPath().str() << "\n";
} else { } else {
std::cout << I->getPath().str() << "\n"; outs() << I->getPath().str() << "\n";
} }
} }
} }

View File

@@ -17,12 +17,10 @@
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
#include <iostream>
#include <iomanip>
#include <memory> #include <memory>
using namespace llvm; using namespace llvm;
// llvm-ar operation code and modifier flags // llvm-ar operation code and modifier flags
@@ -35,12 +33,12 @@ Verbose("verbose",cl::Optional,cl::init(false),
// printSymbolTable - print out the archive's symbol table. // printSymbolTable - print out the archive's symbol table.
void printSymbolTable(Archive* TheArchive) { void printSymbolTable(Archive* TheArchive) {
std::cout << "\nArchive Symbol Table:\n"; outs() << "\nArchive Symbol Table:\n";
const Archive::SymTabType& symtab = TheArchive->getSymbolTable(); const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end(); for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
I != E; ++I ) { I != E; ++I ) {
unsigned offset = TheArchive->getFirstFileOffset() + I->second; unsigned offset = TheArchive->getFirstFileOffset() + I->second;
std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n"; outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
} }
} }