Added F macro to strings and removed unecessary quotes initiating /0 terminator from println's

--- Adafruit_NFCShield_I2C.cpp
+++ Adafruit_NFCShield_I2C.cpp
@@ -139,17 +139,17 @@
   uint32_t szPos;
   for (szPos=0; szPos < numBytes; szPos++)
   {
-    Serial.print("0x");
+    Serial.print(F("0x"));
     // Append leading 0 for small values
     if (data[szPos] <= 0xF)
-      Serial.print("0");
+      Serial.print(F("0"));
     Serial.print(data[szPos]&0xff, HEX);
     if ((numBytes > 1) && (szPos != numBytes - 1))
     {
-      Serial.print(" ");
+      Serial.print(F(" "));
     }
   }
-  Serial.println("");
+  Serial.println();
 }

 /**************************************************************************/
@@ -170,22 +170,22 @@
   {
     // Append leading 0 for small values
     if (data[szPos] <= 0xF)
-      Serial.print("0");
+      Serial.print(F("0"));
     Serial.print(data[szPos], HEX);
     if ((numBytes > 1) && (szPos != numBytes - 1))
     {
-      Serial.print(" ");
+      Serial.print(F(" "));
     }
   }
-  Serial.print("  ");
+  Serial.print(F("  "));
   for (szPos=0; szPos < numBytes; szPos++)
   {
     if (data[szPos] <= 0x1F)
-      Serial.print(".");
+      Serial.print(F("."));
     else
       Serial.print((char)data[szPos]);
   }
-  Serial.println("");
+  Serial.println();
 }

 /**************************************************************************/
@@ -209,7 +209,7 @@
   // check some basic stuff
   if (0 != strncmp((char *)pn532_packetbuffer, (char *)pn532response_firmwarevers, 6)) {
     #ifdef PN532DEBUG
-    Serial.println("Firmware doesn't match!");
+    Serial.println(F("Firmware doesn't match!"));
 	#endif
     return 0;
   }
@@ -256,13 +256,13 @@
   }

   #ifdef PN532DEBUG
-  Serial.println("IRQ received");
+  Serial.println(F("IRQ received"));
   #endif

   // read acknowledgement
   if (!readackframe()) {
     #ifdef PN532DEBUG
-    Serial.println("No ACK frame received!");
+    Serial.println(F("No ACK frame received!"));
     #endif
     return false;
   }
@@ -303,7 +303,7 @@
   pn532_packetbuffer[2] = 0x00;    // P7 GPIO Pins (not used ... taken by I2C)

   #ifdef PN532DEBUG
-    Serial.print("Writing P3 GPIO: "); Serial.println(pn532_packetbuffer[1], HEX);
+    Serial.print(F("Writing P3 GPIO: ")); Serial.println(pn532_packetbuffer[1], HEX);
   #endif

   // Send the WRITEGPIO command (0x0E)
@@ -314,9 +314,9 @@
   wirereaddata(pn532_packetbuffer, 8);

   #ifdef PN532DEBUG
-    Serial.print("Received: ");
+    Serial.print(F("Received: "));
     PrintHex(pn532_packetbuffer, 8);
-    Serial.println("");
+    Serial.println();
   #endif

   return  (pn532_packetbuffer[6] == 0x0F);
@@ -357,23 +357,23 @@
     b10             checksum */

   #ifdef PN532DEBUG
-    Serial.print("Received: ");
+    Serial.print(F("Received: "));
     PrintHex(pn532_packetbuffer, 11);
-    Serial.println("");
-    Serial.print("P3 GPIO: 0x"); Serial.println(pn532_packetbuffer[7], HEX);
-    Serial.print("P7 GPIO: 0x"); Serial.println(pn532_packetbuffer[8], HEX);
-    Serial.print("IO GPIO: 0x"); Serial.println(pn532_packetbuffer[9], HEX);
+    Serial.println();
+    Serial.print(F("P3 GPIO: 0x")); Serial.println(pn532_packetbuffer[7], HEX);
+    Serial.print(F("P7 GPIO: 0x")); Serial.println(pn532_packetbuffer[8], HEX);
+    Serial.print(F("IO GPIO: 0x")); Serial.println(pn532_packetbuffer[9], HEX);
     // Note: You can use the IO GPIO value to detect the serial bus being used
     switch(pn532_packetbuffer[9])
     {
       case 0x00:    // Using UART
-        Serial.println("Using UART (IO = 0x00)");
+        Serial.println(F("Using UART (IO = 0x00)"));
         break;
       case 0x01:    // Using I2C
-        Serial.println("Using I2C (IO = 0x01)");
+        Serial.println(F("Using I2C (IO = 0x01)"));
         break;
       case 0x02:    // Using I2C
-        Serial.println("Using I2C (IO = 0x02)");
+        Serial.println(F("Using I2C (IO = 0x02)"));
         break;
     }
   #endif
@@ -419,7 +419,7 @@
   pn532_packetbuffer[4] = maxRetries;

 #ifdef MIFAREDEBUG
-  Serial.print("Setting MxRtyPassiveActivation to "); Serial.print(maxRetries, DEC); Serial.println(" ");
+  Serial.print(F("Setting MxRtyPassiveActivation to ")); Serial.print(maxRetries, DEC); Serial.println(F(" "));
 #endif

   if (! sendCommandCheckAck(pn532_packetbuffer, 5))
@@ -451,7 +451,7 @@
   if (! sendCommandCheckAck(pn532_packetbuffer, 3))
   {
     #ifdef PN532DEBUG
-	Serial.println("No card(s) read");
+	Serial.println(F("No card(s) read"));
 	#endif
     return 0x0;  // no cards read
   }
@@ -459,7 +459,7 @@
   // Wait for a card to enter the field
   uint8_t status = PN532_I2C_BUSY;
   #ifdef PN532DEBUG
-  Serial.println("Waiting for IRQ (indicates card presence)");
+  Serial.println(F("Waiting for IRQ (indicates card presence)"));
   #endif
   while (wirereadstatus() != PN532_I2C_READY)
   {
@@ -467,7 +467,7 @@
   }

   #ifdef PN532DEBUG
-  Serial.println("Found a card");
+  Serial.println(F("Found a card"));
   #endif

   // read data packet
@@ -487,7 +487,7 @@
     b13..NFCIDLen   NFCID                                      */

 #ifdef MIFAREDEBUG
-    Serial.print("Found "); Serial.print(pn532_packetbuffer[7], DEC); Serial.println(" tags");
+    Serial.print(F("Found ")); Serial.print(pn532_packetbuffer[7], DEC); Serial.println(F(" tags"));
 #endif
   if (pn532_packetbuffer[7] != 1)
     return 0;
@@ -496,20 +496,20 @@
   sens_res <<= 8;
   sens_res |= pn532_packetbuffer[10];
 #ifdef MIFAREDEBUG
-    Serial.print("ATQA: 0x");  Serial.println(sens_res, HEX);
-    Serial.print("SAK: 0x");  Serial.println(pn532_packetbuffer[11], HEX);
+    Serial.print(F("ATQA: 0x"));  Serial.println(sens_res, HEX);
+    Serial.print(F("SAK: 0x"));  Serial.println(pn532_packetbuffer[11], HEX);
 #endif

   /* Card appears to be Mifare Classic */
   *uidLength = pn532_packetbuffer[12];
 #ifdef MIFAREDEBUG
-    Serial.print("UID:");
+    Serial.print(F("UID:"));
 #endif
   for (uint8_t i=0; i < pn532_packetbuffer[12]; i++)
   {
     uid[i] = pn532_packetbuffer[13+i];
 #ifdef MIFAREDEBUG
-      Serial.print(" 0x");Serial.print(uid[i], HEX);
+      Serial.print(F(" 0x"));Serial.print(uid[i], HEX);
 #endif
   }
 #ifdef MIFAREDEBUG
@@ -581,9 +581,9 @@
   _uidLen = uidLen;

   #ifdef MIFAREDEBUG
-  Serial.print("Trying to authenticate card ");
+  Serial.print(F("Trying to authenticate card "));
   Adafruit_NFCShield_I2C::PrintHex(_uid, _uidLen);
-  Serial.print("Using authentication KEY ");Serial.print(keyNumber ? 'B' : 'A');Serial.print(": ");
+  Serial.print(F("Using authentication KEY "));Serial.print(keyNumber ? 'B' : 'A');Serial.print(F(": "));
   Adafruit_NFCShield_I2C::PrintHex(_key, 6);
   #endif

@@ -610,7 +610,7 @@
   if (pn532_packetbuffer[7] != 0x00)
   {
     #ifdef PN532DEBUG
-    Serial.print("Authentification failed: ");
+    Serial.print(F("Authentification failed: "));
     Adafruit_NFCShield_I2C::PrintHexChar(pn532_packetbuffer, 12);
     #endif
     return 0;
@@ -635,7 +635,7 @@
 uint8_t Adafruit_NFCShield_I2C::mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data)
 {
   #ifdef MIFAREDEBUG
-  Serial.print("Trying to read 16 bytes from block ");Serial.println(blockNumber);
+  Serial.print(F("Trying to read 16 bytes from block "));Serial.println(blockNumber);
   #endif

   /* Prepare the command */
@@ -648,7 +648,7 @@
   if (! sendCommandCheckAck(pn532_packetbuffer, 4))
   {
     #ifdef MIFAREDEBUG
-    Serial.println("Failed to receive ACK for read command");
+    Serial.println(F("Failed to receive ACK for read command"));
     #endif
     return 0;
   }
@@ -660,7 +660,7 @@
   if (pn532_packetbuffer[7] != 0x00)
   {
     #ifdef MIFAREDEBUG
-    Serial.println("Unexpected response");
+    Serial.println(F("Unexpected response"));
     Adafruit_NFCShield_I2C::PrintHexChar(pn532_packetbuffer, 26);
     #endif
     return 0;
@@ -672,7 +672,7 @@

   /* Display data for debug if requested */
   #ifdef MIFAREDEBUG
-    Serial.print("Block ");
+    Serial.print(F("Block "));
     Serial.println(blockNumber);
     Adafruit_NFCShield_I2C::PrintHexChar(data, 16);
   #endif
@@ -695,7 +695,7 @@
 uint8_t Adafruit_NFCShield_I2C::mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data)
 {
   #ifdef MIFAREDEBUG
-  Serial.print("Trying to write 16 bytes to block ");Serial.println(blockNumber);
+  Serial.print(F("Trying to write 16 bytes to block "));Serial.println(blockNumber);
   #endif

   /* Prepare the first command */
@@ -709,7 +709,7 @@
   if (! sendCommandCheckAck(pn532_packetbuffer, 20))
   {
     #ifdef MIFAREDEBUG
-    Serial.println("Failed to receive ACK for write command");
+    Serial.println(F("Failed to receive ACK for write command"));
     #endif
     return 0;
   }
@@ -854,13 +854,13 @@
   if (page >= 64)
   {
     #ifdef MIFAREDEBUG
-    Serial.println("Page value out of range");
+    Serial.println(F("Page value out of range"));
     #endif
     return 0;
   }

   #ifdef MIFAREDEBUG
-    Serial.print("Reading page ");Serial.println(page);
+    Serial.print(F("Reading page "));Serial.println(page);
   #endif

   /* Prepare the command */
@@ -873,7 +873,7 @@
   if (! sendCommandCheckAck(pn532_packetbuffer, 4))
   {
     #ifdef MIFAREDEBUG
-    Serial.println("Failed to receive ACK for write command");
+    Serial.println(F("Failed to receive ACK for write command"));
     #endif
     return 0;
   }
@@ -881,7 +881,7 @@
   /* Read the response packet */
   wirereaddata(pn532_packetbuffer, 26);
   #ifdef MIFAREDEBUG
-    Serial.println("Received: ");
+    Serial.println(F("Received: "));
     Adafruit_NFCShield_I2C::PrintHexChar(pn532_packetbuffer, 26);
   #endif

@@ -898,7 +898,7 @@
   else
   {
     #ifdef MIFAREDEBUG
-      Serial.println("Unexpected response reading block: ");
+      Serial.println(F("Unexpected response reading block: "));
       Adafruit_NFCShield_I2C::PrintHexChar(pn532_packetbuffer, 26);
     #endif
     return 0;
@@ -906,7 +906,7 @@

   /* Display data for debug if requested */
   #ifdef MIFAREDEBUG
-    Serial.print("Page ");Serial.print(page);Serial.println(":");
+    Serial.print(F("Page "));Serial.print(page);Serial.println(F(":"));
     Adafruit_NFCShield_I2C::PrintHexChar(buffer, 4);
   #endif

@@ -965,7 +965,7 @@
   delay(2);

 #ifdef PN532DEBUG
-  Serial.print("Reading: ");
+  Serial.print(F("Reading: "));
 #endif
   // Start read (n+1 to take into account leading 0x01 with I2C)
   WIRE.requestFrom((uint8_t)PN532_I2C_ADDRESS, (uint8_t)(n+2));
@@ -975,7 +975,7 @@
     delay(1);
     buff[i] = wirerecv();
 #ifdef PN532DEBUG
-    Serial.print(" 0x");
+    Serial.print(F(" 0x"));
     Serial.print(buff[i], HEX);
 #endif
   }
@@ -1002,7 +1002,7 @@
   cmdlen++;

 #ifdef PN532DEBUG
-  Serial.print("\nSending: ");
+  Serial.print(F("\nSending: "));
 #endif

   delay(2);     // or whatever the delay is for waking up the board
@@ -1021,19 +1021,19 @@
   checksum += PN532_HOSTTOPN532;

 #ifdef PN532DEBUG
-  Serial.print(" 0x"); Serial.print(PN532_PREAMBLE, HEX);
-  Serial.print(" 0x"); Serial.print(PN532_PREAMBLE, HEX);
-  Serial.print(" 0x"); Serial.print(PN532_STARTCODE2, HEX);
-  Serial.print(" 0x"); Serial.print(cmdlen, HEX);
-  Serial.print(" 0x"); Serial.print(~cmdlen + 1, HEX);
-  Serial.print(" 0x"); Serial.print(PN532_HOSTTOPN532, HEX);
+  Serial.print(F(" 0x")); Serial.print(PN532_PREAMBLE, HEX);
+  Serial.print(F(" 0x")); Serial.print(PN532_PREAMBLE, HEX);
+  Serial.print(F(" 0x")); Serial.print(PN532_STARTCODE2, HEX);
+  Serial.print(F(" 0x")); Serial.print(cmdlen, HEX);
+  Serial.print(F(" 0x")); Serial.print(~cmdlen + 1, HEX);
+  Serial.print(F(" 0x")); Serial.print(PN532_HOSTTOPN532, HEX);
 #endif

   for (uint8_t i=0; i<cmdlen-1; i++) {
    wiresend(cmd[i]);
    checksum += cmd[i];
 #ifdef PN532DEBUG
-   Serial.print(" 0x"); Serial.print(cmd[i], HEX);
+   Serial.print(F(" 0x")); Serial.print(cmd[i], HEX);
 #endif
   }

@@ -1044,8 +1044,8 @@
   WIRE.endTransmission();

 #ifdef PN532DEBUG
-  Serial.print(" 0x"); Serial.print(~checksum, HEX);
-  Serial.print(" 0x"); Serial.print(PN532_POSTAMBLE, HEX);
+  Serial.print(F(" 0x")); Serial.print(~checksum, HEX);
+  Serial.print(F(" 0x")); Serial.print(PN532_POSTAMBLE, HEX);
   Serial.println();
 #endif
 }
@@ -1084,7 +1084,7 @@
 boolean Adafruit_NFCShield_I2C::inDataExchange(uint8_t * send, uint8_t sendLength, uint8_t * response, uint8_t * responseLength) {
   if (sendLength > PN532_PACKBUFFSIZ -2) {
     #ifdef PN532DEBUG
-      Serial.println("APDU length too long for packet buffer");
+      Serial.println(F("APDU length too long for packet buffer"));
     #endif
     return false;
   }
@@ -1098,14 +1098,14 @@

   if (!sendCommandCheckAck(pn532_packetbuffer,sendLength+2,1000)) {
     #ifdef PN532DEBUG
-      Serial.println("Could not send ADPU");
+      Serial.println(F("Could not send ADPU"));
     #endif
     return false;
   }

   if (!waitUntilReady(1000)) {
     #ifdef PN532DEBUG
-      Serial.println("Response never received for ADPU...");
+      Serial.println(F("Response never received for ADPU..."));
     #endif
     return false;
   }
@@ -1116,7 +1116,7 @@
     uint8_t length = pn532_packetbuffer[3];
     if (pn532_packetbuffer[4]!=(uint8_t)(~length+1)) {
       #ifdef PN532DEBUG
-        Serial.println("Length check invalid");
+        Serial.println(F("Length check invalid"));
         Serial.println(length,HEX);
         Serial.println((~length)+1,HEX);
       #endif
@@ -1125,7 +1125,7 @@
     if (pn532_packetbuffer[5]==PN532_PN532TOHOST && pn532_packetbuffer[6]==PN532_RESPONSE_INDATAEXCHANGE) {
       if ((pn532_packetbuffer[7] & 0x3f)!=0) {
         #ifdef PN532DEBUG
-          Serial.println("Status code indicates an error");
+          Serial.println(F("Status code indicates an error"));
         #endif
         return false;
       }
@@ -1144,13 +1144,13 @@
       return true;
     }
     else {
-      Serial.print("Don't know how to handle this command: ");
+      Serial.print(F("Don't know how to handle this command: "));
       Serial.println(pn532_packetbuffer[6],HEX);
       return false;
     }
   }
   else {
-    Serial.println("Preamble missing");
+    Serial.println(F("Preamble missing"));
     return false;
   }
 }
@@ -1167,12 +1167,12 @@
   pn532_packetbuffer[2] = 0;

   #ifdef PN532DEBUG
-    Serial.print("About to inList passive target");
+    Serial.print(F("About to inList passive target"));
   #endif

   if (!sendCommandCheckAck(pn532_packetbuffer,3,1000)) {
     #ifdef PN532DEBUG
-      Serial.println("Could not send inlist message");
+      Serial.println(F("Could not send inlist message"));
     #endif
     return false;
   }
@@ -1187,7 +1187,7 @@
     uint8_t length = pn532_packetbuffer[3];
     if (pn532_packetbuffer[4]!=(uint8_t)(~length+1)) {
       #ifdef PN532DEBUG
-        Serial.println("Length check invalid");
+        Serial.println(F("Length check invalid"));
         Serial.println(length,HEX);
         Serial.println((~length)+1,HEX);
       #endif
@@ -1196,28 +1196,28 @@
     if (pn532_packetbuffer[5]==PN532_PN532TOHOST && pn532_packetbuffer[6]==PN532_RESPONSE_INLISTPASSIVETARGET) {
       if (pn532_packetbuffer[7] != 1) {
         #ifdef PN532DEBUG
-        Serial.println("Unhandled number of targets inlisted");
+        Serial.println(F("Unhandled number of targets inlisted"));
         #endif
-        Serial.println("Number of tags inlisted:");
+        Serial.println(F("Number of tags inlisted:"));
         Serial.println(pn532_packetbuffer[7]);
         return false;
       }

       inListedTag = pn532_packetbuffer[8];
-      Serial.print("Tag number: ");
+      Serial.print(F("Tag number: "));
       Serial.println(inListedTag);

       return true;
     } else {
       #ifdef PN532DEBUG
-        Serial.print("Unexpected response to inlist passive host");
+        Serial.print(F("Unexpected response to inlist passive host"));
       #endif
       return false;
     }
   }
   else {
     #ifdef PN532DEBUG
-      Serial.println("Preamble missing");
+      Serial.println(F("Preamble missing"));
     #endif
     return false;
   }


create .cvmfscatalog also for hardlinks

create .cvmfscatalog also for hardlinks

--- cvmfs/sync_union_tarball.cc
+++ cvmfs/sync_union_tarball.cc
@@ -219,6 +219,10 @@
       to_hardlink.push_back(complete_path);
       hardlinks_[hardlink] = to_hardlink;
     }
+    if (filename == ".cvmfscatalog") {
+      // the file is created in the PostUpload phase
+      to_create_catalog_dirs_.insert(parent_path);
+    }
     read_archive_signal_->Wakeup();
     return;
   }


Show statusbar message on successful load/save.

--- qt/src/mainwindow.cpp
+++ qt/src/mainwindow.cpp
@@ -178,14 +178,21 @@
     std::string err;
     if (!filename.isEmpty() && !ui->centralwidget->universe.load(filename.toStdString(), err))
         QMessageBox::warning(NULL, tr("Error loading simulation!"), QString::fromStdString(err));
+    else
+        ui->statusbar->showMessage(("Loaded %1 planets from to \"" + filename + '"').arg(ui->centralwidget->universe.size()), 8000);
 }

 void MainWindow::on_actionAppend_Simulation_triggered() {
     QString filename = QFileDialog::getOpenFileName(this, tr("Append Simulation"), "", tr("Simulation files (*.xml);;All Files (*.*)"));

     std::string err;
+    /* So we can tell how many were added. */
+    auto previousSize = ui->centralwidget->universe.size();
+
     if (!filename.isEmpty() && !ui->centralwidget->universe.load(filename.toStdString(), err, false))
         QMessageBox::warning(NULL, tr("Error loading simulation!"), QString::fromStdString(err));
+    else
+        ui->statusbar->showMessage(("Loaded %1 planets from to \"" + filename + '"').arg(ui->centralwidget->universe.size() - previousSize), 8000);
 }

 bool MainWindow::on_actionSave_Simulation_triggered(){
@@ -195,8 +202,10 @@
         if (!filename.isEmpty()) {
             std::string err;

-            if (ui->centralwidget->universe.save(filename.toStdString(), err))
+            if (ui->centralwidget->universe.save(filename.toStdString(), err)) {
+                ui->statusbar->showMessage("Simulation saved to \"" + filename + '"', 8000);
                 return true;
+            }

             QMessageBox::warning(this, tr("Error Saving Simulation."), QString::fromStdString(err));
         }


bug fix chroma on filter

bug fix chroma on filter

--- plugin-opencv/native/src/main/native/NativeExample.cpp
+++ plugin-opencv/native/src/main/native/NativeExample.cpp
@@ -47,8 +47,8 @@
 	  {
 		  int i = x * channels;

-    // OpenCV: For HSV, Hue range is [0,179] mapped to [0,359], Saturation range is [0,255] and Value range is [0,255].
-		  int h = 2 * (unsigned char)rowaddr[i];
+    // OpenCV: For HSV, Hue range is [0,255] mapped to [0,359], Saturation range is [0,255] and Value range is [0,255].
+		  int h = (unsigned char)rowaddr[i] * 359 / 255;
 		  int s = (unsigned char)rowaddr[i+1];
 		  int v = (unsigned char)rowaddr[i+2];

@@ -60,6 +60,8 @@
         int distance = keyHue - h;
         if (distance<0)
           distance = -distance;
+        if (distance>180)
+          distance  = 360 - distance;

         if (distance>=range-2)
           s = s >>1;


more tests

more tests

--- go/apps/simpleexample/SimpleClientCpp/support_test.cc
+++ go/apps/simpleexample/SimpleClientCpp/support_test.cc
@@ -86,8 +86,106 @@
   return true;
 }

+EVP_PKEY* key_choice(string& key_type, int key_size) {
+  EVP_PKEY* key = nullptr;
+#if 0
+  string* key_bytes;
+  key = EVP_PKEY_new();
+  if (key == nullptr)
+    return nullptr;
+
+  if (key_type == "RSA") {
+    RSA* rsa_program_key = RSA_generate_key(key_size, 0x010001ULL, nullptr, nullptr);
+    if (rsa_program_key == nullptr) {
+      printf("key_choice: couldn't generate RSA program key.\n");
+      return nullptr;
+    }
+    program_key_type_ = "RSA";
+    EVP_PKEY_assign_RSA(key, rsa_program_key);
+    // Bytes for public key are the hash of the der encoding of it.
+    byte out[4096];
+    byte* ptr = out;
+    int n = i2d_RSA_PUBKEY(rsa_program_key, &ptr);
+    if (n <= 0) {
+      printf("key_choice: Can't i2d RSA public key\n");
+      return nullptr;
+    }
+    byte rsa_key_hash[32];
+    SHA256_CTX sha256;
+    SHA256_Init(&sha256);
+    SHA256_Update(&sha256, out, n);
+    SHA256_Final(rsa_key_hash, &sha256);
+    key_bytes = ByteToHexLeftToRight(32, rsa_key_hash);
+  } else if (key_type == "ECC") {
+    EC_KEY* ec_program_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
+    if (ec_program_key == nullptr) {
+      printf("key_choice: couldn't generate ECC program key.\n");
+      return nullptr;
+    }
+    if (1 != EC_KEY_generate_key(ec_program_key)) {
+      printf("key_choice: couldn't generate ECC program key(2).\n");
+      return nullptr;
+    }
+    program_key_type_ = "ECC";
+    EVP_PKEY_assign_EC_KEY(key, ec_program_key);
+    // Bytes for public key are the hash of the der encoding of it.
+    byte out[4096];
+    byte* ptr = out;
+    int n = i2d_EC_PUBKEY(ec_program_key, &ptr);
+    if (n <= 0) {
+      printf("key_choice: Can't i2d ECC public key\n");
+      return nullptr;
+    }
+    byte ec_key_hash[32];
+    SHA256_CTX sha256;
+    SHA256_Init(&sha256);
+    SHA256_Update(&sha256, out, n);
+    SHA256_Final(ec_key_hash, &sha256);
+    key_bytes = ByteToHexLeftToRight(32, ec_key_hash);
+  } else {
+    printf("unsupported key type.\n");
+    return nullptr;
+  }
+  // Print key bytes
+  printf("Bytes: ");
+  PrintBytes((int)key_bytes->size(), (byte*)key_bytes->data());
+  printf("\n");
+#endif
+  return key;
+}
+
+
+bool crypt_test() {
+#if 0
+  int n;
+  string key_type("RSA");
+  int key_size = 2048;
+  EVP_PKEY* key = key_choice(string& key_type, int key_size);
+  if (key == nullptr) {
+  }
+  int n = RSA_public_encrypt(int flen, unsigned char *from,
+    unsigned char *to, RSA *rsa, RSA_PKCS1_OAEP_PADDING);
+
+  n = RSA_private_decrypt(int flen, unsigned char *from,
+     unsigned char *to, RSA *rsa, RSA_PKCS1_OAEP_PADDING);
+
+  key_type = "ECC";
+  key_size = 256;
+  EVP_PKEY* key = key_choice(string& key_type, int key_size);
+  if (key == nullptr) {
+  }
+  n =  ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,
+                unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);
+  n = ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
+                     const ECDSA_SIG *sig, EC_KEY* eckey);
+#endif
+  return true;
+}
+
+
 TEST(ReadWriteTest, ReadWriteTest) { EXPECT_TRUE(readwritetest()); }
 TEST(cert_test, cert_test) { EXPECT_TRUE(cert_test()); }
+TEST(crypt_test, crypt_test) { EXPECT_TRUE(crypt_test()); }

 int main(int an, char** av) {
   ::testing::InitGoogleTest(&an, av);


- key event handling of the wx gui on win32 (wxMSW) fixed. Now the function   DEV_kbd_gen_scancode() is called instead of DEV_kbd_put_scancode(). This   change enables the support for different scancode sets. The win32 scancodes   are now converted to BX_KEY_* values (partially copied from gui/win32.cc)

--- gui/wx.cc
+++ gui/wx.cc
@@ -420,6 +420,106 @@
   BX_KEY_GRAVE
 };

+// copied from gui/win32.cc
+Bit32u
+wxMSW_to_bx_key[0x59] = {
+  /* 0x00 - 0x0f */
+  0,
+  BX_KEY_ESC,
+  BX_KEY_1,
+  BX_KEY_2,
+  BX_KEY_3,
+  BX_KEY_4,
+  BX_KEY_5,
+  BX_KEY_6,
+  BX_KEY_7,
+  BX_KEY_8,
+  BX_KEY_9,
+  BX_KEY_0,
+  BX_KEY_MINUS,
+  BX_KEY_EQUALS,
+  BX_KEY_BACKSPACE,
+  BX_KEY_TAB,
+  /* 0x10 - 0x1f */
+  BX_KEY_Q,
+  BX_KEY_W,
+  BX_KEY_E,
+  BX_KEY_R,
+  BX_KEY_T,
+  BX_KEY_Y,
+  BX_KEY_U,
+  BX_KEY_I,
+  BX_KEY_O,
+  BX_KEY_P,
+  BX_KEY_LEFT_BRACKET,
+  BX_KEY_RIGHT_BRACKET,
+  BX_KEY_ENTER,
+  BX_KEY_CTRL_L,
+  BX_KEY_A,
+  BX_KEY_S,
+  /* 0x20 - 0x2f */
+  BX_KEY_D,
+  BX_KEY_F,
+  BX_KEY_G,
+  BX_KEY_H,
+  BX_KEY_J,
+  BX_KEY_K,
+  BX_KEY_L,
+  BX_KEY_SEMICOLON,
+  BX_KEY_SINGLE_QUOTE,
+  BX_KEY_GRAVE,
+  BX_KEY_SHIFT_L,
+  BX_KEY_BACKSLASH,
+  BX_KEY_Z,
+  BX_KEY_X,
+  BX_KEY_C,
+  BX_KEY_V,
+  /* 0x30 - 0x3f */
+  BX_KEY_B,
+  BX_KEY_N,
+  BX_KEY_M,
+  BX_KEY_COMMA,
+  BX_KEY_PERIOD,
+  BX_KEY_SLASH,
+  BX_KEY_SHIFT_R,
+  BX_KEY_KP_MULTIPLY,
+  BX_KEY_ALT_L,
+  BX_KEY_SPACE,
+  BX_KEY_CAPS_LOCK,
+  BX_KEY_F1,
+  BX_KEY_F2,
+  BX_KEY_F3,
+  BX_KEY_F4,
+  BX_KEY_F5,
+  /* 0x40 - 0x4f */
+  BX_KEY_F6,
+  BX_KEY_F7,
+  BX_KEY_F8,
+  BX_KEY_F9,
+  BX_KEY_F10,
+  BX_KEY_PAUSE,
+  BX_KEY_SCRL_LOCK,
+  BX_KEY_KP_HOME,
+  BX_KEY_KP_UP,
+  BX_KEY_KP_PAGE_UP,
+  BX_KEY_KP_SUBTRACT,
+  BX_KEY_KP_LEFT,
+  BX_KEY_KP_5,
+  BX_KEY_KP_RIGHT,
+  BX_KEY_KP_ADD,
+  BX_KEY_KP_END,
+  /* 0x50 - 0x58 */
+  BX_KEY_KP_DOWN,
+  BX_KEY_KP_PAGE_DOWN,
+  BX_KEY_KP_INSERT,
+  BX_KEY_KP_DELETE,
+  0,
+  0,
+  BX_KEY_LEFT_BACKSLASH,
+  BX_KEY_F11,
+  BX_KEY_F12
+};
+
 #if defined (wxHAS_RAW_KEY_CODES) && defined(__WXMSW__)
 // get windows specific definitions. At present the only thing needed
 // is the definition of HIWORD.
@@ -437,8 +537,6 @@
   Bit32u lParam = wxev.m_rawFlags;
   Bit32u key = HIWORD (lParam) & 0x01FF;
   bxev.bx_key = 0x0000;
-  // Swap the scancodes of "numlock" and "pause"
-  if ((key & 0xff)==0x45) key ^= 0x100;
   if (key & 0x0100) {
     // Its an extended key
     bxev.bx_key = 0xE000;
@@ -846,26 +944,75 @@
       case BX_ASYNC_EVT_KEY:
         bx_key = event_queue[i].u.key.bx_key;
         if (event_queue[i].u.key.raw_scancode) {
-          // event contains raw scancodes: use put_scancode
-          Bit8u scancode;
+          // event contains raw scancodes: convert to BX_KEY values first
+          bx_bool released = ((bx_key & 0x80) > 0);
           if (bx_key & 0xFF00) { // for extended keys
-            // This makes the "AltGr" key on European keyboards work
-            if (bx_key==0xE038) {
-              scancode = 0x9d; // left control key released
-              DEV_kbd_put_scancode (&scancode, 1);
+            switch (bx_key & 0x7f) {
+              case 0x1C:
+                bx_key = BX_KEY_KP_ENTER;
+                break;
+              case 0x1D:
+                bx_key = BX_KEY_CTRL_R;
+                break;
+              case 0x35:
+                bx_key = BX_KEY_KP_DIVIDE;
+                break;
+              case 0x38:
+                // This makes the "AltGr" key on European keyboards work
+                DEV_kbd_gen_scancode(BX_KEY_CTRL_L | BX_KEY_RELEASED);
+                bx_key = BX_KEY_ALT_R;
+                break;
+              case 0x45:
+                bx_key = BX_KEY_NUM_LOCK;
+                break;
+              case 0x47:
+                bx_key = BX_KEY_HOME;
+                break;
+              case 0x48:
+                bx_key = BX_KEY_UP;
+                break;
+              case 0x49:
+                bx_key = BX_KEY_PAGE_UP;
+                break;
+              case 0x4B:
+                bx_key = BX_KEY_LEFT;
+                break;
+              case 0x4D:
+                bx_key = BX_KEY_RIGHT;
+                break;
+              case 0x4F:
+                bx_key = BX_KEY_END;
+                break;
+              case 0x50:
+                bx_key = BX_KEY_DOWN;
+                break;
+              case 0x51:
+                bx_key = BX_KEY_PAGE_DOWN;
+                break;
+              case 0x52:
+                bx_key = BX_KEY_INSERT;
+                break;
+              case 0x53:
+                bx_key = BX_KEY_DELETE;
+                break;
+              case 0x5B:
+                bx_key = BX_KEY_WIN_L;
+                break;
+              case 0x5C:
+                bx_key = BX_KEY_WIN_R;
+                break;
+              case 0x5D:
+                bx_key = BX_KEY_MENU;
+                break;
             }
-            scancode = 0xFF & (bx_key>>8);
-            IFDBG_KEY (wxLogDebug (wxT ("sending raw scancode 0x%02x (extended key))", (int)scancode)));
-            DEV_kbd_put_scancode(&scancode, 1);
+          } else {
+            bx_key = wxMSW_to_bx_key[bx_key & 0x7f];
           }
-          scancode = 0xFF & bx_key;
-          IFDBG_KEY (wxLogDebug (wxT ("sending raw scancode 0x%02x", (int))scancode));
-          DEV_kbd_put_scancode(&scancode, 1);
-        } else {
-          // event contains BX_KEY_* codes: use gen_scancode
-          IFDBG_KEY (wxLogDebug (wxT ("sending key event 0x%02x", bx_key)));
-          DEV_kbd_gen_scancode(bx_key);
+          if (released) bx_key |= BX_KEY_RELEASED;
         }
+        // event contains BX_KEY_* codes: use gen_scancode
+        IFDBG_KEY (wxLogDebug (wxT ("sending key event 0x%02x", bx_key)));
+        DEV_kbd_gen_scancode(bx_key);
         break;
       case BX_ASYNC_EVT_MOUSE:
         DEV_mouse_motion(


Another minor fix :-D

Another minor fix :-D

--- ghost++/ghost/gameplayer.cpp
+++ ghost++/ghost/gameplayer.cpp
@@ -232,7 +232,7 @@
 m_LastMapPartSent( 0 ), m_LastMapPartAcked( 0 ), m_StartedDownloadingTicks( 0 ), m_FinishedLoadingTicks( 0 ), m_StartedLaggingTicks( 0 ), m_StatsSentTime( 0 ), m_StatsDotASentTime( 0 ), m_LastGProxyWaitNoticeSentTime( 0 ), m_Score( -100000.0 ), m_WinPerc( 0.0 ), m_LeavePerc( 0.0 ), m_Games( 0 ),
 m_LoggedIn( false ), m_Spoofed( false ), m_PasswordProt( 0 ), m_Registered( false ), m_Reserved( nReserved ), m_WhoisShouldBeSent( false ), m_WhoisSent( false ), m_DownloadAllowed( false ), m_DownloadStarted( false ), m_DownloadFinished( false ), m_FinishedLoading( false ), m_Lagging( false ),
 m_DropVote( false ), m_KickVote( false ), m_Muted( false ), m_LeftMessageSent( false ), m_GProxy( false ), m_GProxyDisconnectNoticeSent( false ), m_GProxyReconnectKey( rand( ) ), m_LastGProxyAckTime( 0 ), m_Autoban( false ), m_Locked( false ), m_ForfeitVote( false ), m_DrawVote( false ), m_TimeActive( 0 ), m_UsedPause( false ), m_PauseTried( 0 ), m_CLetter( "??" ), m_Country( "unknown" ), m_Cookies( 0 ), m_Count( 0 ), m_Silence( false ), m_ForcedGproxy( false ), m_HasLeft( false ),
-m_AFKMarked( false ), m_SafeDrop( false ), m_FeedLevel( 0 ), m_VKTimes( 0 ), m_HighPingTimes( 0 ), m_AnnounceTime( GetTime( ) ), m_Level( 0 ), m_LevelName( "unknown" ), m_StartVoted( false ), m_GlobalChatMuted( false ), m_InsultM)( "" )
+m_AFKMarked( false ), m_SafeDrop( false ), m_FeedLevel( 0 ), m_VKTimes( 0 ), m_HighPingTimes( 0 ), m_AnnounceTime( GetTime( ) ), m_Level( 0 ), m_LevelName( "unknown" ), m_StartVoted( false ), m_GlobalChatMuted( false ), m_InsultM( "" )
 {
 	// todotodo: properly copy queued packets to the new player, this just discards them
 	// this isn't a big problem because official Warcraft III clients don't send any packets after the join request until they receive a response


#185 fixed (wildcards in the file search query)

--- file-commander-core/src/filesearchengine/cfilesearchengine.cpp
+++ file-commander-core/src/filesearchengine/cfilesearchengine.cpp
@@ -53,8 +53,14 @@
 		QRegExp queryRegExp;
 		if (nameQueryHasWildcards)
 		{
+			QString adjustedQuery = what;
+			if (!what.startsWith('*'))
+				adjustedQuery.prepend('*');
+			if (!what.endsWith('*'))
+				adjustedQuery.append('*');
+
 			queryRegExp.setPatternSyntax(QRegExp::Wildcard);
-			queryRegExp.setPattern(what);
+			queryRegExp.setPattern(adjustedQuery);
 			queryRegExp.setCaseSensitivity(subjectCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
 		}


Delay between functions authorize new node and send FRC, increased to 1000 ms

--- examples/Autonetwork/Autonetwork/autonetwork_core.cpp
+++ examples/Autonetwork/Autonetwork/autonetwork_core.cpp
@@ -1011,7 +1011,7 @@

         // Any new node ?
         if(Prebonding.NewNode){
-          delayMS(500);
+          delayMS(1000);
             // Send FRC command Prebonding to check the new nodes
             notifyMainApp(EVT_FRC_CHECK_NEW_NODES, EVT_WITHOUT_PARAM);
             MyDpaPacket.DpaMessage.Request.PData[0] = 0;       // Command 0 - Prebonding


clang-tidy: modernize-deprecated-headers

--- googletest/src/gtest_main.cc
+++ googletest/src/gtest_main.cc
@@ -27,7 +27,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-#include <stdio.h>
+#include <cstdio>
 #include "gtest/gtest.h"

 #ifdef ARDUINO


Remove some now-duplicated data

Remove some now-duplicated data


Implemented reverse search history

Implemented reverse search history

--- linenoise.cpp
+++ linenoise.cpp
@@ -65,10 +65,13 @@
     size_t len;         /* Current edited line length. */
     size_t cols;        /* Number of columns in terminal. */

+    int history_search; /* 1 if we are searching history */
     int history_index;
     int edit_done;      /* set non-zero when done with editing line */
     int ret_code;	/* return code to linenoise() */
 };
+
+static void lnEditHistorySearchPrev(linenoiseState *ls);

 /* Debugging macro. */
 #if 1
@@ -251,6 +254,25 @@
     fflush(stderr);
 }

+static void
+refreshHistorySearch (struct linenoiseState *ls)
+{
+    char line[LN_MAX_LINE];
+    string_fmt_c ab;
+
+    unsigned hi = history.size() - ls->history_index  - 1;
+
+    snprintf(line, sizeof(line),
+	     "(history-i-search [%d]) '%s': %s",
+	     ls->history_index, ls->buf, history[hi].c_str());
+
+    ab = CSI "0G";
+    ab += line;
+    ab += CSI "0K";  /* Erase Right */
+
+    write(ls->ofd, ab.c_str(), ab.size());
+}
+
 /* Single line low level line refresh.
  *
  * Rewrite the currently edited line accordingly to the buffer content,
@@ -258,6 +280,10 @@
 static void
 refreshSingleLine (struct linenoiseState *ls)
 {
+    if (ls->history_search) {
+	refreshHistorySearch(ls);
+	return;
+    }
     size_t plen = strlen(ls->prompt);
     int fd = ls->ofd;
     char *buf = ls->buf;
@@ -444,19 +470,20 @@
             ls->pos++;
             ls->len++;
             ls->buf[ls->len] = '\0';
-            if (ls->plen+ls->len < ls->cols) {
-                /* Avoid a full update of the line in the
-                 * trivial case. */
-                if (write(ls->ofd, &c, 1) == -1) return -1;
-            }
         } else {
-            memmove(ls->buf+ls->pos + 1, ls->buf + ls->pos, ls->len-ls->pos);
+            memmove(ls->buf + ls->pos + 1, ls->buf + ls->pos, ls->len - ls->pos);
             ls->buf[ls->pos] = c;
             ls->len++;
             ls->pos++;
             ls->buf[ls->len] = '\0';
         }
     }
+
+    if (ls->history_search) {
+	ls->history_index = 0;
+	lnEditHistorySearchPrev(ls);
+    }
+
     refreshLine(ls);
     return 0;
 }
@@ -564,6 +591,31 @@
     editHistoryNext(ls, -1);
 }

+static void
+lnEditHistorySearchPrev (linenoiseState *ls)
+{
+    int history_len = history.size();
+    int i;
+
+    if (strlen(ls->buf) == 0) {
+	ls->history_search = 1;
+	return;
+    }
+
+    /* search backwards through history starting from history_index */
+    for (i = ls->history_index + 1; i < history_len && i >= 0; i++) {
+	if (history[history_len - i - 1].find(ls->buf) != string::npos)
+	    break;
+    }
+    if (i < 0 || i >= history_len) {
+	lnBeep();
+	return;
+    }
+
+    ls->history_index = i;
+    ls->history_search = 1;
+}
+
 /* Delete the character at the right of the cursor without altering the cursor
  * position. Basically this is what happens with the "Delete" keyboard key. */
 void
@@ -584,6 +636,10 @@
         ls->pos--;
         ls->len--;
         ls->buf[ls->len] = '\0';
+    }
+    if (ls->history_search) {
+	ls->history_index = 0;
+	lnEditHistorySearchPrev(ls);
     }
 }

@@ -674,12 +730,29 @@
     ls->ret_code = ls->len;
 }

+static void
+lnEditSetHistoryIndex (linenoiseState *ls)
+{
+    if (!ls->history_search) return;
+
+    unsigned hi = history.size() - ls->history_index  - 1;
+
+    snprintf(ls->buf, ls->buflen, "%s", history[hi].c_str());
+    ls->pos = strlen(ls->buf);
+    ls->len = ls->pos;
+
+    ls->history_search = 0;
+    ls->history_index = 0;
+}
+
 typedef void (ln_func_t)(linenoiseState *);

 static cmd_func
-ln_cmd (linenoiseState *ls, ln_func_t func)
-{
-    return [ls, func] (int ch UNUSED) {
+ln_cmd (linenoiseState *ls, ln_func_t func, int reset_history_search = 1)
+{
+    return [ls, func, reset_history_search] (int ch UNUSED) {
+	if (reset_history_search) lnEditSetHistoryIndex(ls);
+
 	func(ls);
 	refreshLine(ls);
 	return 0;
@@ -725,32 +798,33 @@

     if (write(l.ofd, prompt, l.plen) == -1) return -1;

-    ln_add_key_handler("?", 	ln_cmd(ls, helpLine));
-    ln_add_key_handler(S_BSPACE,    ln_cmd(ls, lnEditBackspace));
-    ln_add_key_handler(S_TAB, 	ln_cmd(ls, completeLine));
+    ln_add_key_handler("?",	    ln_cmd(ls, helpLine));
+    ln_add_key_handler(S_BSPACE,    ln_cmd(ls, lnEditBackspace, 0));
+    ln_add_key_handler(S_TAB,	    ln_cmd(ls, completeLine));
     ln_add_key_handler(S_CTRL('A'), ln_cmd(ls, lnEditMoveHome));
     ln_add_key_handler(S_CTRL('B'), ln_cmd(ls, lnEditMoveLeft));
     ln_add_key_handler(S_CTRL('C'), ln_cmd(ls, lnEditControlC));
     ln_add_key_handler(S_CTRL('D'), ln_cmd(ls, lnEditControlD));
     ln_add_key_handler(S_CTRL('E'), ln_cmd(ls, lnEditMoveEnd));
     ln_add_key_handler(S_CTRL('F'), ln_cmd(ls, lnEditMoveRight));
-    ln_add_key_handler(S_CTRL('H'), ln_cmd(ls, lnEditBackspace));
+    ln_add_key_handler(S_CTRL('H'), ln_cmd(ls, lnEditBackspace, 0));
     ln_add_key_handler(S_CTRL('K'), ln_cmd(ls, lnEditDeleteToEOL));
     ln_add_key_handler(S_CTRL('L'), ln_cmd(ls, lnClearScreen));
     ln_add_key_handler(S_CTRL('M'), ln_cmd(ls, lnEditEnter));
     ln_add_key_handler(S_CTRL('N'), ln_cmd(ls, lnEditHistoryNext));
     ln_add_key_handler(S_CTRL('P'), ln_cmd(ls, lnEditHistoryPrev));
+    ln_add_key_handler(S_CTRL('R'), ln_cmd(ls, lnEditHistorySearchPrev, 0));
     ln_add_key_handler(S_CTRL('T'), ln_cmd(ls, lnEditSwap));
     ln_add_key_handler(S_CTRL('U'), ln_cmd(ls, lnEditDeleteLine));
     ln_add_key_handler(S_CTRL('W'), ln_cmd(ls, lnEditDeletePrevWord));

     ln_add_key_handler(S_ESC S_BRACKET "3~", ln_cmd(ls, lnEditDelete));
-    ln_add_key_handler(S_ESC S_BRACKET "A", ln_cmd(ls, lnEditHistoryPrev));
-    ln_add_key_handler(S_ESC S_BRACKET "B", ln_cmd(ls, lnEditHistoryNext));
-    ln_add_key_handler(S_ESC S_BRACKET "C", ln_cmd(ls, lnEditMoveRight));
-    ln_add_key_handler(S_ESC S_BRACKET "D", ln_cmd(ls, lnEditMoveLeft));
-    ln_add_key_handler(S_ESC S_BRACKET "F", ln_cmd(ls, lnEditMoveEnd));
-    ln_add_key_handler(S_ESC S_BRACKET "H", ln_cmd(ls, lnEditMoveHome));
+    ln_add_key_handler(S_ESC S_BRACKET "A",  ln_cmd(ls, lnEditHistoryPrev));
+    ln_add_key_handler(S_ESC S_BRACKET "B",  ln_cmd(ls, lnEditHistoryNext));
+    ln_add_key_handler(S_ESC S_BRACKET "C",  ln_cmd(ls, lnEditMoveRight));
+    ln_add_key_handler(S_ESC S_BRACKET "D",  ln_cmd(ls, lnEditMoveLeft));
+    ln_add_key_handler(S_ESC S_BRACKET "F",  ln_cmd(ls, lnEditMoveEnd));
+    ln_add_key_handler(S_ESC S_BRACKET "H",  ln_cmd(ls, lnEditMoveHome));

     ln_add_key_handler(S_ESC S_ESC S_BRACKET "C", ln_cmd(ls, lnEditMoveRightWord));
     ln_add_key_handler(S_ESC S_ESC S_BRACKET "D", ln_cmd(ls, lnEditMoveLeftWord));


MB-25723: Force reading the next packet for SSL connections

I've seen cases where the SSL tests would hang because we've
successfully completed a command, but the next command was
stuck inside our input buffers. We would then enter the
waiting state, but as the client was done sending the command
we don't get a read notification on the socket.

To work around that problem let's try to fetch the next command
header from the input stream (which would cause those buffers
to be drained) for SSL connections. If the packet isn't
available it'll enter the conn_waiting state.

For plain connections we don't have data spooled up in this
case so we don't need the extra "recv" call.

Change-Id: I6cbdf6ad254b6096975d5c14be40fd2a2ecf842b
Reviewed-on: http://review.couchbase.org/82394
Tested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Dave Rigby <a09264da4832c7ff1d3bf1608a19f4b870f93750@couchbase.com>

--- daemon/statemachine_mcbp.cc
+++ daemon/statemachine_mcbp.cc
@@ -116,6 +116,8 @@
     c->shrinkBuffers();
     if (c->read.bytes >= sizeof(c->binary_header)) {
         c->setState(conn_parse_cmd);
+    } else if (c->isSslEnabled()) {
+        c->setState(conn_read_packet_header);
     } else {
         c->setState(conn_waiting);
     }


Close PCM after timeout.

Close PCM after timeout.

--- src/player.cpp
+++ src/player.cpp
@@ -192,6 +192,7 @@
                     if (bEmpty) {
                         if (cRetry > c_cMaxRetries) {
                             m_pLog->info("Dropping stream %llu", m_cStreamId);
+                            ALSA::close(m_pPcm);
                             break;
                         }


Add *.GOT extension

Add *.GOT extension

Relates to
https://github.com/adplug/adplug/commit/7c0cd910265ae172c8a9bf0fcd9fb1b8b83ba7ba

--- src/plugin.cpp
+++ src/plugin.cpp
@@ -238,6 +238,7 @@
   filetypes.add("dmo", "TwinTeam Modules (*.DMO)");
   filetypes.add("dro", "DOSBox Raw OPL v1.0 and v2.0 Files (*.DRO)");
   filetypes.add("dtm", "DeFy Adlib Tracker Modules (*.DTM)");
+  filetypes.add("got", "God of Thunder Music (*.GOT)");
   filetypes.add("hsc", "HSC-Tracker Modules (*.HSC)");
   filetypes.add("hsp", "Packed HSC-Tracker Modules (*.HSP)");
   filetypes.add("imf;wlf;adlib", "Apogee IMF Files (*.IMF;*.WLF;*.ADLIB)");


*** empty log message ***

*** empty log message ***

git-svn-id: 6df6a9299d9fe08e1e18eb0c01ae615f7df02338@186 a83610d8-ad2a-0410-a6ab-fc0612d85776

--- src/policy.cpp
+++ src/policy.cpp
@@ -70,36 +70,14 @@
 		free_upload_amount = 4 * 16 * 1024
 	};

-
 	using namespace libtorrent;

-	template<class It1, class It2>
-	bool has_intersection(It1 start1, It1 end1, It2 start2, It2 end2)
-	{
-		return std::find_first_of(start1,end1,start2,end2) != end1;
-	}
-
-	piece_block find_first_common(const std::deque<piece_block>& queue,
-		const std::vector<piece_block>& busy)
-	{
-		std::deque<piece_block>::const_reverse_iterator common_block =
-			std::find_first_of(queue.rbegin(),queue.rend(),busy.begin(),busy.end());
-
-		if(common_block!=queue.rend())
-			return *common_block;
-		assert(false);
-		return piece_block(-1, -1);
-	}
-
-	namespace
-	{
-		float to_seconds(const boost::posix_time::time_duration& d)
-		{
-			return d.hours() * 60.f * 60.f
-				+ d.minutes() * 60.f
-				+ d.seconds()
-				+ d.fractional_seconds() / 1000.f;
-		}
+	float to_seconds(const boost::posix_time::time_duration& d)
+	{
+		return d.hours() * 60.f * 60.f
+			+ d.minutes() * 60.f
+			+ d.seconds()
+			+ d.fractional_seconds() / 1000.f;
 	}

 	void request_a_block(torrent& t, peer_connection& c)
@@ -171,7 +149,7 @@
 		// from this peer instead)

 		peer_connection* peer = 0;
-		float down_speed = -1.f;
+		float down_speed = std::numeric_limits<float>::max();
 		// find the peer with the lowest download
 		// speed that also has a piece that this
 		// peer could send us
@@ -180,14 +158,17 @@
 			++i)
 		{
 			const std::deque<piece_block>& queue = i->second->download_queue();
-			if (i->second->statistics().down_peak() > down_speed
-				&& has_intersection(busy_pieces.begin(),
-					busy_pieces.end(),
-					queue.begin(),
-					queue.end()))
+			const float weight = i->second->statistics().down_peak()
+				/ i->second->download_queue().size();
+			if (weight < down_speed
+				&& std::find_first_of(
+					busy_pieces.begin()
+					, busy_pieces.end()
+					, queue.begin()
+					, queue.end()) != busy_pieces.end())
 			{
 				peer = i->second;
-				down_speed = peer->statistics().down_peak();
+				down_speed = weight;
 			}
 		}

@@ -195,10 +176,21 @@

 		// this peer doesn't have a faster connection than the
 		// slowest peer. Don't take over any blocks
-		if (c.statistics().down_peak() <= down_speed) return;
+		// TODO: is this correct? shouldn't it take over a piece
+		// anyway?
+		if (c.statistics().down_peak() / c.download_queue().size() <= down_speed) return;

 		// find a suitable block to take over from this peer
-		piece_block block = find_first_common(peer->download_queue(), busy_pieces);
+
+		std::deque<piece_block>::const_reverse_iterator common_block =
+			std::find_first_of(
+				peer->download_queue().rbegin()
+				, peer->download_queue().rend()
+				, busy_pieces.begin()
+				, busy_pieces.end());
+
+		assert(common_block != peer->download_queue().rend());
+		piece_block block = *common_block;
 		peer->send_cancel(block);
 		c.send_request(block);


fix issue of adding duplicate incoming connections indefinitely to peer list when allow_multiple_connections_per_ip is enabled

git-svn-id: 6ed3528c1be4534134272ad6dd050eeaa1f628d3@5534 f43f7eb3-cfe1-5f9d-1b5f-e45aa6702bda

--- src/policy.cpp
+++ src/policy.cpp
@@ -1367,6 +1367,17 @@
 		// to still exist when we get back there, to assign the new
 		// peer connection pointer to it. The peer list must
 		// be left intact.
+
+		// if we allow multiple connections per IP, and this peer
+		// was incoming and it never advertised its listen
+		// port, we don't really know which peer it was. In order
+		// to avoid adding one entry for every single connection
+		// the peer makes to us, don't save this entry
+		if (m_torrent->settings().allow_multiple_connections_per_ip
+			&& !p->connectable)
+		{
+			erase_peer(p);
+		}
 	}

 	void policy::peer_is_interesting(peer_connection& c)


fix asserts in policy

fix asserts in policy

git-svn-id: 51f496e7cf1b55ee487494d18ee2d308bae7fe77@8058 f43f7eb3-cfe1-5f9d-1b5f-e45aa6702bda

--- src/policy.cpp
+++ src/policy.cpp
@@ -829,7 +829,7 @@
 		else
 		{
 			std::pair<iterator, iterator> range = find_peers(p->address());
-			TORRENT_ASSERT(range.second - range.first == 1);
+			TORRENT_ASSERT(std::distance(range.first, range.second) == 1);
 		}
 #endif

@@ -1386,7 +1386,7 @@
 			if (!m_torrent->settings().get_bool(settings_pack::allow_multiple_connections_per_ip))
 			{
 				std::pair<const_iterator, const_iterator> range = find_peers(p.address());
-				TORRENT_ASSERT(range.second - range.first == 1);
+				TORRENT_ASSERT(std::distance(range.first, range.second) == 1);
 			}
 			else
 			{


fixed another policy bug

fixed another policy bug

git-svn-id: 6ed3528c1be4534134272ad6dd050eeaa1f628d3@1632 f43f7eb3-cfe1-5f9d-1b5f-e45aa6702bda

--- src/policy.cpp
+++ src/policy.cpp
@@ -971,8 +971,7 @@
 			assert(c.remote() == c.get_socket()->remote_endpoint());

 			peer p(c.remote(), peer::not_connectable, 0);
-			m_peers.insert(std::make_pair(c.remote().address(), p));
-			i = boost::prior(m_peers.end());
+			i = m_peers.insert(std::make_pair(c.remote().address(), p));
 		}

 		assert(m_torrent->connection_for(c.remote()) == &c);


delphes2lcio: replace GetEntriesFast w/ GetEntries

--- examples/cpp/delphes2lcio/src/DelphesLCIOConverter.cc
+++ examples/cpp/delphes2lcio/src/DelphesLCIOConverter.cc
@@ -121,7 +121,7 @@
 void DelphesLCIOConverter::convertTree2LCIO( TTree *tree , lcio::LCEventImpl* evt){

-  //int nEntry =  tree->GetEntriesFast() ;
+  //int nEntry =  tree->GetEntries() ;

   static bool first_event = true ;

@@ -132,7 +132,7 @@
       TBranch *br = dynamic_cast<TBranch*>(tree->GetListOfBranches()->At(i));
       if( !strcmp(br->GetClassName(),"TClonesArray") )
 	std::cout << " *************** branch \"" << br->GetName() << " --- " << br->GetClassName()
-		  << " - " <<   (*(TClonesArray**) br->GetAddress())->GetEntriesFast()
+		  << " - " <<   (*(TClonesArray**) br->GetAddress())->GetEntries()
 		  << std::endl;
     }

@@ -235,7 +235,7 @@

     TClonesArray* col = *(TClonesArray**) gpB->GetAddress()  ;

-    int ngp = col->GetEntriesFast();
+    int ngp = col->GetEntries();

     for(int j = 0; j < ngp ; ++j){
       GenParticle* p = (GenParticle*) col->At(j);
@@ -281,7 +281,7 @@
   if( trB != nullptr ){

     TClonesArray* col = *(TClonesArray**) trB->GetAddress()  ;
-    int nnh = col->GetEntriesFast();
+    int nnh = col->GetEntries();

     for(int j = 0; j < nnh ; ++j){

@@ -354,7 +354,7 @@
   if( nhB != nullptr ){

     TClonesArray* col = *(TClonesArray**) nhB->GetAddress()  ;
-    int nnh = col->GetEntriesFast();
+    int nnh = col->GetEntries();

     for(int j = 0; j < nnh ; ++j){

@@ -409,7 +409,7 @@
   if( efphB != nullptr ){

     TClonesArray* col = *(TClonesArray**) efphB->GetAddress()  ;
-    int nnh = col->GetEntriesFast();
+    int nnh = col->GetEntries();

     for(int j = 0; j < nnh ; ++j){

@@ -702,7 +702,7 @@
 						   int pdg) {
   bool success = true ;

-  int n = tca->GetEntriesFast();
+  int n = tca->GetEntries();

   for(int j = 0; j < n ; ++j){

@@ -751,7 +751,7 @@
   int jetParamID = jetpidH.addAlgorithm( "JetParameters" , {"Flavor","FlavorAlgo","FlavorPhys","BTag",
 							    "BTagAlgo","BTagPhys",
 							    "TauTag","Charge","EhadOverEem"} ) ;
-  int n = tca->GetEntriesFast();
+  int n = tca->GetEntries();

   for(int j = 0; j < n ; ++j){

@@ -769,7 +769,7 @@

     col->addElement( jet ) ;

-    int nc = jd->Constituents.GetEntriesFast() ;
+    int nc = jd->Constituents.GetEntries() ;

     std::vector<lcio::ReconstructedParticle*> jetPFOs;

@@ -866,7 +866,7 @@
   int trackParamID = pfopidH.addAlgorithm( "TrackParameters" , {"L","PT","D0","DZ","Phi","CtgTheta","ErrorPT","ErrorD0",
 								"ErrorDZ","ErrorPhi","ErrorCtgTheta"} ) ;

-  int nnh = tca->GetEntriesFast();
+  int nnh = tca->GetEntries();

   for(int j = 0; j < nnh ; ++j){
     Track* trk = static_cast<Track*> (tca->At(j));
@@ -914,7 +914,7 @@
   lcio::PIDHandler pfopidH( pfos );
   int showerParamID = pfopidH.addAlgorithm( "ShowerParameters" , {"emFraction","hadFraction"} ) ;

-  int nnh = tca->GetEntriesFast();
+  int nnh = tca->GetEntries();

   for(int j = 0; j < nnh ; ++j){


Add OIDs for SHA-224, SHA-256, SHA-384, SHA-512, and DSA with SHA-224 and SHA-256 (from draft-ietf-pkix-sha2-dsa-ecdsa-01)


Dummy whitespace change to force a build.

TEST=none
BUG=none

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

--- gpu/gpu_plugin/gpu_plugin.cc
+++ gpu/gpu_plugin/gpu_plugin.cc
@@ -50,7 +50,8 @@
 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) {
   return NPERR_NO_ERROR;
 }
-}
+
+}  // namespace

 NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* funcs) {
   funcs->newp = NPP_New;


Added warning in case polycones have consecutive identical sections (same z, rmin, rmax)

--- geom/geom/src/TGeoPcon.cxx
+++ geom/geom/src/TGeoPcon.cxx
@@ -282,7 +282,14 @@
 void TGeoPcon::ComputeBBox()
 {
    for (Int_t isec=0; isec<fNz-1; isec++) {
-      if (TMath::Abs(fZ[isec]-fZ[isec+1]) < TGeoShape::Tolerance()) fZ[isec+1]=fZ[isec];
+      if (TMath::Abs(fZ[isec]-fZ[isec+1]) < TGeoShape::Tolerance()) {
+         fZ[isec+1]=fZ[isec];
+         if (IsSameWithinTolerance(fRmin[isec], fRmin[isec+1]) &&
+             IsSameWithinTolerance(fRmax[isec], fRmax[isec+1])) {
+            InspectShape();
+            Error("ComputeBBox", "Duplicated section %d/%d for shape %s", isec, isec+1, GetName());
+         }
+      }
       if (fZ[isec]>fZ[isec+1]) {
          InspectShape();
          Fatal("ComputeBBox", "Wrong section order");


Added {} to constructor to compile on Ubuntu.

--- src/posixmq.cc
+++ src/posixmq.cc
@@ -35,7 +35,7 @@
     bool canwrite;

     PosixMQ() : mqpollhandle(NULL), mqdes(MQDES_INVALID), mqname(NULL),
-                canread(false), canwrite(false);
+                canread(false), canwrite(false) {};

     ~PosixMQ() {
       if (mqdes != MQDES_INVALID) {


remove POSITION_LOCK flag

remove POSITION_LOCK flag

--- glfw3_app/image/img_main.cpp
+++ glfw3_app/image/img_main.cpp
@@ -81,6 +81,7 @@
 			image_->set_state(widget::state::CLIP_PARENTS);
 			image_->set_state(widget::state::RESIZE_ROOT);
 			image_->set_state(widget::state::MOVE_ROOT, false);
+			image_->set_state(widget::state::POSITION_LOCK, false);
 		}

 		{ // 機能ツールパレット


Fixed scale on brush to 0-10.0.

Fixed scale on brush to 0-10.0.

--- src/Editor/Editor.cpp
+++ src/Editor/Editor.cpp
@@ -601,7 +601,7 @@
         ImGui::BeginPopupContextWindow("Paint Brush Tool");
         ImGui::Indent();
         ImGui::SliderFloat("Spawn rate.", paintSpawnRate, 0.02f, 1.0f);
-        ImGui::SliderFloat("Object scale.", paintObjScale, 1.0f, 100.0f);
+        ImGui::SliderFloat("Object scale.", paintObjScale, 0.0f, 10.0f);
         ImGui::SliderInt("Scale randomness", paintScaleRandomness, 1, 10);
         ImGui::Checkbox("Spread randomly", &spreadRand);


trigger action can contain queries and updates in any order

darcs-hash:20070904073713-ac417-0774ede5296f53c22552d97539e9866bf872e783.gz

--- kernel/tr/triggers/triggers_data.cpp
+++ kernel/tr/triggers/triggers_data.cpp
@@ -252,7 +252,7 @@
 	        qep_parameters = &(bta.parameters);
             while(trac!=NULL)
         	{
-				if(strstr(trac->statement, "query") == NULL)
+				if(strstr(trac->statement, "query") != NULL)
 				{
 					bta.action_qep_subtree = NULL;
 					qep_tree = bta.action_qep_tree = build_qep(trac->statement, nulls, xml);
@@ -260,7 +260,6 @@
 					qep_tree->open();
 					is_qep_opened = true;
 					built_trigger_actions_vec.push_back(bta);
-					trac = trac->next;
 				}
 				else
 				{
@@ -271,6 +270,7 @@
 					is_subqep_opened = true;
 					built_trigger_actions_vec.push_back(bta);
 				}
+				trac = trac->next;
 	        }
         }
         catch(SednaUserException &e) {
@@ -288,23 +288,33 @@
      try
      {
          int i = 0;
-         for(i = 0; i < mapIter->second.size()-1; i++)
+         int action_returns_value = ((trigger_time == TRIGGER_BEFORE)&&(trigger_granularity == TRIGGER_FOR_EACH_NODE)) ? 1 : 0;
+         for(i = 0; i < mapIter->second.size()-action_returns_value; i++)
          {
-          	qep_tree = mapIter->second.at(i).action_qep_tree;
+             if(mapIter->second.at(i).action_qep_tree)
+             {
+                 qep_tree = mapIter->second.at(i).action_qep_tree;
+                 qep_parameters = &(mapIter->second.at(i).parameters);
+	 			 set_action_parameters(parameter_new, parameter_old, parameter_where, trigger_granularity, std::string(trigger_title));
+           	     if(qep_tree->is_update())
+   	             qep_tree->execute();
+             }
+             /*else
+             {
+                 qep_subtree = mapIter->second.at(i).action_qep_subtree;
+                 qep_parameters = &(mapIter->second.at(i).parameters);
+                 set_action_parameters(parameter_new, parameter_old, parameter_where, trigger_granularity, std::string(trigger_title));
+				 tuple t = tuple(1);
+		   		 qep_subtree->tree.op->next(t);
+             }*/
+		}
+		if (action_returns_value)
+        {
+            qep_subtree = mapIter->second.at(i).action_qep_subtree;
             qep_parameters = &(mapIter->second.at(i).parameters);
-   	        set_action_parameters(parameter_new, parameter_old, parameter_where, trigger_granularity, std::string(trigger_title));
-           	//is_qep_opened = true;
-            if(qep_tree->is_update())
-   	            qep_tree->execute();
-       	}
-       	qep_subtree = mapIter->second.at(i).action_qep_subtree;
-        qep_parameters = &(mapIter->second.at(i).parameters);
-   	    set_action_parameters(parameter_new, parameter_old, parameter_where, trigger_granularity, std::string(trigger_title));
-//        is_subqep_opened = true;
-		tuple t = tuple(1);
-		qep_subtree->tree.op->next(t);
-
-		if ((trigger_time == TRIGGER_BEFORE)&&(trigger_granularity == TRIGGER_FOR_EACH_NODE))
+            set_action_parameters(parameter_new, parameter_old, parameter_where, trigger_granularity, std::string(trigger_title));
+			tuple t = tuple(1);
+		   	qep_subtree->tree.op->next(t);
 			if (!t.cells[0].is_node())
 				res_xptr = XNULL;
 		   	else
@@ -312,11 +322,12 @@
 				res_xptr = t.cells[0].get_node();
 				CHECKP(res_xptr);
 			}
+       		// retrieve all items to make the qep_subtree usable next time
+			while(!t.is_eos())
+				qep_subtree->tree.op->next(t);
+        }
 		else res_xptr = XNULL;

-		// retrieve all items to make the qep_subtree usable next time
-		while(!t.is_eos())
-			qep_subtree->tree.op->next(t);
 	}
     catch (SednaUserException &e) {
         throw e;


NetEq: Silence a few unexpected mock calls in NetEqImplTest

TBR=kwiberg@webrtc.org

Review URL: https://codereview.webrtc.org/1918193002

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#12507}

--- webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
+++ webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
@@ -351,6 +351,9 @@
   }

   // Expectations for payload splitter.
+  EXPECT_CALL(*mock_payload_splitter_, SplitFec(_, _))
+      .Times(2)
+      .WillRepeatedly(Return(PayloadSplitter::kOK));
   EXPECT_CALL(*mock_payload_splitter_, SplitAudio(_, _))
       .Times(2)
       .WillRepeatedly(Return(PayloadSplitter::kOK));
@@ -516,6 +519,8 @@
   EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1));
   EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _))
       .WillRepeatedly(Return(0));
+  EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes))
+      .WillRepeatedly(Return(kPayloadLengthSamples));
   int16_t dummy_output[kPayloadLengthSamples] = {0};
   // The below expectation will make the mock decoder write
   // |kPayloadLengthSamples| zeros to the output array, and mark it as speech.


Remove unnecessary std::move

Remove unnecessary std::move

--- src/project.cc
+++ src/project.cc
@@ -377,7 +377,7 @@
             startup_commands.emplace_back("type category enable Rust");
           }
         }
-        Debug::LLDB::get().start(*run_arguments, *project_path, breakpoints, std::move(startup_commands), remote_host);
+        Debug::LLDB::get().start(*run_arguments, *project_path, breakpoints, startup_commands, remote_host);
       });
     }
   });


fix debug prints

fix debug prints

--- src/OpenGLTexture.cpp
+++ src/OpenGLTexture.cpp
@@ -143,7 +143,7 @@
   } else if (getInternalFormat() == RGB565) {
     Image tmp_image(width, height, (const unsigned char *)buffer, ImageFormat::RGBA32);
     auto tmp_image2 = tmp_image.changeFormat(ImageFormat::RGB565);
-    cerr << "trying to update rgb565 texture, b1 = " << buffer << ", b2 = " << tmp_image2->getData() << ", x = " << x << ", y = " << y << ", w = " << width << ", h = " << height << ", mm = " << has_mipmaps << endl;
+    cerr << "trying to update rgb565 texture, b1 = " << (void*)buffer << ", b2 = " << (void*)tmp_image2->getData() << ", x = " << x << ", y = " << y << ", w = " << width << ", h = " << height << ", mm = " << has_mipmaps << endl;
     glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, tmp_image2->getData());
   } else {
     cerr << "trying to update rgba texture" << endl;


update comments

update comments

git-svn-id: c9a369146f666b9deda0c4af3838c8001dc825a8@807 ce7aba0d-9f81-40a6-a495-cecae84b0515

--- src/routers/iq_router.cpp
+++ src/routers/iq_router.cpp
@@ -503,6 +503,9 @@

 	// This continue acounts for the interleaving of
 	// VCs when input speedup is used
+	// dub: Essentially, this skips loop iterations corresponding to those
+	// VCs not in the current speedup set. The skipped iterations will be
+	// handled in a different iteration of the enclosing loop over 's'.
 	if ( ( vc % _input_speedup ) != s ) {
 	  vc = ( vc + 1 ) % _vcs;
 	  continue;
@@ -528,10 +531,10 @@
 	    if ( ( _switch_hold_in[expanded_input] == -1 ) &&
 		 ( _switch_hold_out[expanded_output] == -1 ) ) {

-	      // We could have requested this same input-output pair in a previous
-	      // iteration, only replace the previous request if the current
-	      // request has a higher priority (this is default behavior of the
-	      // allocators).  Switch allocation priorities are strictly
+	      // We could have requested this same input-output pair in a
+	      // previous iteration; only replace the previous request if the
+	      // current request has a higher priority (this is default behavior
+	      // of the allocators).  Switch allocation priorities are strictly
 	      // determined by the packet priorities.

 	      _sw_allocator->AddRequest( expanded_input, expanded_output, vc,


Removed extra logic which attempted to load from floc in getPFieldTable()

--- src/rtcmix/Instrument.cpp
+++ src/rtcmix/Instrument.cpp
@@ -445,24 +445,18 @@
 }

 // Utility for returning a double array to the subclass.
-// Returns array from PField if available, else treats
-// value as index into floc tables.
+// Returns array from PField if available.

 const double *
 Instrument::getPFieldTable(int index, int *tableLen) const
 {
 	const PField &pf = getPField(index);
 	double *tableArray = (double *) pf;
-	*tableLen = 0;
 	if (tableArray != NULL) {
 		*tableLen = pf.values();
 	}
-	else {
-		int flocIndex = pf.intValue(0.0);
-		tableArray = floc(flocIndex);
-		if (tableArray)
-			*tableLen = fsize(flocIndex);
-	}
+	else
+		*tableLen = 0;
 	return tableArray;
 }


Fix debug traces.

Fix debug traces.

	* src/runner/interpreter.cc: here.

--- src/runner/interpreter.cc
+++ src/runner/interpreter.cc
@@ -52,7 +52,7 @@
 #define ME JOB (this)

 #define AST(Ast)                                \
-  (Ast).location_get ()                         \
+  (Ast)->location_get ()                        \
   << libport::incendl                           \
   << "{{{"                                      \
   << libport::incendl                           \
@@ -199,7 +199,7 @@
   Interpreter::work ()
   {
     assert (ast_ || code_);
-    JAECHO ("starting evaluation of AST: ", *ast_);
+    JAECHO ("starting evaluation of AST: ", ast_);
     if (ast_)
       operator()(ast_);
     else
@@ -610,10 +610,10 @@
   Interpreter::visit (ast::rConstForeach e)
   {
     // Evaluate the list attribute, and check its type.
-    JAECHO ("foreach list", e.list_get());
+    JAECHO ("foreach list", e->list_get());
     operator() (e->list_get());
     object::type_check<object::List>(current_, SYMBOL(foreach));
-    JAECHO("foreach body", e.body_get());
+    JAECHO("foreach body", e->body_get());

     // We need to copy the pointer on the list, otherwise the list will be
     // destroyed when children are visited and current_ is modified.
@@ -712,12 +712,12 @@

     if (object::is_true(current_))
     {
-      JAECHO ("then", e.thenclause_get ());
+      JAECHO ("then", e->thenclause_get());
       operator() (e->thenclause_get());
     }
     else
     {
-      JAECHO ("else", e.elseclause_get ());
+      JAECHO ("else", e->elseclause_get());
       operator() (e->elseclause_get());
     }
   }
@@ -926,7 +926,7 @@
   void
   Interpreter::visit (ast::rConstStmt e)
   {
-    JAECHO ("expression", e.expression_get ());
+    JAECHO ("expression", e->expression_get());
     operator() (e->expression_get());
   }

@@ -1054,12 +1054,12 @@
     {
       if (tail++)
 	MAYBE_YIELD (e->flavor_get());
-      JAECHO ("while test", e.test_get ());
+      JAECHO ("while test", e->test_get());
       operator() (e->test_get());
       if (!object::is_true(current_))
 	break;

-      JAECHO ("while body", e.body_get ());
+      JAECHO ("while body", e->body_get());

       operator() (e->body_get());
     }


Added 3 methods breaking SaveImageAsPPM() into its constituent pieces.

--- graphics/vtkRenderWindow.cxx
+++ graphics/vtkRenderWindow.cxx
@@ -256,6 +256,7 @@
     delete [] this->ResultFrame;
     this->ResultFrame = NULL;
     }
+
 }

 // Description:
@@ -580,8 +581,39 @@

 void vtkRenderWindow::SaveImageAsPPM()
 {
+  if( this->OpenPPMImageFile() ){
+    this->WritePPMImageFile();
+    this->ClosePPMImageFile();
+  }
+}
+
+
+int vtkRenderWindow::OpenPPMImageFile()
+{
+  //  open the ppm file and write header
+  if ( this->Filename != NULL && *this->Filename != '\0')
+    {
+    PpmImageFilePtr = fopen(this->Filename,"wb");
+    if (!PpmImageFilePtr)
+      {
+      vtkErrorMacro(<< "RenderWindow unable to open image file for writing\n");
+      return 0;
+      }
+    return 0;
+  }
+  return 1;
+}
+
+void vtkRenderWindow::ClosePPMImageFile()
+{
+  fclose(PpmImageFilePtr);
+  PpmImageFilePtr = NULL;
+}
+
+
+void vtkRenderWindow::WritePPMImageFile()
+{
   int    *size;
-  FILE   *fp;
   unsigned char *buffer;
   int i;

@@ -590,30 +622,24 @@
   // get the data
   buffer = this->GetPixelData(0,0,size[0]-1,size[1]-1,1);

-  //  open the ppm file and write header
-  if ( this->Filename != NULL && *this->Filename != '\0')
-    {
-    fp = fopen(this->Filename,"wb");
-    if (!fp)
-      {
-      vtkErrorMacro(<< "RenderWindow unable to open image file for writing\n");
-      delete [] buffer;
-      return;
-      }
+  if(!PpmImageFilePtr)
+    {
+    vtkErrorMacro(<< "RenderWindow: no image file for writing\n");
+    return;
+    }

-    // write out the header info
-    fprintf(fp,"P6\n%i %i\n255\n",size[0],size[1]);
+  // write out the header info
+  fprintf(PpmImageFilePtr,"P6\n%i %i\n255\n",size[0],size[1]);

-    // now write the binary info
-    for (i = size[1]-1; i >= 0; i--)
-      {
-      fwrite(buffer + i*size[0]*3,1,size[0]*3,fp);
-      }
-    fclose(fp);
+  // now write the binary info
+  for (i = size[1]-1; i >= 0; i--)
+    {
+    fwrite(buffer + i*size[0]*3,1,size[0]*3,PpmImageFilePtr);
     }

   delete [] buffer;
 }
+

 // Description:


change filequit in note to only close note, not session


Index.document_ids now returns a pair of external and internal document identifiers for every document.

--- src/pyndri.cpp
+++ src/pyndri.cpp
@@ -138,6 +138,10 @@
         return NULL;
     }

+    if (external_doc_ids == NULL) {
+        return NULL;
+    }
+
     PyObject* const iterator = PyObject_GetIter(external_doc_ids);
     PyObject *item;

@@ -159,12 +163,11 @@
     }

     Py_DECREF(iterator);
-    Py_XDECREF(external_doc_ids);

     std::vector<lemur::api::DOCID_T> int_doc_ids =
         self->query_env_->documentIDsFromMetadata("docno", ext_document_ids);

-    PyObject* const int_doc_ids_tuple = PyTuple_New(int_doc_ids.size());
+    PyObject* const doc_ids_tuple = PyTuple_New(int_doc_ids.size());

     Py_ssize_t pos = 0;
     for (std::vector<lemur::api::DOCID_T>::iterator int_doc_ids_it = int_doc_ids.begin();
@@ -175,13 +178,14 @@
         const std::string ext_document_id =
             self->collection_->retrieveMetadatum(int_document_id, "docno");

-        PyTuple_SetItem(int_doc_ids_tuple, pos,
+        PyTuple_SetItem(doc_ids_tuple,
+                        pos,
                         PyTuple_Pack(2,
                             PyString_FromString(ext_document_id.c_str()),
                             PyInt_FromLong(int_document_id)));
     }

-    return int_doc_ids_tuple;
+    return doc_ids_tuple;
 }

 static PyObject* Index_document(Index* self, PyObject* args) {


Issue #17: using BitmapWrapper class instead of Bitmap directly for Python exposure

--- src/python.cpp
+++ src/python.cpp
@@ -9,6 +9,17 @@

 using namespace boost::python;

+
+class BitmapWrapper : public Bitmap
+                      , public wrapper<Bitmap>
+{
+    public:
+        BitmapWrapper(std::string filepath)
+            : Bitmap(filepath)
+        {
+            // nop
+        }
+};

 class CimageWrapper
     : public Cimage
@@ -61,10 +72,10 @@
         .def("stop", &Cproc::stop)
         ;

-    class_<Bitmap, boost::noncopyable>(
+    class_<BitmapWrapper, boost::noncopyable>(
             "Bitmap", init<std::string>())
-        .def("get_width", &Bitmap::get_width)
-        .def("get_height", &Bitmap::get_height)
-        .def("save", &Bitmap::save)
+        .def("get_width", &BitmapWrapper::get_width)
+        .def("get_height", &BitmapWrapper::get_height)
+        .def("save", &BitmapWrapper::save)
         ;
 }


Fix print function

Fix print function

--- src/random.cpp
+++ src/random.cpp
@@ -71,7 +71,7 @@
     if (ret == ERROR_SUCCESS) {
         RAND_add(begin_ptr(vData), nSize, nSize / 100.0);
         OPENSSL_cleanse(begin_ptr(vData), nSize);
-        LogPrint("rand", "%s: %lu bytes\n", __func__, nSize);
+        print("%s: %lu bytes\n", __func__, nSize);
     } else {
         static bool warned = false; // Warn only once
         if (!warned) {


Debugging raspi2.cpp

Debugging raspi2.cpp

--- src/raspi2.cpp
+++ src/raspi2.cpp
@@ -34,7 +34,7 @@

 // Setup for the UART communications
 int baud = 230400;
-UART ImP;
+ImP IMP(baud);
 comms::Pipe ImP_stream;

 // Ethernet communication setup and variables (we are acting as client)
@@ -130,7 +130,7 @@
 	 */
 	Log("INFO") << "SOE signal received";
 	// Setup the ImP and start requesting data
-	ImP_stream = ImP.startDataCollection("Docs/Data/Pi2/test");
+	ImP_stream = IMP.startDataCollection("Docs/Data/Pi2/test");
 	Log("INFO") << "Started data collection from ImP";
 	comms::Packet p; // Buffer for reading data from the IMU stream
 	// Trigger the burn wire for 10 seconds!


ssm bootstrap mechanism

ssm bootstrap mechanism

--- dbeacon.cpp
+++ dbeacon.cpp
@@ -66,7 +66,7 @@

 static const int timeOutI = 6;
 static const int reportI = 2;
-static const int ssmReportI = 3;
+static const int ssmReportI = 4;
 static const int mapReportI = 6;
 static const int websiteReportI = 24;

@@ -130,6 +130,8 @@

 static vector<address> redist;

+static vector<address> ssmBootstrap;
+
 static uint32_t bytesReceived = 0;
 static uint32_t bytesSent = 0;

@@ -183,6 +185,7 @@
 	fprintf(stderr, "  -b BEACON_ADDR[/PORT]  Multicast group address to send probes to\n");
 	fprintf(stderr, "  -r REDIST_ADDR[/PORT]  Redistribute reports to the supplied host/port. Multiple may be supplied\n");
 	fprintf(stderr, "  -S [GROUP_ADDR[/PORT]] Enables SSM reception/sending on optional GROUP_ADDR/PORT\n");
+	fprintf(stderr, "  -B ADDR                Bootstraps by joining the specified address\n");
 	fprintf(stderr, "  -s ADDR                Bind to local address\n");
 	fprintf(stderr, "  -d [FILE]              Dump periodic reports to dump.xml or specified file\n");
 	fprintf(stderr, "  -I NUMBER              Interval between dumps. Defaults to 5 secs\n");
@@ -360,6 +363,13 @@
 		}
 	}

+	if (ssmMcastSock) {
+		uint64_t now = get_timestamp();
+		for (vector<address>::const_iterator i = ssmBootstrap.begin(); i != ssmBootstrap.end(); i++) {
+			getSource(*i, 0, now, false);
+		}
+	}
+
 	signal(SIGUSR1, dumpBigBwStats);
 	signal(SIGINT, sendLeaveReport);

@@ -435,7 +445,7 @@
 int parse_arguments(int argc, char **argv) {
 	int res;
 	while (1) {
-		res = getopt(argc, argv, "n:a:i:b:r:S::Os:d::I:l:L:W:C:vUhf46V");
+		res = getopt(argc, argv, "n:a:i:b:r:S::OB:s:d::I:l:L:W:C:vUhf46V");
 		if (res == 'n') {
 			if (strlen(optarg) > 254) {
 				fprintf(stderr, "Name is too large.\n");
@@ -465,6 +475,13 @@
 		} else if (res == 'O') {
 			useSSM = true;
 			listenForSSM = false;
+		} else if (res == 'B') {
+			address addr;
+			if (!addr.parse(optarg)) {
+				fprintf(stderr, "Bad address format.\n");
+				return -1;
+			}
+			ssmBootstrap.push_back(addr);
 		} else if (res == 's') {
 			if (!beaconUnicastAddr.parse(optarg, false, false)) {
 				fprintf(stderr, "Bad address format.\n");
@@ -961,7 +978,7 @@
 int send_report(int type) {
 	int len;

-	len = build_report(buffer, bufferLen, type == SSM_REPORT ? STATS_REPORT : type, type != SSM_REPORT);
+	len = build_report(buffer, bufferLen, type == SSM_REPORT ? STATS_REPORT : type, true);
 	if (len < 0)
 		return len;


LTOInternalize: Use a StringSet instead of a sorted vector and a binary search query for each function

From: Mehdi Amini <mehdi.amini@apple.com>

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

--- lib/LTO/LTOInternalize.cpp
+++ lib/LTO/LTOInternalize.cpp
@@ -46,7 +46,7 @@

   // Temps
   llvm::Mangler Mangler;
-  std::vector<StringRef> Libcalls;
+  StringSet<> Libcalls;

   // Output
   SmallPtrSetImpl<const GlobalValue *> &AsmUsed;
@@ -64,7 +64,7 @@
          I != E; ++I) {
       LibFunc::Func F = static_cast<LibFunc::Func>(I);
       if (TLI.has(F))
-        Libcalls.push_back(TLI.getName(F));
+        Libcalls.insert(TLI.getName(F));
     }

     SmallPtrSet<const TargetLowering *, 1> TLSet;
@@ -80,12 +80,8 @@
              I != E; ++I)
           if (const char *Name =
                   Lowering->getLibcallName(static_cast<RTLIB::Libcall>(I)))
-            Libcalls.push_back(Name);
+            Libcalls.insert(Name);
     }
-
-    array_pod_sort(Libcalls.begin(), Libcalls.end());
-    Libcalls.erase(std::unique(Libcalls.begin(), Libcalls.end()),
-                   Libcalls.end());
   }

   void findAsmUses(const GlobalValue &GV) {
@@ -108,8 +104,7 @@
     // optimizations like -globalopt, causing problems when later optimizations
     // add new library calls (e.g., llvm.memset => memset and printf => puts).
     // Leave it to the linker to remove any dead code (e.g. with -dead_strip).
-    if (isa<Function>(GV) &&
-        std::binary_search(Libcalls.begin(), Libcalls.end(), GV.getName()))
+    if (isa<Function>(GV) && Libcalls.count(GV.getName()))
       AsmUsed.insert(&GV);
   }
 };


Actually fixed blocking issue

Actually fixed blocking issue

--- src/reader.cpp
+++ src/reader.cpp
@@ -281,13 +281,22 @@
 	std::string pre = "";
 	if (strcmp(argv[1], "/dev/ttyUSB0") != 0) {
 		pre = "avionics";
-		pipe_gps = open("/tmp/rocket_avionics", O_WRONLY|O_NONBLOCK|O_CREAT);
+		if (!boost::filesystem::exists("/tmp/rocket_avionics"))
+			pipe_gps = open("/tmp/rocket_avionics", O_WRONLY|O_NONBLOCK);
+		else
+			pipe_gps = open("/tmp/rocket_avionics", O_WRONLY|O_NONBLOCK|O_CREAT);
 		pipe_instrument = -1;
 	}
 	else {
 		pre = "payload";
-		pipe_gps = open("/tmp/rocket_payload", O_WRONLY|O_NONBLOCK|O_CREAT);
-		pipe_instrument = open("/tmp/rocket_instrument",O_WRONLY|O_NONBLOCK|O_CREAT);
+		if (!boost::filesystem::exists("/tmp/rocket_payload"))
+			pipe_gps = open("/tmp/rocket_payload", O_WRONLY|O_NONBLOCK);
+		else
+			pipe_gps = open("/tmp/rocket_payload", O_WRONLY|O_NONBLOCK|O_CREAT);
+		if (!boost::filesystem::exists("/tmp/rocket_instrument"))
+			pipe_instrument = open("/tmp/rocket_instrument", O_WRONLY|O_NONBLOCK);
+		else
+			pipe_instrument = open("/tmp/rocket_instrument",O_WRONLY|O_NONBLOCK|O_CREAT);
 	}

 	//Create new numbered log file


Remove dead store.

Remove dead store.

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

--- lib/Linker/LinkModules.cpp
+++ lib/Linker/LinkModules.cpp
@@ -664,7 +664,6 @@
         Var->eraseFromParent();
       else
         cast<Function>(DGV)->eraseFromParent();
-      DGV = NewDGV;

       // If the symbol table renamed the global, but it is an externally visible
       // symbol, DGV must be an existing global with internal linkage.  Rename.


comment

comment

--- NaoTHSoccer/Source/Cognition/Modules/Modeling/SelfLocator/SituationPriorProvider/SituationPriorProvider.cpp
+++ NaoTHSoccer/Source/Cognition/Modules/Modeling/SelfLocator/SituationPriorProvider/SituationPriorProvider.cpp
@@ -58,7 +58,7 @@
     wasLiftedUp = true;
   }

-  // for penalty kicker
+  // for penalty kicker, this has the highest priority
   if(getSituationStatus().oppHalf)
   {
     getSituationPrior().currentPrior = SituationPrior::oppHalf;


Added the missing SHORT_REGION record type.

Signed-off-by: Fuat Keceli <e72929714ff5dfd73f3f68ff0402f9c2c4fa79d8@intel.com>

--- src/record.cpp
+++ src/record.cpp
@@ -21,6 +21,7 @@
             {EVENT_REGION_ENTRY, "REGION_ENTRY"},
             {EVENT_REGION_EXIT, "REGION_EXIT"},
             {EVENT_EPOCH_COUNT, "EPOCH_COUNT"},
+            {EVENT_SHORT_REGION, "EVENT_SHORT_REGION"}
         };
         auto it = event_names.find(event_type);
         if (it == event_names.end()) {
@@ -36,6 +37,7 @@
             {"REGION_ENTRY", EVENT_REGION_ENTRY},
             {"REGION_EXIT", EVENT_REGION_EXIT},
             {"EPOCH_COUNT", EVENT_EPOCH_COUNT},
+            {"EVENT_SHORT_REGION", EVENT_SHORT_REGION}
         };
         auto it = event_types.find(event_name);
         if (it == event_types.end()) {


Avoid an extra loop for computing the section size. NFC.

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

--- lib/MC/ELFObjectWriter.cpp
+++ lib/MC/ELFObjectWriter.cpp
@@ -91,9 +91,6 @@
                            bool Used, bool Renamed);
     static bool isLocal(const MCSymbolData &Data, bool isUsedInReloc);
     static bool IsELFMetaDataSection(const MCSectionData &SD);
-    static uint64_t DataSectionSize(const MCSectionData &SD);
-    static uint64_t GetSectionAddressSize(const MCAsmLayout &Layout,
-                                          const MCSectionData &SD);

     void writeDataSectionData(MCAssembler &Asm, const MCAsmLayout &Layout,
                               const MCSectionData &SD);
@@ -224,8 +221,9 @@
     typedef DenseMap<const MCSectionELF*, const MCSymbol*> GroupMapTy;
     // Map from a signature symbol to the group section
     typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
-    // Map from a section to its offset
-    typedef DenseMap<const MCSectionELF*, uint64_t> SectionOffsetMapTy;
+    // Map from a section to its start and end offset
+    typedef DenseMap<const MCSectionELF *, std::pair<uint64_t, uint64_t>>
+        SectionOffsetMapTy;

     /// Compute the symbol table data
     ///
@@ -1533,24 +1531,6 @@
     !SD.getSection().isVirtualSection();
 }

-uint64_t ELFObjectWriter::DataSectionSize(const MCSectionData &SD) {
-  uint64_t Ret = 0;
-  for (MCSectionData::const_iterator i = SD.begin(), e = SD.end(); i != e;
-       ++i) {
-    const MCFragment &F = *i;
-    assert(F.getKind() == MCFragment::FT_Data);
-    Ret += cast<MCDataFragment>(F).getContents().size();
-  }
-  return Ret;
-}
-
-uint64_t ELFObjectWriter::GetSectionAddressSize(const MCAsmLayout &Layout,
-                                                const MCSectionData &SD) {
-  if (IsELFMetaDataSection(SD))
-    return DataSectionSize(SD);
-  return Layout.getSectionAddressSize(&SD);
-}
-
 void ELFObjectWriter::writeDataSectionData(MCAssembler &Asm,
                                            const MCAsmLayout &Layout,
                                            const MCSectionData &SD) {
@@ -1590,11 +1570,14 @@
       GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm,
                                                      GroupMap.lookup(&Section));

-    uint64_t Size = GetSectionAddressSize(Layout, SD);
-
-    writeSection(Asm, SectionIndexMap, GroupSymbolIndex,
-                 SectionOffsetMap.lookup(&Section), Size, SD.getAlignment(),
-                 Section);
+    const std::pair<uint64_t, uint64_t> &Offsets =
+        SectionOffsetMap.lookup(&Section);
+    uint64_t Size = Section.getType() == ELF::SHT_NOBITS
+                        ? Layout.getSectionAddressSize(&SD)
+                        : Offsets.second - Offsets.first;
+
+    writeSection(Asm, SectionIndexMap, GroupSymbolIndex, Offsets.first, Size,
+                 SD.getAlignment(), Section);
   }
 }

@@ -1637,9 +1620,10 @@
     WriteZeros(Padding);

     // Remember the offset into the file for this section.
-    SectionOffsetMap[&Section] = OS.tell();
-
+    uint64_t SecStart = OS.tell();
     writeDataSectionData(Asm, Layout, SD);
+    uint64_t SecEnd = OS.tell();
+    SectionOffsetMap[&Section] = std::make_pair(SecStart, SecEnd);
   }

   uint64_t NaturalAlignment = is64Bit() ? 8 : 4;


Unresolved weak symbols have value equal zero.

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

--- lib/MC/ELFObjectWriter.cpp
+++ lib/MC/ELFObjectWriter.cpp
@@ -364,7 +364,7 @@
   if (Data.isCommon() && Data.isExternal())
     Value = Data.getCommonAlignment();

-  if (!Data.isCommon())
+  if (!Data.isCommon() && !(Data.getFlags() & ELF_STB_Weak))
     if (MCFragment *FF = Data.getFragment())
       Value = Layout.getSymbolAddress(&Data) -
               Layout.getSectionAddress(FF->getParent());


updated to use the QuickStep method

updated to use the QuickStep method

git-svn-id: 051f6adb867ae8800663f9d761b7f383ac0911ea@698 685f7672-210f-0410-90b4-fe3ad19314fe

--- ode/test/test_crash.cpp
+++ ode/test/test_crash.cpp
@@ -20,7 +20,8 @@
  *                                                                       *
  *************************************************************************/

-// This is a demo of the StepFast code, by David Whittaker.
+// This is a demo of the QuickStep and StepFast methods,
+// originally by David Whittaker.

 #include <ode/ode.h>
 #include <drawstuff/drawstuff.h>
@@ -38,6 +39,10 @@
 #define dsDrawCappedCylinder dsDrawCappedCylinderD
 #endif

+
+// select the method you want to test here (only uncomment *one* line)
+#define QUICKSTEP 1
+//#define STEPFAST 1

 // some constants

@@ -54,7 +59,7 @@
 #define FMAX 25			// car engine fmax
 #define ROWS 1			// rows of cars
 #define COLS 1			// columns of cars
-#define ITERS 10		// number of iterations
+#define ITERS 20		// number of iterations
 #define WBOXSIZE 1.0		// size of wall boxes
 #define WALLWIDTH 20		// width of wall
 #define WALLHEIGHT 10		// height of wall
@@ -237,6 +242,7 @@
 	dWorldSetGravity (world,0,0,-1.5);
 	dWorldSetCFM (world, 1e-5);
 	dWorldSetERP (world, 0.8);
+	dWorldSetQuickStepNumIterations (world,ITERS);
 	ground = dCreatePlane (space,0,0,1,0);

 	bodies = 0;
@@ -456,7 +462,11 @@
 		if (doFast)
 		{
 			dSpaceCollide (space,0,&nearCallback);
+#if defined(QUICKSTEP)
+			dWorldQuickStep (world,0.05);
+#elif defined(STEPFAST)
 			dWorldStepFast1 (world,0.05,ITERS);
+#endif
 			dJointGroupEmpty (contactgroup);
 		}
 		else


More paper code tests

More paper code tests

--- test/SEA17_paper_tests.cpp
+++ test/SEA17_paper_tests.cpp
@@ -26,7 +26,7 @@
 };
 /////////////////////////////////

-TEST(Bwt, test) {
+TEST(SEA17, Bwt) {
     auto i = test::compress_input("aaababaaabaababa");
     auto o = test::compress_output();
     auto c = tdc::builder<BWTComp>().instance();
@@ -67,8 +67,67 @@
       else heap.remove(i);
 }}}}}};
 /////////////////////////////////
-TEST(MaxHeap, test) {
+TEST(SEA17, MaxHeap) {
     auto text_ds = builder<TextDS<>>().instance("abc\0"_v);
     auto maxheap = builder<MaxHeapStrategy<TextDS<>>>().instance();
     maxheap.factorize(text_ds, 1);
 }
+/////////////////////////////////
+void factorize(TextDS<>& T, SuffixTree& ST, std::function<void(int begin, int end, int ref)> output){
+ typedef SuffixTree::node_type node_t;
+ sdsl::int_vector<> R(ST.internal_nodes,0,bits_for(T.size() * bits_for(ST.cst.csa.sigma) / bits_for(T.size())));
+ int pos = 0, z = 0;
+ while(pos < T.size() - 1) {
+  node_t l = ST.select_leaf(ST.cst.csa.isa[pos]);
+  int leaflabel = pos;
+  if(ST.parent(l) == ST.root || R[ST.nid(ST.parent(l))] != 0) {
+   int parent_strdepth = ST.str_depth(ST.parent(l));
+   output(pos + parent_strdepth, pos + parent_strdepth + 1, R[ST.nid(ST.parent(l))]);
+   pos += parent_strdepth+1;
+   ++z;
+   continue;
+  }
+  int d = 1;
+  node_t parent = ST.root;
+  node_t node = ST.level_anc(l, d);
+  while(R[ST.nid(node)] != 0) {
+   parent = node;
+   node = ST.level_anc(l, ++d);
+  }
+  pos += ST.str_depth(parent);
+  int begin = leaflabel + ST.str_depth(parent);
+  int end = leaflabel + ST.str_depth(node);
+  output(begin, end, R[ST.nid(ST.parent(node))]);
+  R[ST.nid(node)] = ++z;
+  pos += end - begin;
+ }
+}
+/////////////////////////////////
+TEST(SEA17, factorize) {
+    auto T = "aaababaaabaababa\0"_v;
+    auto text_ds = builder<TextDS<>>().instance(T);
+    std::vector<int> v;
+    auto f = [&](int begin, int end, int ref) {
+        v.push_back(begin);
+        v.push_back(end);
+        v.push_back(ref);
+    };
+    SuffixTree::cst_t backing_cst;
+    {
+        std::string bad_copy_1 = T.slice(0, T.size() - 1);
+        construct_im(backing_cst, bad_copy_1, 1);
+    }
+    SuffixTree ST(backing_cst);
+
+    factorize(text_ds, ST,f);
+
+    ASSERT_EQ(v, (std::vector<int> {
+        0,   1,   0,
+        2,   3,   1,
+        3,   5,   0,
+        7,   8,   3,
+        9,  11,   1,
+        14, 16,   5,
+        // 16, 17,   0,
+    }));
+}


Check for fold flag and don't call Fold method if not set as this avoids checking in the Fold method.

--- src/ScintillaBase.cxx
+++ src/ScintillaBase.cxx
@@ -372,8 +372,10 @@
 	if (lexCurrent) {	// Should always succeed as null lexer should always be available
 		lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
 		styler.Flush();
-		lexCurrent->Fold(start, len, styleStart, keyWordLists, styler);
-		styler.Flush();
+		if (styler.GetPropertyInt("fold")) {
+			lexCurrent->Fold(start, len, styleStart, keyWordLists, styler);
+			styler.Flush();
+		}
 	}
 }
 #endif


Descriptor expansions only need pubkey entries for PKH/WPKH

--- src/script/descriptor.cpp
+++ src/script/descriptor.cpp
@@ -226,7 +226,7 @@
      *  @param pubkeys The evaluations of the m_pubkey_args field.
      *  @param script The evaluation of m_script_arg (or nullptr when m_script_arg is nullptr).
      *  @param out A FlatSigningProvider to put scripts or public keys in that are necessary to the solver.
-     *             The script and pubkeys argument to this function are automatically added.
+     *             The script arguments to this function are automatically added, as is the origin info of the provided pubkeys.
      *  @return A vector with scriptPubKeys for this descriptor.
      */
     virtual std::vector<CScript> MakeScripts(const std::vector<CPubKey>& pubkeys, const CScript* script, FlatSigningProvider& out) const = 0;
@@ -322,7 +322,6 @@
         for (auto& entry : entries) {
             pubkeys.push_back(entry.first);
             out.origins.emplace(entry.first.GetID(), std::move(entry.second));
-            out.pubkeys.emplace(entry.first.GetID(), entry.first);
         }
         if (m_script_arg) {
             for (const auto& subscript : subscripts) {
@@ -396,7 +395,12 @@
 class PKHDescriptor final : public DescriptorImpl
 {
 protected:
-    std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider&) const override { return Singleton(GetScriptForDestination(keys[0].GetID())); }
+    std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider& out) const override
+    {
+        CKeyID id = keys[0].GetID();
+        out.pubkeys.emplace(id, keys[0]);
+        return Singleton(GetScriptForDestination(id));
+    }
 public:
     PKHDescriptor(std::unique_ptr<PubkeyProvider> prov) : DescriptorImpl(Singleton(std::move(prov)), {}, "pkh") {}
 };
@@ -405,7 +409,12 @@
 class WPKHDescriptor final : public DescriptorImpl
 {
 protected:
-    std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider&) const override { return Singleton(GetScriptForDestination(WitnessV0KeyHash(keys[0].GetID()))); }
+    std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider& out) const override
+    {
+        CKeyID id = keys[0].GetID();
+        out.pubkeys.emplace(id, keys[0]);
+        return Singleton(GetScriptForDestination(WitnessV0KeyHash(id)));
+    }
 public:
     WPKHDescriptor(std::unique_ptr<PubkeyProvider> prov) : DescriptorImpl(Singleton(std::move(prov)), {}, "wpkh") {}
 };
@@ -418,6 +427,7 @@
     {
         std::vector<CScript> ret;
         CKeyID id = keys[0].GetID();
+        out.pubkeys.emplace(id, keys[0]);
         ret.emplace_back(GetScriptForRawPubKey(keys[0])); // P2PK
         ret.emplace_back(GetScriptForDestination(id)); // P2PKH
         if (keys[0].IsCompressed()) {


fix: comparison between signed and unsigned integer

--- test/TestStratumSession.cc
+++ test/TestStratumSession.cc
@@ -415,7 +415,7 @@
   	agent.getSetDiffCommand(diffSessionIds, data);

     uint8_t *p = (uint8_t *)data.data();
-    ASSERT_EQ(data.length(), 9);
+    ASSERT_EQ(data.length(), 9U);
     ASSERT_EQ(*(uint8_t  *)(p+ 4), 1);  // diff_2exp
     ASSERT_EQ(*(uint16_t *)(p+ 5), 1);  // count
     ASSERT_EQ(*(uint16_t *)(p+ 7), 0);  // first session id


Changed function ording to be consistent with other functions in TestStringUtility class.

--- test/TestStringUtility.hpp
+++ test/TestStringUtility.hpp
@@ -216,12 +216,6 @@
         dest_len = (dest != NULL) ? src_len : static_cast<size_type>(0);
     }

-    static void SafeReallocCopy(char*& dest, size_type& dest_len, char const* src)
-    {
-        FastFree(dest);
-        SafeAllocateCopy(dest, dest_len, src);
-    }
-
     static void SafeReallocCopy(char*& dest,
                                 size_type& dest_len,
                                 char const* src,
@@ -229,6 +223,12 @@
     {
         FastFree(dest);
         SafeAllocateCopy(dest, dest_len, src, src_len);
+    }
+
+    static void SafeReallocCopy(char*& dest, size_type& dest_len, char const* src)
+    {
+        FastFree(dest);
+        SafeAllocateCopy(dest, dest_len, src);
     }

     /// Allocate enough space in dest to copy str1 and append str2.


STYLE: Conform (partially) to ITK coding style.

Use braces for control statements/loops.

Use the this-> keyword to call class methods.

Prefer pre-increment to post-increment.

Make local comments conform to the ITK coding style.

Change-Id: I41159aec8daeae8247c57a0cfca05242eae90018

--- Modules/Core/Common/include/itkSymmetricEigenAnalysis.hxx
+++ Modules/Core/Common/include/itkSymmetricEigenAnalysis.hxx
@@ -37,29 +37,31 @@

   unsigned int k = 0;

-  for ( unsigned int row = 0; row < m_Dimension; row++ )
+  for ( unsigned int row = 0; row < m_Dimension; ++row )
     {
       dVector[row] = D[row];
       workArea1[row] = 0;

-    for ( unsigned int col = 0; col < m_Dimension; col++ )
+    for ( unsigned int col = 0; col < m_Dimension; ++col )
       {
       inputMatrix[k++] = A(row, col);
       }
     }

-  ReduceToTridiagonalMatrix(inputMatrix, dVector, workArea1, workArea1);
+  this->ReduceToTridiagonalMatrix(inputMatrix, dVector, workArea1, workArea1);
   const unsigned int eigenErrIndex =
-    ComputeEigenValuesUsingQL(dVector, workArea1);
-
-  for ( unsigned int i = 0; i < m_Dimension; i++ )
-      D[i] = dVector[i];
+    this->ComputeEigenValuesUsingQL(dVector, workArea1);
+
+  for ( unsigned int i = 0; i < m_Dimension; ++i )
+    {
+    D[i] = dVector[i];
+    }

   delete[] dVector;
   delete[] workArea1;
   delete[] inputMatrix;

-  return eigenErrIndex; //index of eigen value that could not be computed
+  return eigenErrIndex; // index of eigenvalue that could not be computed
 }

 template< typename TMatrix, typename TVector, typename TEigenMatrix >
@@ -78,30 +80,30 @@

   unsigned int k = 0;

-  for ( unsigned int row = 0; row < m_Dimension; row++ )
+  for ( unsigned int row = 0; row < m_Dimension; ++row )
     {
       dVector[row] = EigenValues[row];
       workArea1[row] = 0;

-    for ( unsigned int col = 0; col < m_Dimension; col++ )
+    for ( unsigned int col = 0; col < m_Dimension; ++col )
       {
       workArea2[k] = 0;
       inputMatrix[k++] = A(row, col);
       }
     }

-  ReduceToTridiagonalMatrixAndGetTransformation(
+  this->ReduceToTridiagonalMatrixAndGetTransformation(
     inputMatrix, dVector, workArea1, workArea2);

   const unsigned int eigenErrIndex =
-    ComputeEigenValuesAndVectorsUsingQL(dVector, workArea1, workArea2);
-
-  // Copy eigenVectors
+    this->ComputeEigenValuesAndVectorsUsingQL(dVector, workArea1, workArea2);
+
+  // Copy eigenvectors
   k = 0;
-  for ( unsigned int row = 0; row < m_Dimension; row++ )
+  for ( unsigned int row = 0; row < m_Dimension; ++row )
     {
       EigenValues[row] = dVector[row];
-    for ( unsigned int col = 0; col < m_Dimension; col++ )
+    for ( unsigned int col = 0; col < m_Dimension; ++col )
       {
       EigenVectors[row][col] = workArea2[k++];
       }
@@ -112,7 +114,7 @@
   delete[] workArea1;
   delete[] inputMatrix;

-  return eigenErrIndex; //index of eigen value that could not be computed
+  return eigenErrIndex; // index of eigenvalue that could not be computed
 }

 template< typename TMatrix, typename TVector, typename TEigenMatrix >
@@ -122,7 +124,7 @@
 {
   double d__1;

-  /* Local variables */
+  // Local variables
   double f, g, h;
   int    i, j, k, l;
   double scale;
@@ -139,7 +141,7 @@
     h = 0.;
     scale = 0.;

-    /*     .......... scale row (algol tol then not needed) .......... */
+    // Scale row (algol tol then not needed)
     for ( k = 0; k <= l; ++k )
       {
       scale += itk::Math::abs(d[k]);
@@ -172,7 +174,7 @@
     d[l] = f - g;
     if ( l != 0 )
       {
-      /*     .......... form a*u .......... */
+      // Form a*u
       for ( j = 0; j <= l; ++j )
         {
         e[j] = 0.;
@@ -191,7 +193,7 @@
         e[j] = g;
         }

-      /*     .......... form p .......... */
+      // Form p
       f = 0.;

       for ( j = 0; j <= l; ++j )
@@ -201,13 +203,13 @@
         }

       h = f / ( h + h );
-      /*     .......... form q .......... */
+      // Form q
       for ( j = 0; j <= l; ++j )
         {
         e[j] -= h * d[j];
         }

-      /*     .......... form reduced a .......... */
+      // Form reduced a
       for ( j = 0; j <= l; ++j )
         {
         f = d[j];
@@ -240,7 +242,7 @@
 {
   double d__1;

-  /* Local variables */
+  // Local variables
   double       f, g, h;
   unsigned int i, j, k, l;
   double       scale, hh;
@@ -260,7 +262,7 @@
     h = 0.0;
     scale = 0.0;

-    /*     .......... scale row (algol tol then not needed) .......... */
+    // Scale row (algol tol then not needed)
     for ( k = 0; k <= l; ++k )
       {
       scale += itk::Math::abs(d[k]);
@@ -292,7 +294,7 @@
       h -= f * g;
       d[l] = f - g;

-      /*     .......... form a*u .......... */
+      // Form a*u
       for ( j = 0; j <= l; ++j )
         {
         e[j] = 0.0;
@@ -313,7 +315,7 @@
         e[j] = g;
         }

-      /*     .......... form p .......... */
+      // Form p
       f = 0.0;

       for ( j = 0; j <= l; ++j )
@@ -324,13 +326,13 @@

       hh = f / ( h + h );

-      /*     .......... form q .......... */
+      // Form q
       for ( j = 0; j <= l; ++j )
         {
         e[j] -= hh * d[j];
         }

-      /*     .......... form reduced a .......... */
+      // Form reduced a
       for ( j = 0; j <= l; ++j )
         {
         f = d[j];
@@ -349,7 +351,7 @@
     d[i] = h;
     }

-  /*     .......... accumulation of transformation matrices .......... */
+  // Accumulation of transformation matrices
   for ( i = 1; i < m_Order; ++i )
     {
     l = i - 1;
@@ -401,7 +403,7 @@
 {
   const double c_b10 = 1.0;

-  /* Local variables */
+  // Local variables
   double       c, f, g, h;
   unsigned int i, j, l, m;
   double       p, r, s, c2, c3 = 0.0;
@@ -433,7 +435,7 @@
       {
       tst1 = h;
       }
-    /*     .......... look for small sub-diagonal element .......... */
+    // Look for small sub-diagonal element
     for ( m = l; m < m_Order - 1; ++m )
       {
       tst2 = tst1 + itk::Math::abs(e[m]);
@@ -441,8 +443,7 @@
         {
         break;
         }
-      /*     .......... e(n) is always zero, so there is no exit */
-      /*                through the bottom of the loop .......... */
+      // e(n) is always zero, so there is no exit through the bottom of the loop
       }

     if ( m != l )
@@ -451,13 +452,12 @@
         {
         if ( j == 30 )
           {
-          /*     .......... set error -- no convergence to an */
-          /*                eigenvalue after 30 iterations .......... */
+          // Set error: no convergence to an eigenvalue after 30 iterations
           ierr = l + 1;
           return ierr;
           }
         ++j;
-        /*     .......... form shift .......... */
+        // Form shift
         g = d[l];
         p = ( d[l + 1] - g ) / ( e[l] * 2. );
         r = itk::Math::hypot(p, c_b10);
@@ -472,7 +472,7 @@
           }

         f += h;
-        /*     .......... ql transformation .......... */
+        // ql transformation
         p = d[m];
         c = 1.;
         c2 = c;
@@ -522,7 +522,7 @@
       }
     else if ( m_OrderEigenValues == OrderByMagnitude )
       {
-      // Order by magnitude.. make eigen values positive
+      // Order by magnitude. Make eigenvalues positive
       for ( i = l; i > 0; --i )
         {
         if ( itk::Math::abs(p) >= itk::Math::abs(d[i - 1]) )
@@ -539,7 +539,7 @@
       }
     }

-  return ierr;    //ierr'th eigen value that couldn't be computed
+  return ierr; // ierr'th eigenvalue that couldn't be computed
 }

 template< typename TMatrix, typename TVector, typename TEigenMatrix >
@@ -550,7 +550,7 @@
 {
   const double c_b10 = 1.0;

-  /* Local variables */
+  // Local variables
   double       c, f, g, h;
   unsigned int i, j, k, l, m;
   double       p, r, s, c2, c3 = 0.0;
@@ -583,7 +583,7 @@
       tst1 = h;
       }

-    /*     .......... look for small sub-diagonal element .......... */
+    // Look for small sub-diagonal element
     for ( m = l; m < m_Order - 1; ++m )
       {
       tst2 = tst1 + itk::Math::abs(e[m]);
@@ -592,8 +592,7 @@
         break;
         }

-      /*     .......... e(n) is always zero, so there is no exit */
-      /*                through the bottom of the loop .......... */
+      // e(n) is always zero, so there is no exit through the bottom of the loop
       }

     if ( m != l )
@@ -602,13 +601,12 @@
         {
         if ( j == 30 )
           {
-          /*     .......... set error -- no convergence to an */
-          /*                eigenvalue after 30 iterations .......... */
+          // Set error: no convergence to an eigenvalue after 30 iterations
           ierr = l + 1;
           return ierr;
           }
         ++j;
-        /*     .......... form shift .......... */
+        // Form shift
         g = d[l];
         p = ( d[l + 1] - g ) / ( e[l] * 2. );
         r = itk::Math::hypot(p, c_b10);
@@ -623,7 +621,7 @@
           }

         f += h;
-        /*     .......... ql transformation .......... */
+        // ql transformation
         p = d[m];
         c = 1.0;
         c2 = c;
@@ -644,7 +642,7 @@
           p = c * d[i] - s * g;
           d[i + 1] = h + s * ( c * g + s * d[i] );

-          /*     .......... form vector .......... */
+          // Form vector
           for ( k = 0; k < m_Order; ++k )
             {
             h = z[k + ( i + 1 ) * m_Dimension];
@@ -668,7 +666,7 @@
     d[l] += f;
     }

-  /*     .......... order eigenvalues and eigenvectors .......... */
+  // Order eigenvalues and eigenvectors
   if ( m_OrderEigenValues == OrderByValue )
     {
     // Order by value