diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-12-02 09:21:55 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-12-02 09:21:55 +0000 |
commit | 0de66b5cc8766102197c565a32bc7f9436b607da (patch) | |
tree | 55dd1ddd7fa27fa994b1be44e54329c54558b219 /tools | |
parent | 86ac2dcda153cbf317fa6ea7c8ad97ec0f173c4c (diff) | |
download | external_llvm-0de66b5cc8766102197c565a32bc7f9436b607da.zip external_llvm-0de66b5cc8766102197c565a32bc7f9436b607da.tar.gz external_llvm-0de66b5cc8766102197c565a32bc7f9436b607da.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-ar/llvm-ar.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 0707fd6..2a9b471 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -578,8 +578,29 @@ void doReplaceOrInsert() { // 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); |