* Apparently string::find doesn't work right on our sun boxes. Work around this.
authorChris Lattner <sabre@nondot.org>
Thu, 17 Oct 2002 16:22:08 +0000 (16:22 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Oct 2002 16:22:08 +0000 (16:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4219 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/TraceValues.cpp

index 7c9d60fa20428f9940c736dd925ba32b72d7f7c3..f17932b2ebfaf0ab374c96db8eddbb7f493427cf 100644 (file)
@@ -212,10 +212,15 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
                             string Message,
                             Function *Printf, Function* HashPtrToSeqNum) {
   // Escape Message by replacing all % characters with %% chars.
-  unsigned Offset = 0;
-  while ((Offset = Message.find('%', Offset)) != string::npos) {
-    Message.replace(Offset, 1, "%%");
-    Offset += 2;  // Skip over the new %'s
+  string Tmp;
+  std::swap(Tmp, Message);
+  string::iterator I = std::find(Tmp.begin(), Tmp.end(), '%');
+  while (I != Tmp.end()) {
+    Message.append(Tmp.begin(), I);
+    Message += "%%";
+    ++I; // Make sure to erase the % as well...
+    Tmp.erase(Tmp.begin(), I);
+    I = std::find(Tmp.begin(), Tmp.end(), '%');
   }
 
   Module *Mod = BB->getParent()->getParent();