[llvm-commits] CVS: llvm/tools/llvm-ar/llvm-ar.cpp
Reid Spencer
reid at x10sys.com
Thu Dec 2 01:22:06 PST 2004
Changes in directory llvm/tools/llvm-ar:
llvm-ar.cpp updated: 1.20 -> 1.21
---
Log message:
Implement file replacement correctly even with the f (TruncateNames) flag
set. The member name comparison was failing for truncated names. This patch
fixes that. Truncated names are now properly replaced.
---
Diffs of the changes: (+23 -2)
Index: llvm/tools/llvm-ar/llvm-ar.cpp
diff -u llvm/tools/llvm-ar/llvm-ar.cpp:1.20 llvm/tools/llvm-ar/llvm-ar.cpp:1.21
--- llvm/tools/llvm-ar/llvm-ar.cpp:1.20 Sat Nov 20 12:01:22 2004
+++ llvm/tools/llvm-ar/llvm-ar.cpp Thu Dec 2 03:21:55 2004
@@ -578,8 +578,29 @@
// Determine if this archive member matches one of the paths we're trying
// to replace.
- std::set<sys::Path>::iterator found =
- std::find(remaining.begin(),remaining.end(), I->getPath());
+
+ std::set<sys::Path>::iterator found = remaining.end();
+ for (std::set<sys::Path>::iterator RI = remaining.begin(),
+ RE = remaining.end(); RI != RE; ++RI ) {
+ std::string compare(RI->get());
+ 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().get()) {
+ found = RI;
+ break;
+ }
+ }
+
if (found != remaining.end()) {
sys::Path::StatusInfo si;
found->getStatusInfo(si);
More information about the llvm-commits
mailing list