XFAIL cfi/stats.cpp on Windows until we fix our DIA usage

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@280106 91177308-0d34-0410-b5e6-96231b3b80d8

--- test/cfi/stats.cpp
+++ test/cfi/stats.cpp
@@ -4,6 +4,10 @@

 // FIXME: We currently emit the wrong debug info under devirtualization.
 // UNSUPPORTED: devirt
+
+// FIXME: Currently failing on Windows with a DIA error, so we don't get any
+// symbols.
+// XFAIL: win32

 struct ABase {};


nghttpx: Code cleanup

nghttpx: Code cleanup

--- src/shrpx_client_handler.cc
+++ src/shrpx_client_handler.cc
@@ -540,6 +540,16 @@
   }
 }

+void ClientHandler::set_tls_handshake(bool f)
+{
+  tls_handshake_ = f;
+}
+
+bool ClientHandler::get_tls_handshake() const
+{
+  return tls_handshake_;
+}
+
 namespace {
 void shutdown_cb(evutil_socket_t fd, short what, void *arg)
 {
@@ -553,16 +563,6 @@
 }
 } // namespace

-void ClientHandler::set_tls_handshake(bool f)
-{
-  tls_handshake_ = f;
-}
-
-bool ClientHandler::get_tls_handshake() const
-{
-  return tls_handshake_;
-}
-
 void ClientHandler::set_tls_renegotiation(bool f)
 {
   if(tls_renegotiation_ == false) {


nghttpx: Fix freeze in large transfer

nghttpx: Fix freeze in large transfer

--- src/shrpx_http2_upstream.cc
+++ src/shrpx_http2_upstream.cc
@@ -679,19 +679,18 @@
     // Http2Upstream::remove_downstream().
     upstream->set_pending_data_downstream(downstream, length - nwrite);
   }
-
   if (wb->rleft() == 0) {
     downstream->disable_upstream_wtimer();
   } else {
     downstream->reset_upstream_wtimer();
   }

-  if (length > 0 && downstream->resume_read(SHRPX_NO_BUFFER, length) != 0) {
+  if (nwrite > 0 && downstream->resume_read(SHRPX_NO_BUFFER, nwrite) != 0) {
     return NGHTTP2_ERR_CALLBACK_FAILURE;
   }

-  if (length > 0) {
-    downstream->add_response_sent_bodylen(length);
+  if (nwrite > 0) {
+    downstream->add_response_sent_bodylen(nwrite);
   }

   return nwrite < length ? NGHTTP2_ERR_PAUSE : 0;
@@ -938,16 +937,28 @@

       data_pending_ = nullptr;
     } else {
-      auto n = std::min(wb_.wleft(), data_pendinglen_);
+      auto nwrite = std::min(wb_.wleft(), data_pendinglen_);
       DefaultMemchunks *body;
       if (pending_data_downstream_) {
         body = pending_data_downstream_->get_response_buf();
       } else {
         body = &pending_response_buf_;
       }
-      body->remove(wb_.last, n);
-      wb_.write(n);
-      data_pendinglen_ -= n;
+      body->remove(wb_.last, nwrite);
+      wb_.write(nwrite);
+      data_pendinglen_ -= nwrite;
+
+      if (pending_data_downstream_) {
+        if (nwrite > 0 &&
+            pending_data_downstream_->resume_read(SHRPX_NO_BUFFER, nwrite) !=
+                0) {
+          return -1;
+        }
+
+        if (nwrite > 0) {
+          pending_data_downstream_->add_response_sent_bodylen(nwrite);
+        }
+      }

       if (data_pendinglen_ > 0) {
         return 0;


Set needsLayout on WebViewPlugin's container when initialized

A race condition is suspected in which the first setNeedsLayout call happens between a layout and a paint for a webview plugin. This change ensures that setNeedsLayout... is called on the plugin's container at initialization, which occurs during the correct document lifecycle position.

TBR=bauerb@chromium.org,tommycli@chromium.org
BUG=493375

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

(cherry picked from commit f1bc79582bc8e82060e73119a01e29b5894c16df)

Cr-Original-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#339763}
Cr-Commit-Position: d34a0005849006230ae7ffb1a9693419810a06bc@{#542}
Cr-Branched-From: 40cda19e609fd36fbf5fe489055423e611631abc@{#330231}


[std] remove noexcept() declaration from optional::swap, seems hard to get right outside std::

--- components/std/include/caney/std/optional.hpp
+++ components/std/include/caney/std/optional.hpp
@@ -362,11 +362,8 @@
 	 * @brief swap two values
 	 */
 	/* `noexcept(swap(std::declval<value_type&>(), std::declval<value_type&>()))` only works in std:: and std::-nested namespaces.
-	 * using `noexcept(swap(std::declval<std::tuple<value_type>&>(), std::declval<std::tuple<value_type>&>()))` instead - tuples should have the right thing.
-	 */
-	void swap(optional& other) noexcept(
-		std::is_nothrow_move_constructible<value_type>::value&& noexcept(
-			swap(std::declval<std::tuple<value_type>&>(), std::declval<std::tuple<value_type>&>()))) {
+	 */
+	void swap(optional& other) /* noexcept(is_nothrow_move_constructible<T>::value && noexcept(swap(declval<T&>(), declval<T&>()))) */ {
 		if (*this) {
 			if (other) {
 				using std::swap;


The sort interval is no longer a configuration difference that will break a load

--- src/pic_utils.cpp
+++ src/pic_utils.cpp
@@ -505,10 +505,10 @@
       {
          success &= checkConfigValue(inFile, "OOB_PARTICLE", OOB_PARTICLE);
       }
-      else if(line == "SORT_INTERVAL")
-      {
-         success &= checkConfigValue(inFile, "SORT_INTERVAL", SORT_INTERVAL);
-      }
+      //else if(line == "SORT_INTERVAL")
+      //{
+      //   success &= checkConfigValue(inFile, "SORT_INTERVAL", SORT_INTERVAL);
+      //}
       else if(line == "MAX_THREADS_PER_BLOCK")
       {
          success &= checkConfigValue(inFile, "MAX_THREADS_PER_BLOCK", MAX_THREADS_PER_BLOCK);


Improved AI performance.

Improved AI performance.

--- src/player_ai.cpp
+++ src/player_ai.cpp
@@ -34,12 +34,23 @@

     IndexPath previousPositionOfCursor = this->grid->getSelectedPath();

+    bool recompute = true;
+    std::map<IndexPath, int> distanceToNearestEnemyUnit;
+
+    // Helper function to compute best cell to move.
+    auto nearestEnemy = [&distanceToNearestEnemyUnit](IndexPath i, IndexPath j)
+    -> bool {
+        return distanceToNearestEnemyUnit[i] < distanceToNearestEnemyUnit[j];
+    };
+
     // Now we have to make some decisions...
     // We will call the following callback once each 1.5s.
     this->unitNumber = 0;
-    auto moveSomeUnit = [this, previousPositionOfCursor](int ID) {
-        // Here we will store the units of this AI player and the path where they
-        // are located.
+    auto moveSomeUnit = [this, previousPositionOfCursor, &recompute,
+    &distanceToNearestEnemyUnit, nearestEnemy](int ID) {
+        FMAW::printf("Computing AI data...");
+        // Here we will store the units of this AI player and the path where
+        // they are located.
         std::vector<Unit *> IAunits;
         std::vector<IndexPath> IApaths;
         std::vector<Unit *> playerUnits;
@@ -64,11 +75,10 @@
             }
         }

+        FMAW::printf("\tReady units");
+
         std::map<IndexPath, std::vector<IndexPath>> IAUnitCanAttack;
         std::map<IndexPath, std::vector<IndexPath>> PlayerUnitCanBeAttackedBy;
-
-        std::map<IndexPath, std::vector<IndexPath>> IAUnitsPossibleMovements;
-        std::map<IndexPath, int> distanceToNearestEnemyUnit;

         // Compute which units can attack which ones.
         for (IndexPath p : IApaths) {
@@ -84,47 +94,36 @@
             }
         }

-        // Compute where can be moved IA units.
-        for (IndexPath p : IApaths) {
+        FMAW::printf("\tReady attacks");
+
+        if (recompute) {
+            // Compute distance to nearest visible enemy.
             for (int row = 0; row < this->grid->numRows(); row++) {
-                for (int col = 0; col < this->grid->numCols(); col++)  {
-                    IndexPath t = { row, col };
-                    if (grid->canMoveCharacterFromCellToCell(p, t)) {
-                        IAUnitsPossibleMovements[p].push_back(t);
-                    }
-                }
-            }
-        }
-
-        // Compute distance to nearest visible enemy.
-        for (int row = 0; row < this->grid->numRows(); row++) {
-            for (int col = 0; col < this->grid->numCols(); col++) {
-                IndexPath f = { row, col };
-                Cell *from = grid->cellAtIndexPath(f);
-                distanceToNearestEnemyUnit[f] = COST_CELL_INFINITY;
-                for (int t_row = 0; t_row < this->grid->numRows(); t_row++) {
-                    for (int t_col = 0; t_col < this->grid->numCols(); t_col++) {
-                        IndexPath t = { t_row, t_col };
-                        Cell *to = this->grid->cellAtIndexPath(t);
-                        int distance = abs(t.row - f.row) + abs(t.col - f.col);
-                        if (to->isOccupied()) {
-                            Unit *u = to->getCharacter();
-                            if (this->grid->canSeeCharacterAtCell(t) &&
-                                    u->getOwner() != this->ID) {
-                                distanceToNearestEnemyUnit[f] = distance;
+                for (int col = 0; col < this->grid->numCols(); col++) {
+                    IndexPath f = { row, col };
+                    Cell *from = grid->cellAtIndexPath(f);
+                    distanceToNearestEnemyUnit[f] = COST_CELL_INFINITY;
+                    for (int tr = 0; tr < this->grid->numRows(); tr++) {
+                        for (int tc = 0; tc < this->grid->numCols(); tc++) {
+                            IndexPath t = { tr, tc };
+                            Cell *to = this->grid->cellAtIndexPath(t);
+                            int distance = abs(t.row - f.row) +
+                                           abs(t.col - f.col);
+                            if (to->isOccupied()) {
+                                Unit *u = to->getCharacter();
+                                if (this->grid->canSeeCharacterAtCell(t) &&
+                                        u->getOwner() != this->ID) {
+                                    distanceToNearestEnemyUnit[f] = distance;
+                                }
                             }
                         }
                     }
                 }
             }
-        }
-
-        // Helper function to compute best cell to move.
-        auto nearestEnemy = [&distanceToNearestEnemyUnit](
-                                IndexPath i, IndexPath j
-        ) -> bool {
-            return distanceToNearestEnemyUnit[i] < distanceToNearestEnemyUnit[j];
-        };
+            recompute = false;
+        }
+
+        FMAW::printf("\tReady distances");

         bool canDoSomething = false;
         for (Unit *u : IAunits) {
@@ -185,8 +184,11 @@
                     if (this->grid->pickedUpUnitCanAttackCharacterAtCell(tg)) {
                         FMAW::printf("\tWill attack unit at %d %d",
                                      tg.row, tg.col);
-                        this->grid->attackCharacterAtCell(path, tg,
-                                                          ATTACK_DURATION);
+                        bool kill = this->grid->attackCharacterAtCell(
+                                        path, tg, ATTACK_DURATION);
+                        if (kill) {
+                            recompute = true;
+                        }
                         actionDone = true;
                         break;
                     } else {


More optimizations

More optimizations


fix WLexer pe + 1

fix WLexer pe + 1

--- WSLexer.cpp
+++ WSLexer.cpp
@@ -31,7 +31,7 @@
 {
 	outToken->Clear();

-	if( mpCurrChar == mpHttpStrEnd)
+	if( mpCurrChar == mpHttpStrEnd )
 	{
 		if(flagBracketsOpen || flagQuotesOpen)
 		{
@@ -52,9 +52,10 @@
 			{
 				if( !flagLongWord)
 				{
+					mpCurrChar = mpCurrChar + 1; // I only work with UTF-8 char, it has a length of 1.
+
 					outToken->mType = wsSpaceType;
 					outToken->pe = mpCurrChar;
-					mpCurrChar = mpCurrChar + 1; // I only work with UTF-8 char, it has a length of 1.
 				}
 				else
 				{
@@ -71,9 +72,10 @@
 			{
 				if( !flagLongWord)
 				{
+					mpCurrChar = mpCurrChar + 1;
+
 					outToken->mType = wsSymbolType;
 					outToken->pe = mpCurrChar;
-					mpCurrChar = mpCurrChar + 1;
 				}
 				else
 				{
@@ -85,9 +87,10 @@
 			{
 				if( !flagLongWord )
 				{
+					mpCurrChar = mpCurrChar + 1;
+
 					outToken->mType = wsQuotesSymbolType;
 					outToken->pe = mpCurrChar;
-					mpCurrChar = mpCurrChar + 1;

 					flagQuotesOpen = flagQuotesOpen ? false : true;
 				}
@@ -102,9 +105,10 @@
 			{
 				if( !flagLongWord )
 				{
+					mpCurrChar = mpCurrChar + 1;
+
 					outToken->mType = wsBracketsSymbolType;
 					outToken->pe = mpCurrChar;
-					mpCurrChar = mpCurrChar + 1;

 					flagBracketsOpen = flagBracketsOpen ? false : true;
 				}
@@ -119,9 +123,10 @@
 			{
 				if( !flagLongWord )
 				{
+					mpCurrChar = mpCurrChar + 1;
+
 					outToken->mType = wsNewLineSymbolType;
 					outToken->pe = mpCurrChar;
-					mpCurrChar = mpCurrChar + 1;

 					// if the next symbol is not \n or \r, increase Token::mLen by 1
 					if( !(*(mpCurrChar) == 10 || *(mpCurrChar) == 13) )
@@ -138,9 +143,10 @@
 			// All other symbol
 			default:
 			{
+				mpCurrChar = mpCurrChar + 1;
+
 				outToken->mType = wsDefaultType;
 				outToken->pe = mpCurrChar;
-				mpCurrChar = mpCurrChar + 1;

 				flagLongWord = true;
 			}break;


TS-1475: Fix memory leak in regression tests. Coverity #1022150

--- proxy/RegressionSM.cc
+++ proxy/RegressionSM.cc
@@ -240,10 +240,12 @@

 REGRESSION_TEST(RegressionSM)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
 {
-  r_sequential(t, r_parallel(t, new ReRegressionSM(t), new ReRegressionSM(t), NULL_PTR),
+  RegressionSM *top_sm = r_sequential(t, r_parallel(t, new ReRegressionSM(t), new ReRegressionSM(t), NULL_PTR),
                r_sequential(t, new ReRegressionSM(t), new ReRegressionSM(t), NULL_PTR),
                r_parallel(t, 3, new ReRegressionSM(t)), r_sequential(t, 3, new ReRegressionSM(t)),
                r_parallel(t, r_sequential(t, 2, new ReRegressionSM(t)),
                           r_parallel(t, 2, new ReRegressionSM(t)), NULL_PTR),
-               NULL_PTR)->run(pstatus);
-}
+               NULL_PTR);
+  top_sm->run(pstatus);
+  delete top_sm;
+}


removed redundant MSVC code

removed redundant MSVC code

--- test/run_tests.cpp
+++ test/run_tests.cpp
@@ -1,7 +1,4 @@
 #include <gtest/gtest.h>
-
-// windows
-//#pragma comment(lib, "gtestd.lib")

 int main(int argc, char* argv[])
 {


am 37f7775b: Slightly clearer reflection.

* commit '37f7775b92398d87e48bc306f9d10a1b563dcdd5':
  Slightly clearer reflection.

--- src/reflection.cc
+++ src/reflection.cc
@@ -90,13 +90,10 @@
   for (uint32_t i = 0; i < arg_count; ++i) {
     Object* arg = objects->Get(i);
     Class* dst_class = mh.GetClassFromTypeIdx(classes->GetTypeItem(i).type_idx_);
-    if (dst_class->IsPrimitive() || (arg != NULL && !arg->InstanceOf(dst_class))) {
-      // We want to actually unbox primitives, but only reuse the error reporting for reference types.
-      if (!UnboxPrimitiveForArgument(arg, dst_class, decoded_args[i], m, i)) {
-        return NULL;
-      }
-    } else {
-      // We already tested that these types are compatible.
+    if (!UnboxPrimitiveForArgument(arg, dst_class, decoded_args[i], m, i)) {
+      return NULL;
+    }
+    if (!dst_class->IsPrimitive()) {
       args[i].l = AddLocalReference<jobject>(env, arg);
     }
   }


Regex: cleanup and reorganize regex code and improve capture support

Introduce the CompiledRegex class, rename ThreadedExecutor to
ThreadedRegexVM, remove the RegexProgram namespace.

--- src/regex_impl.cc
+++ src/regex_impl.cc
@@ -9,26 +9,29 @@
 namespace Kakoune
 {

-namespace RegexProgram
-{
-enum Op : char
-{
-    Match,
-    Literal,
-    AnyChar,
-    Jump,
-    Split,
-    Save,
-    LineStart,
-    LineEnd,
-    WordBoundary,
-    NotWordBoundary,
-    SubjectBegin,
-    SubjectEnd,
+struct CompiledRegex
+{
+    enum Op : char
+    {
+        Match,
+        Literal,
+        AnyChar,
+        Jump,
+        Split,
+        Save,
+        LineStart,
+        LineEnd,
+        WordBoundary,
+        NotWordBoundary,
+        SubjectBegin,
+        SubjectEnd,
+    };
+
+    using Offset = size_t;
+
+    Vector<char> bytecode;
+    size_t save_count;
 };
-
-using Offset = size_t;
-}

 namespace RegexCompiler
 {
@@ -99,6 +102,8 @@
     {
         return disjunction(pos, end, 0);
     }
+
+    size_t capture_count() const { return m_next_capture; }

 private:
     AstNodePtr disjunction(Iterator& pos, Iterator end, char capture = -1)
@@ -224,40 +229,40 @@
     char m_next_capture = 1;
 };

-RegexProgram::Offset compile_node(Vector<char>& program, const AstNodePtr& node);
-
-RegexProgram::Offset alloc_offset(Vector<char>& instructions)
-{
-    auto pos = instructions.size();
-    instructions.resize(instructions.size() + sizeof(RegexProgram::Offset));
+CompiledRegex::Offset compile_node(CompiledRegex& program, const AstNodePtr& node);
+
+CompiledRegex::Offset alloc_offset(CompiledRegex& program)
+{
+    auto pos = program.bytecode.size();
+    program.bytecode.resize(pos + sizeof(CompiledRegex::Offset));
     return pos;
 }

-RegexProgram::Offset& get_offset(Vector<char>& instructions, RegexProgram::Offset base)
-{
-    return *reinterpret_cast<RegexProgram::Offset*>(&instructions[base]);
-}
-
-RegexProgram::Offset compile_node_inner(Vector<char>& program, const AstNodePtr& node)
-{
-    const auto start_pos = program.size();
+CompiledRegex::Offset& get_offset(CompiledRegex& program, CompiledRegex::Offset pos)
+{
+    return *reinterpret_cast<CompiledRegex::Offset*>(&program.bytecode[pos]);
+}
+
+CompiledRegex::Offset compile_node_inner(CompiledRegex& program, const AstNodePtr& node)
+{
+    const auto start_pos = program.bytecode.size();

     const char capture = (node->op == Op::Alternation or node->op == Op::Sequence) ? node->value : -1;
     if (capture >= 0)
     {
-        program.push_back(RegexProgram::Save);
-        program.push_back(capture * 2);
-    }
-
-    Vector<RegexProgram::Offset> goto_inner_end_offsets;
+        program.bytecode.push_back(CompiledRegex::Save);
+        program.bytecode.push_back(capture * 2);
+    }
+
+    Vector<CompiledRegex::Offset> goto_inner_end_offsets;
     switch (node->op)
     {
         case Op::Literal:
-            program.push_back(RegexProgram::Literal);
-            program.push_back(node->value);
+            program.bytecode.push_back(CompiledRegex::Literal);
+            program.bytecode.push_back(node->value);
             break;
         case Op::AnyChar:
-            program.push_back(RegexProgram::AnyChar);
+            program.bytecode.push_back(CompiledRegex::AnyChar);
             break;
         case Op::Sequence:
             for (auto& child : node->children)
@@ -268,11 +273,11 @@
             auto& children = node->children;
             kak_assert(children.size() == 2);

-            program.push_back(RegexProgram::Split);
+            program.bytecode.push_back(CompiledRegex::Split);
             auto offset = alloc_offset(program);

             compile_node(program, children[0]);
-            program.push_back(RegexProgram::Jump);
+            program.bytecode.push_back(CompiledRegex::Jump);
             goto_inner_end_offsets.push_back(alloc_offset(program));

             auto right_pos = compile_node(program, children[1]);
@@ -281,45 +286,45 @@
             break;
         }
         case Op::LineStart:
-            program.push_back(RegexProgram::LineStart);
+            program.bytecode.push_back(CompiledRegex::LineStart);
             break;
         case Op::LineEnd:
-            program.push_back(RegexProgram::LineEnd);
+            program.bytecode.push_back(CompiledRegex::LineEnd);
             break;
         case Op::WordBoundary:
-            program.push_back(RegexProgram::WordBoundary);
+            program.bytecode.push_back(CompiledRegex::WordBoundary);
             break;
         case Op::NotWordBoundary:
-            program.push_back(RegexProgram::NotWordBoundary);
+            program.bytecode.push_back(CompiledRegex::NotWordBoundary);
             break;
         case Op::SubjectBegin:
-            program.push_back(RegexProgram::SubjectBegin);
+            program.bytecode.push_back(CompiledRegex::SubjectBegin);
             break;
         case Op::SubjectEnd:
-            program.push_back(RegexProgram::SubjectEnd);
+            program.bytecode.push_back(CompiledRegex::SubjectEnd);
             break;
     }

     for (auto& offset : goto_inner_end_offsets)
-        get_offset(program, offset) =  program.size();
+        get_offset(program, offset) =  program.bytecode.size();

     if (capture >= 0)
     {
-        program.push_back(RegexProgram::Save);
-        program.push_back(capture * 2 + 1);
+        program.bytecode.push_back(CompiledRegex::Save);
+        program.bytecode.push_back(capture * 2 + 1);
     }

     return start_pos;
 }

-RegexProgram::Offset compile_node(Vector<char>& program, const AstNodePtr& node)
-{
-    RegexProgram::Offset pos = program.size();
-    Vector<RegexProgram::Offset> goto_end_offsets;
+CompiledRegex::Offset compile_node(CompiledRegex& program, const AstNodePtr& node)
+{
+    CompiledRegex::Offset pos = program.bytecode.size();
+    Vector<CompiledRegex::Offset> goto_end_offsets;

     if (node->quantifier.allows_none())
     {
-        program.push_back(RegexProgram::Split);
+        program.bytecode.push_back(CompiledRegex::Split);
         goto_end_offsets.push_back(alloc_offset(program));
     }

@@ -330,94 +335,96 @@

     if (node->quantifier.allows_infinite_repeat())
     {
-        program.push_back(RegexProgram::Split);
+        program.bytecode.push_back(CompiledRegex::Split);
         get_offset(program, alloc_offset(program)) = inner_pos;
     }
     // Write the node as an optional match for the min -> max counts
     else for (int i = std::max(1, node->quantifier.min); // STILL UGLY !
               i < node->quantifier.max; ++i)
     {
-        program.push_back(RegexProgram::Split);
+        program.bytecode.push_back(CompiledRegex::Split);
         goto_end_offsets.push_back(alloc_offset(program));
         compile_node_inner(program, node);
     }

     for (auto offset : goto_end_offsets)
-        get_offset(program, offset) = program.size();
+        get_offset(program, offset) = program.bytecode.size();

     return pos;
 }

-Vector<char> compile(const AstNodePtr& node)
-{
-    Vector<char> res;
+CompiledRegex compile(const AstNodePtr& node, size_t capture_count)
+{
+    CompiledRegex res;
     compile_node(res, node);
-    res.push_back(RegexProgram::Match);
+    res.bytecode.push_back(CompiledRegex::Match);
+    res.save_count = capture_count * 2;
     return res;
 }

 template<typename Iterator>
-Vector<char> compile(Iterator begin, Iterator end)
-{
-    return compile(Parser<Iterator>{}.parse(begin, end));
-}
-}
-
-namespace RegexProgram
-{
-void dump(ConstArrayView<char> program)
-{
-    for (size_t pos = 0; pos < program.size(); )
-    {
-        printf("%4zd    ", pos);
-        switch ((RegexProgram::Op)program[pos++])
-        {
-            case RegexProgram::Literal:
-                printf("literal %c\n", program[pos++]);
-                break;
-            case RegexProgram::AnyChar:
+CompiledRegex compile(Iterator begin, Iterator end)
+{
+    Parser<Iterator> parser;
+    auto node = parser.parse(begin, end);
+    return compile(node, parser.capture_count());
+}
+
+}
+
+void dump(const CompiledRegex& program)
+{
+    for (auto pos = program.bytecode.begin(); pos < program.bytecode.end(); )
+    {
+        printf("%4zd    ", pos - program.bytecode.begin());
+        switch ((CompiledRegex::Op)*pos++)
+        {
+            case CompiledRegex::Literal:
+                printf("literal %c\n", *pos++);
+                break;
+            case CompiledRegex::AnyChar:
                 printf("any char\n");
                 break;
-            case RegexProgram::Jump:
-                printf("jump %zd\n", *reinterpret_cast<const RegexProgram::Offset*>(&program[pos]));
-                pos += sizeof(RegexProgram::Offset);
-                break;
-            case RegexProgram::Split:
+            case CompiledRegex::Jump:
+                printf("jump %zd\n", *reinterpret_cast<const CompiledRegex::Offset*>(&*pos));
+                pos += sizeof(CompiledRegex::Offset);
+                break;
+            case CompiledRegex::Split:
             {
-                printf("split %zd\n", *reinterpret_cast<const RegexProgram::Offset*>(&program[pos]));
-                pos += sizeof(RegexProgram::Offset);
+                printf("split %zd\n", *reinterpret_cast<const CompiledRegex::Offset*>(&*pos));
+                pos += sizeof(CompiledRegex::Offset);
                 break;
             }
-            case RegexProgram::Save:
-                printf("save %d\n", program[pos++]);
-                break;
-            case RegexProgram::LineStart:
+            case CompiledRegex::Save:
+                printf("save %d\n", *pos++);
+                break;
+            case CompiledRegex::LineStart:
                 printf("line start\n");
                 break;
-            case RegexProgram::LineEnd:
+            case CompiledRegex::LineEnd:
                 printf("line end\n");
                 break;
-            case RegexProgram::WordBoundary:
+            case CompiledRegex::WordBoundary:
                 printf("word boundary\n");
                 break;
-            case RegexProgram::NotWordBoundary:
+            case CompiledRegex::NotWordBoundary:
                 printf("not word boundary\n");
                 break;
-            case RegexProgram::SubjectBegin:
+            case CompiledRegex::SubjectBegin:
                 printf("subject begin\n");
                 break;
-            case RegexProgram::SubjectEnd:
+            case CompiledRegex::SubjectEnd:
                 printf("subject end\n");
                 break;
-            case RegexProgram::Match:
+            case CompiledRegex::Match:
                 printf("match\n");
         }
     }
 }

-struct ThreadedExecutor
-{
-    ThreadedExecutor(ConstArrayView<char> program) : m_program{program} {}
+struct ThreadedRegexVM
+{
+    ThreadedRegexVM(const CompiledRegex& program) : m_program{program} {}

     struct Thread
     {
@@ -432,18 +439,18 @@
         {
             auto& thread = m_threads[thread_index];
             char c = m_pos == m_subject.end() ? 0 : *m_pos;
-            const RegexProgram::Op op = (RegexProgram::Op)*thread.inst++;
+            const CompiledRegex::Op op = (CompiledRegex::Op)*thread.inst++;
             switch (op)
             {
-                case RegexProgram::Literal:
+                case CompiledRegex::Literal:
                     if (*thread.inst++ == c)
                         return StepResult::Consumed;
                     return StepResult::Failed;
-                case RegexProgram::AnyChar:
+                case CompiledRegex::AnyChar:
                     return StepResult::Consumed;
-                case RegexProgram::Jump:
+                case CompiledRegex::Jump:
                 {
-                    auto inst = m_program.begin() + *reinterpret_cast<const RegexProgram::Offset*>(thread.inst);
+                    auto inst = m_program.bytecode.data() + *reinterpret_cast<const CompiledRegex::Offset*>(thread.inst);
                     // if instruction is already going to be executed, drop this thread
                     if (std::find_if(m_threads.begin(), m_threads.end(),
                                      [inst](const Thread& t) { return t.inst == inst; }) != m_threads.end())
@@ -451,54 +458,54 @@
                     thread.inst = inst;
                     break;
                 }
-                case RegexProgram::Split:
+                case CompiledRegex::Split:
                 {
-                    add_thread(*reinterpret_cast<const RegexProgram::Offset*>(thread.inst), thread.saves);
+                    add_thread(*reinterpret_cast<const CompiledRegex::Offset*>(thread.inst), thread.saves);
                     // thread is invalidated now, as we mutated the m_thread vector
-                    m_threads[thread_index].inst += sizeof(RegexProgram::Offset);
+                    m_threads[thread_index].inst += sizeof(CompiledRegex::Offset);
                     break;
                 }
-                case RegexProgram::Save:
+                case CompiledRegex::Save:
                 {
                     const char index = *thread.inst++;
                     thread.saves[index] = m_pos;
                     break;
                 }
-                case RegexProgram::LineStart:
+                case CompiledRegex::LineStart:
                     if (not is_line_start())
                         return StepResult::Failed;
                     break;
-                case RegexProgram::LineEnd:
+                case CompiledRegex::LineEnd:
                     if (not is_line_end())
                         return StepResult::Failed;
                     break;
-                case RegexProgram::WordBoundary:
+                case CompiledRegex::WordBoundary:
                     if (not is_word_boundary())
                         return StepResult::Failed;
                     break;
-                case RegexProgram::NotWordBoundary:
+                case CompiledRegex::NotWordBoundary:
                     if (is_word_boundary())
                         return StepResult::Failed;
                     break;
-                case RegexProgram::SubjectBegin:
+                case CompiledRegex::SubjectBegin:
                     if (m_pos != m_subject.begin())
                         return StepResult::Failed;
                     break;
-                case RegexProgram::SubjectEnd:
+                case CompiledRegex::SubjectEnd:
                     if (m_pos != m_subject.end())
                         return StepResult::Failed;
                     break;
-                case RegexProgram::Match:
+                case CompiledRegex::Match:
                     return StepResult::Matched;
             }
         }
         return StepResult::Failed;
     }

-    bool match(ConstArrayView<char> program, StringView data)
+    bool match(StringView data)
     {
         m_threads.clear();
-        add_thread(0, Vector<const char*>(10, nullptr));
+        add_thread(0, Vector<const char*>(m_program.save_count, nullptr));

         m_subject = data;
         m_pos = data.begin();
@@ -534,9 +541,9 @@
         return false;
     }

-    void add_thread(RegexProgram::Offset pos, Vector<const char*> saves)
-    {
-        const char* inst = m_program.begin() + pos;
+    void add_thread(CompiledRegex::Offset pos, Vector<const char*> saves)
+    {
+        const char* inst = m_program.bytecode.data() + pos;
         if (std::find_if(m_threads.begin(), m_threads.end(),
                          [inst](const Thread& t) { return t.inst == inst; }) == m_threads.end())
             m_threads.push_back({inst, std::move(saves)});
@@ -559,104 +566,102 @@
                is_word(*(m_pos-1)) != is_word(*m_pos);
     }

-    ConstArrayView<char> m_program;
+    const CompiledRegex& m_program;
     Vector<Thread> m_threads;
     Vector<const char*> m_captures;
     StringView m_subject;
     const char* m_pos;
 };
-}

 auto test_regex = UnitTest{[]{
-    using Exec = RegexProgram::ThreadedExecutor;
     {
         StringView re = R"(a*b)";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(exec.match(program, "b"));
-        kak_assert(exec.match(program, "ab"));
-        kak_assert(exec.match(program, "aaab"));
-        kak_assert(not exec.match(program, "acb"));
-        kak_assert(not exec.match(program, ""));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(vm.match("b"));
+        kak_assert(vm.match("ab"));
+        kak_assert(vm.match("aaab"));
+        kak_assert(not vm.match("acb"));
+        kak_assert(not vm.match(""));
     }

     {
         StringView re = R"(^a.*b$)";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(exec.match(program, "afoob"));
-        kak_assert(exec.match(program, "ab"));
-        kak_assert(not exec.match(program, "bab"));
-        kak_assert(not exec.match(program, ""));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(vm.match("afoob"));
+        kak_assert(vm.match("ab"));
+        kak_assert(not vm.match("bab"));
+        kak_assert(not vm.match(""));
     }

     {
         StringView re = R"(^(foo|qux|baz)+(bar)?baz$)";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(exec.match(program, "fooquxbarbaz"));
-        kak_assert(StringView{exec.m_captures[2], exec.m_captures[3]} == "qux");
-        kak_assert(not exec.match(program, "fooquxbarbaze"));
-        kak_assert(not exec.match(program, "quxbar"));
-        kak_assert(not exec.match(program, "blahblah"));
-        kak_assert(exec.match(program, "bazbaz"));
-        kak_assert(exec.match(program, "quxbaz"));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(vm.match("fooquxbarbaz"));
+        kak_assert(StringView{vm.m_captures[2], vm.m_captures[3]} == "qux");
+        kak_assert(not vm.match("fooquxbarbaze"));
+        kak_assert(not vm.match("quxbar"));
+        kak_assert(not vm.match("blahblah"));
+        kak_assert(vm.match("bazbaz"));
+        kak_assert(vm.match("quxbaz"));
     }

     {
         StringView re = R"(.*\b(foo|bar)\b.*)";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(exec.match(program, "qux foo baz"));
-        kak_assert(StringView{exec.m_captures[2], exec.m_captures[3]} == "foo");
-        kak_assert(not exec.match(program, "quxfoobaz"));
-        kak_assert(exec.match(program, "bar"));
-        kak_assert(not exec.match(program, "foobar"));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(vm.match("qux foo baz"));
+        kak_assert(StringView{vm.m_captures[2], vm.m_captures[3]} == "foo");
+        kak_assert(not vm.match("quxfoobaz"));
+        kak_assert(vm.match("bar"));
+        kak_assert(not vm.match("foobar"));
     }
     {
         StringView re = R"(\`(foo|bar)\')";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(exec.match(program, "foo"));
-        kak_assert(exec.match(program, "bar"));
-        kak_assert(not exec.match(program, "foobar"));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(vm.match("foo"));
+        kak_assert(vm.match("bar"));
+        kak_assert(not vm.match("foobar"));
     }

     {
         StringView re = R"(\`a{3,5}b\')";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(not exec.match(program, "aab"));
-        kak_assert(exec.match(program, "aaab"));
-        kak_assert(not exec.match(program, "aaaaaab"));
-        kak_assert(exec.match(program, "aaaaab"));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(not vm.match("aab"));
+        kak_assert(vm.match("aaab"));
+        kak_assert(not vm.match("aaaaaab"));
+        kak_assert(vm.match("aaaaab"));
     }

     {
         StringView re = R"(\`a{3,}b\')";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(not exec.match(program, "aab"));
-        kak_assert(exec.match(program, "aaab"));
-        kak_assert(exec.match(program, "aaaaab"));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(not vm.match("aab"));
+        kak_assert(vm.match("aaab"));
+        kak_assert(vm.match("aaaaab"));
     }

     {
         StringView re = R"(\`a{,3}b\')";
         auto program = RegexCompiler::compile(re.begin(), re.end());
-        RegexProgram::dump(program);
-        Exec exec{program};
-        kak_assert(exec.match(program, "b"));
-        kak_assert(exec.match(program, "ab"));
-        kak_assert(exec.match(program, "aaab"));
-        kak_assert(not exec.match(program, "aaaab"));
+        dump(program);
+        ThreadedRegexVM vm{program};
+        kak_assert(vm.match("b"));
+        kak_assert(vm.match("ab"));
+        kak_assert(vm.match("aaab"));
+        kak_assert(not vm.match("aaaab"));
     }
 }};


Added notes about the two failing tests - that they're (I think) bugs in the YAML spec

--- test/spectests.cpp
+++ test/spectests.cpp
@@ -2032,7 +2032,7 @@
 			YAML_ASSERT(doc.size() == 3);
 			YAML_ASSERT(doc["strip"].to<std::string>() == "# text");
 			YAML_ASSERT(doc["clip"].to<std::string>() == "# text\n");
-			YAML_ASSERT(doc["keep"].to<std::string>() == "# text\n");
+			YAML_ASSERT(doc["keep"].to<std::string>() == "# text\n"); // Note: I believe this is a bug in the YAML spec - it should be "# text\n\n"
 			return true;
 		}

@@ -2290,7 +2290,7 @@

 			PARSE(doc, input);
 			YAML_ASSERT(doc.size() == 2);
-			YAML_ASSERT(doc["literal"].to<std::string>() == "value");
+			YAML_ASSERT(doc["literal"].to<std::string>() == "value"); // Note: I believe this is a bug in the YAML spec - it should be "value\n"
 			YAML_ASSERT(doc["folded"].to<std::string>() == "value");
 			YAML_ASSERT(doc["folded"].Tag() == "!foo");
 			return true;


use rand() replacements

use rand() replacements

git-svn-id: 8421b90a9a43b47d1a188336984f00166a5c4842@748 366fa382-4619-0410-88af-c27c993b82fa

--- src/ri/object.cpp
+++ src/ri/object.cpp
@@ -39,7 +39,7 @@
 #include "surface.h"
 #include "rendererContext.h"
 #include "renderer.h"
-
+#include "random.h"

@@ -116,12 +116,10 @@
 	int		i;
 	float	alpha;

-#define urand()	rand() / (float) RAND_MAX
-
-	tmp[0]	=	urand();
-	tmp[1]	=	urand();
-	tmp[2]	=	urand();
-	tmp[3]	=	urand();
+	tmp[0]	=	_urand();
+	tmp[1]	=	_urand();
+	tmp[2]	=	_urand();
+	tmp[3]	=	_urand();

 	for (i=0;i<10;i++) {
 		mulmp4(tmp2,mat,tmp);


rodrigues.cpp: move constants outside loop in advance_angular.

--- src/rodrigues.cpp
+++ src/rodrigues.cpp
@@ -168,28 +168,29 @@
 void advance_angular (float (* u) [4], float (* w) [4], unsigned count, float dt)
 {
   v4f dt0 = _mm_set1_ps (dt);
+  v4f one = { 1.0f, 1.0f, 1.0f, 1.0f, };
+  v4f twopi = { 0x1.921fb6P2f, 0x1.921fb6P2f, 0x1.921fb6P2f, 0x1.921fb6P2f, };
+  v4f lim1 = { +0x1.3c0000P3f, 0.0f, 0.0f, 0.0f, }; // a touch over pi^2 (~ +0x1.3bd3ccP3)
   for (unsigned n = 0; n != count; ++ n) {
     v4f u1 = bch (dt0 * load4f (w [n]), load4f (u [n]));
     v4f xsq = dot (u1, u1);
-    v4f lim1 = { +0x1.634e46P4f, 0.0f, 0.0f, 0.0f, }; // (3pi/2)^2
     if (_mm_comigt_ss (xsq, lim1)) {
-      v4f one = { 1.0f, 1.0f, 1.0f, 1.0f, };
-      v4f twopi = { 0x1.921fb6P2f, 0x1.921fb6P2f, 0x1.921fb6P2f, 0x1.921fb6P2f, };
       u1 *= one - twopi * rsqrt (xsq);
     }
     store4f (u [n], u1);
   }
 }

-void compute (float (* f) [16], const float (* x) [4], const float (* u) [4], unsigned count)
+void compute (char * buffer, std::size_t stride, const float (* x) [4], const float (* u) [4], unsigned count)
 {
 #if __SSE4_1__
 #else
   __m128i iv = { 0, -0x100000000ll, };
   v4f mask = _mm_castsi128_ps (iv);    // false false false true
 #endif
-
-  for (unsigned n = 0; n != count; ++ n) {
+  char * iter = buffer;
+  for (unsigned n = 0; n != count; ++ n, iter += stride) {
+    float (& f) [16] = * reinterpret_cast <float (*) [16]> (iter);
     v4f u0 = load4f (u [n]);           // u0 u1 u2 0
     v4f usq = u0 * u0;                 // u0^2 u1^2 u2^2 0
     v4f uha = _mm_hadd_ps (usq, usq);
@@ -216,10 +217,10 @@
     v4f phi = _mm_andnot_ps (mask, phicos);
     v4f xyz1 = _mm_or_ps (_mm_andnot_ps (mask, xyz0), _mm_and_ps (mask, one));
 #endif
-    store4f (& f [n] [0], _mm_shuffle_ps (ashd, sub, SHUFFLE (2, 0, 1, 3)));  // d0 a2 s1 0
-    store4f (& f [n] [4], _mm_shuffle_ps (ashd, add, SHUFFLE (1, 3, 0, 3)));  // s2 d1 a0 0
-    store4f (& f [n] [8], _mm_shuffle_ps (aslo, phi, SHUFFLE (1, 2, 2, 3)));  // a1 s0 d2 0
-    store4f (& f [n] [12], xyz1);                                             // x0 x1 x2 1
+    store4f (& f [0], _mm_shuffle_ps (ashd, sub, SHUFFLE (2, 0, 1, 3)));  // d0 a2 s1 0
+    store4f (& f [4], _mm_shuffle_ps (ashd, add, SHUFFLE (1, 3, 0, 3)));  // s2 d1 a0 0
+    store4f (& f [8], _mm_shuffle_ps (aslo, phi, SHUFFLE (1, 2, 2, 3)));  // a1 s0 d2 0
+    store4f (& f [12], xyz1);                                             // x0 x1 x2 1
   }
 }


Fixing warnings in transpose tests

Fixing warnings in transpose tests

--- test/transpose.cpp
+++ test/transpose.cpp
@@ -68,7 +68,7 @@

     ASSERT_EQ(AF_SUCCESS, af_get_data_ptr((void*)outData, outArray));

-    for (int testIter=0; testIter<tests.size(); ++testIter) {
+    for (size_t testIter=0; testIter<tests.size(); ++testIter) {
         vector<T> currGoldBar   = tests[testIter];
         size_t nElems        = currGoldBar.size();
         for (size_t elIter=0; elIter<nElems; ++elIter) {


format

format

--- test/unit_test.cpp
+++ test/unit_test.cpp
@@ -223,7 +223,7 @@
 REFLECTION(ee_t, e);

 TEST_CASE("test enum") {
-  ee_t t{ .e = ee::bb };
+  ee_t t{.e = ee::bb};
   std::string str;
   iguana::to_json(str, t);


Try harder to get the compiler to use float registers in different
places to increase the chance of messing up any preserved registers.

git-svn-id: 6a9f6578bdee8d959f0ed58970538b4ab6004734@207938 91177308-0d34-0410-b5e6-96231b3b80d8

--- test/unwind_06.cpp
+++ test/unwind_06.cpp
@@ -14,30 +14,38 @@

 // Compile with -Os to get compiler uses float registers to hold float variables

-__attribute__((noinline))
-double get(int x) { return (double)x; }
-
+double get_(int x) { return (double)x; }
+
+double (* volatile get)(int) = get_;
+
+volatile int counter;

 double try1(bool v) {
   double a = get(0);
-  double b = get(0);
+  double b = get(1);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b;
   if (v) throw 10;
   return get(0)+a+b;
 }

 double try2(bool v) {
   double a = get(0);
-  double b = get(0);
-  double c = get(0);
+  double b = get(1);
+  double c = get(2);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b + c;
   if (v) throw 10;
   return get(0)+a+b+c;
 }

 double try3(bool v) {
   double a = get(0);
-  double b = get(0);
-  double c = get(0);
-  double d = get(0);
+  double b = get(1);
+  double c = get(2);
+  double d = get(3);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b + c + d;
   if (v) throw 10;
   return get(0)+a+b+c+d;
 }
@@ -48,6 +56,8 @@
   double c = get(0);
   double d = get(0);
   double e = get(0);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b+c+d+e;
   if (v) throw 10;
   return get(0)+a+b+c+d+e;
 }
@@ -59,6 +69,8 @@
   double d = get(0);
   double e = get(0);
   double f = get(0);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b+c+d+e+f;
   if (v) throw 10;
   return get(0)+a+b+c+d+e+f;
 }
@@ -71,6 +83,8 @@
   double e = get(0);
   double f = get(0);
   double g = get(0);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b+c+d+e+f+g;
   if (v) throw 10;
   return get(0)+a+b+c+d+e+f+g;
 }
@@ -84,6 +98,8 @@
   double f = get(0);
   double g = get(0);
   double h = get(0);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b+c+d+e+f+g;
   if (v) throw 10;
   return get(0)+a+b+c+d+e+f+g;
 }
@@ -98,6 +114,8 @@
   double g = get(0);
   double h = get(0);
   double i = get(0);
+  for (counter = 100; counter; --counter)
+    a += get(1) + b+c+d+e+f+g+i;
   if (v) throw 10;
   return get(0)+a+b+c+d+e+f+g+i;
 }


fix a complie bug

fix a complie bug

Signed-off-by: ranger.shi <ranger.shi@gmail.com>

Former-commit-id: 4253109aa3d4c26bf1c560914828e759502e6398 [formerly 5bee4be443ebe8c62d590b6f43f96dd7836b0b63]
Former-commit-id: cb1a4f8332e8ada09cc06d33ad1121ce15d7b206

--- src/rpc/rpctx.cpp
+++ src/rpc/rpctx.cpp
@@ -1636,7 +1636,7 @@
 		Array ComfirmTx;
 		for (auto const &wtx : pwalletMain->mapInBlockTx) {
 			for (auto const & item : wtx.second.mapAccountTx) {
-				Object objtx = GetTxDetailJSON(item.first, false);
+				Object objtx = GetTxDetailJSON(item.first);
 				ComfirmTx.push_back(objtx);
 			}
 		}
@@ -1645,7 +1645,7 @@
 		Array UnComfirmTx;
 		CAccountViewCache view(*pAccountViewTip, true);
 		for (auto const &wtx : pwalletMain->UnConfirmTx) {
-			Object objtx = GetTxDetailJSON(wtx.first, false);
+			Object objtx = GetTxDetailJSON(wtx.first);
 			UnComfirmTx.push_back(objtx);
 		}
 		retObj.push_back(Pair("UnConfirmed", UnComfirmTx));


tests: Error when setgenerate is used on regtest

Ever since #5957 there has been the problem that older RPC test cases
(as can be found plenty in open pulls) use setgenerate() on regtest,
assuming a different interpretation of the arguments. Directly
generating a number of blocks has been split off into a new method
`generate` - however using `setgenerate` with the previous arguments will
result in spawning an unreasonable number of threads, and well, simply
not work as expected without clear indication of the error.

Add an error to point the user at the right method.

--- src/rpcmining.cpp
+++ src/rpcmining.cpp
@@ -196,6 +196,8 @@

     if (pwalletMain == NULL)
         throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
+    if (Params().MineBlocksOnDemand())
+        throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Use the generate method instead of setgenerate on this network");

     bool fGenerate = true;
     if (params.size() > 0)


improved the parser, now every time we receive T character we reset the input_buffer

--- src/terarangerone.cpp
+++ src/terarangerone.cpp
@@ -66,7 +66,7 @@

   // Output loaded parameters to console for double checking
   ROS_INFO("[%s] is up and running with the following parameters:", ros::this_node::getName().c_str());
-  ROS_INFO("[%s] portname: %s",ros::this_node::getName().c_str(), portname_.c_str());
+  ROS_INFO("[%s] portname: %s", ros::this_node::getName().c_str(), portname_.c_str());

   // Set operation Mode
   setMode(BINARY_MODE);
@@ -105,42 +105,68 @@
   range_msg.min_range = 0.2;
   range_msg.radiation_type = sensor_msgs::Range::INFRARED;

+// Debug Code to show the buffer
+//  if (single_character == 'T')
+//  {
+//    ROS_INFO("TTTT single_character = %3d, buffer_ctr = %d |%3d|%3d|%3d|%3d|", single_character, buffer_ctr,
+//             input_buffer[0], input_buffer[1], input_buffer[2], input_buffer[3]);
+//  }
+//  else
+//  {
+//    ROS_INFO("#### single_character = %3d, buffer_ctr = %d |%3d|%3d|%3d|%3d|", single_character, buffer_ctr,
+//             input_buffer[0], input_buffer[1], input_buffer[2], input_buffer[3]);
+//  }
+
   if (single_character != 'T' && buffer_ctr < 4)
   {
     // not begin of serial feed so add char to buffer
     input_buffer[buffer_ctr++] = single_character;
-  }
-  else if (single_character == 'T' && buffer_ctr == 4)
-  {
-    // end of feed, calculate
-    int16_t crc = crc8(input_buffer, 3);
-
-    if (crc == input_buffer[3])
+    return;
+  }
+  else if (single_character == 'T')
+  {
+    if (buffer_ctr == 4)
     {
-      int16_t range = input_buffer[1] << 8;
-      range |= input_buffer[2];
-
-      if (range < 14000 && range > 200)
+      // end of feed, calculate
+      int16_t crc = crc8(input_buffer, 3);
+
+      if (crc == input_buffer[3])
       {
-        range_msg.header.stamp = ros::Time::now();
-        range_msg.header.seq = seq_ctr++;
-        range_msg.range = range * 0.001; // convert to m
-        range_publisher_.publish(range_msg);
+        int16_t range = input_buffer[1] << 8;
+        range |= input_buffer[2];
+
+        if (range < 14000 && range > 200)
+        {
+          range_msg.header.stamp = ros::Time::now();
+          range_msg.header.seq = seq_ctr++;
+          range_msg.range = range * 0.001; // convert to m
+          range_publisher_.publish(range_msg);
+        }
+        ROS_DEBUG("[%s] all good %.3f m", ros::this_node::getName().c_str(), range_msg.range);
+      }
+      else
+      {
+        ROS_DEBUG("[%s] crc missmatch", ros::this_node::getName().c_str());
       }
     }
-    // reset
-    buffer_ctr = 0;
-
-    // clear struct
-    bzero(&input_buffer, BUFFER_SIZE);
-    // store T
-    input_buffer[buffer_ctr++] = single_character;
-
-  }
-  else if (buffer_ctr >= 4)
-  {
-    buffer_ctr = 0;
-  }
+    else
+    {
+      ROS_DEBUG("[%s] reveived T but did not expect it, reset buffer without evaluating data",
+               ros::this_node::getName().c_str());
+    }
+  }
+  else
+  {
+    ROS_DEBUG("[%s] buffer_overflowed without receiving T, reset input_buffer", ros::this_node::getName().c_str());
+  }
+  // reset
+  buffer_ctr = 0;
+
+  // clear struct
+  bzero(&input_buffer, BUFFER_SIZE);
+
+  // store T
+  input_buffer[buffer_ctr++] = 'T';
 }

 void TerarangerOne::setMode(char c)


Removed some silliness

Removed some silliness

--- src/rpcmining.cpp
+++ src/rpcmining.cpp
@@ -166,7 +166,7 @@
     if (vNodes.empty())
         throw JSONRPCError(-9, "Mojocoin is not connected!");

-    if (IsInitialBlockDownload() && pindexBest->nHeight > 100)
+    if (IsInitialBlockDownload())
         throw JSONRPCError(-10, "Mojocoin is downloading blocks...");

     COutPoint kernel;
@@ -247,7 +247,7 @@
     if (vNodes.empty())
         throw JSONRPCError(-9, "Mojocoin is not connected!");

-    if (IsInitialBlockDownload() && pindexBest->nHeight > 100)
+    if (IsInitialBlockDownload())
         throw JSONRPCError(-10, "Mojocoin is downloading blocks...");

     if (pindexBest->nHeight >= Params().LastPOWBlock())
@@ -381,7 +381,7 @@
     if (vNodes.empty())
         throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Mojocoin is not connected!");

-    if (IsInitialBlockDownload() && pindexBest->nHeight > 100)
+    if (IsInitialBlockDownload())
         throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Mojocoin is downloading blocks...");

     if (pindexBest->nHeight >= Params().LastPOWBlock())


22.08.16

22.08.16

Errors correct

--- src/rpcmining.cpp
+++ src/rpcmining.cpp
@@ -496,8 +496,8 @@
     static CBlockIndex* pindexPrev;
     static int64_t nStart;
     static CBlockTemplate* pblocktemplate;
-    if (pindexPrev != chainActive.Tip() && ((chainActive.Tip()->GetBlockTime() + Params().TargetSpacing() - 60 + 1) > GetAdjustedTime()) ||
-        (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 89))
+    if (pindexPrev != chainActive.Tip() ||
+        (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 149))
     {
         // Clear pindexPrev so future calls make a new block, despite any failures from here on
         pindexPrev = NULL;


Save polardrift window size across sessions

--- polardrift_toolwin.cpp
+++ polardrift_toolwin.cpp
@@ -230,9 +230,13 @@
     Layout();
     topSizer->Fit(this);

-    int xpos = pConfig->Global.GetInt("/PolarDriftTool/pos.x", -1);
-    int ypos = pConfig->Global.GetInt("/PolarDriftTool/pos.y", -1);
-    MyFrame::PlaceWindowOnScreen(this, xpos, ypos);
+    int x = pConfig->Global.GetInt("/PolarDriftTool/pos.x", -1);
+    int y = pConfig->Global.GetInt("/PolarDriftTool/pos.y", -1);
+    MyFrame::PlaceWindowOnScreen(this, x, y);
+
+    x = pConfig->Global.GetInt("/PolarDriftTool/size.x", -1);
+    y = pConfig->Global.GetInt("/PolarDriftTool/size.y", -1);
+    SetSize(x, y);

     FillPanel();
 }
@@ -318,6 +322,12 @@
     GetPosition(&x, &y);
     pConfig->Global.SetInt("/PolarDriftTool/pos.x", x);
     pConfig->Global.SetInt("/PolarDriftTool/pos.y", y);
+
+    // save the window size
+    GetSize(&x, &y);
+    pConfig->Global.SetInt("/PolarDriftTool/size.x", x);
+    pConfig->Global.SetInt("/PolarDriftTool/size.y", y);
+
     Debug.AddLine("Close PolarDriftTool");
     Destroy();
 }


Remove proof-of-work field from RPC getinfo command

--- src/rpcwallet.cpp
+++ src/rpcwallet.cpp
@@ -105,7 +105,6 @@
     obj.push_back(Pair("proxy",         (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string())));
     obj.push_back(Pair("ip",            addrSeenByPeer.ToStringIP()));

-    diff.push_back(Pair("proof-of-work",  GetDifficulty()));
     diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true))));
     obj.push_back(Pair("difficulty",      diff));


fuzz: Remove no-op call to get()

fuzz: Remove no-op call to get()

--- src/test/fuzz/pow.cpp
+++ src/test/fuzz/pow.cpp
@@ -114,7 +114,7 @@
         auto current_block{std::make_unique<CBlockIndex>(header)};
         current_block->pprev = blocks.empty() ? nullptr : blocks.back().get();
         current_block->nHeight = height;
-        blocks.emplace_back(std::move(current_block)).get();
+        blocks.emplace_back(std::move(current_block));
     }
     auto last_block{blocks.back().get()};
     unsigned int new_nbits{GetNextWorkRequired(last_block, nullptr, consensus_params)};


show more dynamic loading info on error

show more dynamic loading info on error

--- src/rtl_posix.cpp
+++ src/rtl_posix.cpp
@@ -18,6 +18,8 @@
         std::string libname = library + SO_SUFFIX;
         void *lib = dlopen(libname.c_str(), RTLD_LAZY);
         if (lib == nullptr) {
+            // TODO: fill in exception info
+            fprintf(stderr, "%s\n", dlerror());
             return NULL;
         }
         i = g_Libraries.insert(std::make_pair(library, lib)).first;


Remove Actor-related Tile tests

Remove Actor-related Tile tests

--- src/test/map/Tile.cpp
+++ src/test/map/Tile.cpp
@@ -1,6 +1,5 @@
 #include "gtest/gtest.h"
 #include "map/Tile.h"
-#include "actor/Actor.h"

 TEST(TileTest, WallTileIsOpaque)
 {
@@ -74,35 +73,3 @@
 	EXPECT_TRUE(floor != wall);
 }

-TEST(TileTest, TileDisplaysActor)
-{
-	Actor actor('@', "TestActor", 0x00);
-	Tile floor = FloorTile;
-
-	EXPECT_EQ('.', floor.getDisplay());
-
-	floor.addActor(&actor);
-
-	EXPECT_EQ('@', floor.getDisplay());
-
-	floor.removeActor();
-
-	EXPECT_EQ('.', floor.getDisplay());
-}
-
-TEST(TileTest, TileIsOccupied)
-{
-	Actor actor('@', "TestActor", 0x00);
-	Tile floor = FloorTile;
-
-	EXPECT_FALSE(floor.isOccupied());
-
-	floor.addActor(&actor);
-
-	EXPECT_TRUE(floor.isOccupied());
-
-	floor.removeActor();
-
-	EXPECT_FALSE(floor.isOccupied());
-}
-


Make cpptest main return 0 for SUCCESS.

Make cpptest main return 0 for SUCCESS.

--- test_src/Tests.cpp
+++ test_src/Tests.cpp
@@ -28,6 +28,6 @@
     CppUnit::TextUi::TestRunner runner;
     CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
     runner.addTest( registry.makeTest() );
-    return runner.run( "" );
+    return !runner.run( "" );
 }


Rename stdout/stderr to match mettle's changes

--- src/test_compiler.cpp
+++ src/test_compiler.cpp
@@ -137,8 +137,8 @@
       return parent_failed();

     std::vector<mettle::readfd> dests = {
-      {stdout_pipe.read_fd, &output.stdout},
-      {stderr_pipe.read_fd, &output.stderr}
+      {stdout_pipe.read_fd, &output.stdout_log},
+      {stderr_pipe.read_fd, &output.stderr_log}
     };

     // Read from the piped stdout, stderr, and log. If we're interrupted


Fixed bug in plain scalar folding

Fixed bug in plain scalar folding

--- src/scantoken.cpp
+++ src/scantoken.cpp
@@ -287,7 +287,7 @@
 		params.end = (InFlowContext() ? Exp::EndScalarInFlow : Exp::EndScalar) || (Exp::BlankOrBreak + Exp::Comment);
 		params.eatEnd = false;
 		params.indent = (InFlowContext() ? 0 : GetTopIndent() + 1);
-		params.fold = FOLD_BLOCK;
+		params.fold = FOLD_FLOW;
 		params.eatLeadingWhitespace = true;
 		params.trimTrailingSpaces = true;
 		params.chomp = STRIP;


Fix a bug which caused proxy corruption with setters.

Do not override the TiObject* of a JavaScript proxy object.
This was leading to the proxy becoming un-usable since it
no longer pointed to a valid TiObject* instance.

--- src/tibb/TiObject.cpp
+++ src/tibb/TiObject.cpp
@@ -453,7 +453,6 @@
         destObj = srcObj;
     }
     (destObj->*cb)(value);
-    setTiObjectToJsObject(value, destObj);
     addMember(destObj, propString);
     onSetProperty(propString, value);
     srcObj->release();


Stray declaration.

Stray declaration.

--- src/tightdb/array.hpp
+++ src/tightdb/array.hpp
@@ -536,8 +536,6 @@
     bool minimum(int64_t& result, std::size_t start = 0, std::size_t end = std::size_t(-1),
                  std::size_t* return_ndx = null_ptr) const;

-    void ReferenceSort(Array& ref) const;
-
     /// This information is guaranteed to be cached in the array accessor.
     bool is_inner_bptree_node() const TIGHTDB_NOEXCEPT;


prevent compiler warning

prevent compiler warning

--- src/sell_spmv.cpp
+++ src/sell_spmv.cpp
@@ -367,7 +367,7 @@
     };
 }

-bool operator==(const ghost_sellspmv_parameters_t& a, const ghost_sellspmv_parameters_t& b)
+static bool operator==(const ghost_sellspmv_parameters_t& a, const ghost_sellspmv_parameters_t& b)
 {
     return a.mdt == b.mdt && a.blocksz == b.blocksz && a.storage == b.storage &&
            a.vdt == b.vdt && a.impl == b.impl && a.chunkheight == b.chunkheight &&


hash_map: added node access interface; doc tidy.

--- src/togo/hash_map.hpp
+++ src/togo/hash_map.hpp
@@ -247,9 +247,23 @@
 	hm._data[index].value = value;
 }

+/// Push item.
+///
+/// If there are existing values with key, they are retained.
+template<class K, class T>
+inline void push(HashMap<K, T>& hm, K const key, T const& value) {
+	if (!space(hm)) {
+		internal::grow(hm);
+	}
+	auto const index = internal::make(hm, key, false);
+	hm._data[index].value = value;
+}
+
 /// Get item.
 ///
 /// If key does not exist, nullptr will be returned.
+/// If multiple values are assigned to key, this will get the most
+/// recently pushed one.
 template<class K, class T>
 inline T* get(HashMap<K, T>& hm, K const key) {
 	auto const index = internal::find(hm, key).data;
@@ -259,19 +273,100 @@
 /// Get item.
 ///
 /// If key does not exist, nullptr will be returned.
+/// If multiple values are assigned to key, this will get the most
+/// recently pushed one.
 template<class K, class T>
 inline T const* get(HashMap<K, T> const& hm, K const key) {
 	auto const index = internal::find(hm, key).data;
 	return (index != END) ? &hm._data[index].value : nullptr;
 }

+/// Get first node with key.
+///
+/// If there are no items with key, nullptr will be returned.
+template<class K, class T>
+inline HashMapNode<K, T>* get_node(
+	HashMap<K, T>& hm,
+	K const key
+) {
+	auto const index = internal::find(hm, key).data;
+	return (index != END) ? &hm._data[index] : nullptr;
+}
+
+/// Get first node with key.
+///
+/// If there are no items with key, nullptr will be returned.
+template<class K, class T>
+inline HashMapNode<K, T> const* get_node(
+	HashMap<K, T> const& hm,
+	K const key
+) {
+	auto const index = internal::find(hm, key).data;
+	return (index != END) ? &hm._data[index] : nullptr;
+}
+
+/// Get next node in keyset.
+///
+/// An assertion will fail if node is nullptr. Returns nullptr when
+/// there are no more nodes for the key.
+template<class K, class T>
+inline HashMapNode<K, T>* get_next(
+	HashMap<K, T>& hm,
+	HashMapNode<K, T>* node
+) {
+	TOGO_ASSERTE(node != nullptr);
+	K const key = node->key;
+	while (node->next != END) {
+		node = &hm._data[node->next];
+		if (node->key == key) {
+			return node;
+		}
+	}
+	return nullptr;
+}
+
+/// Get next node in keyset.
+///
+/// An assertion will fail if node is nullptr. Returns nullptr when
+/// there are no more nodes for the key.
+template<class K, class T>
+inline HashMapNode<K, T> const* get_next(
+	HashMap<K, T> const& hm,
+	HashMapNode<K, T> const* node
+) {
+	TOGO_ASSERTE(node != nullptr);
+	K const key = node->key;
+	while (node->next != END) {
+		node = &hm._data[node->next];
+		if (node->key == key) {
+			return node;
+		}
+	}
+	return nullptr;
+}
+
 /// Check if there is a value with key.
 template<class K, class T>
 inline bool has(HashMap<K, T> const& hm, K const key) {
 	return internal::find(hm, key).data != END;
 }

+/// Count the number of values with key.
+template<class K, class T>
+inline unsigned count(HashMap<K, T> const& hm, K const key) {
+	auto const* node = get_node(hm, key);
+	unsigned count = 0;
+	while (node != nullptr) {
+		node = get_next(hm, node);
+		++count;
+	}
+	return count;
+}
+
 /// Remove value.
+///
+/// If there are multiple values with key, the most recently added
+/// one is removed.
 template<class K, class T>
 inline void remove(HashMap<K, T>& hm, K const key) {
 	FindData const fd = internal::find(hm, key);
@@ -280,6 +375,18 @@
 	}
 }

+/// Remove node.
+///
+/// An assertion will fail if node is nullptr.
+template<class K, class T>
+inline void remove(HashMap<K, T>& hm, HashMapNode<K, T> const* node) {
+	TOGO_ASSERTE(node != nullptr);
+	FindData const fd = internal::find(hm, node);
+	if (fd.data != END) {
+		internal::remove(hm, fd);
+	}
+}
+
 /** @cond INTERNAL */
 #undef TOGO_HASH_MAP_MAX_LOAD
 /** @endcond */ // INTERNAL


serialize: fix FromBE*() parameters

serialize: fix FromBE*() parameters

The result from DeserializeT() must be converted, not the current
buffer.  This fixes a major breakage from commit 9e00061959180

--- src/serialize.cxx
+++ src/serialize.cxx
@@ -137,7 +137,7 @@
 {
     uint16_t value;
     DeserializeT(input, value);
-    return FromBE16(*(const uint16_t *)input.data);
+    return FromBE16(value);
 }

 uint32_t
@@ -145,7 +145,7 @@
 {
     uint32_t value;
     DeserializeT(input, value);
-    return FromBE32(*(const uint32_t *)input.data);
+    return FromBE32(value);
 }

 uint64_t
@@ -153,7 +153,7 @@
 {
     uint64_t value;
     DeserializeT(input, value);
-    return FromBE64(*(const uint64_t *)input.data);
+    return FromBE64(value);
 }

 const char *


use cascading name for kdb set

use cascading name for kdb set

--- src/tools/kdb/set.cpp
+++ src/tools/kdb/set.cpp
@@ -76,7 +76,7 @@
 			key.setBinary(0, 0);
 		}
 	}
-	Key n;
+	Key n("/", KEY_CASCADING_NAME, KEY_END);
 	kdb.set(conf, n);
 	printWarnings(cerr, n);
 	printError(cerr, n);


remove pct

remove pct

--- src/tools/tracker.cpp
+++ src/tools/tracker.cpp
@@ -80,7 +80,7 @@
 }

 std::string Tracker::logFramerate() {
-    return  "framerate," + ada::toString(getFramerate()) + ",100.0%\n";// +
+    return  "framerate," + ada::toString(getFramerate()) + "\n";// +
             // "fps," + ada::toString( (1./getFramerate()) * 1000.0 ) ;
 }


log values in normal space, not logspace

--- src/training_core.cpp
+++ src/training_core.cpp
@@ -41,6 +41,9 @@
                 scaled_state.level_log_stdv += data[i].log_read_var;
                 log_pdf[i][j] = log_normal_pdf(data[i].level_mean, scaled_state);
                 assert(not std::isnan(log_pdf[i][j]));
+                LOG("training_core", debug)
+                    << "pdf " << i << " " << j << " "
+                    << std::scientific << std::exp(log_pdf[i][j]) << endl;
             }
         }

@@ -60,6 +63,9 @@
             float log_denom = denom_terms.val();
             for(size_t j = 0; j < n_components; ++j) {
                 log_resp[i][j] -= log_denom;
+                LOG("training_core", debug)
+                    << "resp " << i << " " << j << " "
+                    << std::scientific << std::exp(log_resp[i][j]) << endl;
             }
         }

@@ -113,7 +119,7 @@
             new_mixture.params[j].level_stdv = std::exp(new_mixture.params[j].level_log_stdv);
             LOG("training_core", info)
                 << "new_mixture " << iteration << " " << j << " "
-                << std::fixed << std::setprecision(2) << std::exp(new_mixture.log_weights[j]) << " "
+                << std::scientific << std::exp(new_mixture.log_weights[j]) << " "
                 << new_mixture.params[j].level_mean << " " << new_mixture.params[j].level_stdv << endl;
         }

@@ -143,7 +149,8 @@
             log_pdf[i][j].first = log_normal_pdf(data[i].level_mean, scaled_state);
             assert(not std::isnan(log_pdf[i][j].first));
             LOG("training_core", debug)
-                << "log_gauss_pdf " << i << " " << j << " " << std::scientific << log_pdf[i][j].first << endl;
+                << "log_gauss_pdf " << i << " " << j << " "
+                << std::scientific << std::exp(log_pdf[i][j].first) << endl;
         }
     }

@@ -164,7 +171,8 @@
         for (size_t j = 0; j < n_components; ++j) {
             log_g_weights[i][j] -= log_denom;
             LOG("training_core", debug)
-                << "g_weights " << i << " " << j << " " << std::scientific << std::exp(log_g_weights[i][j]) << endl;
+                << "g_weights " << i << " " << j << " "
+                << std::scientific << std::exp(log_g_weights[i][j]) << endl;
         }
     }

@@ -181,7 +189,8 @@
                 log_pdf[i][j].second = log_invgauss_pdf(data[i].level_stdv, data[i].log_level_stdv, scaled_state);
                 assert(not std::isnan(log_pdf[i][j].second));
                 LOG("training_core", debug)
-                    << "log_invgauss_pdf " << i << " " << j << " " << std::scientific << log_pdf[i][j].second << endl;
+                    << "invgauss_pdf " << i << " " << j << " "
+                    << std::scientific << std::exp(log_pdf[i][j].second) << endl;
             }
         }
         // compute inverse gaussian weights (responsibilities)
@@ -201,7 +210,8 @@
             for (size_t j = 0; j < n_components; ++j) {
                 log_ig_weights[i][j] -= log_denom;
                 LOG("training_core", debug)
-                    << "ig_weights " << i << " " << j << " " << std::scientific << std::exp(log_ig_weights[i][j]) << endl;
+                    << "ig_weights " << i << " " << j << " "
+                    << std::scientific << std::exp(log_ig_weights[i][j]) << endl;
             }
         }

@@ -224,7 +234,7 @@
             new_mixture.params[j].sd_mean = std::exp(log_numer - log_denom);
             LOG("training_core", info)
                 << "new_mixture " << iteration << " " << j << " "
-                << std::fixed << std::setprecision(2) << std::exp(new_mixture.log_weights[j]) << " "
+                << std::scientific << std::exp(new_mixture.log_weights[j]) << " "
                 << new_mixture.params[j].sd_mean << endl;
         }
         std::swap(crt_mixture, new_mixture);


Modify definitions of Swarm and Interceptor categories.

--- src/ship/ship.cxx
+++ src/ship/ship.cxx
@@ -1861,8 +1861,8 @@
 }

 Ship::Category Ship::categorise() const noth {
-  //Swarm: Fewer than 16 cells
-  if (cells.size() < 16) return Swarm;
+  //Swarm: Fewer than 25 cells
+  if (cells.size() < 25) return Swarm;
   //Subcapital: >= 256 cells, reinforcement >= 3
   if (cells.size() >= 256 && reinforcement >= 3) return Subcapital;
   //Defender: Anything else >= 256 cells
@@ -1870,8 +1870,8 @@

   //Attacker: Reinforcement >= 3
   if (reinforcement >= 3) return Attacker;
-  //Interceptor: Reinforcement <= 1
-  if (reinforcement <= 1) return Interceptor;
+  //Interceptor: Reinforcement < 1
+  if (reinforcement < 1) return Interceptor;
   //Anything else: Fighter
   return Fighter;
 }


Brace initialization.

Brace initialization.

--- src/singleton.cpp
+++ src/singleton.cpp
@@ -26,6 +26,6 @@
 }

 int main() {
-  auto const value = CSingleton::GetInstance().getValue();
+  auto const value{CSingleton::GetInstance().getValue()};
   std::cout << value << '\n';
 }


Deleted member function should be public.

--- src/singleton.cpp
+++ src/singleton.cpp
@@ -8,14 +8,14 @@
   static CSingleton& GetInstance();
   int getValue() const { return mValue; }

- private:
-  CSingleton() = default;
-  ~CSingleton() = default;
-
   CSingleton(const CSingleton&) = delete;
   CSingleton& operator=(const CSingleton&) = delete;
   CSingleton(CSingleton&&) = delete;
   CSingleton& operator=(CSingleton&&) = delete;
+
+ private:
+  CSingleton() = default;
+  ~CSingleton() = default;

   int mValue = 0;
 };


This patch from Philippe allos to set  the address of branch in a friend which is a TChain.

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@6329 27541ba8-7e3a-0410-8455-c3a389f83636

--- tree/src/TChain.cxx
+++ tree/src/TChain.cxx
@@ -1,4 +1,4 @@
-// @(#)root/tree:$Name:  $:$Id: TChain.cxx,v 1.63 2003/03/14 19:21:19 rdm Exp $
+// @(#)root/tree:$Name:  $:$Id: TChain.cxx,v 1.64 2003/03/19 14:01:50 rdm Exp $
 // Author: Rene Brun   03/02/97

 /*************************************************************************
@@ -769,30 +769,6 @@
       }
    }

-   //Set the branches status and address for the newly connected file
-   fTree->SetMakeClass(fMakeClass);
-   fTree->SetMaxVirtualSize(fMaxVirtualSize);
-   SetChainOffset(fTreeOffset[t]);
-   TIter next(fStatus);
-   Int_t status;
-   while ((element = (TChainElement*)next())) {
-      status = element->GetStatus();
-      if (status >=0) fTree->SetBranchStatus(element->GetName(),status);
-   }
-   next.Reset();
-   while ((element = (TChainElement*)next())) {
-      void *add = element->GetBaddress();
-      if (add) {
-         TBranch *br = fTree->GetBranch(element->GetName());
-         if (br) {
-            br->SetAddress(add);
-            if (TestBit(kAutoDelete)) br->SetAutoDelete(kTRUE);
-         }
-      }
-   }
-
-   if (cursav) cursav->cd();
-
    if (fFriends) {
       //An Alternative would move this code to each of the function calling LoadTree
       //(and to overload a few more).
@@ -805,6 +781,30 @@
          if (friend_t) fTree->AddFriend(friend_t,fe->GetName());
       }
    }
+
+   //Set the branches status and address for the newly connected file
+   fTree->SetMakeClass(fMakeClass);
+   fTree->SetMaxVirtualSize(fMaxVirtualSize);
+   SetChainOffset(fTreeOffset[t]);
+   TIter next(fStatus);
+   Int_t status;
+   while ((element = (TChainElement*)next())) {
+      status = element->GetStatus();
+      if (status >=0) fTree->SetBranchStatus(element->GetName(),status);
+   }
+   next.Reset();
+   while ((element = (TChainElement*)next())) {
+      void *add = element->GetBaddress();
+      if (add) {
+         TBranch *br = fTree->GetBranch(element->GetName());
+         if (br) {
+            br->SetAddress(add);
+            if (TestBit(kAutoDelete)) br->SetAutoDelete(kTRUE);
+         }
+      }
+   }
+
+   if (cursav) cursav->cd();

    //update list of leaves in all TTreeFormula of the TTreePlayer (if any)
    if (fPlayer) fPlayer->UpdateFormulaLeaves();


tweak DAC_BIST printing to report LVDS capture passes when it matches FPGA

--- src/util/DAC_BIST.cpp
+++ src/util/DAC_BIST.cpp
@@ -35,9 +35,9 @@
   print_pass_fail(results[3] == results[1]);

   cout << " LVDS: ";
-  print_pass_fail(results[4] == results[0]);
+  print_pass_fail(results[4] == results[2]);
   cout << " / ";
-  print_pass_fail(results[5] == results[1]);
+  print_pass_fail(results[5] == results[3]);

   cout << " SYNC: ";
   print_pass_fail(results[6] == results[4]);


Nicer printing of results

Nicer printing of results

--CAR

--- src/util/DAC_BIST.cpp
+++ src/util/DAC_BIST.cpp
@@ -21,7 +21,6 @@
 	string deviceSerial = get_device_id();

 	set_logging_level(4);
-	set_log("stdout");

 	connect_APS(deviceSerial.c_str());

@@ -59,14 +58,14 @@
 			}
 			run_DAC_BIST(deviceSerial.c_str(), dac, testVec.data(), testVec.size(), results.data());

-			FPGAPhase1 = results[3] == results[1] ? "pass" : "fail";
-			FPGAPhase2 = results[4] == results[2] ? "pass" : "fail";
-			LVDSPhase1 = results[5] == results[1] ? "pass" : "fail";
-			LVDSPhase2 = results[6] == results[2] ? "pass" : "fail";
-			SYNCPhase1 = results[7] == results[7] ? "pass" : "fail";
-			SYNCPhase2 = results[8] == results[8] ? "pass" : "fail";
+			FPGAPhase1 = results[2] == results[0] ? "pass" : "fail";
+			FPGAPhase2 = results[3] == results[1] ? "pass" : "fail";
+			LVDSPhase1 = results[4] == results[0] ? "pass" : "fail";
+			LVDSPhase2 = results[5] == results[1] ? "pass" : "fail";
+			SYNCPhase1 = results[6] == results[4] ? "pass" : "fail";
+			SYNCPhase2 = results[7] == results[5] ? "pass" : "fail";

-			cout << "FPGA: " << FPGAPhase1 << " / " << FPGAPhase2 << "LVDS: " << LVDSPhase1 << " / " << LVDSPhase2 << "SYNC: " << SYNCPhase1 << " / " << SYNCPhase2 << endl;
+			cout << "FPGA: " << FPGAPhase1 << " / " << FPGAPhase2 << " LVDS: " << LVDSPhase1 << " / " << LVDSPhase2 << " SYNC: " << SYNCPhase1 << " / " << SYNCPhase2 << endl;

 		}
 		cout << endl;
@@ -78,17 +77,19 @@
 		}
 		run_DAC_BIST(deviceSerial.c_str(), dac, testVec.data(), testVec.size(), results.data());

-		FPGAPhase1 = results[3] == results[1] ? "pass" : "fail";
-		FPGAPhase2 = results[4] == results[2] ? "pass" : "fail";
-		LVDSPhase1 = results[5] == results[1] ? "pass" : "fail";
-		LVDSPhase2 = results[6] == results[2] ? "pass" : "fail";
-		SYNCPhase1 = results[7] == results[7] ? "pass" : "fail";
-		SYNCPhase2 = results[8] == results[8] ? "pass" : "fail";
+		FPGAPhase1 = results[2] == results[0] ? "pass" : "fail";
+		FPGAPhase2 = results[3] == results[1] ? "pass" : "fail";
+		LVDSPhase1 = results[4] == results[0] ? "pass" : "fail";
+		LVDSPhase2 = results[5] == results[1] ? "pass" : "fail";
+		SYNCPhase1 = results[6] == results[4] ? "pass" : "fail";
+		SYNCPhase2 = results[7] == results[5] ? "pass" : "fail";

-		cout << "FPGA: " << FPGAPhase1 << " / " << FPGAPhase2 << "LVDS: " << LVDSPhase1 << " / " << LVDSPhase2 << "SYNC: " << SYNCPhase1 << " / " << SYNCPhase2 << endl;
+		cout << "FPGA: " << FPGAPhase1 << " / " << FPGAPhase2 << " LVDS: " << LVDSPhase1 << " / " << LVDSPhase2 << " SYNC: " << SYNCPhase1 << " / " << SYNCPhase2 << endl;
 		cout << endl;
 		cout << endl;
 	}

+	disconnect_APS(deviceSerial.c_str());
+
 	return 0;
 }


source: release build details before clearing the content

to prevent against potential memory corruption

--- bootstrap/libnanyc/details/context/source.cpp
+++ bootstrap/libnanyc/details/context/source.cpp
@@ -73,6 +73,7 @@
 				auto entry = (info() << "building " << m_filename);
 				entry.message.prefix = arrow;
 			}
+			m_details.reset(nullptr); // release memory first
 			if (m_type == Type::file) {
 				m_content.clear();
 				m_content.shrink();
@@ -86,7 +87,6 @@
 			auto report = Logs::Report{*build.messages} .subgroup();
 			report.data().origins.location.filename = m_filename;
 			report.data().origins.location.target.clear();
-			m_details.reset(nullptr); // making sure that the memory is released first
 			m_details = std::make_unique<BuildInfoSource>(build.cf);
 			if (success) {
 				success &= passASTFromSourceWL();


adding redundant 32 bit equalities

adding redundant 32 bit equalities

--- src/validator/null.cc
+++ src/validator/null.cc
@@ -325,7 +325,7 @@
   for(size_t i=0;i< rows+cols;i++)
 	  for(size_t j=0;j<cols;j++)
 		  SUB(i,j) = SUB(i,j)*(((uint64_t)1)<<32);
-  for(size_t i=0;i<cols-nullity;i++)
+  for(size_t i=0;i<cols;i++)
   {
 	  bool flag = true;
 	  for(size_t j=0;j<rows;j++)


Start trying to decide on different alignment modes

--- src/variant_adder.cpp
+++ src/variant_adder.cpp
@@ -263,50 +263,65 @@
             });
 #endif

-            // Calculate the expected min score, for a giant gap (i.e. this variant is an SV indel)
-            int64_t min_length = min(right_context_past_end - left_context_start, to_align.str().size());
-            int64_t max_length = max(right_context_past_end - left_context_start, to_align.str().size());
-            // TODO: assumes a gap open of 6 and match and gap extend values of 1
-            int64_t expected_score = min_length - 6 - (max_length - 1 - min_length);
-
-            // Record the size of graph we're aligning to in bases
-            total_graph_bases += lock.get_subgraph().length();
-
-            // Work out how far we would have to unroll the graph to account for
-            // a giant deletion. We also want to account for alts that may
-            // alrteady be in the graph and need unrolling for a long insert.
-            size_t max_span = max(right_context_past_end - left_context_start, to_align.str().size());
-
-            // Do the alignment in both orientations
+            // Decide what kind of alignment we need to do. Whatever we pick,
+            // we'll fill this in.
             Alignment aln;
-            Alignment aln2;
-
-            // Align in the forward orientation using banded global aligner, unrolling for large deletions.
-            aln = lock.get_subgraph().align(to_align.str(), 0, false, false, 0, true, max_span);
-            // Align in the reverse orientation using banded global aligner, unrolling for large deletions.
-            // TODO: figure out which way our reference path goes through our subgraph and do half the work.
-            // Note that if we have reversing edges and a lot of unrolling, we might get the same alignment either way.
-            aln2 = lock.get_subgraph().align(reverse_complement(to_align.str()), 0, false, false, 0, true, max_span);
-
-            // Note that the banded global aligner doesn't fill in identity.
-
-#ifdef debug
-            cerr << "Scores: " << aln.score() << " fwd vs. " << aln2.score() << " rev" << endl;
-#endif
-
-            if (aln2.score() > aln.score()) {
-                // This is the better alignment
-                swap(aln, aln2);
-            }
-
-#ifdef debug
-            cerr << "Subgraph: " << pb2json(lock.get_subgraph().graph) << endl;
-            cerr << "Alignment: " << pb2json(aln) << endl;
-#endif
-
-            if (local_variants.size() == 1) {
-                // We only have one variant here, so we ought to have at least the expected giant gap score
-                assert(aln.score() >= expected_score);
+
+
+
+            if (true) {
+                // If the graph and the string are short, do a normal banded global
+                // aligner with permissive banding and the whole string length as
+                // band padding. We can be inefficient but we won;t bring down the
+                // system.
+
+                // TODO: factor into function
+
+
+                // Calculate the expected min score, for a giant gap (i.e. this variant is an SV indel)
+                int64_t min_length = min(right_context_past_end - left_context_start, to_align.str().size());
+                int64_t max_length = max(right_context_past_end - left_context_start, to_align.str().size());
+                // TODO: assumes a gap open of 6 and match and gap extend values of 1
+                int64_t expected_score = min_length - 6 - (max_length - 1 - min_length);
+
+                // Record the size of graph we're aligning to in bases
+                total_graph_bases += lock.get_subgraph().length();
+
+                // Work out how far we would have to unroll the graph to account for
+                // a giant deletion. We also want to account for alts that may
+                // alrteady be in the graph and need unrolling for a long insert.
+                size_t max_span = max(right_context_past_end - left_context_start, to_align.str().size());
+
+                // Do the alignment in both orientations
+
+                // Align in the forward orientation using banded global aligner, unrolling for large deletions.
+                aln = lock.get_subgraph().align(to_align.str(), 0, false, false, 0, true, max_span);
+                // Align in the reverse orientation using banded global aligner, unrolling for large deletions.
+                // TODO: figure out which way our reference path goes through our subgraph and do half the work.
+                // Note that if we have reversing edges and a lot of unrolling, we might get the same alignment either way.
+                Alignment aln2 = lock.get_subgraph().align(reverse_complement(to_align.str()), 0, false, false, 0, true, max_span);
+
+                // Note that the banded global aligner doesn't fill in identity.
+
+    #ifdef debug
+                cerr << "Scores: " << aln.score() << " fwd vs. " << aln2.score() << " rev" << endl;
+    #endif
+
+                if (aln2.score() > aln.score()) {
+                    // This is the better alignment
+                    swap(aln, aln2);
+                }
+
+    #ifdef debug
+                cerr << "Subgraph: " << pb2json(lock.get_subgraph().graph) << endl;
+                cerr << "Alignment: " << pb2json(aln) << endl;
+    #endif
+
+                if (local_variants.size() == 1) {
+                    // We only have one variant here, so we ought to have at least the expected giant gap score
+                    assert(aln.score() >= expected_score);
+                }
+
             }

             // We shouldn't have dangling ends, really, but it's possible for


Fix build for Windows

Fix build for Windows

* winsock2.h is case sensitive, lower case is required for cross build.
* ws2tcpip.h is required for addrinfo.
* FreeAddrInfo conflicts with existing freeaddrinfo, so rename it.

Signed-off-by: Stefan Weil <8d4c780fcfdc41841e5070f4c43da8958ba6aec0@weilnetz.de>

--- src/viewer/svutil.cpp
+++ src/viewer/svutil.cpp
@@ -35,7 +35,8 @@

 #ifdef _WIN32
 #pragma comment(lib, "Ws2_32.lib")
-#  include <WinSock2.h>  // for fd_set, send, ..
+#  include <winsock2.h>  // for fd_set, send, ..
+#  include <ws2tcpip.h>  // for addrinfo
 #else
 #include <arpa/inet.h>
 #include <netdb.h>
@@ -316,7 +317,7 @@

 // Platform-independent freeaddrinfo()
-static void FreeAddrInfo(struct addrinfo* addr_info) {
+static void TessFreeAddrInfo(struct addrinfo* addr_info) {
   #if defined(__linux__)
   freeaddrinfo(addr_info);
   #else
@@ -352,7 +353,7 @@
 #endif

   if (name == nullptr) {
-    FreeAddrInfo(*addr_info);
+    TessFreeAddrInfo(*addr_info);
     *addr_info = nullptr;
     return -1;
   }
@@ -441,7 +442,7 @@
       }
     }
   }
-  FreeAddrInfo(addr_info);
+  TessFreeAddrInfo(addr_info);
 }

 SVNetwork::~SVNetwork() {


add image views for the swap chain

add image views for the swap chain

--- src/vulkan/Engine.cpp
+++ src/vulkan/Engine.cpp
@@ -4,8 +4,8 @@
 #include "core/Log.h"
 #include "core/algorithm.h"

+#include "glm/vec2.hpp"
 #include "vulkan/vulkan.hpp"
-#include "glm/vec2.hpp"

 #include <exception>
 #include <iostream>
@@ -45,6 +45,7 @@
 		vk::SurfaceKHR m_PrimarySurface;
 		vk::SwapchainKHR m_PrimarySwapChain;
 		std::vector<vk::Image> m_PrimarySwapChainImages;
+		std::vector<vk::ImageView> m_primarySwapChainImageViews;

 		uint32_t DeviceMemoryIndex{numeric_limits<uint32_t>::max()};
 		uint32_t HostMemoryIndex{numeric_limits<uint32_t>::max()};
@@ -236,7 +237,7 @@
 	int32_t graphicsQueueIndex     = 0;
 	int32_t presentationQueueIndex = 0;
 	int32_t transferQueueIndex     = 0;
-	int32_t queueIndexMap[256]; //surely no more than 256 queue families for all time
+	int32_t queueIndexMap[256];    // surely no more than 256 queue families for all time
 	fill(queueIndexMap, -1);

 	float graphicsPriority = 1.0f;
@@ -284,15 +285,13 @@

 	auto surfaceFormats = selectedDevice.getSurfaceFormatsKHR(m_PrimarySurface);
 	Log::Info("Supported surface formats:");
-	for (const auto& format : surfaceFormats) {
+	for(const auto& format : surfaceFormats) {
 		Log::Info("    Format: {} ColorSpace {}", to_string(format.format), to_string(format.colorSpace));
 	}

 	auto presentModes = selectedDevice.getSurfacePresentModesKHR(m_PrimarySurface);
 	Log::Info("Presentation modes:");
-	for(const auto& mode : presentModes) {
-		Log::Info("    Presentation Mode: {}", to_string(mode));
-	}
+	for(const auto& mode : presentModes) { Log::Info("    Presentation Mode: {}", to_string(mode)); }

 	vk::SwapchainCreateInfoKHR swapCreateInfo;
 	swapCreateInfo.setClipped(true);
@@ -318,14 +317,27 @@
 	swapCreateInfo.setSurface(m_PrimarySurface);
 	swapCreateInfo.setImageArrayLayers(1);

-	m_PrimarySwapChain = m_Device.createSwapchainKHR(swapCreateInfo);
+	m_PrimarySwapChain       = m_Device.createSwapchainKHR(swapCreateInfo);
 	m_PrimarySwapChainImages = m_Device.getSwapchainImagesKHR(m_PrimarySwapChain);
-
+	for(const auto& image : m_PrimarySwapChainImages) {
+		vk::ImageViewCreateInfo viewInfo;
+		viewInfo.setFormat(vk::Format::eB8G8R8A8Srgb);
+		viewInfo.setImage(image);
+		viewInfo.setViewType(vk::ImageViewType::e2D);
+		viewInfo.subresourceRange.aspectMask     = vk::ImageAspectFlagBits::eColor;
+		viewInfo.subresourceRange.baseArrayLayer = 0;
+		viewInfo.subresourceRange.layerCount     = 1;
+		viewInfo.subresourceRange.baseMipLevel   = 0;
+		viewInfo.subresourceRange.levelCount     = 1;
+		m_primarySwapChainImageViews.push_back(m_Device.createImageView(viewInfo));
+	}
 	m_WindowSize = vec2(surfaceCaps.maxImageExtent.width, surfaceCaps.maxImageExtent.height);
- }
+}

 Engine::~Engine() {
-	 m_Device.destroySwapchainKHR(m_PrimarySwapChain);
+	for(auto& imageView : m_primarySwapChainImageViews) { m_Device.destroyImageView(imageView); }
+	m_primarySwapChainImageViews.clear();
+	m_Device.destroySwapchainKHR(m_PrimarySwapChain);
 	m_Device.destroy();
 	m_Instance.destroySurfaceKHR(m_PrimarySurface);
 	m_Instance.destroy();


[Wallet] Use cold inputs to stake

[Wallet] Use cold inputs to stake

--- src/wallet/wallet.cpp
+++ src/wallet/wallet.cpp
@@ -2124,7 +2124,10 @@
     LOCK(cs_main);
     //Add PIV
     std::vector<COutput> vCoins;
-    AvailableCoins(vCoins, true, NULL, false, STAKABLE_COINS, false, 1);
+
+    // include cold, exclude delegated
+    AvailableCoins(vCoins, true, NULL, false, STAKABLE_COINS, false, 1, true, false);
+
     CAmount nAmountSelected = 0;
     if (GetBoolArg("-pivstake", true) && !fPrecompute) {
         for (const COutput &out : vCoins) {


vs compilation problems

vs compilation problems

--- arangod/Agency/Node.cpp
+++ arangod/Agency/Node.cpp
@@ -518,6 +518,7 @@

 /// Check if element is in array
+/// Remove observer for this node
 template <>
 bool Node::handle<IN>(VPackSlice const& slice) {
   return true;
@@ -556,7 +557,7 @@
     return handle<OBSERVE>(slice);
   } else if (oper == "unobserve") {  // "op":"unobserve"
     return handle<UNOBSERVE>(slice);
-  } else if (oper == "unobserve") {  // "op":"unobserve"
+  } else if (oper == "in") {  // "op":"unobserve"
     return handle<IN>(slice);
   } else {  // "op" might not be a key word after all
     LOG_TOPIC(WARN, Logger::AGENCY)


Avoid duplicate selected boards in TyQt

Avoid duplicate selected boards in TyQt

--- tyqt/main_window.cc
+++ tyqt/main_window.cc
@@ -73,9 +73,11 @@
     }

     selected_boards_.clear();
-    auto selected = boardList->selectionModel()->selection();
-    for (auto &idx: selected.indexes())
-        selected_boards_.push_back(manager_->board(idx.row()));
+    auto selected = boardList->selectionModel()->selectedIndexes();
+    for (auto &idx: selected) {
+        if (idx.column() == 0)
+            selected_boards_.push_back(manager_->board(idx.row()));
+    }

     if (selected_boards_.size() == 1) {
         current_board_ = selected_boards_.front();


wallet: Translate all initErrors in CreateWalletFromFile

Every warning or error in this method is translated, except for those
two. Translate them as well for consistency.

--- src/wallet/wallet.cpp
+++ src/wallet/wallet.cpp
@@ -4424,12 +4424,12 @@
     }

     if (!gArgs.GetArg("-addresstype", "").empty() && !ParseOutputType(gArgs.GetArg("-addresstype", ""), walletInstance->m_default_address_type)) {
-        chain.initError(strprintf("Unknown address type '%s'", gArgs.GetArg("-addresstype", "")));
+        chain.initError(strprintf(_("Unknown address type '%s'").translated, gArgs.GetArg("-addresstype", "")));
         return nullptr;
     }

     if (!gArgs.GetArg("-changetype", "").empty() && !ParseOutputType(gArgs.GetArg("-changetype", ""), walletInstance->m_default_change_type)) {
-        chain.initError(strprintf("Unknown change type '%s'", gArgs.GetArg("-changetype", "")));
+        chain.initError(strprintf(_("Unknown change type '%s'").translated, gArgs.GetArg("-changetype", "")));
         return nullptr;
     }

@@ -4508,9 +4508,10 @@
         walletInstance->m_default_max_tx_fee = nMaxFee;
     }

-    if (chain.relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB)
+    if (chain.relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) {
         chain.initWarning(AmountHighWarn("-minrelaytxfee").translated + " " +
                     _("The wallet will avoid paying less than the minimum relay fee.").translated);
+    }

     walletInstance->m_confirm_target = gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
     walletInstance->m_spend_zero_conf_change = gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);


add a zero to the GenerateNewKey call

add a zero to the GenerateNewKey call

Signed-off-by: Pasta <46139b0b16d7696468a818ef81ab82a93691f7d5@dashboost.org>

--- src/wallet/wallet.cpp
+++ src/wallet/wallet.cpp
@@ -4337,7 +4337,7 @@
             assert(m_max_keypool_index < std::numeric_limits<int64_t>::max()); // How in the hell did you use so many keys?
             int64_t index = ++m_max_keypool_index;

-            if (!walletdb.WritePool(index, CKeyPool(GenerateNewKey(walletdb, fInternal), fInternal))) {
+            if (!walletdb.WritePool(index, CKeyPool(GenerateNewKey(walletdb, 0, fInternal), fInternal))) {
                 throw std::runtime_error(std::string(__func__) + ": writing generated key failed");
             }


win: Don't VIEWS_EXPORT ImagePainter.

win: Don't VIEWS_EXPORT ImagePainter.

ImagePainter is in an unnamed namespace, exporting it makes no sense.

Fixes
..\..\ui\views\painter.cc(187,15) :  error(clang): 'views::(anonymous namespace)::ImagePainter::ImagePainter' must have external linkage when declared 'dllexport'
ImagePainter::ImagePainter(const int image_ids[])
              ^
on the clang/win components bot.

BUG=82385
R=msw@chromium.org

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

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

--- ui/views/painter.cc
+++ ui/views/painter.cc
@@ -163,7 +163,7 @@
 // ImagePainter ---------------------------------------------------------------

 // ImagePainter stores and paints nine images as a scalable grid.
-class VIEWS_EXPORT ImagePainter : public Painter {
+class ImagePainter : public Painter {
  public:
   // Constructs an ImagePainter with the specified image resource ids.
   // See CreateImageGridPainter()'s comment regarding image ID count and order.


After encrypting the wallet, reload the database environment

Calls ReloadDbEnv after encrypting the wallet so that the database
environment is flushed, closed, and reopened to prevent unencrypted
keys from being saved on disk.

--- src/wallet/wallet.cpp
+++ src/wallet/wallet.cpp
@@ -744,6 +744,11 @@
         // Need to completely rewrite the wallet file; if we don't, bdb might keep
         // bits of the unencrypted private key in slack space in the database file.
         database->Rewrite();
+
+        // BDB seems to have a bad habit of writing old data into
+        // slack space in .dat files; that is bad if the old data is
+        // unencrypted private keys. So:
+        database->ReloadDbEnv();

     }
     NotifyStatusChanged(this);


Fixed error messagee

Fixed error messagee

--- src/wave_simulate.cpp
+++ src/wave_simulate.cpp
@@ -69,7 +69,7 @@
     XYZ_Reader reader;
     if(!reader.readFile(&latitude, &longitude, &bathymetry, xLength, yLength, fileName))
     {
-        cout << "Unable to read data" << endl;
+        cout << "Unable to read data: " << fileName << endl;
         return 1;
     }


Fix convert loop

Fix convert loop

--- src/worker/Worker.cpp
+++ src/worker/Worker.cpp
@@ -1190,6 +1190,8 @@
                 {
                     if (sync.Release() == false)
                         return false;
+
+                    return true;
                 }
             }
             else


sstables: mx/writer: migrate off the global reader concurrency_semaphore

And use a local one instead, stopping it when the writer is destroyed.

--- sstables/mx/writer.cc
+++ sstables/mx/writer.cc
@@ -41,12 +41,6 @@

 namespace sstables {
 namespace mc {
-
-namespace {
-
-thread_local reader_concurrency_semaphore reader_semaphore(reader_concurrency_semaphore::no_limits{}, "mx writer");
-
-}

 using indexed_columns = std::vector<std::reference_wrapper<const column_definition>>;

@@ -560,7 +554,8 @@
     std::optional<key> _partition_key;
     std::optional<key> _first_key, _last_key;
     index_sampling_state _index_sampling_state;
-    range_tombstone_stream _range_tombstones;
+    reader_concurrency_semaphore _semaphore;
+    std::optional<range_tombstone_stream> _range_tombstones; // to be able to destroy before the semaphore is stopped
     bytes_ostream _tmp_bufs;

     const sstable_schema _sst_schema;
@@ -761,7 +756,8 @@
         : sstable_writer::writer_impl(sst, s, pc, cfg)
         , _enc_stats(enc_stats)
         , _shard(shard)
-        , _range_tombstones(_schema, reader_semaphore.make_permit(&s, "mx-writer"))
+        , _semaphore(reader_concurrency_semaphore::no_limits{}, "mx writer")
+        , _range_tombstones(range_tombstone_stream(_schema, _semaphore.make_permit(&s, "mx-writer")))
         , _tmp_bufs(_sst.sstable_buffer_size)
         , _sst_schema(make_sstable_schema(s, _enc_stats, _cfg))
         , _run_identifier(cfg.run_identifier)
@@ -835,6 +831,8 @@
     };
     close_writer(_index_writer);
     close_writer(_data_writer);
+    _range_tombstones.reset();
+    _semaphore.stop().get();
 }

 void writer::maybe_set_pi_first_clustering(const writer::clustering_info& info) {
@@ -917,7 +915,7 @@

 void writer::drain_tombstones(std::optional<position_in_partition_view> pos) {
     auto get_next_rt = [this, &pos] {
-        return pos ? _range_tombstones.get_next(*pos) : _range_tombstones.get_next();
+        return pos ? _range_tombstones->get_next(*pos) : _range_tombstones->get_next();
     };

     auto get_rt_start = [] (const range_tombstone& rt) {
@@ -980,7 +978,7 @@
         }

         if (pos && rt.trim_front(_schema, *pos)) {
-            _range_tombstones.apply(std::move(rt));
+            _range_tombstones->apply(std::move(rt));
         }
     }

@@ -1443,7 +1441,7 @@

 stop_iteration writer::consume(range_tombstone&& rt) {
     drain_tombstones(rt.position());
-    _range_tombstones.apply(std::move(rt));
+    _range_tombstones->apply(std::move(rt));
     return stop_iteration::no;
 }