mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242153 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -295,11 +295,11 @@ static ArchiveOperation parseCommandLine() {
|
|||||||
|
|
||||||
// Implements the 'p' operation. This function traverses the archive
|
// Implements the 'p' operation. This function traverses the archive
|
||||||
// looking for members that match the path list.
|
// looking for members that match the path list.
|
||||||
static void doPrint(StringRef Name, object::Archive::child_iterator I) {
|
static void doPrint(StringRef Name, const object::Archive::Child &C) {
|
||||||
if (Verbose)
|
if (Verbose)
|
||||||
outs() << "Printing " << Name << "\n";
|
outs() << "Printing " << Name << "\n";
|
||||||
|
|
||||||
StringRef Data = I->getBuffer();
|
StringRef Data = C.getBuffer();
|
||||||
outs().write(Data.data(), Data.size());
|
outs().write(Data.data(), Data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,16 +324,16 @@ static void printMode(unsigned mode) {
|
|||||||
// the file names of each of the members. However, if verbose mode is requested
|
// the file names of each of the members. However, if verbose mode is requested
|
||||||
// ('v' modifier) then the file type, permission mode, user, group, size, and
|
// ('v' modifier) then the file type, permission mode, user, group, size, and
|
||||||
// modification time are also printed.
|
// modification time are also printed.
|
||||||
static void doDisplayTable(StringRef Name, object::Archive::child_iterator I) {
|
static void doDisplayTable(StringRef Name, const object::Archive::Child &C) {
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
sys::fs::perms Mode = I->getAccessMode();
|
sys::fs::perms Mode = C.getAccessMode();
|
||||||
printMode((Mode >> 6) & 007);
|
printMode((Mode >> 6) & 007);
|
||||||
printMode((Mode >> 3) & 007);
|
printMode((Mode >> 3) & 007);
|
||||||
printMode(Mode & 007);
|
printMode(Mode & 007);
|
||||||
outs() << ' ' << I->getUID();
|
outs() << ' ' << C.getUID();
|
||||||
outs() << '/' << I->getGID();
|
outs() << '/' << C.getGID();
|
||||||
outs() << ' ' << format("%6llu", I->getSize());
|
outs() << ' ' << format("%6llu", C.getSize());
|
||||||
outs() << ' ' << I->getLastModified().str();
|
outs() << ' ' << C.getLastModified().str();
|
||||||
outs() << ' ';
|
outs() << ' ';
|
||||||
}
|
}
|
||||||
outs() << Name << "\n";
|
outs() << Name << "\n";
|
||||||
@@ -341,9 +341,9 @@ static void doDisplayTable(StringRef Name, object::Archive::child_iterator I) {
|
|||||||
|
|
||||||
// Implement the 'x' operation. This function extracts files back to the file
|
// Implement the 'x' operation. This function extracts files back to the file
|
||||||
// system.
|
// system.
|
||||||
static void doExtract(StringRef Name, object::Archive::child_iterator I) {
|
static void doExtract(StringRef Name, const object::Archive::Child &C) {
|
||||||
// Retain the original mode.
|
// Retain the original mode.
|
||||||
sys::fs::perms Mode = I->getAccessMode();
|
sys::fs::perms Mode = C.getAccessMode();
|
||||||
SmallString<128> Storage = Name;
|
SmallString<128> Storage = Name;
|
||||||
|
|
||||||
int FD;
|
int FD;
|
||||||
@@ -355,7 +355,7 @@ static void doExtract(StringRef Name, object::Archive::child_iterator I) {
|
|||||||
raw_fd_ostream file(FD, false);
|
raw_fd_ostream file(FD, false);
|
||||||
|
|
||||||
// Get the data and its length
|
// Get the data and its length
|
||||||
StringRef Data = I->getBuffer();
|
StringRef Data = C.getBuffer();
|
||||||
|
|
||||||
// Write the data.
|
// Write the data.
|
||||||
file.write(Data.data(), Data.size());
|
file.write(Data.data(), Data.size());
|
||||||
@@ -365,7 +365,7 @@ static void doExtract(StringRef Name, object::Archive::child_iterator I) {
|
|||||||
// now.
|
// now.
|
||||||
if (OriginalDates)
|
if (OriginalDates)
|
||||||
failIfError(
|
failIfError(
|
||||||
sys::fs::setLastModificationAndAccessTime(FD, I->getLastModified()));
|
sys::fs::setLastModificationAndAccessTime(FD, C.getLastModified()));
|
||||||
|
|
||||||
if (close(FD))
|
if (close(FD))
|
||||||
fail("Could not close the file");
|
fail("Could not close the file");
|
||||||
@@ -391,10 +391,8 @@ static bool shouldCreateArchive(ArchiveOperation Op) {
|
|||||||
|
|
||||||
static void performReadOperation(ArchiveOperation Operation,
|
static void performReadOperation(ArchiveOperation Operation,
|
||||||
object::Archive *OldArchive) {
|
object::Archive *OldArchive) {
|
||||||
for (object::Archive::child_iterator I = OldArchive->child_begin(),
|
for (const object::Archive::Child &C : OldArchive->children()) {
|
||||||
E = OldArchive->child_end();
|
ErrorOr<StringRef> NameOrErr = C.getName();
|
||||||
I != E; ++I) {
|
|
||||||
ErrorOr<StringRef> NameOrErr = I->getName();
|
|
||||||
failIfError(NameOrErr.getError());
|
failIfError(NameOrErr.getError());
|
||||||
StringRef Name = NameOrErr.get();
|
StringRef Name = NameOrErr.get();
|
||||||
|
|
||||||
@@ -406,13 +404,13 @@ static void performReadOperation(ArchiveOperation Operation,
|
|||||||
default:
|
default:
|
||||||
llvm_unreachable("Not a read operation");
|
llvm_unreachable("Not a read operation");
|
||||||
case Print:
|
case Print:
|
||||||
doPrint(Name, I);
|
doPrint(Name, C);
|
||||||
break;
|
break;
|
||||||
case DisplayTable:
|
case DisplayTable:
|
||||||
doDisplayTable(Name, I);
|
doDisplayTable(Name, C);
|
||||||
break;
|
break;
|
||||||
case Extract:
|
case Extract:
|
||||||
doExtract(Name, I);
|
doExtract(Name, C);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user