llvm.org GIT mirror llvm / 424a04e
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 Chris Lattner 8 years ago
2 changed file(s) with 23 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
1717 #include "llvm/Support/CommandLine.h"
1818 #include "llvm/Support/ManagedStatic.h"
1919 #include "llvm/Support/PrettyStackTrace.h"
20 #include "llvm/Support/Format.h"
2021 #include "llvm/Support/raw_ostream.h"
2122 #include "llvm/Support/Signals.h"
22 #include
2323 #include
24 #include
2524 #include
2625 #include
2726 using namespace llvm;
334333
335334 // printSymbolTable - print out the archive's symbol table.
336335 void printSymbolTable() {
337 std::cout << "\nArchive Symbol Table:\n";
336 outs() << "\nArchive Symbol Table:\n";
338337 const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
339338 for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
340339 I != E; ++I ) {
341340 unsigned offset = TheArchive->getFirstFileOffset() + I->second;
342 std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
341 outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
343342 }
344343 }
345344
364363 continue;
365364
366365 if (Verbose)
367 std::cout << "Printing " << I->getPath().str() << "\n";
366 outs() << "Printing " << I->getPath().str() << "\n";
368367
369368 unsigned len = I->getSize();
370 std::cout.write(data, len);
369 outs().write(data, len);
371370 } else {
372371 countDown--;
373372 }
381380 void
382381 printMode(unsigned mode) {
383382 if (mode & 004)
384 std::cout << "r";
383 outs() << "r";
385384 else
386 std::cout << "-";
385 outs() << "-";
387386 if (mode & 002)
388 std::cout << "w";
387 outs() << "w";
389388 else
390 std::cout << "-";
389 outs() << "-";
391390 if (mode & 001)
392 std::cout << "x";
391 outs() << "x";
393392 else
394 std::cout << "-";
393 outs() << "-";
395394 }
396395
397396 // doDisplayTable - Implement the 't' operation. This function prints out just
410409 // FIXME: Output should be this format:
411410 // Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile
412411 if (I->isBitcode())
413 std::cout << "b";
412 outs() << "b";
414413 else if (I->isCompressed())
415 std::cout << "Z";
414 outs() << "Z";
416415 else
417 std::cout << " ";
416 outs() << " ";
418417 unsigned mode = I->getMode();
419418 printMode((mode >> 6) & 007);
420419 printMode((mode >> 3) & 007);
421420 printMode(mode & 007);
422 std::cout << " " << std::setw(4) << I->getUser();
423 std::cout << "/" << std::setw(4) << I->getGroup();
424 std::cout << " " << std::setw(8) << I->getSize();
425 std::cout << " " << std::setw(20) << I->getModTime().str().substr(4);
426 std::cout << " " << I->getPath().str() << "\n";
421 outs() << " " << format("%4u", I->getUser());
422 outs() << "/" << format("%4u", I->getGroup());
423 outs() << " " << format("%8u", I->getSize());
424 outs() << " " << format("%20s", I->getModTime().str().substr(4).c_str());
425 outs() << " " << I->getPath().str() << "\n";
427426 } else {
428 std::cout << I->getPath().str() << "\n";
427 outs() << I->getPath().str() << "\n";
429428 }
430429 }
431430 }
1616 #include "llvm/Support/CommandLine.h"
1717 #include "llvm/Support/ManagedStatic.h"
1818 #include "llvm/Support/PrettyStackTrace.h"
19 #include "llvm/Support/Format.h"
1920 #include "llvm/Support/raw_ostream.h"
2021 #include "llvm/Support/Signals.h"
21 #include
22 #include
2322 #include
24
2523 using namespace llvm;
2624
2725 // llvm-ar operation code and modifier flags
3432
3533 // printSymbolTable - print out the archive's symbol table.
3634 void printSymbolTable(Archive* TheArchive) {
37 std::cout << "\nArchive Symbol Table:\n";
35 outs() << "\nArchive Symbol Table:\n";
3836 const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
3937 for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
4038 I != E; ++I ) {
4139 unsigned offset = TheArchive->getFirstFileOffset() + I->second;
42 std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
40 outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
4341 }
4442 }
4543