INTEGRATION: CWS pbrwuno (1.3.294); FILE MERGED 2005/10/05 07:14:42 fs 1.3.294.3: RESYNC: (1.3-1.4); FILE MERGED 2005/09/05 07:41:56 fs 1.3.294.2: #i53095# phase 3, part 1: introduced XPropertyControl and relatives, describing one control in the ObjectInspector, responsible for one property known issues: - rebuildPropertyUI can cause problems now: If the user clicks into   the control for property A, which causes property B to be committed,   which causes the UI for property A to be rebuilt, then this will   crash currently. Reason: rebuildPropertyUI now synchronously replaces   the VCL-Window of the rebuilt control, which is exactly the one   which is still in some MouseButtonDown-handler.   possible solutions:   - see if rebuiltPropertyUI can be obsoleted - handlers should be able     to just obtain the XPropertyControl from the PropertyUI, and     re-initialize the control. Shouldn't they?`   - make one of the steps in the chain (mouse-click, handler-call,     rebuildPropertyUI-callback) asynchronous. 2005/08/09 14:00:09 fs 1.3.294.1: #i53095# phase 1: - don't use strings to transver values between controls and introspectee, but Anys - first version of a dedicated property handler for form-component-related properties   (not yet completed) known regressions over previous phase: - handlers for events not yet implemented, thus some assertions - click handlers for form-component-related properties do not yet work,   thus the browse buttons mostly do not work

--- extensions/source/propctrlr/usercontrol.hxx
+++ extensions/source/propctrlr/usercontrol.hxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: usercontrol.hxx,v $
  *
- *  $Revision: 1.4 $
+ *  $Revision: 1.5 $
  *
- *  last change: $Author: rt $ $Date: 2005-09-08 20:32:19 $
+ *  last change: $Author: vg $ $Date: 2006-03-14 11:34:36 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -58,20 +58,43 @@
 //............................................................................

     //========================================================================
-    //= OFormatDescriptionControl
+    //= NumberFormatSampleField
     //========================================================================
-    class OFormatDescriptionControl : public OCommonBehaviourControl, FormattedField
+    class NumberFormatSampleField : public ControlWindow< FormattedField >
     {
-    protected:
-            virtual long                    PreNotify( NotifyEvent& rNEvt );
+    private:
+        typedef ControlWindow< FormattedField > BaseClass;

     public:
-                                            OFormatDescriptionControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
+        NumberFormatSampleField( Window* _pParent, WinBits _nStyle )
+            :BaseClass( _pParent, _nStyle )
+        {
+        }

-            virtual void                    SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False);
-            virtual ::rtl::OUString         GetProperty()const;
+        void SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier );

-            virtual void                    SetFormatSupplier(const SvNumberFormatsSupplierObj* pSupplier);
+    protected:
+        virtual long PreNotify( NotifyEvent& rNEvt );
+    };
+
+    //========================================================================
+    //= OFormatSampleControl
+    //========================================================================
+    typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, NumberFormatSampleField > OFormatSampleControl_Base;
+    class OFormatSampleControl : public OFormatSampleControl_Base
+    {
+    public:
+        OFormatSampleControl( Window* pParent, WinBits nWinStyle );
+
+        // XPropertyControl
+        virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+        virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+        inline void SetFormatSupplier( const SvNumberFormatsSupplierObj* _pSupplier )
+        {
+            getTypedControlWindow()->SetFormatSupplier( _pSupplier );
+        }
     };

     //========================================================================
@@ -86,59 +109,61 @@
     //========================================================================
     //= OFormattedNumericControl
     //========================================================================
-    class OFormattedNumericControl : public OCommonBehaviourControl, FormattedField
+    typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > OFormattedNumericControl_Base;
+    class OFormattedNumericControl : public OFormattedNumericControl_Base
     {
-            sal_Int32                       m_nLastDecimalDigits;
+    private:
+        sal_Int32   m_nLastDecimalDigits;
+
+    public:
+        OFormattedNumericControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
+
+        // XPropertyControl
+        virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+        virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+        void SetFormatDescription( const FormatDescription& rDesc );
+
+        // make some FormattedField methods available
+        void SetDecimalDigits(sal_uInt16 nPrecision) { getTypedControlWindow()->SetDecimalDigits(nPrecision); m_nLastDecimalDigits = nPrecision; }
+        void SetDefaultValue(double dDef) { getTypedControlWindow()->SetDefaultValue(dDef); }
+        void EnableEmptyField(sal_Bool bEnable) { getTypedControlWindow()->EnableEmptyField(bEnable); }
+        void SetThousandsSep(sal_Bool bEnable) { getTypedControlWindow()->SetThousandsSep(bEnable); }

     protected:
-            virtual long                    PreNotify( NotifyEvent& rNEvt );
-
-    public:
-                                            OFormattedNumericControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
-                                            ~OFormattedNumericControl();
-
-            virtual void                    SetProperty(const ::rtl::OUString &rString,sal_Bool bIsUnknown=sal_False);
-            virtual ::rtl::OUString         GetProperty()const;
-
-            virtual void                    SetFormatDescription(const FormatDescription& rDesc);
-
-            // make some FormattedField methods available
-            virtual void                    SetDecimalDigits(sal_uInt16 nPrecision) { FormattedField::SetDecimalDigits(nPrecision); m_nLastDecimalDigits = nPrecision; }
-            virtual void                    SetDefaultValue(double dDef) { FormattedField::SetDefaultValue(dDef); }
-            virtual void                    EnableEmptyField(sal_Bool bEnable) { FormattedField::EnableEmptyField(bEnable); }
-            virtual void                    SetThousandsSep(sal_Bool bEnable) { FormattedField::SetThousandsSep(bEnable); }
+        ~OFormattedNumericControl();
     };

     //========================================================================
     //= OFileUrlControl
     //========================================================================
-    typedef ::svt::FileURLBox OFileUrlControl_Base;
-    class OFileUrlControl : public OCommonBehaviourControl, OFileUrlControl_Base
+    typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< ::svt::FileURLBox > > OFileUrlControl_Base;
+    class OFileUrlControl : public OFileUrlControl_Base
     {
+    public:
+        OFileUrlControl( Window* pParent, WinBits nWinStyle );
+
+        // XPropertyControl
+        virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+        virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
     protected:
-        virtual long                    PreNotify( NotifyEvent& rNEvt );
-
-    public:
-        OFileUrlControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
         ~OFileUrlControl();
-
-        virtual void                    SetProperty( const ::rtl::OUString& _rString, sal_Bool bIsUnknown = sal_False );
-        virtual ::rtl::OUString         GetProperty() const;
-
-        void                            SetBaseURL( const String& _rURL ) { OFileUrlControl_Base::SetBaseURL( _rURL ); }
     };

     //========================================================================
-    //= TimeDurationInput
+    //= OTimeDurationControl
     //========================================================================
-    class TimeDurationInput : public ONumericControl
+    class OTimeDurationControl : public ONumericControl
     {
     public:
-        TimeDurationInput( ::Window* pParent, WinBits nWinStyle = WB_TABSTOP);
-        ~TimeDurationInput();
+        OTimeDurationControl( ::Window* pParent, WinBits nWinStyle );
+        ~OTimeDurationControl();

-    protected:
-        virtual void CustomConvert();
+    private:
+        DECL_LINK( OnCustomConvert, MetricField* );
     };

 //............................................................................


Rename tun interfaces with `fboss` prefix

Summary:
Using `front*` name for Tun-Interfaces was misleading in six-pack because some
of the interfaces were being used for back-plane.

aeckert and jasmeetbagga suggested to rename to `fboss*` and here is the diff

Reviewed By: tfangit

Differential Revision: D3783119

fbshipit-source-id: b8eaefa66ffbb448acf3d367fe307279510d0ca0

--- fboss/agent/TunIntf.cpp
+++ fboss/agent/TunIntf.cpp
@@ -31,7 +31,7 @@

 namespace {

-const std::string kTunIntfPrefix = "front";
+const std::string kTunIntfPrefix = "fboss";
 const std::string kTunDev = "/dev/net/tun";

 // Max packets to be processed which are received from host
@@ -135,10 +135,22 @@
 }

 bool TunIntf::isTunIntfName(std::string const& ifName) {
+  // Special case to handle old front0 interface.
+  // XXX: Delete this case after 6 months (atleast one full rollout). 08-27-2016
+  if (ifName == "front0") {
+    return true;
+  }
+
   return ifName.find(kTunIntfPrefix) == 0;
 }

 std::string TunIntf::createTunIntfName(InterfaceID ifID) {
+  // Special case to handle old front0 interface.
+  // XXX: Delete this case after 6 months (atleast one full rollout). 08-27-2016
+  if (ifID == InterfaceID(0)) {
+    return "front0";
+  }
+
   return folly::sformat("{}{}", kTunIntfPrefix, folly::to<std::string>(ifID));
 }

@@ -146,6 +158,13 @@
   if (not isTunIntfName(ifName)) {
     throw FbossError(ifName, " is not a valid tun interface");
   }
+
+  // Special case to handle old front0 interface.
+  // XXX: Delete this case after 6 months (atleast one full rollout). 08-27-2016
+  if (ifName == "front0") {
+    return InterfaceID(0);
+  }
+
   return InterfaceID(atoi(ifName.substr(kTunIntfPrefix.size()).c_str()));
 }


replace LOGA by LOGF (logf makes an exit, no core)

--- src/agent.cc
+++ src/agent.cc
@@ -143,7 +143,7 @@
 	}

 	tport_t *primaries=tport_primaries(nta_agent_tports(mAgent));
-	if (primaries==NULL) LOGA("No sip transport defined.");
+	if (primaries==NULL) LOGF("No sip transport defined.");
 	su_md5_t ctx;
 	su_md5_init(&ctx);


Modified the fuse_operations struct to eliminate the annoying warnings on compilation

--- src/agfs.cpp
+++ src/agfs.cpp
@@ -365,37 +365,6 @@
   return 0;
 }
 #endif /* HAVE_SETXATTR */
-
-static struct fuse_operations agfs_oper = {
-  .getattr= agfs_getattr,
-  .access= agfs_access,
-  .readlink= agfs_readlink,
-  .readdir= agfs_readdir,
-  .mknod= agfs_mknod,
-  .mkdir= agfs_mkdir,
-  .symlink= agfs_symlink,
-  .unlink= agfs_unlink,
-  .rmdir= agfs_rmdir,
-  .rename= agfs_rename,
-  .link= agfs_link,
-  .chmod= agfs_chmod,
-  .chown= agfs_chown,
-  .truncate= agfs_truncate,
-  .utimens= agfs_utimens,
-  .open= agfs_open,
-  .read= agfs_read,
-  .write= agfs_write,
-  .statfs= agfs_statfs,
-  .release= agfs_release,
-  .fsync= agfs_fsync,
-#ifdef HAVE_SETXATTR
-  .setxattr= agfs_setxattr,
-  .getxattr= agfs_getxattr,
-  .listxattr= agfs_listxattr,
-  .removexattr= agfs_removexattr,
-#endif
-};
-

 /************************************
  * OPTIONS PROCESSING (Not working) *
@@ -462,6 +431,8 @@
 static const std::string EXTENSION(".agkey");

 using namespace boost::filesystem;
+
+static struct fuse_operations agfs_oper;

 int main(int argc, char *argv[])
 {
@@ -491,5 +462,36 @@
       }
     }
   }
+
+  memset(&agfs_oper, 0, sizeof(struct fuse_operations));
+
+  agfs_oper.getattr= agfs_getattr;
+  agfs_oper.access= agfs_access;
+  agfs_oper.readlink= agfs_readlink;
+  agfs_oper.readdir= agfs_readdir;
+  agfs_oper.mknod= agfs_mknod;
+  agfs_oper.mkdir= agfs_mkdir;
+  agfs_oper.symlink= agfs_symlink;
+  agfs_oper.unlink= agfs_unlink;
+  agfs_oper.rmdir= agfs_rmdir;
+  agfs_oper.rename= agfs_rename;
+  agfs_oper.link= agfs_link;
+  agfs_oper.chmod= agfs_chmod;
+  agfs_oper.chown= agfs_chown;
+  agfs_oper.truncate= agfs_truncate;
+  agfs_oper.utimens= agfs_utimens;
+  agfs_oper.open= agfs_open;
+  agfs_oper.read= agfs_read;
+  agfs_oper.write= agfs_write;
+  agfs_oper.statfs= agfs_statfs;
+  agfs_oper.release= agfs_release;
+  agfs_oper.fsync= agfs_fsync;
+#ifdef HAVE_SETXATTR
+  agfs_oper.setxattr= agfs_setxattr;
+  agfs_oper.getxattr= agfs_getxattr;
+  agfs_oper.listxattr= agfs_listxattr;
+  agfs_oper.removexattr= agfs_removexattr;
+#endif
+
   return fuse_main(argc, argv, &agfs_oper, NULL);
 }


Pass in limit address correctly

Pass in limit address correctly

--- src/aira.cpp
+++ src/aira.cpp
@@ -323,13 +323,13 @@
     }
     threads.emplace_back(optimise,
         t, std::ref(p), std::ref(all), std::ref(solutionMutex),
-        std::ref(limits[t]), std::ref(limits[t+1]), &limits[2]);
+        std::ref(limits[t]), std::ref(limits[t+1]), limits);
     // Odd number of threads
     if (t+1 == num_threads)
       continue;
     threads.emplace_back(optimise,
         t+1, std::ref(p), std::ref(all), std::ref(solutionMutex),
-        std::ref(limits[t+1]), std::ref(limits[t]), &limits[2]);
+        std::ref(limits[t+1]), std::ref(limits[t]), limits);
   }
   for (auto& thread: threads)
     thread.join();


Oops, pass permutations to solve()

Oops, pass permutations to solve()

--- src/aira.cpp
+++ src/aira.cpp
@@ -52,7 +52,7 @@

 /* Solve CLMOIP and return status */
-int solve(Env & e, Problem & p, int * result, double * rhs, int thread_id);
+int solve(Env & e, Problem & p, int * result, double * rhs, int perm_id);

 int read_lp_problem(Env& e, Problem& p, bool store_objectives);
 int read_mop_problem(Env& e, Problem& p, bool store_objectives);
@@ -366,13 +366,13 @@
 }

 /* Solve CLMOIP and return solution status */
-int solve(Env & e, Problem & p, int * result, double * rhs, int thread_id) {
+int solve(Env & e, Problem & p, int * result, double * rhs, int perm_id) {

   int cur_numcols, status, solnstat;
   double objval;
   double * srhs;
   srhs = new double[p.objcnt];
-  const int *perm = S[p.objcnt][thread_id];
+  const int *perm = S[p.objcnt][perm_id];

   //for(int i = 0; i < p.objcnt; ++i)
   //  srhs[i] = rhs[perm[i]];
@@ -473,6 +473,12 @@
   }
   Solutions s(p.objcnt);

+  int perm_id = thread_id;
+  if (nullptr != perms) {
+    perm_id = perms[thread_id];
+  }
+  const int* perm = S[p.objcnt][perm_id];
+
   int infcnt;
   bool inflast;
   bool infeasible;
@@ -488,7 +494,7 @@
   clock_gettime(CLOCK_MONOTONIC, &start);
   double starttime = (start.tv_sec + start.tv_nsec/1e9);
 #endif
-  int solnstat = solve(e, p, result, rhs, thread_id);
+  int solnstat = solve(e, p, result, rhs, perm_id);
 #ifdef FINETIMING
   clock_gettime(CLOCK_MONOTONIC, &start);
   cplex_time += (start.tv_sec + start.tv_nsec/1e9) - starttime;
@@ -531,12 +537,15 @@
   min = new int[p.objcnt];
   max = new int[p.objcnt];

-  int perm_id = thread_id;
-  if (nullptr != perms) {
-    perm_id = perms[thread_id];
-  }
-  const int* perm = S[p.objcnt][perm_id];
-
+#ifdef DEBUG
+    debug_mutex.lock();
+    std::cout << "Thread " << thread_id << " using permutation ";
+    for (int i = 0; i < p.objcnt; ++i) {
+      std::cout << perm[i] <<  ", ";
+    }
+    std::cout << std::endl;
+    debug_mutex.unlock();
+#endif
   std::atomic<double> &my_limit = shared_limits[perm[0]];
   std::atomic<double> &partner_limit = shared_limits[perm[1]];

@@ -593,7 +602,7 @@
         clock_gettime(CLOCK_MONOTONIC, &start);
         double starttime = (start.tv_sec + start.tv_nsec/1e9);
 #endif
-        solnstat = solve(e, p, result, rhs, thread_id);
+        solnstat = solve(e, p, result, rhs, perm_id);
 #ifdef FINETIMING
         clock_gettime(CLOCK_MONOTONIC, &start);
         cplex_time += (start.tv_sec + start.tv_nsec/1e9) - starttime;


fem/bilininteg_mass.cpp fix

fem/bilininteg_mass.cpp fix

--- fem/bilininteg_mass.cpp
+++ fem/bilininteg_mass.cpp
@@ -999,7 +999,11 @@
                {
                   u[qz] += DQQ[dz][qy][qx] * B[qz][dz];
                }
-               QQQ[qz][qy][qx] = u * d(qx,qy,qz,e);
+            }
+            MFEM_UNROLL(Q1D)
+            for (int qz = 0; qz < Q1D; qz++)
+            {
+               QQQ[qz][qy][qx] = u[qz] * d(qx,qy,qz,e);
             }
          }
       }


Cleanup.

Cleanup.

--- src/bgfx.cpp
+++ src/bgfx.cpp
@@ -1683,8 +1683,9 @@
 	void dump(const Resolution& _resolution)
 	{
 		const uint32_t reset = _resolution.reset;
-
-		BX_TRACE("Resolution: %d x %d, format: %s, MSAAx%d"
+		const uint32_t msaa = (reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
+
+		BX_TRACE("Resolution: %d x %d, format: %s"
 			, _resolution.width
 			, _resolution.height
 			, TextureFormat::Count == _resolution.format
@@ -1692,6 +1693,7 @@
 				: bimg::getName(bimg::TextureFormat::Enum(_resolution.format) )
 			, 1 << ( (reset & BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT)
 			);
+		BX_TRACE("\t[%c] MSAAx%d", 0 != msaa ? 'x' : ' ', 1<<msaa);
 		BX_TRACE("\t[%c] Fullscreen",         0 != (reset & BGFX_RESET_FULLSCREEN)         ? 'x' : ' ');
 		BX_TRACE("\t[%c] V-sync",             0 != (reset & BGFX_RESET_VSYNC)              ? 'x' : ' ');
 		BX_TRACE("\t[%c] Max Anisotropy",     0 != (reset & BGFX_RESET_MAXANISOTROPY)      ? 'x' : ' ');


fix certlist

fix certlist

Former-commit-id: 5a3e912dd85a39d97986b5ee53a7198ea63a2fd9

--- src/cert.cpp
+++ src/cert.cpp
@@ -272,55 +272,53 @@
 						continue;
 					}
 				}
-				else
+				if(txPos.safetyLevel >= SAFETY_LEVEL1)
 				{
-					if(txPos.safetyLevel >= SAFETY_LEVEL1)
-					{
-						if(safeSearch)
-						{
-							pcursor->Next();
-							continue;
-						}
-						if(txPos.safetyLevel >= SAFETY_LEVEL2)
-						{
-							pcursor->Next();
-							continue;
-						}
-					}
-					if(!txPos.safeSearch && safeSearch)
+					if(safeSearch)
 					{
 						pcursor->Next();
 						continue;
 					}
-					CAliasIndex theAlias;
-					CTransaction aliastx;
-					if(!GetTxOfAlias(txPos.vchAlias, theAlias, aliastx))
+					if(txPos.safetyLevel >= SAFETY_LEVEL2)
 					{
 						pcursor->Next();
 						continue;
 					}
-					if(!theAlias.safeSearch && safeSearch)
+				}
+				if(!txPos.safeSearch && safeSearch)
+				{
+					pcursor->Next();
+					continue;
+				}
+				CAliasIndex theAlias;
+				CTransaction aliastx;
+				if(!GetTxOfAlias(txPos.vchAlias, theAlias, aliastx))
+				{
+					pcursor->Next();
+					continue;
+				}
+				if(!theAlias.safeSearch && safeSearch)
+				{
+					pcursor->Next();
+					continue;
+				}
+				if((safeSearch && theAlias.safetyLevel > txPos.safetyLevel) || (!safeSearch && theAlias.safetyLevel > SAFETY_LEVEL1))
+				{
+					pcursor->Next();
+					continue;
+				}
+				if(strRegexp != "")
+				{
+					const string &cert = stringFromVch(vchMyCert);
+					string title = stringFromVch(txPos.vchTitle);
+					boost::algorithm::to_lower(title);
+					if (!regex_search(title, certparts, cregex) && strRegexp != cert && strRegexpLower != stringFromVch(txPos.vchAlias))
 					{
 						pcursor->Next();
 						continue;
 					}
-					if((safeSearch && theAlias.safetyLevel > txPos.safetyLevel) || (!safeSearch && theAlias.safetyLevel > SAFETY_LEVEL1))
-					{
-						pcursor->Next();
-						continue;
-					}
-					if(strRegexp != "")
-					{
-						const string &cert = stringFromVch(vchMyCert);
-						string title = stringFromVch(txPos.vchTitle);
-						boost::algorithm::to_lower(title);
-						if (!regex_search(title, certparts, cregex) && strRegexp != cert && strRegexpLower != stringFromVch(txPos.vchAlias))
-						{
-							pcursor->Next();
-							continue;
-						}
-					}
 				}
+
 				certScan.push_back(txPos);
 			}
 			if (certScan.size() >= nMax)


certinfo: fixed bug

certinfo: fixed bug

--- src/cert.cpp
+++ src/cert.cpp
@@ -1894,13 +1894,14 @@

     Object oLastCertIssuer;
     vector<unsigned char> vchCertItem = vchFromValue(params[0]);
+    vector<unsigned char> vchCertRand = ParseHex(params[0]);

     // look for a transaction with this key, also returns
     // an certissuer object if it is found
     CTransaction tx;
     CCertIssuer theCertIssuer;
     CCertItem theCertItem;
-    if (!GetTxOfCertItem(*pcertdb, vchCertItem, theCertIssuer, tx))
+    if (!GetTxOfCertItem(*pcertdb, vchCertRand, theCertIssuer, tx))
         throw runtime_error("could not find a certificate with this key");
     uint256 txHash = tx.GetHash();

@@ -1915,7 +1916,7 @@
         if (vtxPos.size() < 1)
             throw JSONRPCError(RPC_WALLET_ERROR, "no result returned");
         theCertIssuer = vtxPos.back();
-        if(!theCertIssuer.GetCertItemByHash(vchCertItem, theCertItem))
+        if(!theCertIssuer.GetCertItemByHash(vchCertRand, theCertItem))
             throw runtime_error("could not find a certificate with this hash in DB");

         Object oCertIssuer;


Add support for Sony Xperia X (F5121/F5122)

This is untested, but hopefully should the paths be the same as for
Xperia X Compact.

--- src/cmon.cpp
+++ src/cmon.cpp
@@ -216,7 +216,9 @@

         res = true;
     }
-    else if (outArgs.at(0).toString() == "f5321")  /* Sony Xperia X Compact */
+    else if (outArgs.at(0).toString() == "f5121" || /* Sony Xperia X */
+             outArgs.at(0).toString() == "f5122" || /* Sony Xperia X dual SIM */
+             outArgs.at(0).toString() == "f5321")  /* Sony Xperia X Compact */
     {
         generalValues.clear();
         generalValues << "";


Full impl with a few remaining issues

Full impl with a few remaining issues

--- src/cmst.cpp
+++ src/cmst.cpp
@@ -3,6 +3,8 @@
 #include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
 #include <CGAL/Constrained_Delaunay_triangulation_2.h>
 #include <CGAL/Segment_2.h>
+#include <CGAL/intersections.h>
+#include <CGAL/intersections_d.h>

 #include <boost/graph/adjacency_list.hpp>
 #include <boost/graph/kruskal_min_spanning_tree.hpp>
@@ -15,16 +17,20 @@
 #include <boost/graph/visitors.hpp>
 #include <boost/property_map/property_map.hpp>
 #include <boost/random/linear_congruential.hpp>
+#include <boost/chrono.hpp>

 #include "Forest.h"

 #include <fstream>
 #include <string>

-// CGAL typedefs
+#define SHOW_DEBUG true
+
+// CGAL typedefs (2 space)
 typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
 typedef K::Point_2 CGALPoint;
 typedef K::Segment_2 CGALSegment;
+typedef K::Intersect_2 CGALIntersect;

 typedef CGAL::Constrained_Delaunay_triangulation_2<K, CGAL::Default, CGAL::No_intersection_tag> CDT;

@@ -53,12 +59,43 @@

 boost::minstd_rand gen;

-CDT* computeCdt(std::vector<CGALPoint>* vertices, std::list<std::pair<int, int>>* edges);
-BoostGraph* convertCdtToGraph(std::vector<CGALPoint>* vertices, CDT* cdt, bool assignZeroWeightToConstraints);
-void printGraph(const char* title, BoostGraph* g);
-
-BoostGraph* CreateRandomPlaneForest(int numVertices, int bounds, double edgeProbability) {
-	std::vector<CGALPoint>* vertices = new std::vector<CGALPoint>();
+/**
+* Naive linear time intersection
+* Returns true if edge (u, v) intersects an edge in g, otherwise false
+**/
+bool DoesIntersect(BoostGraph* g, Vertex u, Vertex v) {
+	CGALPoint uPt = (*g)[u].pt;
+	CGALPoint vPt = (*g)[v].pt;
+	CGALSegment segUV(uPt, vPt);
+
+	std::pair<EdgeIter, EdgeIter> ep;
+	EdgeIter ei, ei_end;
+	for (tie(ei, ei_end) = boost::edges(*g); ei != ei_end; ++ei) {
+		Edge e = *ei;
+		Vertex src = source(e, *g);
+		Vertex tar = target(e, *g);
+		CGALSegment seg((*g)[src].pt, (*g)[tar].pt);
+
+		CGAL::cpp11::result_of<CGALIntersect(CGALSegment, CGALSegment)>::type result = intersection(seg, segUV);
+		if (result) {
+			if (const CGALSegment* s = boost::get<CGALSegment>(&*result)) {
+				//std::cout << *s << std::endl;
+				return true;
+			}
+			else if (const CGALPoint* p = boost::get<CGALPoint >(&*result)) {
+				//std::cout << " i " << *p;
+				// Ignore intersection at segment endpoints
+				if (*p != uPt && *p != vPt) {
+					return true;
+				}
+			}
+		}
+	}
+	return false;
+}
+
+BoostGraph* CreateRandomPlaneForest(int numVertices, int bounds, int edgeRolls, double edgeProbability) {
+	BoostGraph* g = new BoostGraph();

 	// Define bounds random gen
 	boost::uniform_int<> boundsRange(0, bounds);
@@ -66,8 +103,9 @@
 	boundsDice.engine().seed(static_cast<unsigned int>(std::time(0)));

 	// To maintain unique x, y
-	std::map<int, std::map<int, int>> xBounds;
-
+	std::unordered_map<int, std::unordered_map<int, int>> xBounds;
+
+	// Generate vertices with random coordinated within bounds
 	for (int i = 0; i < numVertices; i++) {
 		int x = boundsDice();
 		int y = boundsDice();
@@ -75,31 +113,15 @@
 			while (xBounds[x].count(y)) { // y exists, reroll (TODO: range check to prevent infinite loop)
 				y = boundsDice();
 			}
-			xBounds[x].insert(std::pair<int, int>(y, NULL));
+			xBounds[x].emplace(y, NULL);
 		}
 		else {
-			std::map<int, int> yBounds;
-			yBounds.insert(std::pair<int, int>(y, NULL));
-			xBounds.insert(std::pair<int, std::map<int, int>>(x, yBounds));
-		}
-		vertices->push_back(CGALPoint(x, y));
-	}
-
-	// Compute DT (no constraints)
-	CDT* cdt = computeCdt(vertices, NULL);
-
-	BoostGraph* g = convertCdtToGraph(vertices, cdt, false);
-	//printGraph("Random Forest", g);
-	vertices->clear();
-	delete vertices;
-
-	// Removal of edges on vecS graphs invalidates the iterator. It is easier to through them in a list
-	std::list<Edge> edges;
-	std::pair<EdgeIter, EdgeIter> ep;
-	EdgeIter ei, ei_end;
-	for (tie(ei, ei_end) = boost::edges(*g); ei != ei_end; ++ei) {
-		Edge e = *ei;
-		edges.push_back(e);
+			std::unordered_map<int, int> yBounds;
+			yBounds.emplace(y, NULL);
+			xBounds.emplace(x, yBounds);
+		}
+		Vertex v = add_vertex(*g);
+		(*g)[v].pt = CGALPoint(x, y);
 	}

 	// Define edge random gen
@@ -107,22 +129,35 @@
 	boost::variate_generator<boost::minstd_rand, boost::uniform_real<>> edgeDice(gen, edgeRange);
 	edgeDice.engine().seed(static_cast<unsigned int>(std::time(0)));

-	int count = 0;
-	int removed = 0;
-	for (std::list<Edge>::iterator it = edges.begin(); it != edges.end(); ++it) {
-		Edge e = *it;
-		// E.g. edgeDice is 0.6 and edgeProbability = 0.35 then the edge will be removed
-		double roll = edgeDice();
-		if (roll > edgeProbability) {
-			remove_edge(e, (*g));
-			removed++;
-		}
-		count++;
-	}
-
-	std::cout << "Edge count before removal " << count << std::endl;
-	std::cout << "Edge count after removal " << (count - removed) << std::endl;
-	std::cout << "Ratio " << (double(count - removed) / (double)count) << std::endl;
+	boost::uniform_int<> vertexRange(0, numVertices - 1);
+	boost::variate_generator<boost::minstd_rand, boost::uniform_int<>> vertexDice(gen, vertexRange);
+	vertexDice.engine().seed(static_cast<unsigned int>(std::time(0)));
+
+	Forest f;
+	f.Initialize(numVertices);
+
+	// Select random vertices u, v for edgeRolls number of times
+	// An edge connects u, v:
+	//		1. u != v
+	//		2. roll <= edgeProbability
+	//		3. adding edge(u, v) does not create a cycle
+	//		4. edge(u, v) does not intersect any other edge
+	for (int i = 0; i < edgeRolls; i++) {
+		Vertex u = vertexDice();
+		Vertex v = vertexDice();
+		double d = edgeDice();
+		if (u != v
+			&& d <= edgeProbability
+			&& !f.SameTree(u, v)
+			&& !DoesIntersect(g, u, v)) {
+
+			// Add edge(u, v)
+			std::pair<Edge, bool> result = add_edge(u, v, *g);
+			assert(result.second);
+			f.Link(u, v);
+			//std::cout << " - added";
+		}
+	}

 	return g;
 }
@@ -149,41 +184,6 @@
 		std::cout << (*g)[e].weight << " (" << (*g)[src].pt << ") (" << (*g)[tar].pt << ")" << std::endl;
 	}
 	std::cout << std::endl;
-}
-
-void printGraph(const char* title, std::vector<CGALPoint>* vertices, std::list<std::pair<int, int>>* edges) {
-	std::cout << std::endl << "=== " << title << std::endl;
-
-	// Insert vertices
-	std::cout << "Vertices: " << std::endl;
-	for (std::vector<CGALPoint>::iterator it = vertices->begin(); it != vertices->end(); ++it) {
-		std::cout << "(" << *it << ")" << std::endl;
-	}
-
-	std::cout << std::endl << "Edges: " << std::endl;
-	// Insert constraint edges
-	for (std::list<std::pair<int, int>>::iterator it = edges->begin(); it != edges->end(); ++it) {
-		std::cout << "(" << (*vertices)[it->first] << ") (" << (*vertices)[it->second] << ")" << std::endl;
-	}
-}
-
-CDT* computeCdt(std::vector<CGALPoint>* vertices, std::list<std::pair<int, int>>* edges) {
-	CDT* cdt = new CDT();
-
-	// Insert vertices
-	for (std::vector<CGALPoint>::iterator it = vertices->begin(); it != vertices->end(); ++it) {
-		cdt->insert(*it);
-	}
-
-	// Insert constraint edges
-	if (edges) {
-		for (std::list<std::pair<int, int>>::iterator it = edges->begin(); it != edges->end(); ++it) {
-			cdt->insert_constraint((*vertices)[it->first], (*vertices)[it->second]);
-		}
-	}
-
-	assert(cdt->is_valid());
-	return cdt;
 }

 CDT* computeCdt(BoostGraph* g) {
@@ -232,10 +232,10 @@
 	std::cout << "# constrained edges " << constraintCount << std::endl;
 	std::cout << "# unconstrained edges " << unconstraintCount << std::endl << std::endl;

-	for (CDT::Vertex_iterator vit = cdt->vertices_begin(); vit != cdt->vertices_end(); ++vit) {
+	/*for (CDT::Vertex_iterator vit = cdt->vertices_begin(); vit != cdt->vertices_end(); ++vit) {
 		CDT::Vertex v = *vit;
 		std::cout << "(" << v << ")" << std::endl;
-	}
+		}*/
 }

 BoostGraph* convertCdtToGraph(BoostGraph* g, CDT* cdt, bool assignZeroWeightToConstraints) {
@@ -272,38 +272,6 @@
 	return bg_cdt;
 }

-BoostGraph* convertCdtToGraph(std::vector<CGALPoint>* vertices, CDT* cdt, bool assignZeroWeightToConstraints) {
-	BoostGraph* g = new BoostGraph();
-
-	// Add vertices to graph
-	std::map<CGALPoint, Vertex> verticesMap;
-	for (std::vector<CGALPoint>::iterator it = vertices->begin(); it != vertices->end(); ++it) {
-		Vertex v = add_vertex(*g);
-		(*g)[v].pt = *it;
-		verticesMap.insert(std::pair<CGALPoint, Vertex>(*it, v));
-	}
-
-	for (CDT::Edge_iterator eit = cdt->edges_begin(); eit != cdt->edges_end(); ++eit) {
-		CDT::Edge cgal_e = *eit;
-		CGALSegment segement = cdt->segment(cgal_e);
-		CGALPoint cgal_u = segement.point(0);
-		CGALPoint cgal_v = segement.point(1);
-		Vertex u = verticesMap[cgal_u];
-		Vertex v = verticesMap[cgal_v];
-		std::pair<Edge, bool> result = add_edge(u, v, *g);
-		assert(result.second);
-		Edge e = result.first;
-		if (assignZeroWeightToConstraints && cdt->is_constrained(cgal_e)) {
-			(*g)[e].weight = 0;
-		}
-		else {
-			(*g)[e].weight = CGAL::squared_distance(cgal_u, cgal_v);
-		}
-	}
-
-	return g;
-}
-
 BoostGraph* computeMst(BoostGraph* g) {
 	std::list<Edge>* mst = new std::list<Edge>();

@@ -332,11 +300,11 @@
 		(*m)[mE].weight = (*g)[e].weight;
 	}

+	delete mst;
 	return m;
 }

 struct tree_visitor : boost::default_bfs_visitor {
-	Forest* forest;
 	tree_visitor(Forest* f) {
 		forest = f;
 	}
@@ -347,8 +315,11 @@
 		int weight = CGAL::squared_distance(g[src].pt, g[tar].pt); // Re-calculate weights since constraint edges have 0 weight
 		forest->Link(tar, src);
 		forest->SetCost(tar, weight); // First param to Link() is always the leafmost node
-		std::cout << "Tree edge: w:" << weight << " : " << tar << " (" << g[tar].pt << ") " << src << " (" << g[src].pt << ")" << std::endl;
-	}
+		//std::cout << "Tree edge: w:" << weight << " : " << tar << " (" << g[tar].pt << ") " << src << " (" << g[src].pt << ")" << std::endl;
+	}
+
+private:
+	Forest* forest;
 };

 Forest* createLinkCutTree(BoostGraph* g) {
@@ -429,82 +400,243 @@
 	return s;
 }

-BoostGraph* computeCmst(BoostGraph* f) {
+void printDuration(const char* title, boost::chrono::milliseconds duration) {
+	std::cout << title << " Duration: " << duration << std::endl;
+}
+
+void computeCmst(BoostGraph* F, BoostGraph** TPrime, BoostGraph** Cmst, BoostGraph** S) {
 	// Input: plane forest F = (V, E)
 	// Output: minimum set S ⊆ E of constraints such that F ⊆ CMST(V, S)
-	printGraph("Input graph F = (V, E)", f);
+	if (SHOW_DEBUG) { printGraph("Input graph F = (V, E)", F); }
+
+	boost::chrono::high_resolution_clock::time_point start;
+	boost::chrono::high_resolution_clock::time_point end;
+	boost::chrono::milliseconds duration(0);
+	boost::chrono::milliseconds total(0);

 	// Compute CDT(F)
-	CDT* cdt = computeCdt(f);
-	printCdtInfo(cdt);
+	start = boost::chrono::high_resolution_clock::now();
+	CDT* cdt = computeCdt(F);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("CDT(F)", duration);
+	if (SHOW_DEBUG) { printCdtInfo(cdt); }

 	// Create graph representations for CDT(F)
-	BoostGraph* g1 = convertCdtToGraph(f, cdt, false);
-	printGraph("Contraint Delaunay Triangulation (as BoostGraph)", g1);
+	start = boost::chrono::high_resolution_clock::now();
+	BoostGraph* g1 = convertCdtToGraph(F, cdt, false);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("Graph conversion CDT(F)", duration);
+	if (SHOW_DEBUG) { printGraph("Contraint Delaunay Triangulation (as BoostGraph)", g1); }

 	// Create graph representations for CDT◦(F)
-	BoostGraph* g2 = convertCdtToGraph(f, cdt, true);
-	printGraph("CDT◦(F)", g2);
-
-	// Compute T' = MST(CDT(F))
-	BoostGraph* mst = computeMst(g1);
-	printGraph("T' = MST(CDT(F))", mst);
+	start = boost::chrono::high_resolution_clock::now();
+	BoostGraph* g2 = convertCdtToGraph(F, cdt, true);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("Graph conversion CDT◦(F)", duration);
+	if (SHOW_DEBUG) { printGraph("CDT◦(F)", g2); }
+
+	// Compute T' = MST(CDT(F)) (Best case MST)
+	start = boost::chrono::high_resolution_clock::now();
+	*TPrime = computeMst(g1);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("T' = MST(CDT(F))", duration);
+	if (SHOW_DEBUG) { printGraph("T' = MST(CDT(F))", *TPrime); }

 	// Compute CMST(F) = MST(CDT◦(F))
-	BoostGraph* mst2 = computeMst(g2);
-	printGraph("CMST(F) = MST(CDT◦(F))", mst2);
+	start = boost::chrono::high_resolution_clock::now();
+	*Cmst = computeMst(g2);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("CMST(F) = MST(CDT◦(F))", duration);
+	if (SHOW_DEBUG) { printGraph("CMST(F) = MST(CDT◦(F))", *Cmst); }

 	// Create DynamicTree for CMST(F)
-	Forest* forest = createLinkCutTree(mst2);
+	start = boost::chrono::high_resolution_clock::now();
+	Forest* forest = createLinkCutTree(*Cmst);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("Dynamic Tree construction", duration);

 	// Check for cycles and construct constraint set s
-	BoostGraph* s = checkCycles(forest, mst);
-	printGraph("Contraint set S", s);
+	start = boost::chrono::high_resolution_clock::now();
+	*S = checkCycles(forest, *TPrime);
+	end = boost::chrono::high_resolution_clock::now();
+	duration = (boost::chrono::duration_cast<boost::chrono::milliseconds>(end - start));
+	total += duration;
+	printDuration("Check cycles", duration);
+	if (SHOW_DEBUG) { printGraph("Contraint set S", *S); }
+
+	printDuration("Total", total);

 	delete forest;
-
-	mst2->clear();
-	delete mst2;
-
-	mst->clear();
-	delete mst;

 	g2->clear();
 	delete g2;
-
+
 	g1->clear();
 	delete g1;

 	cdt->clear();
 	delete cdt;
-
-	return s;
-}
+}
+
+bool containsEdge(BoostGraph* g, Vertex u, Vertex v) {
+	// Iterate through the edges
+	std::pair<EdgeIter, EdgeIter> ep;
+	EdgeIter ei, ei_end;
+	for (tie(ei, ei_end) = boost::edges(*g); ei != ei_end; ++ei) {
+		Edge e = *ei;
+		Vertex src = source(e, *g);
+		Vertex tar = target(e, *g);
+		if ((u == src && v == tar) || (u == tar && v == src)) {
+			return true;
+		}
+	}
+	return false;
+}
+
+// True if A a subgraph of B
+bool isSubgraph(BoostGraph* a, BoostGraph* b) {
+	// Iterate through the edges
+	std::pair<EdgeIter, EdgeIter> ep;
+	EdgeIter ei, ei_end;
+	for (tie(ei, ei_end) = boost::edges(*a); ei != ei_end; ++ei) {
+		Edge e = *ei;
+		Vertex u = source(e, *a);
+		Vertex v = target(e, *a);
+
+		if (!containsEdge(b, u, v)) {
+			return false;
+		}
+	}
+
+	return true;
+}
+
+BoostGraph* graphOmitEdge(BoostGraph* S, int omitIndex) {
+	BoostGraph* newS = new BoostGraph();
+
+	std::pair<VertexIter, VertexIter> vp;
+	for (vp = boost::vertices(*S); vp.first != vp.second; ++vp.first) {
+		Vertex v = *vp.first;
+		Vertex nV = add_vertex(*newS);
+		(*newS)[nV].pt = (*S)[v].pt;
+	}
+
+	int index = 0;
+	std::pair<EdgeIter, EdgeIter> ep;
+	EdgeIter ei, ei_end;
+	for (tie(ei, ei_end) = boost::edges(*S); ei != ei_end; ++ei) {
+		if (index++ == omitIndex) {
+			continue;
+		}
+
+		Edge e = *ei;
+		Vertex src = source(e, *S);
+		Vertex tar = target(e, *S);
+
+		std::pair<Edge, bool> result = add_edge(src, tar, *newS);
+		assert(result.second);
+		Edge nE = result.first;
+		(*newS)[nE].weight = (*S)[e].weight;
+	}
+
+	return newS;
+}
+
+bool isCmstSubgraph(BoostGraph* F, BoostGraph* S) {
+	CDT* cdtS = computeCdt(S);
+	BoostGraph* bg_cdtS = convertCdtToGraph(S, cdtS, true);
+	BoostGraph* cmstS = computeMst(bg_cdtS);
+	if (SHOW_DEBUG) {
+		printGraph("CMST(V, S)", cmstS);
+	}
+
+	bool res = isSubgraph(F, cmstS);
+
+	delete cmstS;
+	delete bg_cdtS;
+	delete cdtS;
+
+	return res;
+}
+
+bool isMinimal(BoostGraph* F, BoostGraph* S) {
+	// Validate
+	// S ⊆ E s.t. F ⊆ CMST(V, S). Note: CMST(G) = MST(CVG(G)) = MST(CDT◦(G)) (where CDT◦(G) = CDT(G) when all edges in G have 0 weight)
+	// Notice: CMST(V, S) is a spanning graph, that is there is at least 1 edge that connects every vertex. So F, the constraint set should be a subset of CMST(V, S)
+	// In other words, we want to find the smallest subset S of edges of F such that
+	// CMST(F) is equal to CMST(V, S), although the weights of the two trees may
+	// be different.
+	if (!isCmstSubgraph(F, S)) {
+		return false;
+	}
+
+	// Removal of any edge of S should result in F !⊆ CMST(V, S)
+	for (int i = 0; i < S->m_edges.size(); i++) {
+		BoostGraph* omittedS = graphOmitEdge(S, i);
+		bool sub = isCmstSubgraph(F, omittedS);
+		delete omittedS;
+
+		if (sub) {
+			return false;
+		}
+	}
+	return true;
+}
+
+bool isContainedIn(BoostGraph* F, BoostGraph* S, BoostGraph* TPrime) {
+	std::pair<EdgeIter, EdgeIter> ep;
+	EdgeIter ei, ei_end;
+	for (tie(ei, ei_end) = boost::edges(*F); ei != ei_end; ++ei) {
+		Edge e = *ei;
+		Vertex src = source(e, *F);
+		Vertex tar = target(e, *F);
+
+		if (containsEdge(S, src, tar))
+			continue;
+		else if (containsEdge(TPrime, src, tar))
+			continue;
+		else
+			return false;
+	}
+
+	return true;
+}
+
+// TODO:
+// Figure out the edge list so it's not linear time or slow for MSTs
+// CDT constraint list is sometimes different from F's edge list, is this an CGAL bug?
+// Traffic data

 int main(int argc, char* argv[]) {
-	BoostGraph* F = CreateRandomPlaneForest(10, 10, 0.20);
-	printGraph("Input plane forest F = (V, E)", F);
-
-	BoostGraph* S = computeCmst(F);
-
-	// Validate F ⊆ CMST(V, S)
-	CDT* cdtF = computeCdt(F);
-	CDT* cdtS = computeCdt(S);
-	BoostGraph* bg_cdtF = convertCdtToGraph(F, cdtF, true);
-	BoostGraph* bg_cdtS = convertCdtToGraph(S, cdtS, true);
-	BoostGraph* mstF = computeMst(bg_cdtF);
-	BoostGraph* mstS = computeMst(bg_cdtS);
-	printGraph("MST(F)", mstF);
-	printGraph("MST(S)", mstS);
-
-	delete mstS;
-	delete mstF;
-	delete bg_cdtS;
-	delete bg_cdtF;
-	delete cdtS;
-	delete cdtF;
+	BoostGraph* F = CreateRandomPlaneForest(10, 10, 10, 0.40);
+
+	BoostGraph* TPrime = NULL;
+	BoostGraph* Cmst = NULL;
+	BoostGraph* S = NULL;
+
+	computeCmst(F, &TPrime, &Cmst, &S);
+
+	// S ⊆ E s.t. F ⊆ CMST(V, S)
+	assert(isMinimal(F, S));
+
+	// For each e in F, if e not in S, then e in T'
+	assert(isContainedIn(F, S, TPrime));
+
 	delete S;
-
+	delete Cmst;
+	delete TPrime;
 	delete F;

 	return 0;


bugfix: outside combing was skipped sometimes

--- src/comb.cpp
+++ src/comb.cpp
@@ -164,7 +164,7 @@
             middle_from = startPoint;
             inside_middle_from = startPoint;
             middle_to = endPoint;
-            inside_middle_to = startPoint;
+            inside_middle_to = endPoint;
         }
         else if(!startInside && endInside)
         {


Handle edge case of parallel line intersection

If a line was parallel with an edge of the polygon, the line should be marked as intersecting that edge to properly register the scanline crossing. This handles that edge case for most cases by adding one intersection. In some cases it is plausible that two intersections should be registered. For those cases this procedure is still wrong, since it is computationally expensive to detect them.

--- src/comb.cpp
+++ src/comb.cpp
@@ -243,9 +243,33 @@
         for(unsigned int point_idx = 0; point_idx < poly.size(); point_idx++)
         {
             Point p1 = transformation_matrix.apply(PolygonUtils::getBoundaryPointWithOffset(poly,point_idx,dist_to_move_boundary_point_outside));
-            if ((p0.Y > transformed_startPoint.Y && p1.Y < transformed_startPoint.Y) || (p1.Y > transformed_startPoint.Y && p0.Y < transformed_startPoint.Y))
-            {
-                int64_t x = p0.X + (p1.X - p0.X) * (transformed_startPoint.Y - p0.Y) / (p1.Y - p0.Y);
+            if((p0.Y >= transformed_startPoint.Y && p1.Y <= transformed_startPoint.Y) || (p1.Y >= transformed_startPoint.Y && p0.Y <= transformed_startPoint.Y))
+            {
+                int64_t x;
+                if(p1.Y == p0.Y) //Line segment is parallel with the scanline. The intersection is also a line segment. So pick any point on the intersection. No guarantees!
+                {
+                    //If they intersect, two of {p0,p1,transformed_startPoint,transformed_endPoint} will be on the intersection.
+                    if(p0.X >= transformed_startPoint.X && p0.X <= transformed_endPoint.X) //p0 is on the intersection.
+                    {
+                        x = p0.X;
+                    }
+                    else if(p1.X >= transformed_startPoint.X && p1.X <= transformed_endPoint.X) //p1 is on the intersection.
+                    {
+                        x = p1.X;
+                    }
+                    else if(transformed_startPoint.X >= p0.X && transformed_startPoint.X <= p1.X) //The start point is on the intersection.
+                    {
+                        x = transformed_startPoint.X;
+                    }
+                    else //The end point is on the intersection, or none are. If the end point is on the intersection, take it. Otherwise, take it anyway but it will fail to trigger an intersection.
+                    {
+                        x = transformed_endPoint.X;
+                    }
+                }
+                else
+                {
+                    x = p0.X + (p1.X - p0.X) * (transformed_startPoint.Y - p0.Y) / (p1.Y - p0.Y);
+                }

                 if (x >= transformed_startPoint.X && x <= transformed_endPoint.X)
                 {


Revert "New way from line 229 to 36"

Revert "New way from line 229 to 36"

This reverts commit 39e7ec81aed78c19849a0a1f5faba6a65edc62b8.

--- src/core.cpp
+++ src/core.cpp
@@ -226,14 +226,6 @@
 	   return HashX17(BEGIN(nVersion), END(nNonce));
 	}
 }*/
-/*uint256 CBlockHeader::GetHash() const{
-	if (LastHeight>=15){
-    return HashX11(BEGIN(nVersion), END(nNonce));
-	}
-    else {
-	   return HashX17(BEGIN(nVersion), END(nNonce));
-	}
-    }*/

 uint256 CBlockHeader::GetHashX11() const
 {


Month bug fixed.

Month bug fixed.

--- src/date.cpp
+++ src/date.cpp
@@ -84,7 +84,7 @@
   std::tm * current_time = std::localtime(&time_);

   day = current_time->tm_mday;
-  month = current_time->tm_mon;
+  month = current_time->tm_mon + 1;
   year = BASE_YEAR + current_time->tm_year;

 }


Finally happy with background color.

Finally happy with background color.

--- src/demo.cpp
+++ src/demo.cpp
@@ -421,7 +421,7 @@

     // Prepare render pass instance.
     VkClearValue clear_values[2];
-    clear_values[0].color = {0.5f, 0.5f, 0.57f, 0.0f};
+    clear_values[0].color = {0.6f, 0.6f, 0.66f, 0.0f};
     clear_values[1].depthStencil.depth = 1.0;
     clear_values[1].depthStencil.stencil = 0;


demo调整

demo调整

--- src/demo.cpp
+++ src/demo.cpp
@@ -21,7 +21,7 @@
 //AI֣ʾڽ
 extern "C" DECLSPEC_EXPORT char const *WINAPI Name()
 {
-    static std::string name = "ai demo (random)";
+    static std::string name = tetris_ai.ai_name();
     return name.c_str();
 }


[fix] working with visible

[fix] working with visible

--- src/draw.cpp
+++ src/draw.cpp
@@ -133,14 +133,14 @@
         for ( size_t j = 0; j < f.f[i].size(); j++ ) {
             if ( f.f[i][j] ) {
                 auto cc = cell_contour( { (int)i, (int)j }, f, 32 );
-                SDL_Point sc[cc.size()];
-                for (std::size_t i = 0; i < cc.size(); ++i)
-                {
-                    cc[i].r = R;
-                    sc[i] = surf_to_screen( n, cc[i], center);
-                }
                 if ( n * cc[0] >= 0 ) { // так не видно косяков
                 // if ( visible( n, cc[0] ) ) {
+                    SDL_Point sc[cc.size()];
+                    for (std::size_t i = 0; i < cc.size(); ++i)
+                    {
+                        cc[i].r = R;
+                        sc[i] = surf_to_screen( n, cc[i], center);
+                    }
                     draw_filled_polygon( sc, 32 );
                 }
             }


fix bug: when using with hadoop profile, filename get garbled

--- src/entry.cc
+++ src/entry.cc
@@ -172,7 +172,10 @@
   }
   size_t len = POSITIVE(name_end - name_begin);
   char *file_name = new char[len];
-  strncpy(file_name, name_begin, len);
+  for(int i = 0; i < len; ++i){
+    file_name[i] = '\0';
+  }
+  strcpy(file_name, name_begin);
   if (strcmp(file_name, "stderr") == 0) {
     Globals::OutFile = stderr;
   } else if (strcmp(file_name, "stdout") == 0) {


use ber and wer function in operator<<

use ber and wer function in operator<<

--- src/eval.c++
+++ src/eval.c++
@@ -59,7 +59,8 @@
   const auto wrong_words = e.reconstruction_failures + e.reconstruction_errors;
   os << std::setprecision(12) << wrong_words / samples_ << " ";
   os << std::setprecision(12) << e.fk_corr / samples_ << " ";
-  os << std::setprecision(12) << e.bit_errors / (samples_ * e.n);
+  os << std::setprecision(12) << e.ber() << " ";
+  os << std::setprecision(12) << e.wer();
   return os;
 }


Check stack depth at each instruction when tracing

--- src/exec.cpp
+++ src/exec.cpp
@@ -2196,7 +2196,14 @@
     while (callstack.size() > min_callstack_depth && ip < module->object.code.size() && exit_code == 0) {
         if (options->enable_trace) {
             auto i = ip;
-            std::cerr << "mod " << module->name << " ip " << ip << " " << disassemble_instruction(module->object, i) << " | st " << stack.depth() << "\n";
+            std::cerr << "mod " << module->name << " ip " << ip << " (" << stack.depth() << ") " << disassemble_instruction(module->object, i) << "\n";
+            if (module->debug != nullptr) {
+                auto sd = module->debug->stack_depth.find(ip);
+                if (sd != module->debug->stack_depth.end() && sd->second != static_cast<int>(stack.depth())) {
+                    std::cerr << "stack depth mismatch: expected=" << sd->second << " actual=" << stack.depth() << "\n";
+                    abort();
+                }
+            }
         }
         if (debug_server != nullptr) {
             switch (debugger_state) {


*** empty log message ***

*** empty log message ***

--- src/file.cpp
+++ src/file.cpp
@@ -40,7 +40,10 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+
+#ifndef _MODE_T_
 typedef int mode_t;
+#endif

 #else


Inserting elses in game.cpp

Inserting elses in game.cpp

--- src/game.cpp
+++ src/game.cpp
@@ -52,7 +52,7 @@
 		exit(EXIT_FAILURE);
 	}
 	else {
-		//Nothing to do
+		//Nothing to do
 	}

 	instance = this;
@@ -66,6 +66,9 @@
 		error_messege = "Could not initialize SDL:\n" + error_messege;

 		throw GameException(error_messege);
+	}
+	else {
+		//Nothing to do
 	}

 	// Initialize image module and check if process went OK
@@ -97,18 +100,26 @@
 		string error_messege_main = SDL_GetError();
 		string error_messege = "Could not initiazlie image libary for type:";

-		for (auto format : image_formats)
+		for (auto format : image_formats) {
 			if ((format & res) == 0) {
 				error_messege += code_name_map[format];
 			}
+			else {
+				//Nothing to do
+			}
+		}

 		error_messege += "\n";
 		error_messege = error_messege_main + error_messege;

 		throw GameException(error_messege);
 	}
+	else {
+		//Nothing to do
+	}

 	int audio_modules = MIX_INIT_OGG;
+
 	res = Mix_Init(audio_modules);

 	/* Check the possibility initiation of SDL audio and return a error messege
@@ -117,15 +128,18 @@

 	if (res != audio_modules) {

+		throw GameException("Problem when initiating SDL audio!");
+
 		if ((MIX_INIT_OGG & res ) == 0 ){
 			cerr << "OGG flag not in res!" << endl;
 		}
+		else {
+			//Nothing to do
+		}

 		if ((MIX_INIT_MP3 & res ) == 0 ){
 			cerr << "MP3 flag not in res!" << endl;
 		}
-
-		throw GameException("Problem when initiating SDL audio!");

 	}


print some nonsense before game starts

print some nonsense before game starts

--- src/game.cpp
+++ src/game.cpp
@@ -524,6 +524,19 @@
     return true;
 }

+static string funnyGo(){
+    switch (Util::rnd(10)){
+        case 0 : return "Robofrance 99";
+        case 1 : return "Is that a weasel?";
+        case 2 : return "You are the insult master!";
+        case 3 : return "Get to the choppaa!!!";
+        case 4 : return "Ride or die";
+        case 5 : return "Let the Dragon ride on the winds of time";
+        case 6 : return "I LIKE TURTLES";
+        default : return "Go!";
+    }
+}
+
 void realGame(const vector< Object * > & players, const Level::LevelInfo & levelInfo){

     // Level::LevelInfo levelInfo = Level::readLevels( levelFile );
@@ -554,6 +567,7 @@
             Global::info("Setting up world");
             AdventureWorld world( players, Filesystem::find(*it));
             Global::info("World setup");
+            Global::info(funnyGo());

             Music::pause();
             Music::fadeIn( 0.3 );
@@ -571,7 +585,6 @@
                 playerX->setStatus( Status_Falling );
             }

-            Global::info("Go!");
             stopLoading( loading_screen_thread );

             gameState = playLevel( world, players, showHelp );


Fix memset for linux gcc

Fix memset for linux gcc

Change-Id: I55054580c0afd9692c1b8c6e35a1053e57cd371a
Signed-off-by: Artur Troian <074b12614ab7f9e8d27abe59a593f8d13fab9fa5@gmail.com>

--- src/hmac.cpp
+++ src/hmac.cpp
@@ -1,6 +1,8 @@
 //
 // Created by Artur Troian on 1/21/17.
 //
+
+#include <cstring>

 #include <jwtpp/crypto.hpp>


Custom 'strtod' implementation.

Custom 'strtod' implementation.

--- src/html.cpp
+++ src/html.cpp
@@ -167,3 +167,64 @@

 	str = ss.str();
 }
+
+double litehtml::strtod(const char *nptr, char **endptr)
+{
+	tstring num;
+	tstring dec;
+	const char *p;
+	double val = 0;
+	bool neg;
+	double f;
+	int i;
+
+	p = nptr;
+
+	if (*p == '+')
+	{
+		neg = false;
+		p++;
+	}
+	else if (*p == '-')
+	{
+		neg = true;
+		p++;
+	}
+
+	while (*p)
+	{
+		if (*p == '.' || !t_isdigit(*p))
+			break;
+		num += *p++;
+	}
+
+	f = 1.0;
+	for (i = num.length() - 1; i >= 0; i--)
+	{
+		val += (num[i] - '0') * f;
+		f *= 10.0;
+	}
+
+	if (*p == '.')
+	{
+		p++;
+		while(*p)
+		{
+			if (!t_isdigit(*p))
+				break;
+			dec += *p++;
+		}
+
+		f = 1.0;
+		for (i = 0; i < dec.length(); i++)
+		{
+			f /= 10.0;
+			val += (dec[i] - '0') * f;
+		}
+	}
+
+	if (endptr)
+		*endptr = (char *)p;
+
+	return neg ? (-val) : val;
+}


Use constexpr on array

Use constexpr on array

--- src/ics3.cpp
+++ src/ics3.cpp
@@ -65,7 +65,7 @@
 }

 ics::ID ics::ICS3::getID() {
-  const Core::IDContainerTx tx {0xFF, 0x00, 0x00, 0x00};
+  constexpr Core::IDContainerTx tx {0xFF, 0x00, 0x00, 0x00};
   Core::IDContainerRx rx;
   core->communicateID(tx, rx);
   return ID {static_cast<uint8_t>(0x1F & rx[4])};


Small unittest to check the handles of a vertexohalfedge iterator

git-svn-id: e0b5bbb11d0e9fdbbfcabba14dc32ad5d6b235bd@767 fdac6126-5c0c-442c-9429-916003d36597

--- src/Unittests/unittests_trimesh_circulators.hh
+++ src/Unittests/unittests_trimesh_circulators.hh
@@ -637,7 +637,7 @@
   // Iterate around vertex 1 at the middle (with holes in between)
   Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_iter(vhandle[1]);

-  // TODO: If called
+  // TODO: If called without handle, it won't build
   Mesh::EdgeHandle       eh  = mesh_.edge_handle(voh_it.handle());
   Mesh::HalfedgeHandle   heh = mesh_.halfedge_handle(voh_it);
   Mesh::VertexHandle     vh2 = mesh_.to_vertex_handle(voh_it);


Refactor ICF.

Refactor ICF.

In order to use forEachGroup in the final loop in ICF::run,
I changed some function parameter types.

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

--- ELF/ICF.cpp
+++ ELF/ICF.cpp
@@ -95,10 +95,11 @@
   static bool isEligible(InputSectionBase<ELFT> *Sec);
   static std::vector<InputSection<ELFT> *> getSections();

-  void segregate(InputSection<ELFT> **Begin, InputSection<ELFT> **End,
-                 Comparator Eq);
-
-  void forEachGroup(std::vector<InputSection<ELFT> *> &V, Comparator Eq);
+  void segregate(MutableArrayRef<InputSection<ELFT> *> Arr, Comparator Eq);
+
+  void
+  forEachGroup(std::vector<InputSection<ELFT> *> &V,
+               std::function<void(MutableArrayRef<InputSection<ELFT> *>)> Fn);

   template <class RelTy>
   static bool relocationEq(ArrayRef<RelTy> RA, ArrayRef<RelTy> RB);
@@ -153,18 +154,18 @@
 // you call this function. This function compare sections between Begin
 // and End using Eq and assign new group IDs for new groups.
 template <class ELFT>
-void ICF<ELFT>::segregate(InputSection<ELFT> **Begin, InputSection<ELFT> **End,
+void ICF<ELFT>::segregate(MutableArrayRef<InputSection<ELFT> *> Arr,
                           Comparator Eq) {
   // This loop rearranges [Begin, End) so that all sections that are
   // equal in terms of Eq are contiguous. The algorithm is quadratic in
   // the worst case, but that is not an issue in practice because the
   // number of distinct sections in [Begin, End) is usually very small.
-  InputSection<ELFT> **I = Begin;
+  InputSection<ELFT> **I = Arr.begin();
   for (;;) {
     InputSection<ELFT> *Head = *I;
     auto Bound = std::stable_partition(
-        I + 1, End, [&](InputSection<ELFT> *S) { return Eq(Head, S); });
-    if (Bound == End)
+        I + 1, Arr.end(), [&](InputSection<ELFT> *S) { return Eq(Head, S); });
+    if (Bound == Arr.end())
       return;
     uint64_t Id = NextId++;
     for (; I != Bound; ++I)
@@ -173,14 +174,15 @@
 }

 template <class ELFT>
-void ICF<ELFT>::forEachGroup(std::vector<InputSection<ELFT> *> &V,
-                             Comparator Eq) {
+void ICF<ELFT>::forEachGroup(
+    std::vector<InputSection<ELFT> *> &V,
+    std::function<void(MutableArrayRef<InputSection<ELFT> *>)> Fn) {
   for (InputSection<ELFT> **I = V.data(), **E = I + V.size(); I != E;) {
     InputSection<ELFT> *Head = *I;
     auto Bound = std::find_if(I + 1, E, [&](InputSection<ELFT> *S) {
       return S->GroupId != Head->GroupId;
     });
-    segregate(I, Bound, Eq);
+    Fn({I, Bound});
     I = Bound;
   }
 }
@@ -259,14 +261,14 @@
   // Initially, we use hash values as section group IDs. Therefore,
   // if two sections have the same ID, they are likely (but not
   // guaranteed) to have the same static contents in terms of ICF.
-  std::vector<InputSection<ELFT> *> V = getSections();
-  for (InputSection<ELFT> *S : V)
+  std::vector<InputSection<ELFT> *> Sections = getSections();
+  for (InputSection<ELFT> *S : Sections)
     // Set MSB on to avoid collisions with serial group IDs
     S->GroupId = getHash(S) | (uint64_t(1) << 63);

   // From now on, sections in V are ordered so that sections in
   // the same group are consecutive in the vector.
-  std::stable_sort(V.begin(), V.end(),
+  std::stable_sort(Sections.begin(), Sections.end(),
                    [](InputSection<ELFT> *A, InputSection<ELFT> *B) {
                      if (A->GroupId != B->GroupId)
                        return A->GroupId < B->GroupId;
@@ -276,34 +278,32 @@
                    });

   // Compare static contents and assign unique IDs for each static content.
-  forEachGroup(V, equalsConstant);
+  forEachGroup(Sections, [&](MutableArrayRef<InputSection<ELFT> *> V) {
+    segregate(V, equalsConstant);
+  });

   // Split groups by comparing relocations until we get a convergence.
   int Cnt = 1;
   for (;;) {
     ++Cnt;
     uint64_t Id = NextId;
-    forEachGroup(V, equalsVariable);
+    forEachGroup(Sections, [&](MutableArrayRef<InputSection<ELFT> *> V) {
+      segregate(V, equalsVariable);
+    });
     if (Id == NextId)
       break;
   }
   log("ICF needed " + Twine(Cnt) + " iterations.");

   // Merge sections in the same group.
-  for (auto I = V.begin(), E = V.end(); I != E;) {
-    InputSection<ELFT> *Head = *I++;
-    auto Bound = std::find_if(I, E, [&](InputSection<ELFT> *S) {
-      return Head->GroupId != S->GroupId;
-    });
-    if (I == Bound)
-      continue;
+  forEachGroup(Sections, [&](MutableArrayRef<InputSection<ELFT> *> V) {
+    InputSection<ELFT> *Head = V[0];
     log("selected " + Head->Name);
-    while (I != Bound) {
-      InputSection<ELFT> *S = *I++;
+    for (InputSection<ELFT> *S : V.slice(1)) {
       log("  removed " + S->Name);
       Head->replace(S);
     }
-  }
+  });
 }

 // ICF entry point function.


Keep Socket Open Between Calls, Massive Improvement to Stability

--- Exosite.cpp
+++ Exosite.cpp
@@ -67,7 +67,11 @@

   Serial.print(F("Connecting to Exosite..."));

-  if (client->connect(serverName,80)) {
+  if (!client->connected()) {
+    client->connect(serverName,80);
+  }
+
+  if (client->connected()) {
     client->flush();
     Serial.println(F("Connected"));

@@ -165,8 +169,6 @@
     Serial.println(F("Error: Can't Open Connection to Exosite."));
   }

-  client->stop();
-
   #ifdef EXOSITEDEBUG
     Serial.println(F("End Char ReadWrite"));
   #endif
@@ -288,7 +290,11 @@

   Serial.print(F("Connecting to Exosite (Provision)..."));

-  if (client->connect(serverName,80)) {
+  if (!client->connected()) {
+    client->connect(serverName,80);
+  }
+
+  if (client->connected()) {
     client->flush();
     Serial.println(F("Connected"));

@@ -366,8 +372,6 @@
     Serial.println(F("Error: Can't Open Connection to Exosite."));
   }

-  client->stop();
-
   free(writeString);

   #ifdef EXOSITEDEBUG
@@ -434,7 +438,11 @@

   Serial.print(F("Connecting to Exosite (Time)..."));

-  if (client->connect(serverName,80)) {
+  if (!client->connected()) {
+    client->connect(serverName,80);
+  }
+
+  if (client->connected()) {
     client->flush();
     Serial.println(F("Connected"));

@@ -502,8 +510,6 @@
     Serial.println(F("Error: Can't Open Connection to Exosite."));
   }

-  client->stop();
-
   #ifdef EXOSITEDEBUG
     Serial.println(F("End of Time"));
   #endif


error out, when we detect -socks argument

--- src/init.cpp
+++ src/init.cpp
@@ -881,6 +881,10 @@
         fDaemon = gArgs.GetBoolArg("-daemon");
 #endif

+    // Check for -socks - as this is a privacy risk to continue, exit here
+    if (gArgs.IsArgSet("-socks"))
+        return InitError(_("Error: Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
+
     if (fDaemon)
         fServer = true;
     else


re-add -reindex help message

re-add -reindex help message

was suddenly removed with fc44231cb72afae2fffe0fac64e236a1d33b90e6 (probably not by purpose)

--- src/init.cpp
+++ src/init.cpp
@@ -279,7 +279,7 @@
     strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. "
             "Warning: Reverting this setting requires re-downloading the entire blockchain. "
             "(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
-
+    strUsage += HelpMessageOpt("-reindex", _("Rebuild block chain index from current blk000??.dat files on startup"));
 #if !defined(WIN32)
     strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
 #endif


windows: remove call to SetProcessDEPPolicy

SetProcessDEPPolicy() is only supported by 32-bit Windows processes. On 64-bit
Windows it fails with ERROR_NOT_SUPPORTED (DEP is always enabled on 64-bit).

More info:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessdeppolicy

--- src/init.cpp
+++ src/init.cpp
@@ -828,9 +828,6 @@
     _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
 #endif
 #ifdef WIN32
-    // Enable Data Execution Prevention (DEP)
-    SetProcessDEPPolicy(PROCESS_DEP_ENABLE);
-
     // Enable heap terminate-on-corruption
     HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
 #endif


make -logtimestamps default on and rework help-message

Rebased-By: Wladimir J. van der Laan <bbc07dc96bb50bf6868a2ddfc4dae14fbed703d9@gmail.com>
Rebased-From: 959e62f

--- src/init.cpp
+++ src/init.cpp
@@ -335,7 +335,7 @@
         "  -testnet               " + _("Use the test network") + "\n" +
         "  -debug                 " + _("Output extra debugging information. Implies all other -debug* options") + "\n" +
         "  -debugnet              " + _("Output extra network debugging information") + "\n" +
-        "  -logtimestamps         " + _("Prepend debug output with timestamp") + "\n" +
+        "  -logtimestamps         " + _("Prepend debug output with timestamp (default: 1)") + "\n" +
         "  -shrinkdebugfile       " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n" +
         "  -printtoconsole        " + _("Send trace/debug info to console instead of debug.log file") + "\n" +
 #ifdef WIN32
@@ -571,7 +571,7 @@
 #endif
     fPrintToConsole = GetBoolArg("-printtoconsole");
     fPrintToDebugger = GetBoolArg("-printtodebugger");
-    fLogTimestamps = GetBoolArg("-logtimestamps");
+    fLogTimestamps = GetBoolArg("-logtimestamps", true);

     if (mapArgs.count("-timeout"))
     {


log used config file to debug.log on startup

(cherry picked from commit 5bd02cf715dcb44cfc797c0d1fb94b80350b6489)

--- src/init.cpp
+++ src/init.cpp
@@ -652,6 +652,7 @@
         LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
     LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
     LogPrintf("Using data directory %s\n", strDataDir);
+    LogPrintf("Using config file %s\n", GetConfigFile().string());
     LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
     std::ostringstream strErrors;


make peertimeout a debug argument, remove error message translation

--- src/init.cpp
+++ src/init.cpp
@@ -403,7 +403,7 @@
     gArgs.AddArg("-proxyrandomize", strprintf("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE), false, OptionsCategory::CONNECTION);
     gArgs.AddArg("-seednode=<ip>", "Connect to a node to retrieve peer addresses, and disconnect. This option can be specified multiple times to connect to multiple nodes.", false, OptionsCategory::CONNECTION);
     gArgs.AddArg("-timeout=<n>", strprintf("Specify connection timeout in milliseconds (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT), false, OptionsCategory::CONNECTION);
-    gArgs.AddArg("-peertimeout=<n>", strprintf("Specify p2p connection timeout in seconds. This option determines the amount of time a peer may be inactive before the connection to it is dropped. (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), false, OptionsCategory::CONNECTION);
+    gArgs.AddArg("-peertimeout=<n>", strprintf("Specify p2p connection timeout in seconds. This option determines the amount of time a peer may be inactive before the connection to it is dropped. (minimum: 1, default: %d)", DEFAULT_PEER_CONNECT_TIMEOUT), true, OptionsCategory::CONNECTION);
     gArgs.AddArg("-torcontrol=<ip>:<port>", strprintf("Tor control port to use if onion listening enabled (default: %s)", DEFAULT_TOR_CONTROL), false, OptionsCategory::CONNECTION);
     gArgs.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", false, OptionsCategory::CONNECTION);
 #ifdef USE_UPNP
@@ -1054,7 +1054,7 @@

     peer_connect_timeout = gArgs.GetArg("-peertimeout", DEFAULT_PEER_CONNECT_TIMEOUT);
     if (peer_connect_timeout <= 0) {
-        return InitError(_("peertimeout cannot be configured with a negative value."));
+        return InitError("peertimeout cannot be configured with a negative value.");
     }

     if (gArgs.IsArgSet("-minrelaytxfee")) {


Set RPC warmup to finished at the very end of init.

Previously it was before the wallet had finished startup and
possibly at times the wallet had not finished re-accepting txns
before rpc's from python tests were executed against the wallet.
Therefore indicating rpc is ready after the wallet has loaded fully
will possibly prevent a few spurious wallet test failures.

--- src/init.cpp
+++ src/init.cpp
@@ -1491,22 +1491,20 @@
     StartTxAdmission(threadGroup);
     StartNode(threadGroup, scheduler);

-    // Monitor the chain, and alert if we get blocks much quicker or slower than expected
-    // The "bad chain alert" scheduler has been disabled because the current system gives far
-    // too many false positives, such that users are starting to ignore them.
-    // This code will be disabled for 0.12.1 while a fix is deliberated in #7568
-    // this was discussed in the IRC meeting on 2016-03-31.
-    //
-    // --- disabled ---
-    // int64_t nPowTargetSpacing = Params().GetConsensus().nPowTargetSpacing;
-    // CScheduler::Function f = boost::bind(&PartitionCheck, &IsInitialBlockDownload,
-    //                                     boost::ref(cs_main), boost::cref(pindexBestHeader), nPowTargetSpacing);
-    // scheduler.scheduleEvery(f, nPowTargetSpacing);
-    // --- end disabled ---
-
-    // ********************************************************* Step 12: finished
-
-    SetRPCWarmupFinished();
+// Monitor the chain, and alert if we get blocks much quicker or slower than expected
+// The "bad chain alert" scheduler has been disabled because the current system gives far
+// too many false positives, such that users are starting to ignore them.
+// This code will be disabled for 0.12.1 while a fix is deliberated in #7568
+// this was discussed in the IRC meeting on 2016-03-31.
+//
+// --- disabled ---
+// int64_t nPowTargetSpacing = Params().GetConsensus().nPowTargetSpacing;
+// CScheduler::Function f = boost::bind(&PartitionCheck, &IsInitialBlockDownload,
+//                                     boost::ref(cs_main), boost::cref(pindexBestHeader), nPowTargetSpacing);
+// scheduler.scheduleEvery(f, nPowTargetSpacing);
+// --- end disabled ---
+
+// ********************************************************* Step 12: finished

 #ifdef ENABLE_WALLET
     uiInterface.InitMessage(_("Reaccepting Wallet Transactions"));
@@ -1521,5 +1519,10 @@
 #endif

     uiInterface.InitMessage(_("Done loading"));
+
+    // This should be done last in init. If not, then RPC's could be allowed before the wallet
+    // is ready.
+    SetRPCWarmupFinished();
+
     return true;
 }


accept variations of argon2d for --algo parameter

--- src/init.cpp
+++ src/init.cpp
@@ -500,7 +500,7 @@
     strUsage += HelpMessageGroup(_("Block creation options:"));
     strUsage += HelpMessageOpt("-blockmaxweight=<n>", strprintf(_("Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT));
     strUsage += HelpMessageOpt("-blockmintxfee=<amt>", strprintf(_("Set lowest fee rate (in %s/kB) for transactions to be included in block creation. (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_BLOCK_MIN_TX_FEE)));
-    strUsage += HelpMessageOpt("-algo=<algo>", _("Mining algorithm: sha256d, scrypt, groestl, skein, qubit, yescrypt"));
+    strUsage += HelpMessageOpt("-algo=<algo>", _("Mining algorithm: sha256d, scrypt, groestl, skein, qubit, yescrypt, argon2d"));
     if (showDebug)
         strUsage += HelpMessageOpt("-blockversion=<n>", "Override block version to test forking scenarios");

@@ -1173,6 +1173,8 @@
         miningAlgo = ALGO_QUBIT;
     else if (strAlgo == "yescrypt")
         miningAlgo = ALGO_YESCRYPT;
+    else if (strAlgo == "argon2d" || strAlgo == "argon2" || strAlgo == "argon2d4096")
+        miningAlgo = ALGO_ARGON2D;
     else
         miningAlgo = ALGO_SHA256D;


print build time

print build time

git-svn-id: 39e099a8ed5324aded674b764a67f7a08796d9a7@2176 662fdd30-d327-0410-a531-f549c87e1e9e

--- src/init.cpp
+++ src/init.cpp
@@ -119,6 +119,7 @@
 	out << "-- BEGIN init --" << endl;
         out << "Data path is " << Util::getDataPath() << endl;
         out << "Paintown version " << Global::getVersionString() << endl;
+        out << "Build date " << __DATE__ << " " << __TIME__ << endl;
 	out << "Allegro version: " << ALLEGRO_VERSION_STR << endl;
 	out <<"Allegro init: "<<allegro_init()<<endl;
 	out <<"Install timer: "<<install_timer()<<endl;


make -logtimestamps default on and rework help-message

--- src/init.cpp
+++ src/init.cpp
@@ -227,7 +227,7 @@
     {
         strUsage += ".\n";
     }
-        strUsage += "  -logtimestamps         " + _("Prepend debug output with timestamp") + "\n";
+        strUsage += "  -logtimestamps         " + _("Prepend debug output with timestamp (default: 1)") + "\n";
         strUsage += "  -shrinkdebugfile       " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n";
         strUsage += "  -printtoconsole        " + _("Send trace/debug info to console instead of debug.log file") + "\n";
         strUsage += "  -regtest               " + _("Enter regression test mode, which uses a special chain in which blocks can be "
@@ -500,7 +500,7 @@
         fServer = true;
     fPrintToConsole = GetBoolArg("-printtoconsole", false);
     fPrintToDebugger = GetBoolArg("-printtodebugger", false);
-    fLogTimestamps = GetBoolArg("-logtimestamps", false);
+    fLogTimestamps = GetBoolArg("-logtimestamps", true);

     if (mapArgs.count("-timeout"))
     {


Remove unnecessary handle scope

Remove unnecessary handle scope

Handle scopes are only necessary when using the V8 API independently from JS land.

--- src/kexec.cc
+++ src/kexec.cc
@@ -42,8 +42,6 @@
 }

 NAN_METHOD(kexec) {
-    Nan::HandleScope scope;
-
     /*
      * Steve Blott: 17 Jan, 2014
      *              Temporary comment by way of explanation...


update list

update list

--- src/list.cpp
+++ src/list.cpp
@@ -36,7 +36,15 @@
 	l.push_back(2);

-
+
+	//返回第一个元素的引用
+	int n= l.front()    // = 1
+    //返回最后一元素的引用
+	n = l.back()     // = 2
+	//返回第一个元素的迭代器(iterator)
+	list<int>::iterator it = l.begin();    // *it = 1
+    //返回最后一个元素的下一位置的指针(list为空时end()=begin())
+    it = l.end();

 	return 0;
 }


Add missing output format in the help message

--- src/main.cpp
+++ src/main.cpp
@@ -28,8 +28,8 @@
 				<< "       bookmarkconverter --help" << std::endl
 				<< std::endl
 				<< "       format            "
-				<< "The destination format (HTML, CHROME, WEBPOSITIVE)"
-				<< std::endl;
+				<< "The destination format (HTML, CHROME, WEBPOSITIVE, "
+				<< "QUPZILLA)" << std::endl;
 	return code;
 }


Added benchmark to measure time performance executing free operations.

--- src/main.cpp
+++ src/main.cpp
@@ -185,10 +185,10 @@
 }

-void benchmark_stack(long MAX_OPERATIONS = 1e4){
+void benchmark_stack_allocate(long MAX_OPERATIONS = 1e4){
 	timespec start, end;

-	std::cout << "BENCHMARK STACK ALLOCATOR: START" << std::endl;
+	std::cout << "BENCHMARK STACK A: START" << std::endl;

 	setTimer(start);

@@ -208,13 +208,48 @@
 	const std::size_t  memory_wasted = 0;
 	stackAllocator.Reset();
 	print_benchmark_stats(elapsed_time, memory_used, memory_wasted, MAX_OPERATIONS);
-	std::cout << "BENCHMARK STACK ALLOCATOR: END" << std::endl;
-}
-
-void benchmark_malloc(long MAX_OPERATIONS = 1e4){
+	std::cout << "BENCHMARK STACK A: END" << std::endl;
+}
+
+void benchmark_stack_allocate_free(long MAX_OPERATIONS = 1e4){
 	timespec start, end;

-	std::cout << "BENCHMARK MALLOC ALLOCATOR: START" << std::endl;
+	std::cout << "BENCHMARK STACK A/F: START" << std::endl;
+
+	setTimer(start);
+
+	StackAllocator stackAllocator(1e10);
+
+	int operations = 0;
+	bool allocate = true;
+	while(operations < MAX_OPERATIONS){
+		if (allocate) {
+			stackAllocator.Allocate(sizeof(int), alignof(int));			// 4  -> 4
+			stackAllocator.Allocate(sizeof(bool), alignof(bool));		// 1  -> 5
+																		// 3  -> 8
+			stackAllocator.Allocate(sizeof(foo), alignof(foo));			// 16 -> 24
+			allocate = false;
+		}else {
+			stackAllocator.Free(nullptr, sizeof(foo));
+			stackAllocator.Free(nullptr, sizeof(bool));
+			stackAllocator.Free(nullptr, sizeof(int));
+			allocate = true;
+		}
+		++operations;
+	}
+	setTimer(end);
+	const timespec elapsed_time = diff(start, end);
+	const std::size_t memory_used = 0;
+	const std::size_t  memory_wasted = 0;
+	stackAllocator.Reset();
+	print_benchmark_stats(elapsed_time, memory_used, memory_wasted, MAX_OPERATIONS);
+	std::cout << "BENCHMARK STACK A/F: END" << std::endl;
+}
+
+void benchmark_malloc_allocate(long MAX_OPERATIONS = 1e4){
+	timespec start, end;
+
+	std::cout << "BENCHMARK MALLOC A: START" << std::endl;

 	setTimer(start);

@@ -233,16 +268,56 @@
 	const std::size_t  memory_wasted = 0;

 	print_benchmark_stats(elapsed_time, memory_used, memory_wasted, MAX_OPERATIONS);
-	std::cout << "BENCHMARK MALLOC ALLOCATOR: END" << std::endl;
-}
+	std::cout << "BENCHMARK MALLOC A: END" << std::endl;
+}
+
+void benchmark_malloc_allocate_free(long MAX_OPERATIONS = 1e4){
+	timespec start, end;
+
+	std::cout << "BENCHMARK MALLOC A/F: START" << std::endl;
+
+	setTimer(start);
+
+	int operations = 0;
+	bool allocate = true;
+	int * i;
+	bool * b;
+	foo * f;
+	while(operations < MAX_OPERATIONS){
+		if (allocate){
+			i = (int*) malloc(sizeof(int));
+			b = (bool*) malloc(sizeof(bool));
+			f = (foo*) malloc(sizeof(foo));
+			allocate = false;
+		}else {
+			free(f);
+			free(b);
+			free(i);
+			allocate = true;
+		}
+
+		++operations;
+	}
+
+	setTimer(end);
+	const timespec elapsed_time = diff(start, end);
+	const std::size_t memory_used = 0;
+	const std::size_t  memory_wasted = 0;
+
+	print_benchmark_stats(elapsed_time, memory_used, memory_wasted, MAX_OPERATIONS);
+	std::cout << "BENCHMARK MALLOC A/F: END" << std::endl;
+}
+
 /* TODO
 	1-  Deinterface
+	2- Stack/Linear ->Calculate padding (Aligned allocators interface?)
 	2- benchmark free (3pointers)
-	3- move to utils file?
+	3- read values (check speed)
+	4- move to utils file?
 */
 int main(){
-	//benchmark_stack(1e7);
-	benchmark_malloc(1e7);
+	benchmark_stack_allocate_free(1e8);
+	benchmark_malloc_allocate_free(1e8);
 	return 1;
 }


Do not invoke anti-DoS system for invalid BIP16 transactions

Doing so would allow an attack on old nodes, which would relay a
standard transaction spending a BIP16 output in an invalid way,
until reaching a new node, which will disconnect their peer.

Reported by makomk on IRC.

--- src/main.cpp
+++ src/main.cpp
@@ -1138,7 +1138,14 @@
             {
                 // Verify signature
                 if (!VerifySignature(txPrev, *this, i, fStrictPayToScriptHash, 0))
+                {
+                    // only during transition phase for P2SH: do not invoke anti-DoS code for
+                    // potentially old clients relaying bad P2SH transactions
+                    if (fStrictPayToScriptHash && VerifySignature(txPrev, *this, i, false, 0))
+                        return error("ConnectInputs() : %s P2SH VerifySignature failed", GetHash().ToString().substr(0,10).c_str());
+
                     return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
+                }
             }

             // Mark outpoints as spent


resizing works

resizing works


simplify intersect_all

simplify intersect_all

--- src/main.cpp
+++ src/main.cpp
@@ -323,22 +323,21 @@

 void intersect_all(HitResult *closest, World *world, const Ray &r) {
   HitResult result;
+  result.distance = FLT_MAX;

   HitResult hit;
-  float distance = FLT_MAX;

   for (auto it = array::begin(world->models); it != array::end(world->models); it++) {
     intersect_model(&hit, it, r);
-    if (hit.distance != FLT_MAX && hit.distance < distance) {
+    if (hit.distance < result.distance) {
       result = hit;
-      distance = hit.distance;
     }
   }

   *closest = result;
 }

-vec3 reflect(const vec3 &value, const vec3 &normal) {
+vec3 reflect(vec3 value, vec3 normal) {
   return value - normal * 2.0f * glm::dot(normal, value);
 }


Don't enforce v2 blocks.

Don't enforce v2 blocks.

Version 2 blocks have their height encoded in the first 4 bytes of
the coinbase input script. getauxblock produces v1 blocks.

This can be enabled later if getauxblock is updated and most miners
produce v2 blocks. (desireable, but it won't cause a hard fork, since
95% of the miners automatically produce the best chain)

--- src/main.cpp
+++ src/main.cpp
@@ -2349,6 +2349,9 @@
         if (!Checkpoints::CheckBlock(nHeight, hash))
             return state.DoS(100, error("AcceptBlock() : rejected by checkpoint lock-in at %d", nHeight));

+	// I0coin currently doesn't enforce 2 blocks, since merged mining
+	// produces v1 blocks and normal mining should produce v2 blocks.
+#if 0
         // Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
         if ((nVersion&0xff) < 2)
         {
@@ -2370,6 +2373,7 @@
                     return state.DoS(100, error("AcceptBlock() : block height mismatch in coinbase"));
             }
         }
+#endif
     }

     // Write block to history file


testnet sync fix - bad blocks on exception list

removed duplicate error message

compacted if statement and renamed exception list

--- src/main.cpp
+++ src/main.cpp
@@ -3389,6 +3389,17 @@
                             if (fTestNet || (pindex->nHeight > 975000)) return DoS(20, error(" %s ",sNarr.c_str()));
                         }

+                        /* ignore bad blocks already in chain on testnet */
+                        const std::set<uint256> badSignBlocksTestnet =
+                        {   uint256("129ae6779d620ec189f8e5148e205efca2dfe31d9f88004b918da3342157b7ff") //T407024
+                           ,uint256("c3f85818ba5290aaea1bcbd25b4e136f83acc93999942942bbb25aee2c655f7a") //T407068
+                           ,uint256("cf7f1316f92547f611852cf738fc7a4a643a2bb5b9290a33cd2f9425f44cc3f9") //T407099
+                           ,uint256("b47085beb075672c6f20d059633d0cad4dba9c5c20f1853d35455b75dc5d54a9") //T407117
+                           ,uint256("5a7d437d15bccc41ee8e39143e77960781f3dcf08697a888fa8c4af8a4965682") //T407161
+                           ,uint256("aeb3c24277ae1047bda548975a515e9d353d6e12a2952fb733da03f92438fb0f") //T407181
+                           ,uint256("fc584b18239f3e3ea78afbbd33af7c6a29bb518b8299f01c1ed4b52d19413d4f") //T407214
+                           ,uint256("d5441f7c35eb9ea1b786bbbed820b7f327504301ae70ef2ac3ca3cbc7106236b") //T479114
+                        };
                         if (dStakeReward > ((OUT_POR*1.25)+OUT_INTEREST+1+CoinToDouble(nFees)))
                         {
                             StructCPID st1 = GetLifetimeCPID(pindex->GetCPID(),"ConnectBlock()");
@@ -3396,12 +3407,12 @@
                                         pindex, "connectblock_researcher_doublecheck", OUT_POR, OUT_INTEREST, dAccrualAge, dMagnitudeUnit, dAvgMagnitude);
                             if (dStakeReward > ((OUT_POR*1.25)+OUT_INTEREST+1+CoinToDouble(nFees)))
                             {
-
-                                if (fDebug3) LogPrintf("ConnectBlockError[ResearchAge] : Researchers Reward Pays too much : Interest %f and Research %f and StakeReward %f, OUT_POR %f, with Out_Interest %f for CPID %s ",
-                                    (double)bb.InterestSubsidy,(double)bb.ResearchSubsidy,dStakeReward,(double)OUT_POR,(double)OUT_INTEREST,bb.cpid);
-
-                                return DoS(10,error("ConnectBlock[ResearchAge] : Researchers Reward Pays too much : Interest %f and Research %f and StakeReward %f, OUT_POR %f, with Out_Interest %f for CPID %s ",
-                                    (double)bb.InterestSubsidy,(double)bb.ResearchSubsidy,dStakeReward,(double)OUT_POR,(double)OUT_INTEREST,bb.cpid.c_str()));
+                                if(!fTestNet || badSignBlocksTestnet.count(pindex->GetBlockHash()) ==0)
+                                {
+                                    return DoS(10,error("ConnectBlock[ResearchAge] : Researchers Reward Pays too much : Interest %f and Research %f and StakeReward %f, OUT_POR %f, with Out_Interest %f for CPID %s ",
+                                        (double)bb.InterestSubsidy,(double)bb.ResearchSubsidy,dStakeReward,(double)OUT_POR,(double)OUT_INTEREST,bb.cpid.c_str()));
+                                }
+                                else LogPrintf("WARNING: ignoring Researchers Reward Pays too Much on block %s", pindex->GetBlockHash().ToString());
                             }
                         }
                 }


Fixed missing null assignment after detach().

--- Cosa/Driver/NEXA.cpp
+++ Cosa/Driver/NEXA.cpp
@@ -101,8 +101,7 @@
     else {
       Listener* d;
       for (d = m_first; (d->m_next != 0) && (d->m_next != &device); d = d->m_next);
-      if (d->m_next == 0) return;
-      d->m_next = device.m_next;
+      if (d->m_next != 0) d->m_next = device.m_next;
     }
   }
   device.m_next = 0;


Fix sysyem fonts checker

Fix sysyem fonts checker

--- DesktopEditor/fontengine/ApplicationFontsWorker.cpp
+++ DesktopEditor/fontengine/ApplicationFontsWorker.cpp
@@ -161,6 +161,19 @@
         int nFlag = 3;
         if (!m_bIsUseOpenType)
             nFlag = 2;
+
+        NSStringUtils::CStringBuilder oFontsLog;
+#ifdef ONLYOFFICE_FONTS_VERSION_
+        oFontsLog.WriteString(L"ONLYOFFICE_FONTS_VERSION_");
+        oFontsLog.WriteString(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
+        oFontsLog.WriteString(L"\n");
+#endif
+        int nCount = (int)strFontsW_Cur.size();
+        for (int i = 0; i < nCount; ++i)
+        {
+            oFontsLog.WriteString(strFontsW_Cur[i]);
+            oFontsLog.WriteString(L"\n");
+        }

         pApplicationF->InitializeFromArrayFiles(strFontsW_Cur, nFlag);

@@ -170,22 +183,9 @@
         {
             NSCommon::SaveAllFontsJS(pApplicationF, strAllFontsJSPath + L".1", L"", L"", 0);
         }
-    }
-
-    NSFile::CFileBinary oFile;
-    oFile.CreateFileW(strFontsCheckPath);
-#ifdef ONLYOFFICE_FONTS_VERSION_
-    oFile.WriteStringUTF8(L"ONLYOFFICE_FONTS_VERSION_");
-    oFile.WriteStringUTF8(std::to_wstring(ONLYOFFICE_FONTS_VERSION_));
-    oFile.WriteFile((BYTE*)"\n", 1);
-#endif
-    int nCount = (int)strFontsW_Cur.size();
-    for (int i = 0; i < nCount; ++i)
-    {
-        oFile.WriteStringUTF8(strFontsW_Cur[i]);
-        oFile.WriteFile((BYTE*)"\n", 1);
-    }
-    oFile.CloseFile();
+
+        NSFile::CFileBinary::SaveToFile(strFontsCheckPath, oFontsLog.GetData());
+    }

     pApplicationF->Release();
     pApplicationF = NSFonts::NSApplication::Create();


main: print out results and fix read identifiers

--- src/main.cpp
+++ src/main.cpp
@@ -131,8 +131,8 @@
   {
     for (uint32_t j = i + 1; j < sequences.size(); ++j)
     {
-      g_sequence_pairs.emplace(i, sequences[i], j, sequences[j]);
-      g_minimizer_pairs.emplace(i, &minimizers[i], j, &minimizers[j]);
+      g_sequence_pairs.emplace(i + 1, sequences[i], j + 1, sequences[j]);
+      g_minimizer_pairs.emplace(i + 1, &minimizers[i], j + 1, &minimizers[j]);
     }
   }

@@ -145,6 +145,13 @@
   for (uint8_t i = 0; i < threads.size(); ++i)
     threads[i].join();

+  for (size_t i = 0; i < g_results.size(); ++i)
+  {
+    auto identifiers = g_results[i]->getIdentifiers();
+
+    std::cout << "Found overlap with length of " << g_results[i]->getLength() << " between " << std::get<0>(identifiers) << " and " << std::get<1>(identifiers) << "\n";
+  }
+
   // cleanup
   for (size_t i = 0; i < sequences.size(); ++i)
     delete sequences[i];


[doxyrest] set axl tag

[doxyrest] set axl tag

--- src/main.cpp
+++ src/main.cpp
@@ -472,6 +472,7 @@
 {
 	int result;

+	g::getModule ()->setTag ("doxyrest");
 	xml::registerExpatErrorProvider ();
 	lex::registerParseErrorProvider ();


Test Updates

Test Updates

--- src/main.cpp
+++ src/main.cpp
@@ -1212,10 +1212,10 @@

 int64_t GetDGBSubsidy(int nHeight) {
    // thanks to RealSolid & WDC for helping out with this code
-
-        if (nHeight < alwaysupdateDiffChangTarget)
+	int64_t qSubsidy;
+        if (nHeight < alwaysUpdateDiffChangeTarget)
    	{
-		int64_t qSubsidy = 8000*COIN;
+		qSubsidy = 8000*COIN;
    		int blocks = nHeight - nDiffChangeTarget;
    		int weeks = (blocks / patchBlockRewardDuration)+1;
    		//decrease reward by 0.5% every week
@@ -1223,7 +1223,7 @@
    	}
    	else
    	{
-	        int64_t qSubsidy = 2434*COIN;
+	        qSubsidy = 2434*COIN;
    		int blocks = nHeight - nDiffChangeTarget;
    		int weeks = (blocks / patchBlockRewardDuration2)+1;
    		//decrease reward by 0.5% every week


remove help text about seed only displayed once

--- src/simplewallet/simplewallet.cpp
+++ src/simplewallet/simplewallet.cpp
@@ -193,7 +193,7 @@
   std::string electrum_words;
   crypto::ElectrumWords::bytes_to_words(m_wallet->get_account().get_keys().m_spend_secret_key, electrum_words);

-  success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control. You will not be able to view these words again, so it is imperative to make note of them now.\n";
+  success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n";
   std::cout << electrum_words << std::endl;
   return true;
 }
@@ -448,7 +448,7 @@

   if (!two_random)
   {
-    success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control. You will not be able to view these words again, so it is imperative to make note of them now.\n";
+    success_msg_writer(true) << "\nPLEASE NOTE: the following 24 words can be used to recover access to your wallet. Please write them down and store them somewhere safe and secure. Please do not store them in your email or on file storage services outside of your immediate control.\n";
     std::cout << electrum_words << std::endl;
   }
   success_msg_writer() << "**********************************************************************";


relay compatible txns to 1.5 wallets

relay compatible txns to 1.5 wallets

--- src/main.cpp
+++ src/main.cpp
@@ -3676,20 +3676,13 @@
                     LOCK(cs_mapRelay);
                     map<CInv, CDataStream>::iterator mi = mapRelay.find(inv);
                     if (mi != mapRelay.end()) {
-                        if (inv.type == MSG_TX)
-                        {
-                            int nType = SER_NETWORK;
-                            if (pfrom->nVersion <= PROTOCOL_VERSION_POW)
-                                nType |= SER_LEGACYPROTOCOL;
-                            CDataStream ss(nType, PROTOCOL_VERSION);
-                            ss.reserve(1000);
-                            ss << (*mi).second;
-                            pfrom->PushMessage("tx", ss);
-                        }
-                        else
-                        {
-                            pfrom->PushMessage(inv.GetCommand(), (*mi).second);
-                        }
+                        int nType = SER_NETWORK;
+                        if (pfrom->nVersion <= PROTOCOL_VERSION_POW)
+                            nType |= SER_LEGACYPROTOCOL;
+                        CDataStream ss(nType, PROTOCOL_VERSION);
+                        ss.reserve(1000);
+                        ss << (*mi).second;
+                        pfrom->PushMessage(inv.GetCommand(), ss);
                         pushed = true;
                     }
                 }


I does work....

I does work....

no realy, does_work now uses equation 1 and 2 correctly(i think)

--- pthread.cpp
+++ pthread.cpp
@@ -17,7 +17,7 @@
 std::vector<int> wholeCost;
 std::vector< std::vector<int> > Distance;
 std::vector<std::vector<double> > Pher;
-//std::vector
+std::vector<int> Locations;

 int main(int argc, char** argv)
 {
@@ -40,6 +40,7 @@
 	for(int i =0; i < ANTCOUNT; i++)
 	{
 		std::vector<int> temp;
+		Locations.push_back(i);
 		results.push_back(temp);
 		wholeCost.push_back(0);
 	}
@@ -109,7 +110,7 @@
   int id = *((int *)ptr);
   //std::vector<double> res;
   std::vector<int> history;
-
+  std::vector<int> unvisited = Locations;

   while(history.size() < problemSize)
   {
@@ -121,6 +122,8 @@

     double choice = ((double) rand() / (RAND_MAX)) + 1;

+    double choice2 = ((double) rand() / (RAND_MAX)) + 1;
+
     double max = 0;
     int maxIndex =0;

@@ -131,25 +134,30 @@
       {
 	if(std::find(history.begin(), history.end(), i) != history.end())
 	  continue;
-	double temp = Pher[pos][i] / pow(Distance[pos][i],BETA) ;
+
+	double temp = Pher[pos][i] / pow(Distance[pos][i], BETA) ;
+
 	if( temp > max)
 	{
 	  max =temp;
 	  maxIndex = i;
 	}
       }
-
     }
     else //we expolore
     {
+	  std::vector cho = eq2(Distance, Pher, unvisited, pos);

+	  maxIndex = eq2_helper(cho,choice2);
+	  max = Pher[pos][maxIndex] / pow(Distance[pos][maxIndex], BETA);
     }

     Pher[pos][maxIndex] = eq3(Pher[pos][maxIndex],problemSize);
     antDist += Distance[pos][maxIndex];
     pos = maxIndex;
     history.push_back(maxIndex);
-
+    int temp = std::find(unvisited.begin(),unvisited.end(),maxIndex);
+    unvisited.erase(unvisited.begin() + temp);
   }

   results[id] = history;


Config directory is now created if missing

--- ui/main-window.cpp
+++ ui/main-window.cpp
@@ -218,6 +218,11 @@

 bool MainWindow::saveConfig()
 {
+    QDir configDir("");
+    if (!configDir.exists(QDir::homePath() + "/.config/")){
+        configDir.mkdir(QDir::homePath() + "/.config/");
+    }
+
     QFile configFile(QDir::homePath() + "/.config/dwrandomizer2.conf");
     if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
         printf("Failed to save configuration.\n");


correct help text for map

correct help text for map

--- src/main.cpp
+++ src/main.cpp
@@ -4930,7 +4930,7 @@
          << "algorithm:" << endl
          << "    -t, --threads N         number of compute threads to use" << endl
          << "    -k, --min-seed INT      minimum seed (MEM) length [estimated given -e]" << endl
-         << "    -c, --hit-max N         ignore kmers or MEMs who have >N hits in our index (default: 16384)" << endl
+         << "    -c, --hit-max N         ignore kmers or MEMs who have >N hits in our index [65536]" << endl
          << "    -e, --seed-chance FLOAT set {-k} such that this fraction of {-k} length hits will by by chance [0.05]" << endl
          << "    -Y, --max-seed INT      ignore seeds longer than this length [0]" << endl
          << "    -r, --reseed-x FLOAT    look for internal seeds inside a seed longer than {-k} * FLOAT [1.5]" << endl


UI: paintwidgets.cc: use CAIRO_CHECK_STATUS()

Signed-off-by: Tim Janik <6ec6ff229c4e1c5bbd5933ee92e6c5832ff023bb@gnu.org>

--- ui/paintwidgets.cc
+++ ui/paintwidgets.cc
@@ -2,12 +2,7 @@
 #include "paintwidgets.hh"
 #include "factory.hh"
 #include "painter.hh"
-
-#define CHECK_CAIRO_STATUS(status)      do {    \
-  cairo_status_t ___s = (status);               \
-  if (___s != CAIRO_STATUS_SUCCESS)             \
-    RAPICORN_DIAG ("%s: %s", cairo_status_to_string (___s), #status);   \
-  } while (0)
+#include "rcore/cairoutils.hh"

 namespace Rapicorn {

@@ -386,7 +381,7 @@
       const int rowstride = pixbuf_.width();
       cairo_surface_t *surface = cairo_image_surface_create_for_data ((uint8*) pixbuf_.pixels.data(), CAIRO_FORMAT_ARGB32,
                                                                       pixbuf_.width(), pixbuf_.height(), rowstride * 4);
-      CHECK_CAIRO_STATUS (cairo_surface_status (surface));
+      CAIRO_CHECK_STATUS (cairo_surface_status (surface));
       cairo_set_source_surface (cr, surface, x_, y_);
       cairo_paint (cr);
       cairo_surface_destroy (surface);


writerfilter: remove copy&paste

writerfilter: remove copy&paste

Change-Id: I7a5be1963e41dfba1394291becb53318cf4ae8f2

--- writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3249,14 +3249,13 @@
                         xToInsert = uno::Reference< text::XTextContent >(pContext->GetTextField(), uno::UNO_QUERY);
                     if( xToInsert.is() )
                     {
-                        uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( xTextAppend, uno::UNO_QUERY_THROW );
                         uno::Sequence<beans::PropertyValue> aValues;
                         // Character properties of the field show up here the
                         // last (always empty) run. Inherit character
                         // properties from there.
                         if (m_pLastCharacterContext.get())
                             aValues = m_pLastCharacterContext->GetPropertyValues();
-                        xTextAppendAndConvert->appendTextContent(xToInsert, aValues);
+                        appendTextContent(xToInsert, aValues);
                     }
                     else
                     {


Fixed compile error

Fixed compile error

--- src/main.cpp
+++ src/main.cpp
@@ -13,7 +13,7 @@
 #include <QtCore>
 #include <QFile>
 #include <QString>
-#include "server/websocketserver.h"
+#include <websocketserver.h>
 #include "prepare_tmp_deb_package.h"

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


Splashscreen: Faster unhidding of main window.

--- src/main.cpp
+++ src/main.cpp
@@ -23,7 +23,7 @@
     w.hide();

     QTimer::singleShot(2500, &splash, SLOT(close()));
-    QTimer::singleShot(1500, &w, SLOT(unhide()));
+    QTimer::singleShot(500, &w, SLOT(unhide()));
 #else
     w.show();
 #endif


Updating the version number and adding link to homepage on utils.kde.org

CCMAIL: kde-utils-devel@kde.org

svn path=/trunk/KDE/kdeutils/superkaramba/; revision=836046

--- src/main.cpp
+++ src/main.cpp
@@ -41,7 +41,7 @@
 static const char *description =
     I18N_NOOP("A KDE Eye-candy Application");

-static const char *version = "0.50";
+static const char *version = "0.52";

 int main(int argc, char **argv)
 {
@@ -84,7 +84,8 @@
     KAboutData about("superkaramba", 0, ki18n("SuperKaramba"),
                      version, ki18n(description),
                      KAboutData::License_GPL,
-                     ki18n("(c) 2003-2007 The SuperKaramba developers"));
+                     ki18n("(c) 2003-2007 The SuperKaramba developers"), KLocalizedString(),
+                     "http://utils.kde.org/projects/superkaramba");
     about.addAuthor(ki18n("Adam Geitgey"), KLocalizedString(), "adam@rootnode.org");
     about.addAuthor(ki18n("Hans Karlsson"), KLocalizedString(), "karlsson.h@home.se");
     about.addAuthor(ki18n("Ryan Nickell"), KLocalizedString(), "p0z3r@earthlink.net");