summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-11 12:38:02 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-11 12:38:02 +0000
commitab7348f8b188270ecbd309d5f0f4696f1f782c9b (patch)
treecfd7c69ca63dfbaa91a282c54b432cc2cdda87c3 /tools
parent4f2779b809f6a9bb5ca63b10d55f8302cca2c656 (diff)
downloadllvm-ab7348f8b188270ecbd309d5f0f4696f1f782c9b.tar.gz
llvm-ab7348f8b188270ecbd309d5f0f4696f1f782c9b.tar.bz2
llvm-ab7348f8b188270ecbd309d5f0f4696f1f782c9b.tar.xz
Remove support for truncating names in archives.
* All systems we support have some form of long name support. * The options has different names and semantics in different implementations ('f' on gnu, 'T' on OS X), which makes it unlikely it is normally used on build systems. * It was completely untested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-ar/Archive.h4
-rw-r--r--tools/llvm-ar/ArchiveWriter.cpp21
-rw-r--r--tools/llvm-ar/llvm-ar.cpp26
3 files changed, 9 insertions, 42 deletions
diff --git a/tools/llvm-ar/Archive.h b/tools/llvm-ar/Archive.h
index 977fe62d60..52622dde35 100644
--- a/tools/llvm-ar/Archive.h
+++ b/tools/llvm-ar/Archive.h
@@ -318,7 +318,6 @@ class Archive {
/// returns false if the writing succeeded.
/// @brief Write (possibly modified) archive contents to disk
bool writeToDisk(
- bool TruncateNames=false, ///< Truncate the filename to 15 chars
std::string* ErrMessage=0 ///< If non-null, where error msg is set
);
@@ -372,13 +371,12 @@ class Archive {
bool writeMember(
const ArchiveMember& member, ///< The member to be written
raw_fd_ostream& ARFile, ///< The file to write member onto
- bool TruncateNames, ///< Should names be truncated to 11 chars?
std::string* ErrMessage ///< If non-null, place were error msg is set
);
/// @brief Fill in an ArchiveMemberHeader from ArchiveMember.
bool fillHeader(const ArchiveMember&mbr,
- ArchiveMemberHeader& hdr,int sz, bool TruncateNames) const;
+ ArchiveMemberHeader& hdr,int sz) const;
/// @brief Maps archive into memory
bool mapToMemory(std::string* ErrMsg);
diff --git a/tools/llvm-ar/ArchiveWriter.cpp b/tools/llvm-ar/ArchiveWriter.cpp
index ef910019df..bdccf3e0d9 100644
--- a/tools/llvm-ar/ArchiveWriter.cpp
+++ b/tools/llvm-ar/ArchiveWriter.cpp
@@ -80,7 +80,7 @@ Archive* Archive::CreateEmpty(StringRef FilePath, LLVMContext& C) {
// compressed.
bool
Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
- int sz, bool TruncateNames) const {
+ int sz) const {
// Set the permissions mode, uid and gid
hdr.init();
@@ -107,18 +107,6 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr,
memcpy(hdr.name,ARFILE_SVR4_SYMTAB_NAME,16);
} else if (mbr.isBSD4SymbolTable()) {
memcpy(hdr.name,ARFILE_BSD4_SYMTAB_NAME,16);
- } else if (TruncateNames) {
- const char* nm = mbrPath.c_str();
- unsigned len = mbrPath.length();
- size_t slashpos = mbrPath.rfind('/');
- if (slashpos != std::string::npos) {
- nm += slashpos + 1;
- len -= slashpos +1;
- }
- if (len > 15)
- len = 15;
- memcpy(hdr.name,nm,len);
- hdr.name[len] = '/';
} else if (mbrPath.length() < 16 && mbrPath.find('/') == std::string::npos) {
memcpy(hdr.name,mbrPath.c_str(),mbrPath.length());
hdr.name[mbrPath.length()] = '/';
@@ -193,7 +181,6 @@ bool
Archive::writeMember(
const ArchiveMember& member,
raw_fd_ostream& ARFile,
- bool TruncateNames,
std::string* ErrMsg
) {
@@ -221,7 +208,7 @@ Archive::writeMember(
// Compute the fields of the header
ArchiveMemberHeader Hdr;
- bool writeLongName = fillHeader(member,Hdr,hdrSize,TruncateNames);
+ bool writeLongName = fillHeader(member,Hdr,hdrSize);
// Write header to archive file
ARFile.write((char*)&Hdr, sizeof(Hdr));
@@ -248,7 +235,7 @@ Archive::writeMember(
// This writes to a temporary file first. Options are for creating a symbol
// table, flattening the file names (no directories, 15 chars max) and
// compressing each archive member.
-bool Archive::writeToDisk(bool TruncateNames, std::string *ErrMsg) {
+bool Archive::writeToDisk(std::string *ErrMsg) {
// Make sure they haven't opened up the file, not loaded it,
// but are now trying to write it which would wipe out the file.
if (members.empty() && mapfile && mapfile->getBufferSize() > 8) {
@@ -277,7 +264,7 @@ bool Archive::writeToDisk(bool TruncateNames, std::string *ErrMsg) {
// Loop over all member files, and write them out. Note that this also
// builds the symbol table, symTab.
for (MembersList::iterator I = begin(), E = end(); I != E; ++I) {
- if (writeMember(*I, ArchiveFile, TruncateNames, ErrMsg)) {
+ if (writeMember(*I, ArchiveFile, ErrMsg)) {
sys::fs::remove(Twine(TmpArchive));
ArchiveFile.close();
return true;
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index 9e17853fd5..3d5250ee53 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -64,7 +64,6 @@ static cl::extrahelp MoreHelp(
"\nMODIFIERS (operation specific):\n"
" [a] - put file(s) after [relpos]\n"
" [b] - put file(s) before [relpos] (same as [i])\n"
- " [f] - truncate inserted file names\n"
" [i] - put file(s) before [relpos] (same as [b])\n"
" [N] - use instance [count] of name\n"
" [o] - preserve original dates\n"
@@ -93,7 +92,6 @@ enum ArchiveOperation {
bool AddAfter = false; ///< 'a' modifier
bool AddBefore = false; ///< 'b' modifier
bool Create = false; ///< 'c' modifier
-bool TruncateNames = false; ///< 'f' modifier
bool InsertBefore = false; ///< 'i' modifier
bool UseCount = false; ///< 'N' modifier
bool OriginalDates = false; ///< 'o' modifier
@@ -213,7 +211,6 @@ ArchiveOperation parseCommandLine() {
case 't': ++NumOperations; Operation = DisplayTable; break;
case 'x': ++NumOperations; Operation = Extract; break;
case 'c': Create = true; break;
- case 'f': TruncateNames = true; break;
case 'l': /* accepted but unused */ break;
case 'o': OriginalDates = true; break;
case 's': break; // Ignore for now.
@@ -267,9 +264,6 @@ ArchiveOperation parseCommandLine() {
}
if (OriginalDates && Operation != Extract)
show_help("The 'o' modifier is only applicable to the 'x' operation");
- if (TruncateNames && Operation!=QuickAppend && Operation!=ReplaceOrInsert)
- show_help("The 'f' modifier is only applicable to the 'q' and 'r' "
- "operations");
if (OnlyUpdate && Operation != ReplaceOrInsert)
show_help("The 'u' modifier is only applicable to the 'r' operation");
if (Count > 1 && Members.size() > 1)
@@ -460,7 +454,7 @@ doDelete(std::string* ErrMsg) {
}
// We're done editting, reconstruct the archive.
- if (TheArchive->writeToDisk(TruncateNames,ErrMsg))
+ if (TheArchive->writeToDisk(ErrMsg))
return true;
return false;
}
@@ -513,7 +507,7 @@ doMove(std::string* ErrMsg) {
}
// We're done editting, reconstruct the archive.
- if (TheArchive->writeToDisk(TruncateNames,ErrMsg))
+ if (TheArchive->writeToDisk(ErrMsg))
return true;
return false;
}
@@ -536,7 +530,7 @@ doQuickAppend(std::string* ErrMsg) {
}
// We're done editting, reconstruct the archive.
- if (TheArchive->writeToDisk(TruncateNames,ErrMsg))
+ if (TheArchive->writeToDisk(ErrMsg))
return true;
return false;
}
@@ -569,18 +563,6 @@ doReplaceOrInsert(std::string* ErrMsg) {
for (std::set<std::string>::iterator RI = remaining.begin(),
RE = remaining.end(); RI != RE; ++RI ) {
std::string compare(sys::path::filename(*RI));
- if (TruncateNames && compare.length() > 15) {
- const char* nm = compare.c_str();
- unsigned len = compare.length();
- size_t slashpos = compare.rfind('/');
- if (slashpos != std::string::npos) {
- nm += slashpos + 1;
- len -= slashpos +1;
- }
- if (len > 15)
- len = 15;
- compare.assign(nm,len);
- }
if (compare == I->getPath().str()) {
found = RI;
break;
@@ -631,7 +613,7 @@ doReplaceOrInsert(std::string* ErrMsg) {
}
// We're done editting, reconstruct the archive.
- if (TheArchive->writeToDisk(TruncateNames,ErrMsg))
+ if (TheArchive->writeToDisk(ErrMsg))
return true;
return false;
}