[llvm-commits] CVS: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp

Reid Spencer reid at x10sys.com
Wed Nov 17 10:28:40 PST 2004



Changes in directory llvm/lib/Bytecode/Archive:

ArchiveWriter.cpp updated: 1.6 -> 1.7
---
Log message:

Fix some things for Mac OSX archives:
* ensure trailing spaces are eliminated so they don't factor into the 
  length of a member's name.
* make sure all the bytes of a name are written even if the name ends in
  multiple null characters (bug in OSX ar)
* make sure we provide the full member name when searching for symbols so
  the module name is not accidentally duplicated.


---
Diffs of the changes:  (+14 -5)

Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.6 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.7
--- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.6	Wed Nov 17 10:14:21 2004
+++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp	Wed Nov 17 12:28:29 2004
@@ -93,9 +93,16 @@
   sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch));
   memcpy(hdr.date,buffer,12);
 
+  // Get rid of trailing blanks in the name
+  std::string mbrPath = mbr.getPath().get();
+  size_t mbrLen = mbrPath.length();
+  while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') {
+    mbrPath.erase(mbrLen-1,1);
+    mbrLen--;
+  }
+
   // Set the name field in one of its various flavors.
   bool writeLongName = false;
-  const std::string& mbrPath = mbr.getPath().get();
   if (mbr.isStringTable()) {
     memcpy(hdr.name,ARFILE_STRTAB_NAME,16);
   } else if (mbr.isForeignSymbolTable()) {
@@ -115,12 +122,12 @@
     memcpy(hdr.name,nm,len);
     hdr.name[len] = '/';
   } else if (mbrPath.length() < 16 && mbrPath.find('/') == std::string::npos) {
-    mbrPath.copy(hdr.name,mbrPath.length());
+    memcpy(hdr.name,mbrPath.c_str(),mbrPath.length());
     hdr.name[mbrPath.length()] = '/';
   } else {
     std::string nm = "#1/";
     nm += utostr(mbrPath.length());
-    nm.copy(hdr.name,nm.length());
+    memcpy(hdr.name,nm.data(),nm.length());
     if (sz < 0)
       sz -= mbrPath.length();
     else
@@ -203,8 +210,10 @@
   if (CreateSymbolTable && 
       (member.isBytecode() || member.isCompressedBytecode())) {
     std::vector<std::string> symbols;
+    std::string FullMemberName = archPath.get() + "(" + member.getPath().get() 
+      + ")";
     ModuleProvider* MP = GetBytecodeSymbols(
-      (const unsigned char*)data,fSize,member.getPath().get(), symbols);
+      (const unsigned char*)data,fSize,FullMemberName, symbols);
 
     // If the bytecode parsed successfully
     if ( MP ) {
@@ -270,7 +279,7 @@
 
   // Write the long filename if its long
   if (writeLongName) {
-    ARFile << member.getPath().c_str();
+    ARFile.write(member.getPath().get().data(),member.getPath().get().length());
   }
 
   // Make sure we write the compressed bytecode magic number if we should.






More information about the llvm-commits mailing list