Adding special logic for worktitle keywords

--- cpp/rewrite_keywords_and_authors_from_authority_data.cc
+++ cpp/rewrite_keywords_and_authors_from_authority_data.cc
@@ -93,18 +93,33 @@
 }

+bool IsWorkTitleField(MARC::Subfields &subfields) {
+    return subfields.hasSubfieldWithValue('D', "u");
+}
+
+
 void UpdateTitleField(MARC::Record::Field * const field, const MARC::Record authority_record) {
-     auto authority_primary_field(GetFirstPrimaryField(authority_record));
-     if (authority_primary_field == authority_record.end())
-         LOG_ERROR("Could not find appropriate Tag for authority PPN " + authority_record.getControlNumber());
-     MARC::Subfields subfields(field->getSubfields());
-     // We have to make sure that the order of the subfields is inherited from the authority data
-     // so delete the subfields to be replaced first
-     for (auto &authority_subfield : authority_primary_field->getSubfields())
-	  subfields.deleteAllSubfieldsWithCode(authority_subfield.code_);
-     for (auto &authority_subfield : authority_primary_field->getSubfields())
-          subfields.appendSubfield(authority_subfield.code_, authority_subfield.value_);
-     field->setContents(subfields, field->getIndicator1(), field->getIndicator2());
+    auto authority_primary_field(GetFirstPrimaryField(authority_record));
+    if (authority_primary_field == authority_record.end())
+        LOG_ERROR("Could not find appropriate Tag for authority PPN " + authority_record.getControlNumber());
+    MARC::Subfields subfields(field->getSubfields());
+    // We have to make sure that the order of the subfields is inherited from the authority data
+    // so delete the subfields to be replaced first
+    // Moreover there is a special case with "Werktitel". These are in $a
+    // in the authority data but must be mapped to $t in the title data
+    for (auto &authority_subfield : authority_primary_field->getSubfields()) {
+        if (IsWorkTitleField(subfields) and authority_subfield.code_ == 'a')
+            subfields.deleteAllSubfieldsWithCode('t');
+        else
+            subfields.deleteAllSubfieldsWithCode(authority_subfield.code_);
+    }
+    for (auto &authority_subfield : authority_primary_field->getSubfields()){
+        if (IsWorkTitleField(subfields) and authority_subfield.code_ == 'a')
+            subfields.appendSubfield('t', authority_subfield.value_);
+        else
+            subfields.appendSubfield(authority_subfield.code_, authority_subfield.value_);
+    }
+    field->setContents(subfields, field->getIndicator1(), field->getIndicator2());
 }


Changed.

Changed.

--- AuxNode.hpp
+++ AuxNode.hpp
@@ -14,7 +14,7 @@
 	void makeDelta(const T &value);

 public:
-	void pushdown();
+	void pushTagTree();
 	void update();

 };


(unstable) [modified] armor decay formula

git-svn-id: e4cf3396f21da4a5d638eecf7e3b4dd52b27f938@5556 c3d1530f-68f5-4bd0-87dc-8ef779617e40

--- MMOCoreORB/src/server/zone/managers/combat/CombatManager.cpp
+++ MMOCoreORB/src/server/zone/managers/combat/CombatManager.cpp
@@ -727,7 +727,6 @@
 	ManagedReference<ArmorObject*> psg = getPSGArmor(attacker, defender);

 	if (psg != NULL && !psg->isVulnerable(weapon->getDamageType())) {
-		float originalDamage = damage;
 		float armorPiercing = getArmorPiercing(psg, weapon);
 		float armorReduction =  getArmorObjectReduction(attacker, psg);

@@ -737,8 +736,7 @@
 		// inflict condition damage
 		// TODO: this formula makes PSG's take more damage than regular armor, but that's how it was on live
 		// it can be fixed by doing condition damage after all damage reductions
-		float conditionDamage = (originalDamage * armorPiercing - damage) * 0.1;
-		psg->inflictDamage(psg, 0, conditionDamage, true, true);
+		psg->inflictDamage(psg, 0, damage * 0.1, true, true);
 	}

 	// Next is Jedi stuff
@@ -784,7 +782,6 @@

 	if (armor != NULL && !armor->isVulnerable(weapon->getDamageType())) {
 		// use only the damage applied to the armor for piercing (after the PSG takes some off)
-		float originalDamage = damage;
 		float armorPiercing = getArmorPiercing(armor, weapon);
 		float armorReduction = getArmorObjectReduction(attacker, armor);

@@ -792,8 +789,7 @@
 		if (armorReduction > 0) damage *= (1.f - (armorReduction / 100.f));

 		// inflict condition damage
-		float conditionDamage = (originalDamage * armorPiercing - damage) * 0.1;
-		armor->inflictDamage(armor, 0, conditionDamage, true, true);
+		armor->inflictDamage(armor, 0, damage * 0.1, true, true);
 	}

 	return damage;


SimpleCache: have tests run on all three streams

Many unit tests only run on the first stream. With the upcoming changes to
SimpleCache, each stream will have a different implementation. This CL ensures
test are ran on all streams.

BUG=173398

Review URL: https://codereview.chromium.org/23702024

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@243170 0039d316-1c4b-4281-b951-d872f2087c98

--- net/disk_cache/entry_unittest.cc
+++ net/disk_cache/entry_unittest.cc
@@ -40,22 +40,22 @@
   void InternalAsyncIO();
   void ExternalSyncIO();
   void ExternalAsyncIO();
-  void ReleaseBuffer();
+  void ReleaseBuffer(int stream_index);
   void StreamAccess();
   void GetKey();
-  void GetTimes();
-  void GrowData();
-  void TruncateData();
-  void ZeroLengthIO();
+  void GetTimes(int stream_index);
+  void GrowData(int stream_index);
+  void TruncateData(int stream_index);
+  void ZeroLengthIO(int stream_index);
   void Buffering();
   void SizeAtCreate();
-  void SizeChanges();
-  void ReuseEntry(int size);
-  void InvalidData();
-  void ReadWriteDestroyBuffer();
+  void SizeChanges(int stream_index);
+  void ReuseEntry(int size, int stream_index);
+  void InvalidData(int stream_index);
+  void ReadWriteDestroyBuffer(int stream_index);
   void DoomNormalEntry();
   void DoomEntryNextToOpenEntry();
-  void DoomedEntry();
+  void DoomedEntry(int stream_index);
   void BasicSparseIO();
   void HugeSparseIO();
   void GetAvailableRange();
@@ -611,7 +611,7 @@
 }

 // Tests that IOBuffers are not referenced after IO completes.
-void DiskCacheEntryTest::ReleaseBuffer() {
+void DiskCacheEntryTest::ReleaseBuffer(int stream_index) {
   disk_cache::Entry* entry = NULL;
   ASSERT_EQ(net::OK, CreateEntry("the first key", &entry));
   ASSERT_TRUE(NULL != entry);
@@ -621,8 +621,8 @@
   CacheTestFillBuffer(buffer->data(), kBufferSize, false);

   net::ReleaseBufferCompletionCallback cb(buffer.get());
-  int rv =
-      entry->WriteData(0, 0, buffer.get(), kBufferSize, cb.callback(), false);
+  int rv = entry->WriteData(
+      stream_index, 0, buffer.get(), kBufferSize, cb.callback(), false);
   EXPECT_EQ(kBufferSize, cb.GetResult(rv));
   entry->Close();
 }
@@ -630,13 +630,13 @@
 TEST_F(DiskCacheEntryTest, ReleaseBuffer) {
   InitCache();
   cache_impl_->SetFlags(disk_cache::kNoBuffering);
-  ReleaseBuffer();
+  ReleaseBuffer(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyReleaseBuffer) {
   SetMemoryOnlyMode();
   InitCache();
-  ReleaseBuffer();
+  ReleaseBuffer(0);
 }

 void DiskCacheEntryTest::StreamAccess() {
@@ -758,7 +758,7 @@
   GetKey();
 }

-void DiskCacheEntryTest::GetTimes() {
+void DiskCacheEntryTest::GetTimes(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;

@@ -770,7 +770,7 @@
   AddDelay();
   Time t2 = Time::Now();
   EXPECT_TRUE(t2 > t1);
-  EXPECT_EQ(0, WriteData(entry, 0, 200, NULL, 0, false));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 200, NULL, 0, false));
   if (type_ == net::APP_CACHE) {
     EXPECT_TRUE(entry->GetLastModified() < t2);
   } else {
@@ -783,7 +783,7 @@
   EXPECT_TRUE(t3 > t2);
   const int kSize = 200;
   scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize));
-  EXPECT_EQ(kSize, ReadData(entry, 0, 0, buffer.get(), kSize));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 0, buffer.get(), kSize));
   if (type_ == net::APP_CACHE) {
     EXPECT_TRUE(entry->GetLastUsed() < t2);
     EXPECT_TRUE(entry->GetLastModified() < t2);
@@ -799,28 +799,28 @@

 TEST_F(DiskCacheEntryTest, GetTimes) {
   InitCache();
-  GetTimes();
+  GetTimes(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyGetTimes) {
   SetMemoryOnlyMode();
   InitCache();
-  GetTimes();
+  GetTimes(0);
 }

 TEST_F(DiskCacheEntryTest, AppCacheGetTimes) {
   SetCacheType(net::APP_CACHE);
   InitCache();
-  GetTimes();
+  GetTimes(0);
 }

 TEST_F(DiskCacheEntryTest, ShaderCacheGetTimes) {
   SetCacheType(net::SHADER_CACHE);
   InitCache();
-  GetTimes();
-}
-
-void DiskCacheEntryTest::GrowData() {
+  GetTimes(0);
+}
+
+void DiskCacheEntryTest::GrowData(int stream_index) {
   std::string key1("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key1, &entry));
@@ -832,78 +832,82 @@
   memset(buffer2->data(), 0, kSize);

   base::strlcpy(buffer1->data(), "the data", kSize);
-  EXPECT_EQ(10, WriteData(entry, 0, 0, buffer1.get(), 10, false));
-  EXPECT_EQ(10, ReadData(entry, 0, 0, buffer2.get(), 10));
+  EXPECT_EQ(10, WriteData(entry, stream_index, 0, buffer1.get(), 10, false));
+  EXPECT_EQ(10, ReadData(entry, stream_index, 0, buffer2.get(), 10));
   EXPECT_STREQ("the data", buffer2->data());
-  EXPECT_EQ(10, entry->GetDataSize(0));
-
-  EXPECT_EQ(2000, WriteData(entry, 0, 0, buffer1.get(), 2000, false));
-  EXPECT_EQ(2000, entry->GetDataSize(0));
-  EXPECT_EQ(2000, ReadData(entry, 0, 0, buffer2.get(), 2000));
+  EXPECT_EQ(10, entry->GetDataSize(stream_index));
+
+  EXPECT_EQ(2000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 2000, false));
+  EXPECT_EQ(2000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(2000, ReadData(entry, stream_index, 0, buffer2.get(), 2000));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), 2000));

-  EXPECT_EQ(20000, WriteData(entry, 0, 0, buffer1.get(), kSize, false));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
-  EXPECT_EQ(20000, ReadData(entry, 0, 0, buffer2.get(), kSize));
+  EXPECT_EQ(20000,
+            WriteData(entry, stream_index, 0, buffer1.get(), kSize, false));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(20000, ReadData(entry, stream_index, 0, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), kSize));
   entry->Close();

   memset(buffer2->data(), 0, kSize);
   std::string key2("Second key");
   ASSERT_EQ(net::OK, CreateEntry(key2, &entry));
-  EXPECT_EQ(10, WriteData(entry, 0, 0, buffer1.get(), 10, false));
-  EXPECT_EQ(10, entry->GetDataSize(0));
+  EXPECT_EQ(10, WriteData(entry, stream_index, 0, buffer1.get(), 10, false));
+  EXPECT_EQ(10, entry->GetDataSize(stream_index));
   entry->Close();

   // Go from an internal address to a bigger block size.
   ASSERT_EQ(net::OK, OpenEntry(key2, &entry));
-  EXPECT_EQ(2000, WriteData(entry, 0, 0, buffer1.get(), 2000, false));
-  EXPECT_EQ(2000, entry->GetDataSize(0));
-  EXPECT_EQ(2000, ReadData(entry, 0, 0, buffer2.get(), 2000));
+  EXPECT_EQ(2000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 2000, false));
+  EXPECT_EQ(2000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(2000, ReadData(entry, stream_index, 0, buffer2.get(), 2000));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), 2000));
   entry->Close();
   memset(buffer2->data(), 0, kSize);

   // Go from an internal address to an external one.
   ASSERT_EQ(net::OK, OpenEntry(key2, &entry));
-  EXPECT_EQ(20000, WriteData(entry, 0, 0, buffer1.get(), kSize, false));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
-  EXPECT_EQ(20000, ReadData(entry, 0, 0, buffer2.get(), kSize));
+  EXPECT_EQ(20000,
+            WriteData(entry, stream_index, 0, buffer1.get(), kSize, false));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(20000, ReadData(entry, stream_index, 0, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), kSize));
   entry->Close();

   // Double check the size from disk.
   ASSERT_EQ(net::OK, OpenEntry(key2, &entry));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));

   // Now extend the entry without actual data.
-  EXPECT_EQ(0, WriteData(entry, 0, 45500, buffer1.get(), 0, false));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 45500, buffer1.get(), 0, false));
   entry->Close();

   // And check again from disk.
   ASSERT_EQ(net::OK, OpenEntry(key2, &entry));
-  EXPECT_EQ(45500, entry->GetDataSize(0));
+  EXPECT_EQ(45500, entry->GetDataSize(stream_index));
   entry->Close();
 }

 TEST_F(DiskCacheEntryTest, GrowData) {
   InitCache();
-  GrowData();
+  GrowData(0);
 }

 TEST_F(DiskCacheEntryTest, GrowDataNoBuffer) {
   InitCache();
   cache_impl_->SetFlags(disk_cache::kNoBuffering);
-  GrowData();
+  GrowData(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyGrowData) {
   SetMemoryOnlyMode();
   InitCache();
-  GrowData();
-}
-
-void DiskCacheEntryTest::TruncateData() {
+  GrowData(0);
+}
+
+void DiskCacheEntryTest::TruncateData(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key, &entry));
@@ -917,86 +921,91 @@
   memset(buffer2->data(), 0, kSize2);

   // Simple truncation:
-  EXPECT_EQ(200, WriteData(entry, 0, 0, buffer1.get(), 200, false));
-  EXPECT_EQ(200, entry->GetDataSize(0));
-  EXPECT_EQ(100, WriteData(entry, 0, 0, buffer1.get(), 100, false));
-  EXPECT_EQ(200, entry->GetDataSize(0));
-  EXPECT_EQ(100, WriteData(entry, 0, 0, buffer1.get(), 100, true));
-  EXPECT_EQ(100, entry->GetDataSize(0));
-  EXPECT_EQ(0, WriteData(entry, 0, 50, buffer1.get(), 0, true));
-  EXPECT_EQ(50, entry->GetDataSize(0));
-  EXPECT_EQ(0, WriteData(entry, 0, 0, buffer1.get(), 0, true));
-  EXPECT_EQ(0, entry->GetDataSize(0));
+  EXPECT_EQ(200, WriteData(entry, stream_index, 0, buffer1.get(), 200, false));
+  EXPECT_EQ(200, entry->GetDataSize(stream_index));
+  EXPECT_EQ(100, WriteData(entry, stream_index, 0, buffer1.get(), 100, false));
+  EXPECT_EQ(200, entry->GetDataSize(stream_index));
+  EXPECT_EQ(100, WriteData(entry, stream_index, 0, buffer1.get(), 100, true));
+  EXPECT_EQ(100, entry->GetDataSize(stream_index));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 50, buffer1.get(), 0, true));
+  EXPECT_EQ(50, entry->GetDataSize(stream_index));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 0, buffer1.get(), 0, true));
+  EXPECT_EQ(0, entry->GetDataSize(stream_index));
   entry->Close();
   ASSERT_EQ(net::OK, OpenEntry(key, &entry));

   // Go to an external file.
-  EXPECT_EQ(20000, WriteData(entry, 0, 0, buffer1.get(), 20000, true));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
-  EXPECT_EQ(20000, ReadData(entry, 0, 0, buffer2.get(), 20000));
+  EXPECT_EQ(20000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 20000, true));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(20000, ReadData(entry, stream_index, 0, buffer2.get(), 20000));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), 20000));
   memset(buffer2->data(), 0, kSize2);

   // External file truncation
-  EXPECT_EQ(18000, WriteData(entry, 0, 0, buffer1.get(), 18000, false));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
-  EXPECT_EQ(18000, WriteData(entry, 0, 0, buffer1.get(), 18000, true));
-  EXPECT_EQ(18000, entry->GetDataSize(0));
-  EXPECT_EQ(0, WriteData(entry, 0, 17500, buffer1.get(), 0, true));
-  EXPECT_EQ(17500, entry->GetDataSize(0));
+  EXPECT_EQ(18000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 18000, false));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(18000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 18000, true));
+  EXPECT_EQ(18000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 17500, buffer1.get(), 0, true));
+  EXPECT_EQ(17500, entry->GetDataSize(stream_index));

   // And back to an internal block.
-  EXPECT_EQ(600, WriteData(entry, 0, 1000, buffer1.get(), 600, true));
-  EXPECT_EQ(1600, entry->GetDataSize(0));
-  EXPECT_EQ(600, ReadData(entry, 0, 1000, buffer2.get(), 600));
+  EXPECT_EQ(600,
+            WriteData(entry, stream_index, 1000, buffer1.get(), 600, true));
+  EXPECT_EQ(1600, entry->GetDataSize(stream_index));
+  EXPECT_EQ(600, ReadData(entry, stream_index, 1000, buffer2.get(), 600));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), 600));
-  EXPECT_EQ(1000, ReadData(entry, 0, 0, buffer2.get(), 1000));
+  EXPECT_EQ(1000, ReadData(entry, stream_index, 0, buffer2.get(), 1000));
   EXPECT_TRUE(!memcmp(buffer1->data(), buffer2->data(), 1000))
       << "Preserves previous data";

   // Go from external file to zero length.
-  EXPECT_EQ(20000, WriteData(entry, 0, 0, buffer1.get(), 20000, true));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
-  EXPECT_EQ(0, WriteData(entry, 0, 0, buffer1.get(), 0, true));
-  EXPECT_EQ(0, entry->GetDataSize(0));
+  EXPECT_EQ(20000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 20000, true));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 0, buffer1.get(), 0, true));
+  EXPECT_EQ(0, entry->GetDataSize(stream_index));

   entry->Close();
 }

 TEST_F(DiskCacheEntryTest, TruncateData) {
   InitCache();
-  TruncateData();
+  TruncateData(0);
 }

 TEST_F(DiskCacheEntryTest, TruncateDataNoBuffer) {
   InitCache();
   cache_impl_->SetFlags(disk_cache::kNoBuffering);
-  TruncateData();
+  TruncateData(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyTruncateData) {
   SetMemoryOnlyMode();
   InitCache();
-  TruncateData();
-}
-
-void DiskCacheEntryTest::ZeroLengthIO() {
+  TruncateData(0);
+}
+
+void DiskCacheEntryTest::ZeroLengthIO(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key, &entry));

-  EXPECT_EQ(0, ReadData(entry, 0, 0, NULL, 0));
-  EXPECT_EQ(0, WriteData(entry, 0, 0, NULL, 0, false));
+  EXPECT_EQ(0, ReadData(entry, stream_index, 0, NULL, 0));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 0, NULL, 0, false));

   // This write should extend the entry.
-  EXPECT_EQ(0, WriteData(entry, 0, 1000, NULL, 0, false));
-  EXPECT_EQ(0, ReadData(entry, 0, 500, NULL, 0));
-  EXPECT_EQ(0, ReadData(entry, 0, 2000, NULL, 0));
-  EXPECT_EQ(1000, entry->GetDataSize(0));
-
-  EXPECT_EQ(0, WriteData(entry, 0, 100000, NULL, 0, true));
-  EXPECT_EQ(0, ReadData(entry, 0, 50000, NULL, 0));
-  EXPECT_EQ(100000, entry->GetDataSize(0));
+  EXPECT_EQ(0, WriteData(entry, stream_index, 1000, NULL, 0, false));
+  EXPECT_EQ(0, ReadData(entry, stream_index, 500, NULL, 0));
+  EXPECT_EQ(0, ReadData(entry, stream_index, 2000, NULL, 0));
+  EXPECT_EQ(1000, entry->GetDataSize(stream_index));
+
+  EXPECT_EQ(0, WriteData(entry, stream_index, 100000, NULL, 0, true));
+  EXPECT_EQ(0, ReadData(entry, stream_index, 50000, NULL, 0));
+  EXPECT_EQ(100000, entry->GetDataSize(stream_index));

   // Let's verify the actual content.
   const int kSize = 20;
@@ -1004,15 +1013,15 @@
   scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize));

   CacheTestFillBuffer(buffer->data(), kSize, false);
-  EXPECT_EQ(kSize, ReadData(entry, 0, 500, buffer.get(), kSize));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 500, buffer.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer->data(), zeros, kSize));

   CacheTestFillBuffer(buffer->data(), kSize, false);
-  EXPECT_EQ(kSize, ReadData(entry, 0, 5000, buffer.get(), kSize));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 5000, buffer.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer->data(), zeros, kSize));

   CacheTestFillBuffer(buffer->data(), kSize, false);
-  EXPECT_EQ(kSize, ReadData(entry, 0, 50000, buffer.get(), kSize));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 50000, buffer.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer->data(), zeros, kSize));

   entry->Close();
@@ -1020,19 +1029,19 @@

 TEST_F(DiskCacheEntryTest, ZeroLengthIO) {
   InitCache();
-  ZeroLengthIO();
+  ZeroLengthIO(0);
 }

 TEST_F(DiskCacheEntryTest, ZeroLengthIONoBuffer) {
   InitCache();
   cache_impl_->SetFlags(disk_cache::kNoBuffering);
-  ZeroLengthIO();
+  ZeroLengthIO(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyZeroLengthIO) {
   SetMemoryOnlyMode();
   InitCache();
-  ZeroLengthIO();
+  ZeroLengthIO(0);
 }

 // Tests that we handle the content correctly when buffering, a feature of the
@@ -1149,7 +1158,7 @@

 // Some extra tests to make sure that buffering works properly when changing
 // the entry size.
-void DiskCacheEntryTest::SizeChanges() {
+void DiskCacheEntryTest::SizeChanges(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key, &entry));
@@ -1161,68 +1170,83 @@
   CacheTestFillBuffer(buffer1->data(), kSize, true);
   CacheTestFillBuffer(buffer2->data(), kSize, true);

-  EXPECT_EQ(kSize, WriteData(entry, 1, 0, buffer1.get(), kSize, true));
-  EXPECT_EQ(kSize, WriteData(entry, 1, 17000, buffer1.get(), kSize, true));
-  EXPECT_EQ(kSize, WriteData(entry, 1, 23000, buffer1.get(), kSize, true));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 0, buffer1.get(), kSize, true));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 17000, buffer1.get(), kSize, true));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 23000, buffer1.get(), kSize, true));
   entry->Close();

   // Extend the file and read between the old size and the new write.
   ASSERT_EQ(net::OK, OpenEntry(key, &entry));
-  EXPECT_EQ(23000 + kSize, entry->GetDataSize(1));
-  EXPECT_EQ(kSize, WriteData(entry, 1, 25000, buffer1.get(), kSize, true));
-  EXPECT_EQ(25000 + kSize, entry->GetDataSize(1));
-  EXPECT_EQ(kSize, ReadData(entry, 1, 24000, buffer2.get(), kSize));
+  EXPECT_EQ(23000 + kSize, entry->GetDataSize(stream_index));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 25000, buffer1.get(), kSize, true));
+  EXPECT_EQ(25000 + kSize, entry->GetDataSize(stream_index));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 24000, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), zeros, kSize));

   // Read at the end of the old file size.
-  EXPECT_EQ(kSize,
-            ReadData(entry, 1, 23000 + kSize - 35, buffer2.get(), kSize));
+  EXPECT_EQ(
+      kSize,
+      ReadData(entry, stream_index, 23000 + kSize - 35, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), buffer1->data() + kSize - 35, 35));

   // Read slightly before the last write.
   CacheTestFillBuffer(buffer2->data(), kSize, true);
-  EXPECT_EQ(kSize, ReadData(entry, 1, 24900, buffer2.get(), kSize));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 24900, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), zeros, 100));
   EXPECT_TRUE(!memcmp(buffer2->data() + 100, buffer1->data(), kSize - 100));

   // Extend the entry a little more.
-  EXPECT_EQ(kSize, WriteData(entry, 1, 26000, buffer1.get(), kSize, true));
-  EXPECT_EQ(26000 + kSize, entry->GetDataSize(1));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 26000, buffer1.get(), kSize, true));
+  EXPECT_EQ(26000 + kSize, entry->GetDataSize(stream_index));
   CacheTestFillBuffer(buffer2->data(), kSize, true);
-  EXPECT_EQ(kSize, ReadData(entry, 1, 25900, buffer2.get(), kSize));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 25900, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), zeros, 100));
   EXPECT_TRUE(!memcmp(buffer2->data() + 100, buffer1->data(), kSize - 100));

   // And now reduce the size.
-  EXPECT_EQ(kSize, WriteData(entry, 1, 25000, buffer1.get(), kSize, true));
-  EXPECT_EQ(25000 + kSize, entry->GetDataSize(1));
-  EXPECT_EQ(28, ReadData(entry, 1, 25000 + kSize - 28, buffer2.get(), kSize));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 25000, buffer1.get(), kSize, true));
+  EXPECT_EQ(25000 + kSize, entry->GetDataSize(stream_index));
+  EXPECT_EQ(
+      28,
+      ReadData(entry, stream_index, 25000 + kSize - 28, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), buffer1->data() + kSize - 28, 28));

   // Reduce the size with a buffer that is not extending the size.
-  EXPECT_EQ(kSize, WriteData(entry, 1, 24000, buffer1.get(), kSize, false));
-  EXPECT_EQ(25000 + kSize, entry->GetDataSize(1));
-  EXPECT_EQ(kSize, WriteData(entry, 1, 24500, buffer1.get(), kSize, true));
-  EXPECT_EQ(24500 + kSize, entry->GetDataSize(1));
-  EXPECT_EQ(kSize, ReadData(entry, 1, 23900, buffer2.get(), kSize));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 24000, buffer1.get(), kSize, false));
+  EXPECT_EQ(25000 + kSize, entry->GetDataSize(stream_index));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 24500, buffer1.get(), kSize, true));
+  EXPECT_EQ(24500 + kSize, entry->GetDataSize(stream_index));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 23900, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), zeros, 100));
   EXPECT_TRUE(!memcmp(buffer2->data() + 100, buffer1->data(), kSize - 100));

   // And now reduce the size below the old size.
-  EXPECT_EQ(kSize, WriteData(entry, 1, 19000, buffer1.get(), kSize, true));
-  EXPECT_EQ(19000 + kSize, entry->GetDataSize(1));
-  EXPECT_EQ(kSize, ReadData(entry, 1, 18900, buffer2.get(), kSize));
+  EXPECT_EQ(kSize,
+            WriteData(entry, stream_index, 19000, buffer1.get(), kSize, true));
+  EXPECT_EQ(19000 + kSize, entry->GetDataSize(stream_index));
+  EXPECT_EQ(kSize, ReadData(entry, stream_index, 18900, buffer2.get(), kSize));
   EXPECT_TRUE(!memcmp(buffer2->data(), zeros, 100));
   EXPECT_TRUE(!memcmp(buffer2->data() + 100, buffer1->data(), kSize - 100));

   // Verify that the actual file is truncated.
   entry->Close();
   ASSERT_EQ(net::OK, OpenEntry(key, &entry));
-  EXPECT_EQ(19000 + kSize, entry->GetDataSize(1));
+  EXPECT_EQ(19000 + kSize, entry->GetDataSize(stream_index));

   // Extend the newly opened file with a zero length write, expect zero fill.
-  EXPECT_EQ(0, WriteData(entry, 1, 20000 + kSize, buffer1.get(), 0, false));
-  EXPECT_EQ(kSize, ReadData(entry, 1, 19000 + kSize, buffer1.get(), kSize));
+  EXPECT_EQ(
+      0,
+      WriteData(entry, stream_index, 20000 + kSize, buffer1.get(), 0, false));
+  EXPECT_EQ(kSize,
+            ReadData(entry, stream_index, 19000 + kSize, buffer1.get(), kSize));
   EXPECT_EQ(0, memcmp(buffer1->data(), zeros, kSize));

   entry->Close();
@@ -1230,18 +1254,18 @@

 TEST_F(DiskCacheEntryTest, SizeChanges) {
   InitCache();
-  SizeChanges();
+  SizeChanges(1);
 }

 TEST_F(DiskCacheEntryTest, SizeChangesNoBuffer) {
   InitCache();
   cache_impl_->SetFlags(disk_cache::kNoBuffering);
-  SizeChanges();
+  SizeChanges(1);
 }

 // Write more than the total cache capacity but to a single entry. |size| is the
 // amount of bytes to write each time.
-void DiskCacheEntryTest::ReuseEntry(int size) {
+void DiskCacheEntryTest::ReuseEntry(int size, int stream_index) {
   std::string key1("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key1, &entry));
@@ -1254,8 +1278,9 @@
   CacheTestFillBuffer(buffer->data(), size, false);

   for (int i = 0; i < 15; i++) {
-    EXPECT_EQ(0, WriteData(entry, 0, 0, buffer.get(), 0, true));
-    EXPECT_EQ(size, WriteData(entry, 0, 0, buffer.get(), size, false));
+    EXPECT_EQ(0, WriteData(entry, stream_index, 0, buffer.get(), 0, true));
+    EXPECT_EQ(size,
+              WriteData(entry, stream_index, 0, buffer.get(), size, false));
     entry->Close();
     ASSERT_EQ(net::OK, OpenEntry(key2, &entry));
   }
@@ -1268,31 +1293,31 @@
 TEST_F(DiskCacheEntryTest, ReuseExternalEntry) {
   SetMaxSize(200 * 1024);
   InitCache();
-  ReuseEntry(20 * 1024);
+  ReuseEntry(20 * 1024, 0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyReuseExternalEntry) {
   SetMemoryOnlyMode();
   SetMaxSize(200 * 1024);
   InitCache();
-  ReuseEntry(20 * 1024);
+  ReuseEntry(20 * 1024, 0);
 }

 TEST_F(DiskCacheEntryTest, ReuseInternalEntry) {
   SetMaxSize(100 * 1024);
   InitCache();
-  ReuseEntry(10 * 1024);
+  ReuseEntry(10 * 1024, 0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyReuseInternalEntry) {
   SetMemoryOnlyMode();
   SetMaxSize(100 * 1024);
   InitCache();
-  ReuseEntry(10 * 1024);
+  ReuseEntry(10 * 1024, 0);
 }

 // Reading somewhere that was not written should return zeros.
-void DiskCacheEntryTest::InvalidData() {
+void DiskCacheEntryTest::InvalidData(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key, &entry));
@@ -1308,49 +1333,56 @@
   memset(buffer2->data(), 0, kSize2);

   // Simple data grow:
-  EXPECT_EQ(200, WriteData(entry, 0, 400, buffer1.get(), 200, false));
-  EXPECT_EQ(600, entry->GetDataSize(0));
-  EXPECT_EQ(100, ReadData(entry, 0, 300, buffer3.get(), 100));
+  EXPECT_EQ(200,
+            WriteData(entry, stream_index, 400, buffer1.get(), 200, false));
+  EXPECT_EQ(600, entry->GetDataSize(stream_index));
+  EXPECT_EQ(100, ReadData(entry, stream_index, 300, buffer3.get(), 100));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer2->data(), 100));
   entry->Close();
   ASSERT_EQ(net::OK, OpenEntry(key, &entry));

   // The entry is now on disk. Load it and extend it.
-  EXPECT_EQ(200, WriteData(entry, 0, 800, buffer1.get(), 200, false));
-  EXPECT_EQ(1000, entry->GetDataSize(0));
-  EXPECT_EQ(100, ReadData(entry, 0, 700, buffer3.get(), 100));
+  EXPECT_EQ(200,
+            WriteData(entry, stream_index, 800, buffer1.get(), 200, false));
+  EXPECT_EQ(1000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(100, ReadData(entry, stream_index, 700, buffer3.get(), 100));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer2->data(), 100));
   entry->Close();
   ASSERT_EQ(net::OK, OpenEntry(key, &entry));

   // This time using truncate.
-  EXPECT_EQ(200, WriteData(entry, 0, 1800, buffer1.get(), 200, true));
-  EXPECT_EQ(2000, entry->GetDataSize(0));
-  EXPECT_EQ(100, ReadData(entry, 0, 1500, buffer3.get(), 100));
+  EXPECT_EQ(200,
+            WriteData(entry, stream_index, 1800, buffer1.get(), 200, true));
+  EXPECT_EQ(2000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(100, ReadData(entry, stream_index, 1500, buffer3.get(), 100));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer2->data(), 100));

   // Go to an external file.
-  EXPECT_EQ(200, WriteData(entry, 0, 19800, buffer1.get(), 200, false));
-  EXPECT_EQ(20000, entry->GetDataSize(0));
-  EXPECT_EQ(4000, ReadData(entry, 0, 14000, buffer3.get(), 4000));
+  EXPECT_EQ(200,
+            WriteData(entry, stream_index, 19800, buffer1.get(), 200, false));
+  EXPECT_EQ(20000, entry->GetDataSize(stream_index));
+  EXPECT_EQ(4000, ReadData(entry, stream_index, 14000, buffer3.get(), 4000));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer2->data(), 4000));

   // And back to an internal block.
-  EXPECT_EQ(600, WriteData(entry, 0, 1000, buffer1.get(), 600, true));
-  EXPECT_EQ(1600, entry->GetDataSize(0));
-  EXPECT_EQ(600, ReadData(entry, 0, 1000, buffer3.get(), 600));
+  EXPECT_EQ(600,
+            WriteData(entry, stream_index, 1000, buffer1.get(), 600, true));
+  EXPECT_EQ(1600, entry->GetDataSize(stream_index));
+  EXPECT_EQ(600, ReadData(entry, stream_index, 1000, buffer3.get(), 600));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer1->data(), 600));

   // Extend it again.
-  EXPECT_EQ(600, WriteData(entry, 0, 2000, buffer1.get(), 600, false));
-  EXPECT_EQ(2600, entry->GetDataSize(0));
-  EXPECT_EQ(200, ReadData(entry, 0, 1800, buffer3.get(), 200));
+  EXPECT_EQ(600,
+            WriteData(entry, stream_index, 2000, buffer1.get(), 600, false));
+  EXPECT_EQ(2600, entry->GetDataSize(stream_index));
+  EXPECT_EQ(200, ReadData(entry, stream_index, 1800, buffer3.get(), 200));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer2->data(), 200));

   // And again (with truncation flag).
-  EXPECT_EQ(600, WriteData(entry, 0, 3000, buffer1.get(), 600, true));
-  EXPECT_EQ(3600, entry->GetDataSize(0));
-  EXPECT_EQ(200, ReadData(entry, 0, 2800, buffer3.get(), 200));
+  EXPECT_EQ(600,
+            WriteData(entry, stream_index, 3000, buffer1.get(), 600, true));
+  EXPECT_EQ(3600, entry->GetDataSize(stream_index));
+  EXPECT_EQ(200, ReadData(entry, stream_index, 2800, buffer3.get(), 200));
   EXPECT_TRUE(!memcmp(buffer3->data(), buffer2->data(), 200));

   entry->Close();
@@ -1358,23 +1390,23 @@

 TEST_F(DiskCacheEntryTest, InvalidData) {
   InitCache();
-  InvalidData();
+  InvalidData(0);
 }

 TEST_F(DiskCacheEntryTest, InvalidDataNoBuffer) {
   InitCache();
   cache_impl_->SetFlags(disk_cache::kNoBuffering);
-  InvalidData();
+  InvalidData(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyInvalidData) {
   SetMemoryOnlyMode();
   InitCache();
-  InvalidData();
+  InvalidData(0);
 }

 // Tests that the cache preserves the buffer of an IO operation.
-void DiskCacheEntryTest::ReadWriteDestroyBuffer() {
+void DiskCacheEntryTest::ReadWriteDestroyBuffer(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key, &entry));
@@ -1385,7 +1417,8 @@

   net::TestCompletionCallback cb;
   EXPECT_EQ(net::ERR_IO_PENDING,
-            entry->WriteData(0, 0, buffer.get(), kSize, cb.callback(), false));
+            entry->WriteData(
+                stream_index, 0, buffer.get(), kSize, cb.callback(), false));

   // Release our reference to the buffer.
   buffer = NULL;
@@ -1395,8 +1428,9 @@
   buffer = new net::IOBuffer(kSize);
   CacheTestFillBuffer(buffer->data(), kSize, false);

-  EXPECT_EQ(net::ERR_IO_PENDING,
-            entry->ReadData(0, 0, buffer.get(), kSize, cb.callback()));
+  EXPECT_EQ(
+      net::ERR_IO_PENDING,
+      entry->ReadData(stream_index, 0, buffer.get(), kSize, cb.callback()));
   buffer = NULL;
   EXPECT_EQ(kSize, cb.WaitForResult());

@@ -1405,7 +1439,7 @@

 TEST_F(DiskCacheEntryTest, ReadWriteDestroyBuffer) {
   InitCache();
-  ReadWriteDestroyBuffer();
+  ReadWriteDestroyBuffer(0);
 }

 void DiskCacheEntryTest::DoomNormalEntry() {
@@ -1485,7 +1519,7 @@
 }

 // Verify that basic operations work as expected with doomed entries.
-void DiskCacheEntryTest::DoomedEntry() {
+void DiskCacheEntryTest::DoomedEntry(int stream_index) {
   std::string key("the first key");
   disk_cache::Entry* entry;
   ASSERT_EQ(net::OK, CreateEntry(key, &entry));
@@ -1503,8 +1537,9 @@
   CacheTestFillBuffer(buffer1->data(), kSize1, false);
   memset(buffer2->data(), 0, kSize2);

-  EXPECT_EQ(2000, WriteData(entry, 0, 0, buffer1.get(), 2000, false));
-  EXPECT_EQ(2000, ReadData(entry, 0, 0, buffer2.get(), 2000));
+  EXPECT_EQ(2000,
+            WriteData(entry, stream_index, 0, buffer1.get(), 2000, false));
+  EXPECT_EQ(2000, ReadData(entry, stream_index, 0, buffer2.get(), 2000));
   EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize1));
   EXPECT_EQ(key, entry->GetKey());
   EXPECT_TRUE(initial < entry->GetLastModified());
@@ -1515,13 +1550,13 @@

 TEST_F(DiskCacheEntryTest, DoomedEntry) {
   InitCache();
-  DoomedEntry();
+  DoomedEntry(0);
 }

 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomedEntry) {
   SetMemoryOnlyMode();
   InitCache();
-  DoomedEntry();
+  DoomedEntry(0);
 }

 // Tests that we discard entries if the data is missing.
@@ -2315,7 +2350,11 @@
 TEST_F(DiskCacheEntryTest, SimpleCacheReleaseBuffer) {
   SetSimpleCacheMode();
   InitCache();
-  ReleaseBuffer();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    ReleaseBuffer(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheStreamAccess) {
@@ -2333,25 +2372,41 @@
 TEST_F(DiskCacheEntryTest, SimpleCacheGetTimes) {
   SetSimpleCacheMode();
   InitCache();
-  GetTimes();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    GetTimes(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheGrowData) {
   SetSimpleCacheMode();
   InitCache();
-  GrowData();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    GrowData(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheTruncateData) {
   SetSimpleCacheMode();
   InitCache();
-  TruncateData();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    TruncateData(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheZeroLengthIO) {
   SetSimpleCacheMode();
   InitCache();
-  ZeroLengthIO();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    ZeroLengthIO(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheSizeAtCreate) {
@@ -2364,32 +2419,57 @@
   SetSimpleCacheMode();
   SetMaxSize(200 * 1024);
   InitCache();
-  ReuseEntry(20 * 1024);
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    ReuseEntry(20 * 1024, i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheReuseInternalEntry) {
   SetSimpleCacheMode();
   SetMaxSize(100 * 1024);
   InitCache();
-  ReuseEntry(10 * 1024);
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    ReuseEntry(10 * 1024, i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheSizeChanges) {
   SetSimpleCacheMode();
   InitCache();
-  SizeChanges();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    SizeChanges(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheInvalidData) {
   SetSimpleCacheMode();
   InitCache();
-  InvalidData();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    InvalidData(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheReadWriteDestroyBuffer) {
-  SetSimpleCacheMode();
-  InitCache();
-  ReadWriteDestroyBuffer();
+  // Proving that the test works well with optimistic operations enabled is
+  // subtle, instead run only in APP_CACHE mode to disable optimistic
+  // operations. Stream 0 always uses optimistic operations, so the test is not
+  // run on stream 0.
+  SetCacheType(net::APP_CACHE);
+  SetSimpleCacheMode();
+  InitCache();
+  for (int i = 1; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    ReadWriteDestroyBuffer(i);
+  }
 }

 TEST_F(DiskCacheEntryTest, SimpleCacheDoomEntry) {
@@ -2407,7 +2487,13 @@
 TEST_F(DiskCacheEntryTest, SimpleCacheDoomedEntry) {
   SetSimpleCacheMode();
   InitCache();
-  DoomedEntry();
+  // Stream 2 is excluded because the implementation does not support writing to
+  // it on a doomed entry, if it was previously lazily omitted.
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount - 1; ++i) {
+    EXPECT_EQ(net::OK, DoomAllEntries());
+    CleanupCacheDir();
+    DoomedEntry(i);
+  }
 }

 // Creates an entry with corrupted last byte in stream 0.
@@ -3448,36 +3534,35 @@
   CacheTestFillBuffer(buffer1->data(), kSize, false);
   char* buffer1_data = buffer1->data() + kHalfSize;
   memcpy(buffer2->data(), buffer1_data, kHalfSize);
+
   disk_cache::Entry* entry = NULL;
-
-  ASSERT_EQ(net::OK, CreateEntry(key, &entry));
-  EXPECT_NE(null, entry);
-
-  int offset = kHalfSize;
-  int buf_len = kHalfSize;
-
-  EXPECT_EQ(buf_len,
-            WriteData(entry, 0, offset, buffer2.get(), buf_len, false));
-  offset = 0;
-  buf_len = kHalfSize;
-  EXPECT_EQ(buf_len,
-            WriteData(entry, 0, offset, buffer1.get(), buf_len, false));
-  entry->Close();
-
-  disk_cache::Entry* entry2 = NULL;
-  ASSERT_EQ(net::OK, OpenEntry(key, &entry2));
-  EXPECT_EQ(entry, entry2);
-
-  scoped_refptr<net::IOBuffer> buffer1_read1(new net::IOBuffer(kSize));
-  EXPECT_EQ(kSize, ReadData(entry2, 0, 0, buffer1_read1.get(), kSize));
-  EXPECT_EQ(0, memcmp(buffer1->data(), buffer1_read1->data(), kSize));
-
-  // Check that we are not leaking.
-  ASSERT_NE(entry, null);
-  EXPECT_TRUE(
-      static_cast<disk_cache::SimpleEntryImpl*>(entry)->HasOneRef());
-  entry->Close();
-  entry = NULL;
+  ASSERT_EQ(net::OK, CreateEntry(key, &entry));
+  entry->Close();
+  for (int i = 0; i < disk_cache::kSimpleEntryStreamCount; ++i) {
+    ASSERT_EQ(net::OK, OpenEntry(key, &entry));
+    EXPECT_NE(null, entry);
+
+    int offset = kHalfSize;
+    int buf_len = kHalfSize;
+
+    EXPECT_EQ(buf_len,
+              WriteData(entry, i, offset, buffer2.get(), buf_len, false));
+    offset = 0;
+    buf_len = kHalfSize;
+    EXPECT_EQ(buf_len,
+              WriteData(entry, i, offset, buffer1.get(), buf_len, false));
+    entry->Close();
+
+    ASSERT_EQ(net::OK, OpenEntry(key, &entry));
+
+    scoped_refptr<net::IOBuffer> buffer1_read1(new net::IOBuffer(kSize));
+    EXPECT_EQ(kSize, ReadData(entry, i, 0, buffer1_read1.get(), kSize));
+    EXPECT_EQ(0, memcmp(buffer1->data(), buffer1_read1->data(), kSize));
+    // Check that we are not leaking.
+    ASSERT_NE(entry, null);
+    EXPECT_TRUE(static_cast<disk_cache::SimpleEntryImpl*>(entry)->HasOneRef());
+    entry->Close();
+  }
 }

 // Test that changing stream1 size does not affect stream0 (stream0 and stream1


Forgot format

Forgot format

--- DoremiEngine/AI/Source/PotentialField/PotentialFieldImpl.cpp
+++ DoremiEngine/AI/Source/PotentialField/PotentialFieldImpl.cpp
@@ -247,24 +247,23 @@
                         float chargeFromField;
                         DirectX::XMFLOAT3 positionFromField;
                         AttemptJumpToNewField(newUnitPosition, chargeFromField, positionFromField);
-                        if (chargeFromField > highestCharge)
+                        if(chargeFromField > highestCharge)
                         {
                             highestCharge = chargeFromField;
-                            highestChargedPos = XMFLOAT2( positionFromField.x, positionFromField.z);
+                            highestChargedPos = XMFLOAT2(positionFromField.x, positionFromField.z);
                         }
                         else
                         {
                             // Try a jump!
                             newUnitPosition = XMFLOAT3(newPosition.x + (static_cast<float>(sign<int>(x)) * 5), p_unitPosition.y,
-                                                        newPosition.y + (static_cast<float>(sign<int>(y)) * 5));
+                                                       newPosition.y + (static_cast<float>(sign<int>(y)) * 5));
                             AttemptJumpToNewField(newUnitPosition, chargeFromField, positionFromField);
-                            if (chargeFromField > highestCharge)
+                            if(chargeFromField > highestCharge)
                             {
                                 highestCharge = chargeFromField;
                                 highestChargedPos = XMFLOAT2(positionFromField.x, positionFromField.z);
                             }
                         }
-
                     }
                 }
             }
@@ -281,12 +280,12 @@
             using namespace DirectX;
             PotentialFieldImpl* newField = static_cast<PotentialFieldImpl*>(m_context.PFModule->FindBestPotentialField(p_position));
             o_charge = std::numeric_limits<float>::min();
-            if (newField != nullptr)
+            if(newField != nullptr)
             {
                 // if a field was found check what grid point in that field we are in
                 XMINT2 gridPoint = newField->WhatGridPosAmIOn(p_position);
                 // if for some wierd reason we are in the field but not in a grid point screw it...
-                if (gridPoint.x != -1)
+                if(gridPoint.x != -1)
                 {
                     // calculate a new charge from the new field
                     o_charge = newField->CalculateCharge(gridPoint.x, gridPoint.y, nullptr);
@@ -309,7 +308,7 @@
                     // This is for the actors influence
                     totalCharge += GetChargeInfluenceFromActor(quadPos, *actor);
                     // This is for the current actors special influence, if any TODOKO Might be a speed up to do this only if we are in range of actor
-                    if (p_currentActor != nullptr)
+                    if(p_currentActor != nullptr)
                     {
                         totalCharge += GetSpecialInfluenceBetweenActors(quadPos, *actor, *p_currentActor, usePhermone);
                     }


update Class PointerCall

update Class PointerCall

--- lib/dyckaa/AAAnalyzer.cpp
+++ lib/dyckaa/AAAnalyzer.cpp
@@ -1108,7 +1108,7 @@
     FUNCTION_COUNT++;

     bool ret = false;
-
+
     set<PointerCall*>& pointercalls = caller->getPointerCalls();
     set<PointerCall*>::iterator mit = pointercalls.begin();

@@ -1122,9 +1122,11 @@
         int percentage = ((++PTCALL_COUNT)*100 / PTCALL_TOTAL);
         outs() << "Handling indirect calls in Function #" << FUNCTION_COUNT << "... " << percentage << "%, \r";

-        //Value * inst = mit->first;
         PointerCall * pcall = *mit;
-        set<Function*>* cands = this->getCompatibleFunctions((FunctionType*) (pcall->calledValue->getType()->getPointerElementType()));
+        Type* fty = pcall->calledValue->getType()->getPointerElementType();
+        assert(fty->isFunctionTy() && "Error in AAAnalyzer::handle_pointer_function_calls!");
+
+        set<Function*>* cands = this->getCompatibleFunctions((FunctionType*)fty);
         set<Function*>* maycallfuncs = &(pcall->mayAliasedCallees);

         // print in console
@@ -1136,23 +1138,24 @@
             continue;
         }

-        // cv, numOfArguments
-        set<Function*>::iterator pfit = cands->begin();
-        while (pfit != cands->end()) {
+        // handle each unhandled, possible function
+        set<Function*> unhandled_function;
+        set_difference(cands->begin(), cands->end(),
+                        maycallfuncs->begin(), maycallfuncs->end(),
+                        inserter(unhandled_function, unhandled_function.begin()));
+
+        set<Function*>::iterator pfit = unhandled_function.begin();
+        while (pfit != unhandled_function.end()) {
             // print in console
             outs() << "Handling indirect calls in Function #" << FUNCTION_COUNT << "... " << percentage << "%, " << ((100 * (++CAND_COUNT)) / CAND_TOTAL) << "%         \r";

             AliasAnalysis::AliasResult ar = ((DyckAliasAnalysis*) aa)->function_alias(*pfit, pcall->calledValue);
             if (ar == AliasAnalysis::MayAlias || ar == AliasAnalysis::MustAlias) {
                 ret = true;
+                maycallfuncs->insert(*pfit);

                 handle_common_function_call(pcall, caller, callgraph->getOrInsertFunction(*pfit));
-
-                maycallfuncs->insert(*pfit);
-
-                this->handle_lib_invoke_call_inst(pcall->instruction, *pfit, &(pcall->args), caller);
-
-                cands->erase(pfit++);
+                handle_lib_invoke_call_inst(pcall->instruction, *pfit, &(pcall->args), caller);

                 if (ar == AliasAnalysis::MustAlias) {
                     // print in console
@@ -1162,9 +1165,8 @@
                     outs() << "Handling indirect calls in Function #" << FUNCTION_COUNT << "... " << "100%, 100%. Done!\r";
                     break;
                 }
-            } else {
-                pfit++;
-            }
+            }
+            pfit++;
         }

         mit++;


Fix comments again.

Fix comments again.

I thought I fixed the page size, but there were still errors.
This patch also contains fixes for grammatical errors.
Thanks pcc for proofreading!

git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@301454 91177308-0d34-0410-b5e6-96231b3b80d8

--- COFF/Chunks.cpp
+++ COFF/Chunks.cpp
@@ -326,40 +326,37 @@
 // usually loaded to that address. However, if there's already another
 // DLL that overlaps, the loader has to relocate it. To do that, DLLs
 // contain .reloc sections which contain offsets that need to be fixed
-// up at runtime. If the loader find that a DLL cannot be loaded to its
+// up at runtime. If the loader finds that a DLL cannot be loaded to its
 // desired base address, it loads it to somewhere else, and add <actual
 // base address> - <desired base address> to each offset that is
-// specified by .reloc section.
-//
-// In ELF terms, .reloc sections contain arrays of relocation offsets.
-// All these offsets in the section are implicitly R_*_RELATIVE, and
-// addends are read from section contents (so it is REL as opposed to
-// RELA).
-//
-// This already reduce the size of relocations to 1/3 compared to ELF
-// .dynrel, but Windows does more to reduce it (probably because it was
-// invented for PCs in the late '80s or early '90s.) Offsets in .reloc
-// are grouped by page where page size is 20 bits, and offsets sharing
-// the same page address are stored consecutively to represent them with
-// less space. This is a very similar to the page table which is grouped
-// by (multiple stages of) pages.
-//
-// For example, let's say we have 0x00030, 0x00500, 0x01000, 0x01100,
-// 0x20004, and 0x20008 in a .reloc section. In the section, they are
-// represented like this:
+// specified by the .reloc section. In ELF terms, .reloc sections
+// contain relative relocations in REL format (as opposed to RELA.)
+//
+// This already significantly reduces the size of relocations compared
+// to ELF .rel.dyn, but Windows does more to reduce it (probably because
+// it was invented for PCs in the late '80s or early '90s.)  Offsets in
+// .reloc are grouped by page where the page size is 12 bits, and
+// offsets sharing the same page address are stored consecutively to
+// represent them with less space. This is very similar to the page
+// table which is grouped by (multiple stages of) pages.
+//
+// For example, let's say we have 0x00030, 0x00500, 0x00700, 0x00A00,
+// 0x20004, and 0x20008 in a .reloc section for x64. The uppermost 4
+// bits have a type IMAGE_REL_BASED_DIR64 or 0xA. In the section, they
+// are represented like this:
 //
 //   0x00000  -- page address (4 bytes)
 //   16       -- size of this block (4 bytes)
-//     0x0030 -- entries (2 bytes each)
-//     0x0500
-//     0x1000
-//     0x1100
+//     0xA030 -- entries (2 bytes each)
+//     0xA500
+//     0xA700
+//     0xAA00
 //   0x20000  -- page address (4 bytes)
 //   12       -- size of this block (4 bytes)
-//     0x0004 -- entries (2 bytes each)
-//     0x0008
-//
-// Usually we have a lot of relocatinos for each page, so the number of
+//     0xA004 -- entries (2 bytes each)
+//     0xA008
+//
+// Usually we have a lot of relocations for each page, so the number of
 // bytes for one .reloc entry is close to 2 bytes on average.
 BaserelChunk::BaserelChunk(uint32_t Page, Baserel *Begin, Baserel *End) {
   // Block header consists of 4 byte page RVA and 4 byte block size.


unused #endif removed

unused #endif removed


fix queueActiveTracklet

fix queueActiveTracklet

--- GarbageDumping/MTTracker.cpp
+++ GarbageDumping/MTTracker.cpp
@@ -419,7 +419,7 @@
 		// estimated box
 		CKeyPoints dummyPoints;
 		dummyPoints.bbox = estimatedBox;
-		_queueTracklets[trackIdx]->insertKeyPoints(dummyPoints, _currTimeIndex);
+		_queueTracklets[trackIdx]->insertKeyPoints(dummyPoints, _currTimeIndex);//_currTimeIndex);
 	}

 	return _queueTracklets;
@@ -664,7 +664,7 @@
 			trackerIter = this->listCTracklet_.erase(trackerIter);
 			continue;
 		}
-		if ((*trackerIter).timeEnd == (int)nCurrentFrameIdx_)
+		if ((*trackerIter).timeEnd == (int)nCurrentFrameIdx_ && (*trackerIter).length() < stParam_.nMaxTrackletLength) //JM
 			newActiveTracklets.push_back(&(*trackerIter));
 		trackerIter++;
 	}
@@ -768,7 +768,7 @@
 	//---------------------------------------------------
 	CHungarianMethod cHungarianMatcher;
 	cHungarianMatcher.Initialize(arrInterTrackletMatchingCost_, (unsigned int)newTracklets.size(), (unsigned int)vecPendedTrajectories.size());
-	stMatchInfo *curMatchInfo = cHungarianMatcher.Match();
+	stMatchInfo* curMatchInfo = cHungarianMatcher.Match();
 	for (size_t matchIdx = 0; matchIdx < curMatchInfo->rows.size(); matchIdx++)
 	{
 		if (maxCost == curMatchInfo->matchCosts[matchIdx]) { continue; }


<pair> is <utility> (ROOT-6578).

<pair> is <utility> (ROOT-6578).

--- core/rint/src/TRint.cxx
+++ core/rint/src/TRint.cxx
@@ -164,7 +164,7 @@
    // In $ROOTSYS/etc/system.rootrc, you can set the variable Rint.Includes to 0
    // to disable the loading of these includes at startup.
    // You can set the variable to 1 (default) to load only <iostream>, <string> and <RTypesCint.h>
-   // You can set it to 2 to load in addition <vector> and <pair>
+   // You can set it to 2 to load in addition <vector> and <utility>
    // We strongly recommend setting the variable to 2 if your scripts include <vector>
    // and you execute your scripts multiple times.
    if (includes > 0) {
@@ -173,7 +173,7 @@
       ProcessLine("#include <DllImport.h>", kTRUE);// Defined R__EXTERN
       if (includes > 1) {
          ProcessLine("#include <vector>", kTRUE);  // Needed because std::vector and std::pair are
-         ProcessLine("#include <pair>", kTRUE);    // used within the core ROOT dictionaries
+         ProcessLine("#include <utility>", kTRUE);    // used within the core ROOT dictionaries
                                                    // and CINT will not be able to properly unload these files
       }
    }


[D3D11] D3D11HardwarePixelBuffer::_map simplified, HRESULT checked

--- RenderSystems/Direct3D11/src/OgreD3D11HardwarePixelBuffer.cpp
+++ RenderSystems/Direct3D11/src/OgreD3D11HardwarePixelBuffer.cpp
@@ -43,6 +43,22 @@

 namespace Ogre {

+	namespace
+	{
+		const char* toString(TextureType textureType)
+		{
+			switch(textureType)
+			{
+			case TEX_TYPE_1D:       return "1D texture";
+			case TEX_TYPE_CUBE_MAP: return "cube map texture";
+			case TEX_TYPE_2D:       return "2D texture";
+			case TEX_TYPE_2D_ARRAY: return "2D texture array";
+			case TEX_TYPE_3D:       return "3D texture";
+			default:                return "texture";
+			}
+		}
+	}
+
     //-----------------------------------------------------------------------------

     D3D11HardwarePixelBuffer::D3D11HardwarePixelBuffer(D3D11Texture * parentTexture, D3D11Device & device, UINT mipLevel,
@@ -86,63 +102,17 @@
     //-----------------------------------------------------------------------------
     void D3D11HardwarePixelBuffer::_map(ID3D11Resource *res, D3D11_MAP flags, PixelBox & box)
     {
-        D3D11_MAPPED_SUBRESOURCE pMappedResource;
-        pMappedResource.pData = NULL;
-
-        switch(mParentTexture->getTextureType())
-        {
-        case TEX_TYPE_1D:
-            {
-				HRESULT hr = mDevice.GetImmediateContext()->Map(res, mMipLevel, flags, 0, &pMappedResource);
-                if (mDevice.isError())
-                {
-					String errorDescription = mDevice.getErrorDescription(hr);
-					OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
-                        "D3D11 device cannot map 1D texture\nError Description:" + errorDescription,
-                        "D3D11HardwarePixelBuffer::_map");
-                }
-            }
-            break;
-        case TEX_TYPE_CUBE_MAP:
-        case TEX_TYPE_2D:
-            {
-				HRESULT hr = mDevice.GetImmediateContext()->Map(res, D3D11CalcSubresource(mMipLevel, mFace, mParentTexture->getNumMipmaps()+1),
-                    flags, 0, &pMappedResource);
-                if (mDevice.isError())
-                {
-					String errorDescription = mDevice.getErrorDescription(hr);
-					OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
-                        "D3D11 device cannot map 2D texture\nError Description:" + errorDescription,
-                        "D3D11HardwarePixelBuffer::_map");
-                }
-            }
-            break;
-        case TEX_TYPE_2D_ARRAY:
-            {
-				HRESULT hr = mDevice.GetImmediateContext()->Map(res, D3D11CalcSubresource(mMipLevel, mLockBox.front, mParentTexture->getNumMipmaps()+1),
-                    flags, 0, &pMappedResource);
-                if (mDevice.isError())
-                {
-					String errorDescription = mDevice.getErrorDescription(hr);
-					OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
-                        "D3D11 device cannot map 2D texture array\nError Description:" + errorDescription,
-                        "D3D11HardwarePixelBuffer::_map");
-                }
-            }
-            break;
-        case TEX_TYPE_3D:
-            {
-				HRESULT hr = mDevice.GetImmediateContext()->Map(res, mMipLevel, flags, 0, &pMappedResource);
-
-                if (mDevice.isError())
-                {
-					String errorDescription = mDevice.getErrorDescription(hr);
-					OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr,
-                        "D3D11 device cannot map 3D texture\nError Description:" + errorDescription,
-                        "D3D11HardwarePixelBuffer::lockImpl");
-                }
-            }
-            break;
+        assert(mLockBox.getDepth() == 1 || mParentTexture->getTextureType() == TEX_TYPE_3D);
+
+        D3D11_MAPPED_SUBRESOURCE pMappedResource = { 0 };
+
+        HRESULT hr = mDevice.GetImmediateContext()->Map(res, getSubresourceIndex(mLockBox.front), flags, 0, &pMappedResource);
+        if(FAILED(hr) || mDevice.isError())
+        {
+            String errorDescription; errorDescription
+                .append("D3D11 device cannot map ").append(toString(mParentTexture->getTextureType()))
+                .append("\nError Description:").append(mDevice.getErrorDescription(hr));
+            OGRE_EXCEPT_EX(Exception::ERR_RENDERINGAPI_ERROR, hr, errorDescription, "D3D11HardwarePixelBuffer::_map");
         }

         box.data = pMappedResource.pData;


Add ctrl+shift+a to instance scene in scenetree dock

Adds another key shortcut to instance a scene in the scentree dock. Complements ctrl+a to add a node.

--- editor/scene_tree_dock.cpp
+++ editor/scene_tree_dock.cpp
@@ -3024,7 +3024,7 @@
 	ED_SHORTCUT("scene_tree/rename", TTR("Rename"), KEY_F2);
 	ED_SHORTCUT("scene_tree/batch_rename", TTR("Batch Rename"), KEY_MASK_SHIFT | KEY_F2);
 	ED_SHORTCUT("scene_tree/add_child_node", TTR("Add Child Node"), KEY_MASK_CMD | KEY_A);
-	ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"));
+	ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_A);
 	ED_SHORTCUT("scene_tree/expand_collapse_all", TTR("Expand/Collapse All"));
 	ED_SHORTCUT("scene_tree/cut_node", TTR("Cut"), KEY_MASK_CMD | KEY_X);
 	ED_SHORTCUT("scene_tree/copy_node", TTR("Copy"), KEY_MASK_CMD | KEY_C);


BUG: Set the number of thread to 1 so as MeanShift filter to output always the same result for regression tests

--- Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx
+++ Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx
@@ -155,6 +155,10 @@
   filter->SetScale(scale);
   // Software Guide : EndCodeSnippet

+  // For non regression tests, set the number of threads to 1
+  // because MeanShift results depends on the number of threads
+  filter->SetNumberOfThreads(1);
+
   //  Software Guide : BeginLatex
   //
   // The \doxygen{otb}{MeanShiftImageFilter} type is instantiated using the image


[COFF] Improve correctness of def parsing for GNU features

The operator == used for exporting a function with a different
name in the DLL compared to the name in the import library
(which is useful for adding linker level aliases for function
in the import library) is a feature distinct and different from
the operator = used for exporting a function with a different
name (both in import library and DLL) than in the implementation
producing the DLL.

When creating an import library using dlltool, from a def file that
contains forwards (Func = OtherDll.Func), this shouldn't affect the
produced import library, which should still behave just as if it
was a normal exported function.

This clears a lot of confusion and subtle misunderstandings, and
avoids a parameter that was used to avoid creating weak aliases
when invoked from lld. (This parameter was added previously due to
the existing conflation of the two features.)

Differential Revision: https://reviews.llvm.org/D46245

git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@331860 91177308-0d34-0410-b5e6-96231b3b80d8

--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -559,7 +559,7 @@

   if (!Config->Incremental) {
     HandleError(writeImportLibrary(LibName, Path, Exports, Config->Machine,
-                                   false, Config->MinGW));
+                                   Config->MinGW));
     return;
   }

@@ -569,7 +569,7 @@
       Path, /*FileSize*/ -1, /*RequiresNullTerminator*/ false);
   if (!OldBuf) {
     HandleError(writeImportLibrary(LibName, Path, Exports, Config->Machine,
-                                   false, Config->MinGW));
+                                   Config->MinGW));
     return;
   }

@@ -580,7 +580,7 @@
           EC.message());

   if (Error E = writeImportLibrary(LibName, TmpName, Exports, Config->Machine,
-                                   false, Config->MinGW)) {
+                                   Config->MinGW)) {
     HandleError(std::move(E));
     return;
   }
@@ -626,8 +626,7 @@
   for (COFFShortExport E1 : M.Exports) {
     Export E2;
     E2.Name = Saver.save(E1.Name);
-    if (E1.isWeak())
-      E2.ExtName = Saver.save(E1.ExtName);
+    E2.ExtName = Saver.save(E1.ExtName);
     E2.Ordinal = E1.Ordinal;
     E2.Noname = E1.Noname;
     E2.Data = E1.Data;


fixed for compile

fixed for compile

--- NFComm/NFCore/NFMapEx.hpp
+++ NFComm/NFCore/NFMapEx.hpp
@@ -81,18 +81,18 @@
         return false;
     }

-    //virtual TD* GetElementNude(const T& name)
-    //{
-    //    typename NFMapOBJECT::iterator itr = mObjectList.find(name);
-    //    if (itr != mObjectList.end())
-    //    {
-    //        return itr->second.get();
-    //    }
-    //    else
-    //    {
-    //        return NULL;
-    //    }
-    //}
+    virtual TD* GetElementNude(const T& name)
+    {
+        typename NFMapOBJECT::iterator itr = mObjectList.find(name);
+        if (itr != mObjectList.end())
+        {
+            return itr->second.get();
+        }
+        else
+        {
+            return NULL;
+        }
+    }

     virtual NF_SHARE_PTR<TD> GetElement(const T& name)
     {


Fixed pointer formatting, fixed integer to pointer cast

--- NULLC/Executor_Common.cpp
+++ NULLC/Executor_Common.cpp
@@ -341,7 +341,7 @@
 	nullcPrintDepthIndent(indentDepth);
 	printf("typeid type = %d (%s)\n", arr->typeID, codeSymbols + codeTypes[arr->typeID].offsetToName);
 	nullcPrintDepthIndent(indentDepth);
-	printf("%s[] data = 0x%x\n", codeSymbols + codeTypes[arr->typeID].offsetToName, arr->ptr);
+	printf("%s[] data = %p\n", codeSymbols + codeTypes[arr->typeID].offsetToName, arr->ptr);
 }

 void nullcPrintVariableInfo(const ExternTypeInfo& type, char* ptr, unsigned indentDepth);
@@ -367,10 +367,10 @@
 	printf(")\n");

 	nullcPrintDepthIndent(indentDepth);
-	printf("%s context = 0x%x\n", func.contextType == ~0u ? "void ref" : codeSymbols + codeTypes[func.contextType].offsetToName, *(int*)(ptr));
-
-	if(*(int*)(ptr))
-		nullcPrintVariableInfo(codeTypes[codeTypes[func.contextType].subType], (char*)*(int*)(ptr), indentDepth + 1);
+	printf("%s context = %p\n", func.contextType == ~0u ? "void ref" : codeSymbols + codeTypes[func.contextType].offsetToName, *(char**)(ptr));
+
+	if(*(char**)(ptr))
+		nullcPrintVariableInfo(codeTypes[codeTypes[func.contextType].subType], *(char**)(ptr), indentDepth + 1);
 }

 void nullcPrintComplexVariableInfo(const ExternTypeInfo& type, char* ptr, unsigned indentDepth)
@@ -481,7 +481,7 @@
 			int alignOffset = (offset % 16 != 0) ? (16 - (offset % 16)) : 0;
 			offset += alignOffset;

-			printf("0x%x: function %s(", data + offset, codeSymbols + function.offsetToName);
+			printf("%p: function %s(", data + offset, codeSymbols + function.offsetToName);
 			for(unsigned arg = 0; arg < function.paramCount; arg++)
 			{
 				ExternLocalInfo &lInfo = codeLocals[function.offsetToFirstLocal + arg];
@@ -499,7 +499,7 @@
 				ExternTypeInfo &localType = codeTypes[lInfo.type];

 				nullcPrintDepthIndent(indent);
-				printf("0x%x: %s %s", data + offset + lInfo.offset, codeSymbols + codeTypes[lInfo.type].offsetToName, codeSymbols + lInfo.offsetToName);
+				printf("%p: %s %s", data + offset + lInfo.offset, codeSymbols + codeTypes[lInfo.type].offsetToName, codeSymbols + lInfo.offsetToName);

 				if(localType.subCat == ExternTypeInfo::CAT_NONE || localType.subCat == ExternTypeInfo::CAT_POINTER)
 				{
@@ -526,7 +526,7 @@
 				char *ptr = (char*)(data + offset + function.bytesToPop - NULLC_PTR_SIZE);

 				nullcPrintDepthIndent(indent);
-				printf("0x%x: %s %s = %p\n", ptr, "$this", codeSymbols + codeTypes[function.parentType].offsetToName, *(char**)ptr);
+				printf("%p: %s %s = %p\n", ptr, "$this", codeSymbols + codeTypes[function.parentType].offsetToName, *(char**)ptr);
 			}

 			if(function.contextType != ~0u)
@@ -534,7 +534,7 @@
 				char *ptr = (char*)(data + offset + function.bytesToPop - NULLC_PTR_SIZE);

 				nullcPrintDepthIndent(indent);
-				printf("0x%x: %s %s = %p\n", ptr, "$context", codeSymbols + codeTypes[function.contextType].offsetToName, *(char**)ptr);
+				printf("%p: %s %s = %p\n", ptr, "$context", codeSymbols + codeTypes[function.contextType].offsetToName, *(char**)ptr);
 			}

 			offset += offsetToNextFrame;
@@ -546,7 +546,7 @@
 				ExternTypeInfo &type = codeTypes[codeVars[i].type];

 				nullcPrintDepthIndent(indent);
-				printf("0x%x: %s %s", data + codeVars[i].offset, codeSymbols + type.offsetToName, codeSymbols + codeVars[i].offsetToName);
+				printf("%p: %s %s", data + codeVars[i].offset, codeSymbols + type.offsetToName, codeSymbols + codeVars[i].offsetToName);

 				if(type.subCat == ExternTypeInfo::CAT_NONE || type.subCat == ExternTypeInfo::CAT_POINTER)
 				{


fixing the work-around

fixing the work-around

--- education/posit/values.cpp
+++ education/posit/values.cpp
@@ -5,15 +5,13 @@
 // This file is part of the universal numbers project, which is released under an MIT Open Source license.

 #include "common.hpp"
-#define POSIT_VERBOSE_OUTPUT
+//#define POSIT_VERBOSE_OUTPUT
 #define POSIT_TRACE_CONVERSION
 #include <posit>

-//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+/*-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 //
 // Constants
-//
-//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 #define DBL_DECIMAL_DIG  17                      // # of decimal digits of rounding precision
 #define DBL_DIG          15                      // # of decimal digits of precision
 #define DBL_EPSILON      2.2204460492503131e-016 // smallest such that 1.0+DBL_EPSILON != 1.0
@@ -56,6 +54,7 @@
 #define LDBL_MIN_EXP     DBL_MIN_EXP             // min binary exponent
 #define _LDBL_RADIX      _DBL_RADIX              // exponent radix
 #define LDBL_TRUE_MIN    DBL_TRUE_MIN            // min positive value
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*/

 using namespace std;
 using namespace sw::unum;
@@ -121,11 +120,12 @@
 bool ValidateSubnormalFloats() {
 	constexpr float flt_min = std::numeric_limits<float>::min();
 	constexpr float flt_max = std::numeric_limits<float>::max();
+	constexpr float flt_true_min = 1.401298464e-45F;

 	bool bSuccess = false;

 	std::cout << flt_min << " " << flt_max << std::endl;
-	std::cout << FLT_TRUE_MIN << std::endl;
+	std::cout << flt_true_min << std::endl;
 	std::cout << hexfloat << flt_min << defaultfloat << std::endl;

 	value<23> v;
@@ -137,7 +137,7 @@
 		std::cout << hexfloat << flt << defaultfloat << " " << flt << " " << components(v) << " " << v << std::endl;
 	}

-	flt = FLT_TRUE_MIN + flt_min;
+	flt = flt_min + 3*flt_true_min;
 	v = flt;
 	std::cout << hexfloat << flt << defaultfloat << " " << flt << " " << components(v) << " " << v << std::endl;

@@ -152,6 +152,9 @@
 int main()
 try {
 	int nrOfFailedTestCases = 0;
+
+	cout << "Validate subnormal floats" << endl;
+	ValidateSubnormalFloats<std::numeric_limits<float>::digits>();

 	cout << "Value configuration validation" << endl;
 	TestConversionResult(ValidateValue<8>(), "value<8>");


Lines authored by ritzau

Lines authored by ritzau

This commit forms part of the blame-preserving initial commit suite.


Fix NotepadLog for Unicode, C++ conformance

The 'A' versions of FindWindow(Ex) and SendMessage must be used to avoid
compile errors and text misinterpretation, and char * str needs to be
const.

--- NotepadLog/NotepadLog.cpp
+++ NotepadLog/NotepadLog.cpp
@@ -30,7 +30,10 @@
 // Don't leave NotepadLog statements in your shipping binaries or else unwitting
 // users will find notepad filled with your debug statements.

-static void NotepadLog(char * str, ...)
+// Note that using the 'A' versions of FindWindow(Ex) is important to make this
+// compile when built for unicode. Using SendMessageA is important to ensure
+// that the message is interpreted correctly by notepad as ASCII.
+static void NotepadLog(const char * str, ...)
 {
   va_list ap;
   va_start(ap, str);
@@ -40,11 +43,11 @@
   va_end(ap);

   strncat_s(buf, _countof(buf), "\r\n", _TRUNCATE);
-  HWND notepad = FindWindow(NULL, "Untitled - Notepad");
+  HWND notepad = FindWindowA(NULL, "Untitled - Notepad");
   if (!notepad)
-    notepad = FindWindow(NULL, "*Untitled - Notepad");
-  HWND edit = FindWindowEx(notepad, nullptr, "EDIT", nullptr);
-  SendMessage(edit, EM_REPLACESEL, TRUE, (LPARAM)buf);
+    notepad = FindWindowA(NULL, "*Untitled - Notepad");
+  HWND edit = FindWindowExA(notepad, nullptr, "EDIT", nullptr);
+  SendMessageA(edit, EM_REPLACESEL, TRUE, (LPARAM)buf);
 }

 // Test code, prints whatever is in the first argument.


Fix Develco EMIZB-132 voltage calculation

--- electrical_measurement.cpp
+++ electrical_measurement.cpp
@@ -145,7 +145,6 @@
                     }
                     else if (modelId == QLatin1String("RICI01") ||                                     // LifeControl Smart Plug
                              modelId.startsWith(QLatin1String("outlet")) ||                            // Samsung SmartThings IM6001-OTP/IM6001-OTP01
-                             modelId.startsWith(QLatin1String("EMIZB-1")) ||                           // Develco EMI
                              modelId.startsWith(QLatin1String("ROB_200")) ||                           // ROBB Smarrt micro dimmer
                              modelId.startsWith(QLatin1String("Micro Smart Dimmer")) ||                // Sunricher Micro Smart Dimmer
                              modelId == QLatin1String("Connected socket outlet") ||                    // Niko smart socket


Replace &vector[0] with vector.data() to avoid invalid dereference caught by debug STL. Also move a '*' for consistency and fix an 80-col violation.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@244134 91177308-0d34-0410-b5e6-96231b3b80d8

--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -103,7 +103,7 @@
   // use only and will not be passed.
   static std::vector<const char *> extra;

-  static void process_plugin_option(const char* opt_)
+  static void process_plugin_option(const char *opt_)
   {
     if (opt_ == nullptr)
       return;
@@ -322,7 +322,8 @@
       message(LDPL_ERROR, "Failed to get a view of %s", file->name);
       return LDPS_ERR;
     }
-    BufferRef = MemoryBufferRef(StringRef((const char *)view, file->filesize), "");
+    BufferRef =
+        MemoryBufferRef(StringRef((const char *)view, file->filesize), "");
   } else {
     int64_t offset = 0;
     // Gold has found what might be IR part-way inside of a file, such as
@@ -429,7 +430,7 @@
   }

   if (!cf.syms.empty()) {
-    if (add_symbols(cf.handle, cf.syms.size(), &cf.syms[0]) != LDPS_OK) {
+    if (add_symbols(cf.handle, cf.syms.size(), cf.syms.data()) != LDPS_OK) {
       message(LDPL_ERROR, "Unable to add symbols!");
       return LDPS_ERR;
     }
@@ -583,7 +584,7 @@
                  ld_plugin_input_file &Info, raw_fd_ostream *ApiFile,
                  StringSet<> &Internalize, StringSet<> &Maybe) {

-  if (get_symbols(F.handle, F.syms.size(), &F.syms[0]) != LDPS_OK)
+  if (get_symbols(F.handle, F.syms.size(), F.syms.data()) != LDPS_OK)
     message(LDPL_FATAL, "Failed to get symbol information");

   const void *View;


Avoid temporary construction and potential for corrupted data access.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@35771 91177308-0d34-0410-b5e6-96231b3b80d8

--- tools/llvm-db/Commands.cpp
+++ tools/llvm-db/Commands.cpp
@@ -49,10 +49,9 @@
   eliminateRunInfo();

   // If the program has been modified, reload it!
-  sys::Path Program(Dbg.getProgramPath());
+  sys::PathWithStatus Program(Dbg.getProgramPath());
   std::string Err;
-  const sys::FileStatus *Status =
-    sys::PathWithStatus(Program).getFileStatus(false, &Err);
+  const sys::FileStatus *Status = Program.getFileStatus(false, &Err);
   if (!Status)
     throw Err;
   if (TheProgramInfo->getProgramTimeStamp() != Status->getTimestamp()) {


slicer crits: use getAccessedMemory instead of directly PTA when
matching crits

getAccessedMemory handles also calls and other instructions than
just Store/Load.

Fixes #354.

--- tools/llvm-slicer-crit.cpp
+++ tools/llvm-slicer-crit.cpp
@@ -48,15 +48,21 @@
 static std::map<const llvm::Value *, std::string> valuesToVariables;

 static bool usesTheVariable(LLVMDependenceGraph& dg,
-                            const llvm::Value *v,
+                            const llvm::Instruction& I,
                             const std::string& var)
 {
-    auto pts = dg.getPTA()->getLLVMPointsTo(v);
-    if (pts.empty() || pts.hasUnknown())
-        return true; // it may be a definition of the variable, we do not know
-
-    for (const auto& ptr : pts) {
-        auto name = valuesToVariables.find(ptr.value);
+    if (!I.mayReadOrWriteMemory())
+        return false;
+
+    auto memacc  =dg.getPTA()->getAccessedMemory(&I);
+    if (memacc.first) {
+        // PTA has no information, it may be a definition of the variable,
+        // we do not know
+        return true;
+    }
+
+    for (const auto& region : memacc.second) {
+        auto name = valuesToVariables.find(region.pointer.value);
         if (name != valuesToVariables.end()) {
             if (name->second == var)
                 return true;
@@ -64,33 +70,6 @@
     }

     return false;
-}
-
-template <typename InstT>
-static bool useOfTheVar(LLVMDependenceGraph& dg,
-                        const llvm::Instruction& I,
-                        const std::string& var)
-{
-    // check that we store to that variable
-    const InstT *tmp = llvm::dyn_cast<InstT>(&I);
-    if (!tmp)
-        return false;
-
-    return usesTheVariable(dg, tmp->getPointerOperand(), var);
-}
-
-static bool isStoreToTheVar(LLVMDependenceGraph& dg,
-                            const llvm::Instruction& I,
-                            const std::string& var)
-{
-    return useOfTheVar<llvm::StoreInst>(dg, I, var);
-}
-
-static bool isLoadOfTheVar(LLVMDependenceGraph& dg,
-                           const llvm::Instruction& I,
-                           const std::string& var)
-{
-    return useOfTheVar<llvm::LoadInst>(dg, I, var);
 }

@@ -111,8 +90,7 @@
         if (static_cast<int>(Loc.getLine()) != c.first)
             continue;

-        if (isStoreToTheVar(dg, I, c.second) ||
-            isLoadOfTheVar(dg, I, c.second)) {
+        if (usesTheVariable(dg, I, c.second)) {
             llvm::errs() << "Matched line " << c.first << " with variable "
                          << c.second << " to:\n" << I << "\n";
             return true;


CDA opts: add the "scd" alias for "standard"

--- tools/llvm-slicer-opts.cpp
+++ tools/llvm-slicer-opts.cpp
@@ -211,6 +211,8 @@
                        "standard", "Ferrante's algorithm (default)"),
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::STANDARD,
                        "classic", "Alias to \"standard\""),
+            clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::STANDARD,
+                       "scd", "Alias to \"standard\""),
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::NTSCD,
                        "ntscd", "Non-termination sensitive control dependencies algorithm"),
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::NTSCD2,
@@ -221,7 +223,7 @@
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::NTSCD_LEGACY,
                        "ntscd-legacy", "Non-termination sensitive control dependencies algorithm (legacy implementation)"),
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::DOD_RANGANATH,
-                       "dod-ranganath", "Decisive order dependencies algorithm by Ranganath (standalone - for debugging)"),
+                       "dod-ranganath", "Decisive order dependencies algorithm by Ranganath et al. - fixed version (standalone - for debugging)"),
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::DOD,
                        "dod", "Decisive order dependencies algorithm (standalone - for debugging)"),
             clEnumValN(dg::ControlDependenceAnalysisOptions::CDAlgorithm::DODNTSCD,


Publishing the frame window handle as the user data of the receiver window.

--- win32/DirectorExtension.cxx
+++ win32/DirectorExtension.cxx
@@ -150,6 +150,9 @@
 	                0);
 	if (!wReceiver)
 		::exit(FALSE);
+	// Make the frame window handle available so the director can activate it.
+	::SetWindowLong(wReceiver, GWL_USERDATA,
+		reinterpret_cast<LONG>(((SciTEBase*)host)->GetID()));
 	CheckEnvironment(host);
 	return true;
 }


Fix unit tests names

Fix unit tests names

--- src/components/application_manager/test/resumption/resume_ctrl_test.cc
+++ src/components/application_manager/test/resumption/resume_ctrl_test.cc
@@ -1229,7 +1229,9 @@
             res_ctrl_->GetSavedAppHmiLevel(kTestPolicyAppId_, kMacAddress_));
 }

-TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_Restored) {
+TEST_F(
+    ResumeCtrlTest,
+    ResumptionLowVoltage_AppInFullUnregisteredWithinTimeFrame_HMILevelRestored) {
   const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
   const uint32_t time_offset = 5;
   const uint32_t time_stamp =
@@ -1270,7 +1272,52 @@
   res_ctrl_->StartAppHmiStateResumption(mock_app_);
 }

-TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_NotRestored) {
+TEST_F(
+    ResumeCtrlTest,
+    ResumptionLowVoltage_AppInFullUnregisteredOnTheBorderOfTimeFrame_HMILevelRestored) {
+  const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
+  const uint32_t time_offset = 5;
+  const uint32_t time_stamp =
+      time(nullptr) - resumption_delay_before_ign_ + time_offset;
+  smart_objects::SmartObject saved_app;
+  saved_app[application_manager::strings::hmi_level] = restored_test_type;
+  saved_app[application_manager::strings::time_stamp] = time_stamp;
+
+  application_manager::CommandsMap command;
+  DataAccessor<application_manager::CommandsMap> data_accessor(
+      command, app_set_lock_ptr_);
+
+  EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type))
+      .Times(AtLeast(1));
+  GetInfoFromApp();
+  EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+      .WillRepeatedly(Return(kDefaultTestLevel_));
+  EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
+  ON_CALL(*mock_storage_,
+          GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
+      .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
+
+  EXPECT_CALL(*mock_storage_,
+              RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_))
+      .WillOnce(Return(true));
+
+  ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345"))
+      .WillByDefault(Return(policy::kDeviceAllowed));
+
+  NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
+  EXPECT_CALL(mock_app_mngr_, get_settings())
+      .WillOnce(ReturnRef(app_mngr_settings_));
+
+  EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
+      .WillOnce(Return(resumption_delay_before_ign_ + time_offset));
+
+  res_ctrl_->SaveLowVoltageTime();
+  res_ctrl_->StartAppHmiStateResumption(mock_app_);
+}
+
+TEST_F(
+    ResumeCtrlTest,
+    ResumptionLowVoltage_AppInFullUnregisteredBeyondTimeFrame_HMILevelNotRestored) {
   const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
   const uint32_t time_offset = 5;
   const uint32_t time_stamp =
@@ -1306,48 +1353,7 @@
   res_ctrl_->StartAppHmiStateResumption(mock_app_);
 }

-TEST_F(ResumeCtrlTest, LowVoltage_AppInFull_Restored2) {
-  const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
-  const uint32_t time_offset = 5;
-  const uint32_t time_stamp =
-      time(nullptr) - resumption_delay_before_ign_ + time_offset;
-  smart_objects::SmartObject saved_app;
-  saved_app[application_manager::strings::hmi_level] = restored_test_type;
-  saved_app[application_manager::strings::time_stamp] = time_stamp;
-
-  application_manager::CommandsMap command;
-  DataAccessor<application_manager::CommandsMap> data_accessor(
-      command, app_set_lock_ptr_);
-
-  EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type))
-      .Times(AtLeast(1));
-  GetInfoFromApp();
-  EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
-      .WillRepeatedly(Return(kDefaultTestLevel_));
-  EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
-  ON_CALL(*mock_storage_,
-          GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
-      .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
-
-  EXPECT_CALL(*mock_storage_,
-              RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_))
-      .WillOnce(Return(true));
-
-  ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345"))
-      .WillByDefault(Return(policy::kDeviceAllowed));
-
-  NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
-  EXPECT_CALL(mock_app_mngr_, get_settings())
-      .WillOnce(ReturnRef(app_mngr_settings_));
-
-  EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
-      .WillOnce(Return(resumption_delay_before_ign_ + time_offset));
-
-  res_ctrl_->SaveLowVoltageTime();
-  res_ctrl_->StartAppHmiStateResumption(mock_app_);
-}
-
-TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInBackground_Restored) {
+TEST_F(ResumeCtrlTest, ResumptionLowVoltage_AppInBackground_NotRestored) {
   const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_BACKGROUND;
   const uint32_t time_offset = 5;
   const uint32_t time_stamp =
@@ -1373,7 +1379,9 @@
   res_ctrl_->StartAppHmiStateResumption(mock_app_);
 }

-TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_Restored) {
+TEST_F(
+    ResumeCtrlTest,
+    ResumptionLowVoltage_AppInLimitedlUnregisteredWithinTimeFrame_HMILevelRestored) {
   const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED;
   const uint32_t time_offset = 5;
   const uint32_t time_stamp =
@@ -1414,7 +1422,9 @@
   res_ctrl_->StartAppHmiStateResumption(mock_app_);
 }

-TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInLimited_NotRestored) {
+TEST_F(
+    ResumeCtrlTest,
+    ResumptionLowVoltage_AppInLimitedlUnregisteredBeyondTimeFrame_HMILevelNotRestored) {
   const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED;
   const uint32_t time_offset = 5;
   const uint32_t time_stamp =


failure_detector_multimaster: add missing header cinttypes (#14)

--- src/dist/failure_detector_multimaster/failure_detector_multimaster.cpp
+++ src/dist/failure_detector_multimaster/failure_detector_multimaster.cpp
@@ -33,6 +33,7 @@
  *     xxxx-xx-xx, author, fix bug about xxx
  */

+#include <cinttypes>
 #include <dsn/tool-api/rpc_address.h>
 #include <dsn/tool-api/group_address.h>
 #include <dsn/dist/failure_detector_multimaster.h>


Set stencil if not specified when registering python kernel

--- scanner/engine/worker.cpp
+++ scanner/engine/worker.cpp
@@ -1679,6 +1679,9 @@
   bool can_stencil = op_registration->can_stencil();
   const std::vector<i32> stencil(op_registration->preferred_stencil().begin(),
                                  op_registration->preferred_stencil().end());
+  if (stencil.empty()) {
+    stencil = {0};
+  }
   OpInfo* info = new OpInfo(name, variadic_inputs, input_columns,
                             output_columns, can_stencil, stencil);
   OpRegistry* registry = get_op_registry();


Disable identification of periodic vertices when orient is disabled.

--- utilities/PreProcessing/MeshConvert/ProcessPerAlign.cpp
+++ utilities/PreProcessing/MeshConvert/ProcessPerAlign.cpp
@@ -199,53 +199,55 @@
                         int nVerts = c1->items[i]->GetVertexCount();
                         vector<int> perVerts(nVerts, 0), perVertsInv(nVerts, 0);

-                        for (int k = 0; k < nVerts; ++k)
+                        if (orient)
                         {
-                            NodeSharedPtr n1 = c1->items[i]->GetFaceLink()->vertexList[k];
-                            int l;
-
-                            for (l = 0; l < nVerts; ++l)
+                            for (int k = 0; k < nVerts; ++k)
                             {
-                                NodeSharedPtr n2 =
-                                    c2->items[it->first]->GetFaceLink()->vertexList[l];
-
-                                Node dn = *n2 - *n1;
-                                if (fabs(fabs(dn.x*vec[0] + dn.y*vec[1] +
-                                              dn.z*vec[2])/
-                                         sqrt(dn.abs2()) - 1.0) < 1e-6)
+                                NodeSharedPtr n1 = c1->items[i]->GetFaceLink()->vertexList[k];
+                                int l;
+
+                                for (l = 0; l < nVerts; ++l)
                                 {
-                                    perVerts   [k] = l;
-                                    perVertsInv[l] = k;
-
-                                    int id1 = n1->id;
-                                    int id2 = n2->id;
-                                    if (vertCheck.count(id1) == 0)
+                                    NodeSharedPtr n2 =
+                                        c2->items[it->first]->GetFaceLink()->vertexList[l];
+
+                                    Node dn = *n2 - *n1;
+                                    if (fabs(fabs(dn.x*vec[0] + dn.y*vec[1] +
+                                                  dn.z*vec[2])/
+                                             sqrt(dn.abs2()) - 1.0) < 1e-6)
                                     {
-                                        vertCheck[id1] = id2;
+                                        perVerts   [k] = l;
+                                        perVertsInv[l] = k;
+
+                                        int id1 = n1->id;
+                                        int id2 = n2->id;
+                                        if (vertCheck.count(id1) == 0)
+                                        {
+                                            vertCheck[id1] = id2;
+                                        }
+                                        else
+                                        {
+                                            ASSERTL0(vertCheck[id1] == id2,
+                                                     "Periodic vertex already "
+                                                     "identified!");
+                                        }
+                                        break;
                                     }
-                                    else
-                                    {
-                                        ASSERTL0(vertCheck[id1] == id2,
-                                                 "Periodic vertex already "
-                                                 "identified!");
-                                    }
-                                    break;
                                 }
+                                ASSERTL1(l < nVerts,
+                                         "Could not identify periodic vertices.");
                             }
-                            ASSERTL1(l < nVerts,
-                                     "Could not identify periodic vertices.");
+
+                            int tot1 = 0, tot2 = 0;
+                            for (int k = 0; k < nVerts; ++k)
+                            {
+                                tot1 += perVerts   [k];
+                                tot2 += perVertsInv[k];
+                            }
+                            ASSERTL0(tot1 == nVerts*(nVerts-1)/2 &&
+                                     tot2 == nVerts*(nVerts-1)/2,
+                                     "Error identifying periodic vertices");
                         }
-
-                        int tot1 = 0, tot2 = 0;
-                        for (int k = 0; k < nVerts; ++k)
-                        {
-                            tot1 += perVerts   [k];
-                            tot2 += perVertsInv[k];
-                        }
-
-                        ASSERTL0(tot1 == nVerts*(nVerts-1)/2 &&
-                                 tot2 == nVerts*(nVerts-1)/2,
-                                 "Error identifying periodic vertices");

                         perFaces[id1] = make_pair(
                             c2->items[it->first]->GetFaceLink(), perVerts);


BUG: Fix index error for ultrasound origin vector

--- Base/USTK/Testing/itkAngleOfIncidenceImageFilterTest.cxx
+++ Base/USTK/Testing/itkAngleOfIncidenceImageFilterTest.cxx
@@ -108,7 +108,7 @@

   UltrasoundProbeOriginVector[0] = UltrasoundProbeOriginX;
   UltrasoundProbeOriginVector[1] = UltrasoundProbeOriginY;
-  UltrasoundProbeOriginVector[0] = UltrasoundProbeOriginZ;
+  UltrasoundProbeOriginVector[2] = UltrasoundProbeOriginZ;

   filterAngleOfIncidence->SetUltrasoundProbeOrigin( UltrasoundProbeOriginVector );
   filterAngleOfIncidence->SetInput( thresholdFilter->GetOutput() );


Linux: fix include filename case

Linux: fix include filename case

Review URL: http://codereview.chromium.org/42383

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@12075 0039d316-1c4b-4281-b951-d872f2087c98

--- webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp
+++ webkit/port/bindings/v8/WorkerContextExecutionProxy.cpp
@@ -35,8 +35,8 @@

 #include "WorkerContextExecutionProxy.h"

-#include "v8Binding.h"
-#include "v8Proxy.h"
+#include "V8Binding.h"
+#include "V8Proxy.h"
 #include "v8_index.h"
 #include "Event.h"
 #include "V8WorkerContextEventListener.h"


FAR patch 01673.DeleteSymLink
Дата              : 12.06.2003
Сделал            : Valentin Skirdin
Описание          : Ошибка при удалении вложенного симлинка
Измененные файлы  : delete.cpp
Новые файлы       :
Удаленные файлы   :
Состав            : 01673.DeleteSymLink.txt
                    delete.cpp.1673.diff
Основан на патче  : 1672
Дополнение        :

folder\      - при удалении вот этого...
   dir1\
   @link\    - ...этот удаляется, но получаем сообщение о несуществовании
               каталога link.

--- far/delete.cpp
+++ far/delete.cpp
@@ -5,10 +5,12 @@

 */

-/* Revision: 1.60 01.06.2003 $ */
+/* Revision: 1.61 10.06.2003 $ */

 /*
 Modify:
+  10.06.2003 SVS
+    -    -
   01.06.2003 SVS
     ! FAR_DeleteFile  FAR_RemoveDirectory   delete.cpp  farwinapi.cpp
   21.04.2003 SVS
@@ -481,6 +483,7 @@
                 TreeList::DelTreeName(FullName);
                 if (UpdateDiz)
                   SrcPanel->DeleteDiz(FullName,SelShortName);
+                ScTree.SkipDir(); // ???    , ...
                 continue;
                 /* KM $ */
               }


Неправильные переименования некоторых констант в 3482.

--- far/syslog.cpp
+++ far/syslog.cpp
@@ -1264,8 +1264,8 @@
 		DEF_MCODE_(C_PPANEL_BOF),               //   ?
 		DEF_MCODE_(C_APANEL_EOF),               //    ?
 		DEF_MCODE_(C_PPANEL_EOF),               //   ?
-		DEF_MCODE_(C_APANEL_empty),           //  :  ?
-		DEF_MCODE_(C_PPANEL_empty),           //  : ?
+		DEF_MCODE_(C_APANEL_ISEMPTY),           //  :  ?
+		DEF_MCODE_(C_PPANEL_ISEMPTY),           //  : ?
 		DEF_MCODE_(C_APANEL_SELECTED),          //  :    ?
 		DEF_MCODE_(C_PPANEL_SELECTED),          //  :   ?
 		DEF_MCODE_(C_APANEL_ROOT),              //     ?


Make the constructor of Promise public

Make the constructor of Promise public

--- engine/core/WorkerPool.hpp
+++ engine/core/WorkerPool.hpp
@@ -64,8 +64,12 @@

     class Promise final
     {
-        friend class WorkerPool;
     public:
+        Promise(const TaskGroup& taskGroup) noexcept:
+            sharedState{std::make_shared<Future::State>(taskGroup.getTaskCount())}
+        {
+        }
+
         Future getFuture() const
         {
             return Future{sharedState};
@@ -83,11 +87,6 @@
         }

     private:
-        Promise(const TaskGroup& taskGroup) noexcept:
-            sharedState{std::make_shared<Future::State>(taskGroup.getTaskCount())}
-        {
-        }
-
         std::shared_ptr<Future::State> sharedState;
     };

@@ -99,7 +98,7 @@
             const std::size_t cpuCount = std::thread::hardware_concurrency();
             const std::size_t count = (cpuCount > 1) ? cpuCount - 1 : 1;

-            for (unsigned int i = 0; i < count; ++i)
+            for (std::size_t i = 0; i < count; ++i)
                 workers.emplace_back(&WorkerPool::work, this);
         }


removed commented code

removed commented code

--- Modules/MitkExt/Algorithms/mitkImageStatisticsCalculator.cpp
+++ Modules/MitkExt/Algorithms/mitkImageStatisticsCalculator.cpp
@@ -997,12 +997,6 @@
   this->ConnectPipelines( vtkExporter, itkImporter );
   itkImporter->Update();

-  //typedef itk::ImageFileWriter< MaskImage2DType > FileWriterType;
-  //FileWriterType::Pointer writer = FileWriterType::New();
-  //writer->SetInput( itkImporter->GetOutput() );
-  //writer->SetFileName( "d:/test/test.mhd" );
-  //writer->Update();
-
   // Store mask
   m_InternalImageMask2D = itkImporter->GetOutput();


Fixed cout and default logger having different output formats

--- OpenSim/Common/Logger.cpp
+++ OpenSim/Common/Logger.cpp
@@ -30,9 +30,9 @@

 using namespace OpenSim;

-static void initializeLogger(spdlog::logger& l) {
+static void initializeLogger(spdlog::logger& l, const char* pattern) {
     l.set_level(spdlog::level::info);
-    l.set_pattern("%v");
+    l.set_pattern(pattern);
 }

 // cout logger will be initialized during static initialization time
@@ -46,8 +46,8 @@
 // this function returns a dummy value so that it can be used in an assignment
 // expression (below) that *must* be executed in-order at static init time
 static bool initializeLogging() {
-    initializeLogger(*coutLogger);
-    initializeLogger(*defaultLogger);
+    initializeLogger(*coutLogger, "%v");
+    initializeLogger(*defaultLogger, "[%l] %v");
     spdlog::flush_on(spdlog::level::info);
     return true;
 }


(toNumber) : Replace with the esjs implementation to support ECMAScript grammar.

--- esidl/npapi/src/bridge.cpp
+++ esidl/npapi/src/bridge.cpp
@@ -58,38 +58,90 @@
     }
 }

-// TODO: Check length strictly.
-double toNumber(const char* string, size_t length)
-{
-    const char* ptr = string;
+char* skipSpace(const char* str)
+{
+    static const char* rgsp[] =
+    {
+        // NBSP
+        "\xc2\xa0",
+        // LS
+        "\xe2\x80\xa8",
+        // PS
+        "\xe2\x80\xa9",
+        // USP
+        "\xe1\x9a\x80",
+        "\xe1\xa0\x8e",
+        "\xe2\x80\x80",
+        "\xe2\x80\x81",
+        "\xe2\x80\x82",
+        "\xe2\x80\x83",
+        "\xe2\x80\x84",
+        "\xe2\x80\x85",
+        "\xe2\x80\x86",
+        "\xe2\x80\x87",
+        "\xe2\x80\x88",
+        "\xe2\x80\x89",
+        "\xe2\x80\x8a",
+        "\xe2\x80\xaf",
+        "\xe2\x81\x9f",
+        "\xe3\x80\x80",
+        // BOM
+        "\xef\xbb\xbf"
+    };
+
+    while (char c = *str)
+    {
+        if (strchr(" \t\v\f\n\r", c))
+        {
+            ++str;
+            continue;
+        }
+        int i;
+        for (i = 0; i < sizeof(rgsp) / sizeof(rgsp[0]); ++i)
+        {
+            const char* sp = rgsp[i];
+            size_t len = strlen(sp);
+            if (strncmp(str, sp, len) == 0)
+            {
+                str += len;
+                break;
+            }
+        }
+        if (sizeof(rgsp) / sizeof(rgsp[0]) <= i)
+        {
+            break;
+        }
+    }
+    return const_cast<char*>(str);
+}
+
+double toNumber(const std::string value)
+{
+    const char* ptr = value.c_str();
+    ptr = skipSpace(ptr);
+    const char* uptr = ptr;
+    bool negative = (*ptr == '-');
+    if (negative || *ptr == '+')
+    {
+        ++uptr;
+    }
+    char* end;
     double number;
-    while (*ptr && isspace(*ptr))  // TODO: Check UTF8 space
-    {
-        ++ptr;
-    }
-    char* end;
-    if (strncasecmp(ptr, "0x", 2) == 0)
-    {
-        ptr += 2;
-        number = strtoll(ptr, &end, 16);
-    }
-    else if (strncmp(ptr, "Infinity", 8) == 0)
-    {
-        end = const_cast<char*>(ptr) + 8;
-        number = INFINITY;
-    } else
+    if (strncmp(uptr, "Infinity", 8) == 0)
+    {
+        end = const_cast<char*>(uptr) + 8;
+        number = negative ? -INFINITY : INFINITY;
+    }
+    else
     {
         number = strtod(ptr, &end);
-    }
-    if (end == ptr)
-    {
-        return NAN;
-    }
-    while (*end && isspace(*end))  // TODO: Check UTF8 space
-    {
-        ++end;
-    }
-    if (*end != 0 || string + length < end)
+        if (end == ptr)
+        {
+            return NAN;
+        }
+    }
+    end = skipSpace(end);
+    if (*end != 0)
     {
         return NAN;
     }
@@ -111,8 +163,8 @@
     case NPVariantType_Double:
         return NPVARIANT_TO_DOUBLE(*variant);
     case NPVariantType_String:
-        return toNumber(NPVARIANT_TO_STRING(*variant).utf8characters,
-                        NPVARIANT_TO_STRING(*variant).utf8length);
+        return toNumber(std::string(NPVARIANT_TO_STRING(*variant).utf8characters,
+                                    NPVARIANT_TO_STRING(*variant).utf8length));
     case NPVariantType_Object:
         return NAN; // TODO: Try valueOf, toString, etc.
     default: