[llvm] r186078 - Remove support for truncating names in archives.

Rafael Espindola rafael.espindola at gmail.com
Thu Jul 11 05:38:02 PDT 2013


Author: rafael
Date: Thu Jul 11 07:38:02 2013
New Revision: 186078

URL: http://llvm.org/viewvc/llvm-project?rev=186078&view=rev
Log:
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.

Modified:
    llvm/trunk/tools/llvm-ar/Archive.h
    llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/tools/llvm-ar/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/Archive.h?rev=186078&r1=186077&r2=186078&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/Archive.h (original)
+++ llvm/trunk/tools/llvm-ar/Archive.h Thu Jul 11 07:38:02 2013
@@ -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);

Modified: llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp?rev=186078&r1=186077&r2=186078&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp (original)
+++ llvm/trunk/tools/llvm-ar/ArchiveWriter.cpp Thu Jul 11 07:38:02 2013
@@ -80,7 +80,7 @@ Archive* Archive::CreateEmpty(StringRef
 // 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
     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 TruncateN
   // 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;

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=186078&r1=186077&r2=186078&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Jul 11 07:38:02 2013
@@ -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;
 }





More information about the llvm-commits mailing list