X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-ar%2Fllvm-ar.cpp;h=3271f7c82f46670635ee43aaf28d681e24582d57;hb=a75ce9f5d2236d93c117e861e60e6f3f748c9555;hp=c31f86ec5fdb887b6dd6a530c1f8b84e9feac423;hpb=0d7c695c74ae6d5f68cc07378c17491915e607d3;p=oota-llvm.git diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index c31f86ec5fd..3271f7c82f4 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -18,12 +18,12 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/System/Signals.h" -#include +#include "llvm/Support/Signals.h" #include -#include #include +#include using namespace llvm; // Option for compatibility with AIX, not used but must allow it to be present. @@ -334,12 +334,12 @@ bool buildPaths(bool checkExistence, std::string* ErrMsg) { // printSymbolTable - print out the archive's symbol table. void printSymbolTable() { - std::cout << "\nArchive Symbol Table:\n"; + outs() << "\nArchive Symbol Table:\n"; const Archive::SymTabType& symtab = TheArchive->getSymbolTable(); for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end(); I != E; ++I ) { unsigned offset = TheArchive->getFirstFileOffset() + I->second; - std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n"; + outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n"; } } @@ -364,10 +364,10 @@ bool doPrint(std::string* ErrMsg) { continue; if (Verbose) - std::cout << "Printing " << I->getPath().toString() << "\n"; + outs() << "Printing " << I->getPath().str() << "\n"; unsigned len = I->getSize(); - std::cout.write(data, len); + outs().write(data, len); } else { countDown--; } @@ -381,17 +381,17 @@ bool doPrint(std::string* ErrMsg) { void printMode(unsigned mode) { if (mode & 004) - std::cout << "r"; + outs() << "r"; else - std::cout << "-"; + outs() << "-"; if (mode & 002) - std::cout << "w"; + outs() << "w"; else - std::cout << "-"; + outs() << "-"; if (mode & 001) - std::cout << "x"; + outs() << "x"; else - std::cout << "-"; + outs() << "-"; } // doDisplayTable - Implement the 't' operation. This function prints out just @@ -410,23 +410,22 @@ doDisplayTable(std::string* ErrMsg) { // FIXME: Output should be this format: // Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile if (I->isBitcode()) - std::cout << "b"; + outs() << "b"; else if (I->isCompressed()) - std::cout << "Z"; + outs() << "Z"; else - std::cout << " "; + outs() << " "; unsigned mode = I->getMode(); printMode((mode >> 6) & 007); printMode((mode >> 3) & 007); printMode(mode & 007); - std::cout << " " << std::setw(4) << I->getUser(); - std::cout << "/" << std::setw(4) << I->getGroup(); - std::cout << " " << std::setw(8) << I->getSize(); - std::cout << " " << std::setw(20) << - I->getModTime().toString().substr(4); - std::cout << " " << I->getPath().toString() << "\n"; + outs() << " " << format("%4u", I->getUser()); + outs() << "/" << format("%4u", I->getGroup()); + outs() << " " << format("%8u", I->getSize()); + outs() << " " << format("%20s", I->getModTime().str().substr(4).c_str()); + outs() << " " << I->getPath().str() << "\n"; } else { - std::cout << I->getPath().toString() << "\n"; + outs() << I->getPath().str() << "\n"; } } } @@ -528,7 +527,7 @@ doMove(std::string* ErrMsg) { if (AddBefore || InsertBefore || AddAfter) { for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end(); I != E; ++I ) { - if (RelPos == I->getPath().toString()) { + if (RelPos == I->getPath().str()) { if (AddAfter) { moveto_spot = I; moveto_spot++; @@ -616,7 +615,7 @@ doReplaceOrInsert(std::string* ErrMsg) { std::set::iterator found = remaining.end(); for (std::set::iterator RI = remaining.begin(), RE = remaining.end(); RI != RE; ++RI ) { - std::string compare(RI->toString()); + std::string compare(RI->str()); if (TruncateNames && compare.length() > 15) { const char* nm = compare.c_str(); unsigned len = compare.length(); @@ -629,7 +628,7 @@ doReplaceOrInsert(std::string* ErrMsg) { len = 15; compare.assign(nm,len); } - if (compare == I->getPath().toString()) { + if (compare == I->getPath().str()) { found = RI; break; } @@ -661,9 +660,9 @@ doReplaceOrInsert(std::string* ErrMsg) { } // Determine if this is the place where we should insert - if ((AddBefore || InsertBefore) && (RelPos == I->getPath().toString())) + if ((AddBefore || InsertBefore) && RelPos == I->getPath().str()) insert_spot = I; - else if (AddAfter && (RelPos == I->getPath().toString())) { + else if (AddAfter && RelPos == I->getPath().str()) { insert_spot = I; insert_spot++; } @@ -719,14 +718,14 @@ int main(int argc, char **argv) { if (!ArchivePath.exists()) { // Produce a warning if we should and we're creating the archive if (!Create) - errs() << argv[0] << ": creating " << ArchivePath.toString() << "\n"; + errs() << argv[0] << ": creating " << ArchivePath.str() << "\n"; TheArchive = Archive::CreateEmpty(ArchivePath, Context); TheArchive->writeToDisk(); } else { std::string Error; TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error); if (TheArchive == 0) { - errs() << argv[0] << ": error loading '" << ArchivePath << "': " + errs() << argv[0] << ": error loading '" << ArchivePath.str() << "': " << Error << "!\n"; return 1; }