Despite my pathological distrust of spin locks, the number just don't lie.  I've put a small spin in __sp_mut::lock() on std::mutex::try_lock(), which is testing quite well.  In my experience, putting in a yield for every failed iteration is also a major performance booster.  This change makes one of the performance tests I was using (a highly contended one) run about 20 times faster.

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@160967 91177308-0d34-0410-b5e6-96231b3b80d8

--- src/memory.cpp
+++ src/memory.cpp
@@ -10,6 +10,7 @@
 #define _LIBCPP_BUILDING_MEMORY
 #include "memory"
 #include "mutex"
+#include "thread"

 _LIBCPP_BEGIN_NAMESPACE_STD

@@ -129,13 +130,23 @@
 void
 __sp_mut::lock() _NOEXCEPT
 {
-    reinterpret_cast<mutex*>(_)->lock();
+    mutex& m = *static_cast<mutex*>(_);
+    unsigned count = 0;
+    while (!m.try_lock())
+    {
+        if (++count > 16)
+        {
+            m.lock();
+            break;
+        }
+        this_thread::yield();
+    }
 }

 void
 __sp_mut::unlock() _NOEXCEPT
 {
-    reinterpret_cast<mutex*>(_)->unlock();
+    static_cast<mutex*>(_)->unlock();
 }

 __sp_mut&


(ModbusTest): подправил вывод лога

(ModbusTest): подправил вывод лога

--- Utilities/MBTester/mbtcptester.cc
+++ Utilities/MBTester/mbtcptester.cc
@@ -222,7 +222,7 @@
 		if( verb )
 		{
 			cout << "(init): ip=" << iaddr << ":" << port
-					<< ModbusRTU::addr2str(myaddr)
+					<< " mbaddr=" << ModbusRTU::addr2str(myaddr)
 					<< " timeout=" << tout << " msec "
 					<< endl;


COMP: Fix compilation on MacOSX

COMP: Fix compilation on MacOSX

--- Utilities/kwsys/DynamicLoader.cxx
+++ Utilities/kwsys/DynamicLoader.cxx
@@ -144,7 +144,7 @@
 //----------------------------------------------------------------------------
 int DynamicLoader::CloseLibrary( LibHandle lib)
 {
-  DYLD_BOOL success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE);
+  bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE);
   return success;
 }


Use a full if/else block around an exception throw

--- WangscapeTest/OptionsFilename.cpp
+++ WangscapeTest/OptionsFilename.cpp
@@ -15,7 +15,12 @@
 void setOptionsFilename(const std::string & optionsFilename)
 {
     if (filenameSet)
+    {
         throw std::runtime_error("Options filename already set");
-    filename = optionsFilename;
-    filenameSet = true;
+    }
+    else
+    {
+        filename = optionsFilename;
+        filenameSet = true;
+    }
 }


Add --bench-out parameter to specify file to save the image in

--- apps/modelViewer/modelViewer.cpp
+++ apps/modelViewer/modelViewer.cpp
@@ -26,6 +26,7 @@
 // stl
 #include <algorithm>
 #include <sstream>
+#include <string>

 namespace ospray {
   using namespace ospcommon;
@@ -52,6 +53,7 @@
   int maxAccum = 64;
   // If we want to clear the framebuffer after reaching maxAccum accumulations, useful for benchmarking
   bool accumReset = false;
+  std::string benchmarkImageOut = "benchmark.ppm";
   bool useDisplay = true;
   int spp = 1; /*! number of samples per pixel */
   int maxDepth = 2; // only set with home/end
@@ -358,10 +360,13 @@
       if (g_benchFrames > 0 && frameID== g_benchWarmup+g_benchFrames) {
         double time = ospray::getSysTime()-benchStart;
         double avgFps = fpsSum/double(frameID-g_benchWarmup);
-        printf("Benchmark: time: %f avg fps: %f avg frame time: %fs\n", time, avgFps, time/double(frameID-g_benchWarmup));
+        std::cout << "Benchmark: time: " << time << " avg fps: " << avgFps
+          << " avg frame time: " << time/double(frameID-g_benchWarmup) << "s\n"
+          << "Saving benchmark image result to " << benchmarkImageOut.c_str() << std::endl;

         const uint32_t * p = (uint32_t*)ospMapFrameBuffer(fb, OSP_FB_COLOR);
-        writePPM("benchmark.ppm", g_windowSize.x, g_windowSize.y, p);
+
+        writePPM(benchmarkImageOut.c_str(), g_windowSize.x, g_windowSize.y, p);

         exit(0);
       }
@@ -652,6 +657,8 @@
         }
         std::cout << "Benchmarking with " << g_benchWarmup << " warmup frames and "
           << g_benchFrames << " timing frames" << std::endl;
+      } else if (arg == "--bench-out") {
+        benchmarkImageOut = std::string(av[++i]);
       } else if (arg == "--no-default-material") {
         g_createDefaultMaterial = false;
       } else if (av[i][0] == '-') {


Using WButton for buttons in Find In Files dialog.

--- gtk/SciTEGTK.cxx
+++ gtk/SciTEGTK.cxx
@@ -438,6 +438,8 @@
 	WComboBoxEntry comboDir;
 	WToggle toggleWord;
 	WToggle toggleCase;
+	WButton btnDotDot;
+	WButton btnBrowse;
 };

 class DialogFindReplace : public Dialog {
@@ -1954,12 +1956,12 @@
 	gtk_label_set_mnemonic_widget(GTK_LABEL(labelDirectory), dlgFindInFiles.comboDir);

 	Signal<&SciTEGTK::FindInFilesDotDot> sigDotDot;
-	GtkWidget *btnDotDot = dlgFindInFiles.Button("_..", sigDotDot.Function);
-	table.Add(btnDotDot);
+	dlgFindInFiles.btnDotDot.Create(localiser.Text("_.."), GtkSignalFunc(sigDotDot.Function), this);
+	table.Add(dlgFindInFiles.btnDotDot);

 	Signal<&SciTEGTK::FindInFilesBrowse> sigBrowse;
-	GtkWidget *btnBrowse = dlgFindInFiles.Button("_Browse...", sigBrowse.Function);
-	table.Add(btnBrowse);
+	dlgFindInFiles.btnBrowse.Create(localiser.Text("_Browse..."), GtkSignalFunc(sigBrowse.Function), this);
+	table.Add(dlgFindInFiles.btnBrowse);

 	table.Add();	// Space


Fix the issue that the loading stuck when the extractor cannot read the file.

--- ArchiveExtractor.cpp
+++ ArchiveExtractor.cpp
@@ -32,7 +32,7 @@
     return nullptr;

   bool success = true;
-  while ((r = archive_read_next_header(a, &entry)) != ARCHIVE_EOF) {
+  while ((r = archive_read_next_header(a, &entry)) == ARCHIVE_OK) {
     success = updateFnc();
     if (!success)
       break;


formatting

formatting

--- include/fl/model/observation/interface/observation_density.hpp
+++ include/fl/model/observation/interface/observation_density.hpp
@@ -38,7 +38,7 @@
 {
 public:
     typedef Eigen::Array<State, BatchSize, 1> StateArray;
-    typedef Eigen::Array<Real,  BatchSize, 1>  ValueArray;
+    typedef Eigen::Array<Real,  BatchSize, 1> ValueArray;

 public:
     /// \todo should add the unnormalized log probability interface
@@ -145,9 +145,6 @@
     }
 };

-
-
-
 }

 #endif


building_symbolizer - update to mapnik-geometry

--- include/mapnik/renderer_common/process_building_symbolizer.hpp
+++ include/mapnik/renderer_common/process_building_symbolizer.hpp
@@ -25,6 +25,8 @@

 #include <mapnik/segment.hpp>
 #include <mapnik/feature.hpp>
+#include <mapnik/geometry_impl.hpp>
+#include <mapnik/geometry_type.hpp>
 #include <mapnik/geometry.hpp>

 #include <algorithm>
@@ -32,88 +34,101 @@

 namespace mapnik {

+namespace detail {
+
 template <typename F1, typename F2, typename F3>
-void render_building_symbolizer(mapnik::feature_impl &feature,
+void make_building(new_geometry::polygon const& poly, double height, F1 const& face_func, F2 const& frame_func, F3 const& roof_func)
+{
+    const std::unique_ptr<geometry_type> frame(new geometry_type(geometry_type::types::LineString));
+    const std::unique_ptr<geometry_type> roof(new geometry_type(geometry_type::types::Polygon));
+    std::deque<segment_t> face_segments;
+    double x0 = 0;
+    double y0 = 0;
+    double x,y;
+    new_geometry::polygon_vertex_adapter va(poly);
+    va.rewind(0);
+    for (unsigned cm = va.vertex(&x, &y); cm != SEG_END;
+         cm = va.vertex(&x, &y))
+    {
+        if (cm == SEG_MOVETO)
+        {
+            frame->move_to(x,y);
+        }
+        else if (cm == SEG_LINETO)
+        {
+            frame->line_to(x,y);
+            face_segments.push_back(segment_t(x0,y0,x,y));
+        }
+        else if (cm == SEG_CLOSE)
+        {
+            frame->close_path();
+        }
+        x0 = x;
+        y0 = y;
+    }
+
+    std::sort(face_segments.begin(),face_segments.end(), y_order);
+    for (auto const& seg : face_segments)
+    {
+        const std::unique_ptr<geometry_type> faces(new geometry_type(geometry_type::types::Polygon));
+        faces->move_to(std::get<0>(seg),std::get<1>(seg));
+        faces->line_to(std::get<2>(seg),std::get<3>(seg));
+        faces->line_to(std::get<2>(seg),std::get<3>(seg) + height);
+        faces->line_to(std::get<0>(seg),std::get<1>(seg) + height);
+
+        face_func(*faces);
+        //
+        frame->move_to(std::get<0>(seg),std::get<1>(seg));
+        frame->line_to(std::get<0>(seg),std::get<1>(seg)+height);
+    }
+
+    va.rewind(0);
+    for (unsigned cm = va.vertex(&x, &y); cm != SEG_END;
+         cm = va.vertex(&x, &y))
+    {
+        if (cm == SEG_MOVETO)
+        {
+            frame->move_to(x,y+height);
+            roof->move_to(x,y+height);
+        }
+        else if (cm == SEG_LINETO)
+        {
+            frame->line_to(x,y+height);
+            roof->line_to(x,y+height);
+        }
+        else if (cm == SEG_CLOSE)
+        {
+            frame->close_path();
+            roof->close_path();
+        }
+    }
+
+    frame_func(*frame);
+    roof_func(*roof);
+}
+
+} // ns detail
+
+template <typename F1, typename F2, typename F3>
+void render_building_symbolizer(mapnik::feature_impl const& feature,
                                 double height,
                                 F1 face_func, F2 frame_func, F3 roof_func)
 {
-    // FIXME
-    /*
-    for (auto const& geom : feature.paths())
+
+    auto const& geom = feature.get_geometry();
+    if (geom.is<new_geometry::polygon>())
     {
-        if (geom.size() > 2)
+        auto const& poly = geom.get<new_geometry::polygon>();
+        detail::make_building(poly, height, face_func, frame_func, roof_func);
+    }
+    else if (geom.is<new_geometry::multi_polygon>())
+    {
+        auto const& multi_poly = geom.get<new_geometry::multi_polygon>();
+        for (auto const& poly : multi_poly)
         {
-
-            const std::unique_ptr<geometry_type> frame(new geometry_type(geometry_type::types::LineString));
-            const std::unique_ptr<geometry_type> roof(new geometry_type(geometry_type::types::Polygon));
-            std::deque<segment_t> face_segments;
-            double x0 = 0;
-            double y0 = 0;
-            double x,y;
-            vertex_adapter va(geom);
-            va.rewind(0);
-            for (unsigned cm = va.vertex(&x, &y); cm != SEG_END;
-                 cm = va.vertex(&x, &y))
-            {
-                if (cm == SEG_MOVETO)
-                {
-                    frame->move_to(x,y);
-                }
-                else if (cm == SEG_LINETO)
-                {
-                    frame->line_to(x,y);
-                    face_segments.push_back(segment_t(x0,y0,x,y));
-                }
-                else if (cm == SEG_CLOSE)
-                {
-                    frame->close_path();
-                }
-                x0 = x;
-                y0 = y;
-            }
-
-            std::sort(face_segments.begin(),face_segments.end(), y_order);
-            for (auto const& seg : face_segments)
-            {
-                const std::unique_ptr<geometry_type> faces(new geometry_type(geometry_type::types::Polygon));
-                faces->move_to(std::get<0>(seg),std::get<1>(seg));
-                faces->line_to(std::get<2>(seg),std::get<3>(seg));
-                faces->line_to(std::get<2>(seg),std::get<3>(seg) + height);
-                faces->line_to(std::get<0>(seg),std::get<1>(seg) + height);
-
-                face_func(*faces);
-                //
-                frame->move_to(std::get<0>(seg),std::get<1>(seg));
-                frame->line_to(std::get<0>(seg),std::get<1>(seg)+height);
-
-            }
-
-            va.rewind(0);
-            for (unsigned cm = va.vertex(&x, &y); cm != SEG_END;
-                 cm = va.vertex(&x, &y))
-            {
-                if (cm == SEG_MOVETO)
-                {
-                    frame->move_to(x,y+height);
-                    roof->move_to(x,y+height);
-                }
-                else if (cm == SEG_LINETO)
-                {
-                    frame->line_to(x,y+height);
-                    roof->line_to(x,y+height);
-                }
-                else if (cm == SEG_CLOSE)
-                {
-                    frame->close_path();
-                    roof->close_path();
-                }
-            }
-
-            frame_func(*frame);
-            roof_func(*roof);
+            detail::make_building(poly, height, face_func, frame_func, roof_func);
         }
     }
-    */
 }

 } // namespace mapnik


#346 in progress: Export ARCH.X86_64 for x86 machine into Python namespace

--- src/libtriton/bindings/python/namespaces/initArchNamespace.cpp
+++ src/libtriton/bindings/python/namespaces/initArchNamespace.cpp
@@ -39,9 +39,7 @@

       void initArchNamespace(PyObject* archDict) {
         PyDict_SetItemString(archDict, "X86", PyLong_FromUint32(triton::arch::ARCH_X86));
-        #if defined(__x86_64__) || defined(_M_X64)
         PyDict_SetItemString(archDict, "X86_64", PyLong_FromUint32(triton::arch::ARCH_X86_64));
-        #endif
       }

     }; /* python namespace */


Also define stripping of CTCPs from messages

--- src/module.cpp
+++ src/module.cpp
@@ -391,5 +391,13 @@
 }

 void Module::stripCTCP(std::string& line) {
-
+	size_t ctcpPos = line.find((char)1);
+	while (ctcpPos != std::string::npos) {
+		size_t secondPos = line.find((char)1, ctcpPos + 1);
+		if (secondPos == std::string::npos)
+			line = line.substr(0, ctcpPos);
+		else
+			line.replace(ctcpPos, secondPos - ctcpPos + 1, "");
+		ctcpPos = line.find((char)1);
+	}
 }


requiring signal pt cut in sidebands

requiring signal pt cut in sidebands

--- ZHtautauAnalysis/src/Analysis.cxx
+++ ZHtautauAnalysis/src/Analysis.cxx
@@ -2051,7 +2051,7 @@
 			if(Ad_lepton) continue;
 			if(isFakeRate) tauTau=true;
 			if(signal) tauTau=true;
-			if(!isFakeRate&&!signal&&LTcut){
+			if(!isFakeRate&&!signal&&LTcut&&signalPtCuts){
 				if(!pass1 && !pass2 && !category0)
 				{
 					if(examineThisEvent) std::cout << " in category 0!" << std::endl;
@@ -2212,7 +2212,7 @@
 			if(examineThisEvent) std::cout << "checking categories: " << category0 << category1 << category2 << std::endl;
 			if(examineThisEvent) std::cout << "The isolation is " << pass2 << pass1 << std::endl;

-			if(!isFakeRate && !signal && LTcut){
+			if(!isFakeRate && !signal && LTcut && pt2>Cut_tau_base_Pt){
 				if( !pass1 && !pass2 && !category0)
 				{
 					if(examineThisEvent) std::cout << " in category 0!" << std::endl;
@@ -2376,7 +2376,7 @@
 			if(examineThisEvent) std::cout << "checking categories: " << category0 << category1 << category2 << std::endl;
 			if(examineThisEvent) std::cout << "The isolation is " << pass1 << pass2 << std::endl;

-			if(!isFakeRate && !signal &&LTcut){
+			if(!isFakeRate && !signal &&LTcut && pt2>Cut_tau_base_Pt){
 				if( !pass1 && !pass2 && !category0)
 				{
 					if(examineThisEvent) std::cout << "In category0" << std::endl;


fix merge omission of closing brace

fix merge omission of closing brace

--- src/mvf-bu.cpp
+++ src/mvf-bu.cpp
@@ -108,6 +108,7 @@
     else if (activeNetworkID == CBaseChainParams::UNL) {
         minForkHeightForNetwork = HARDFORK_HEIGHT_NOLNET;
         defaultDropFactorForNetwork = HARDFORK_DROPFACTOR_NOLNET;
+    }
     else if (activeNetworkID == CBaseChainParams::BFGTEST) {
         minForkHeightForNetwork = HARDFORK_HEIGHT_BFGTEST;
         defaultDropFactorForNetwork = HARDFORK_DROPFACTOR_BFGTEST;


natpmp fix

natpmp fix

git-svn-id: c39a6fcb73c71bf990fd9353909696546eb40440@4063 a83610d8-ad2a-0410-a6ab-fc0612d85776

--- src/natpmp.cpp
+++ src/natpmp.cpp
@@ -473,6 +473,8 @@
 		l.lock();
 	}

+	if (m_abort) return;
+
 	m_currently_mapping = -1;
 	m->action = mapping_t::action_none;
 	m_send_timer.cancel(ec);


natpmp fix if set_mappings is called more than once

--- src/natpmp.cpp
+++ src/natpmp.cpp
@@ -207,6 +207,7 @@
 {
 	using boost::posix_time::hours;
 	if (e) return;
+	if (m_currently_mapping != i) return;
 	if (m_retry_count >= 9)
 	{
 		m_mappings[i].need_update = false;
@@ -332,6 +333,7 @@
 	int i = m_currently_mapping;
 	m_currently_mapping = -1;
 	m_mappings[i].need_update = false;
+	m_send_timer.cancel();
 	update_expiration_timer();
 	try_next_mapping(i);
 }


Added Clifford's bram patch.

Added Clifford's bram patch.

--- src/netlist.cc
+++ src/netlist.cc
@@ -992,11 +992,11 @@

 	bram->add_port("RCLKE", Direction::IN, Value::ONE);
 	bram->add_port("RCLK", Direction::IN, Value::ZERO);
-	bram->add_port("RE", Direction::IN, Value::ONE);
+	bram->add_port("RE", Direction::IN, Value::ZERO);

 	bram->add_port("WCLKE", Direction::IN, Value::ONE);
 	bram->add_port("WCLK", Direction::IN, Value::ZERO);
-	bram->add_port("WE", Direction::IN, Value::ONE);
+	bram->add_port("WE", Direction::IN, Value::ZERO);

 	for (int i = 0; i <= 15; ++i)
 	  bram->set_param(fmt("INIT_" << (i < 10 ? '0' + i : 'A' + (i - 10))), "0");


add content type

add content type

--- src/notify.cpp
+++ src/notify.cpp
@@ -34,6 +34,7 @@
 	if(curl) {
 		string apikey="apikey: "+Notify::ApiKey;
 		list = curl_slist_append(list, apikey.c_str());
+		list = curl_slist_append(list, "Content-Type: application/json");
 		curl_easy_setopt(curl, CURLOPT_URL, Notify::ApiUrl.c_str());
 		curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
 		curl_easy_setopt(curl, CURLOPT_POST, 1L);


Properly propagate failures from helper methods.

Otherwise failures are not reported and callback may fail to setup.

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

git-svn-id: b158db1e4b4ab85d4c9e510fdef4b1e8c614b15b@5120 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

--- src/objects.cc
+++ src/objects.cc
@@ -2966,7 +2966,8 @@
         break;
     }

-    SetElementCallback(index, info, info->property_attributes());
+    Object* ok = SetElementCallback(index, info, info->property_attributes());
+    if (ok->IsFailure()) return ok;
   } else {
     // Lookup the name.
     LookupResult result;
@@ -2976,7 +2977,8 @@
     if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) {
       return Heap::undefined_value();
     }
-    SetPropertyCallback(name, info, info->property_attributes());
+    Object* ok = SetPropertyCallback(name, info, info->property_attributes());
+    if (ok->IsFailure()) return ok;
   }

   return this;


Remove map-copying for global objects. This was an old (broken) requirement that has been fixed for a while.

BUG=

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

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

--- src/objects.cc
+++ src/objects.cc
@@ -7264,12 +7264,7 @@
   Isolate* isolate = name->GetIsolate();

   // Dictionary maps can always have additional data properties.
-  if (map->is_dictionary_map()) {
-    // For global objects, property cells are inlined. We need to change the
-    // map.
-    if (map->IsGlobalObjectMap()) return Copy(map, "GlobalAccessor");
-    return map;
-  }
+  if (map->is_dictionary_map()) return map;

   // Migrate to the newest map before transitioning to the new property.
   map = Update(map);


fixed bug

fixed bug

--- src/opt/ctr.cc
+++ src/opt/ctr.cc
@@ -103,8 +103,11 @@
     }

     std::vector<PathPtr> paths_up_to_free;
-    CHECK(paths_in_output.size() <= per_aggregate_path_limit_);
     size_t remaining_paths = per_aggregate_path_limit_ - paths_in_output.size();
+    if (paths_in_output.size() > per_aggregate_path_limit_) {
+      remaining_paths = 0;
+    }
+
     if (total_path_count > soft_path_limit_) {
       remaining_paths = 0;
     }


Show errors in overlay icon on Windows 7.

Complements 275146afdfc2e75dcdc74f5737e65c315ea5851a

Task-Number: QTCREATORBUG-386

--- src/plugins/coreplugin/progressmanager/progressmanager_win.cpp
+++ src/plugins/coreplugin/progressmanager/progressmanager_win.cpp
@@ -29,6 +29,11 @@

 #include <QtCore/QVariant>
 #include <QtGui/QMainWindow>
+#include <QtGui/QFont>
+#include <QtGui/QFontMetrics>
+#include <QtGui/QPixmap>
+#include <QtGui/QPainter>
+#include <QtGui/QLabel>

 #include <coreplugin/icore.h>

@@ -76,7 +81,22 @@

 void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
 {
-    Q_UNUSED(text)
+    if (!pITask)
+        return;
+
+    WId winId = Core::ICore::instance()->mainWindow()->winId();
+    if (text.isNull()) {
+        pITask->SetOverlayIcon(winId, NULL, NULL);
+    } else {
+        QPixmap pix = QPixmap(":/projectexplorer/images/compile_error.png");
+        QPainter p(&pix);
+        p.setPen(Qt::white);
+        QFont font = p.font();
+        font.setPointSize(font.pointSize()-2);
+        p.setFont(font);
+        p.drawText(QRect(QPoint(0,0), pix.size()), Qt::AlignHCenter|Qt::AlignCenter, text);
+        pITask->SetOverlayIcon(winId, pix.toWinHICON(), text.utf16());
+    }
 }

 void Core::Internal::ProgressManagerPrivate::setApplicationProgressRange(int min, int max)


QmlDesigner.MetaInfo: Remove qDebug

QmlDesigner.MetaInfo: Remove qDebug

--- src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -415,8 +415,6 @@
                                         m_model(model)
 {
     if (lookupContext()) {
-        if (type == "Popup")
-            qDebug() << __FUNCTION__ << type;
         const Interpreter::QmlObjectValue *objectValue = getQmlObjectValue();
         if (objectValue) {
             setupPropertyInfo(getTypes(objectValue, lookupContext()));


Fix on linear movement

Fix on linear movement

--- src/oscore.cpp
+++ src/oscore.cpp
@@ -414,7 +414,7 @@

 uint8_t movementSystemStatus = MOVEMENT_SYSTEM_STATUS_OFF;

-int32_t distancePassedByLeftTire, distancePassedByRightTire,
+float distancePassedByLeftTire, distancePassedByRightTire,
 		distanceExpectedByLeftTire, distanceExpectedByRightTire;

 int16_t leftMotorSpeed, rightMotorSpeed, leftMotorDir, rightMotorDir;
@@ -503,7 +503,7 @@
 			leftMotorDir = 1;
 			rightMotorDir = 1;
 		}
-
+
 		// set motor speeds, used in handler
 		rightMotorSpeed = STANDARD_SPEED;
 		leftMotorSpeed = circleMotorSpeedDifference * STANDARD_SPEED;
@@ -523,8 +523,8 @@

 		case MOVEMENT_SYSTEM_STATUS_LINEAR_MOVEMENT:
 		{
-			int32_t leftTyreSpeed = leftEncoder.getSpeed();
-			int32_t rightTyreSpeed = rightEncoder.getSpeed();
+			float leftTyreSpeed = leftEncoder.getSpeed();
+			float rightTyreSpeed = rightEncoder.getSpeed();

 			// check if the speeds are the same if not correct the speed of the slower motors
 			if(leftTyreSpeed > rightTyreSpeed)
@@ -537,8 +537,8 @@
 			}

 			// update moved distance
-			distanceExpectedByLeftTire -= leftTyreSpeed;
-			distanceExpectedByRightTire -= rightTyreSpeed;
+			distanceExpectedByLeftTire -= leftTyreSpeed / SAMPLE_FREQUENCY;
+			distanceExpectedByRightTire -= rightTyreSpeed / SAMPLE_FREQUENCY;

 			if(	(distanceExpectedByLeftTire < 0 && directionOfLinearMovement > 0) ||
 				(distanceExpectedByLeftTire > 0 && directionOfLinearMovement < 0) )
@@ -565,8 +565,8 @@

 		case MOVEMENT_SYSTEM_STATUS_ROUND_MOVEMENT:
 		{
-			int32_t leftTyreSpeed = leftEncoder.getSpeed();
-			int32_t rightTyreSpeed = rightEncoder.getSpeed();
+			float leftTyreSpeed = leftEncoder.getSpeed();
+			float rightTyreSpeed = rightEncoder.getSpeed();

 			// check if the speeds are the same if not correct the speed of the slower motors
 			if((float)(leftTyreSpeed) > (float)((float)(rightTyreSpeed) * (float)circleMotorSpeedDifference))
@@ -579,8 +579,8 @@
 			}

 			// update moved distance
-			distanceExpectedByLeftTire -= leftTyreSpeed;
-			distanceExpectedByRightTire -= rightTyreSpeed;
+			distanceExpectedByLeftTire -= leftTyreSpeed / SAMPLE_FREQUENCY;
+			distanceExpectedByRightTire -= rightTyreSpeed / SAMPLE_FREQUENCY;

 			if(	(distanceExpectedByLeftTire < 0 && leftMotorDir > 0) ||
 				(distanceExpectedByLeftTire > 0 && leftMotorDir < 0) )


osd: print a bit more debug info about compat problems

--- src/osd/OSD.cc
+++ src/osd/OSD.cc
@@ -700,18 +700,19 @@
   ::decode(superblock, p);

   dout(10) << "read_superblock " << superblock << dendl;
-
   if (osd_compat.compare(superblock.compat_features) < 0) {
-    dout(5) << "The disk uses features unsupported by the executable." << dendl;
+    dout(0) << "The disk uses features unsupported by the executable." << dendl;
+    dout(0) << " ondisk features " << superblock.compat_features << dendl;
+    dout(0) << " daemon features " << osd_compat << dendl;
+
     if (osd_compat.writeable(superblock.compat_features)) {
-      dout(5) << "it is still writeable, though. Missing features:" << dendl;
+      dout(0) << "it is still writeable, though. Missing features:" << dendl;
       CompatSet diff = osd_compat.unsupported(superblock.compat_features);
-      //NEEDS_ITER
+      return -EOPNOTSUPP;
     }
     else {
       dout(0) << "Cannot write to disk! Missing features:" << dendl;
       CompatSet diff = osd_compat.unsupported(superblock.compat_features);
-      //NEEDS_ITER
       return -EOPNOTSUPP;
     }
   }


osd: drop messages from before we moved back to boot state

We want to make sure we ignore any messages sent to us before we moved
back to the boot state (after being wrongly marked down).  This is only
a problem currently while we are in the BOOT state and waiting to be
re-added to the map, because we may then call _share_map_incoming and
send something on the new rebound messenger to an old peer.  Also assert
that we are !booting there to be sure.

Signed-off-by: Sage Weil <6dd34506bbd5e58221bbb3e4732d97c91f02277b@newdream.net>

--- src/osd/OSD.cc
+++ src/osd/OSD.cc
@@ -1360,7 +1360,7 @@
     heartbeat_to[from] = m->peer_as_of_epoch;
     heartbeat_inst[from] = m->get_source_inst();

-    if (locked && m->map_epoch)
+    if (locked && m->map_epoch && !is_booting())
       _share_map_incoming(m->get_source_inst(), m->map_epoch,
 			  (Session*) m->get_connection()->get_priv());
   }
@@ -1370,7 +1370,7 @@

     // only take peer stat or share map now if map_lock is uncontended
     if (locked) {
-      if (m->map_epoch)
+      if (m->map_epoch && !is_booting())
 	_share_map_incoming(m->get_source_inst(), m->map_epoch,
 			    (Session*) m->get_connection()->get_priv());
       take_peer_stat(from, m->peer_stat);  // only with map_lock held!
@@ -1955,6 +1955,8 @@
   bool shared = false;
   dout(20) << "_share_map_incoming " << inst << " " << epoch << dendl;
   //assert(osd_lock.is_locked());
+
+  assert(!is_booting());

   // does client have old map?
   if (inst.name.is_client()) {
@@ -3325,6 +3327,13 @@
       m->put();
       return false;
     }
+  }
+
+  // ok, we have at least as new a map as they do.  are we (re)booting?
+  if (is_booting()) {
+    dout(7) << "still in boot state, dropping message " << *m << dendl;
+    m->put();
+    return false;
   }

   return true;


code review comments

code review comments

--- src/resolve-system-dependencies/resolve-system-dependencies.cc
+++ src/resolve-system-dependencies/resolve-system-dependencies.cc
@@ -11,14 +11,11 @@

 using namespace nix;

-typedef std::map<string, std::set<string>> SetMap;
-
 static auto cacheDir = Path{};

-Path resolveCacheFile(const Path & lib) {
-    Path lib2 = Path(lib);
-    std::replace(lib2.begin(), lib2.end(), '/', '%');
-    return cacheDir + "/" + lib2;
+Path resolveCacheFile(Path lib) {
+    std::replace(lib.begin(), lib.end(), '/', '%');
+    return cacheDir + "/" + lib;
 }

 std::set<string> readCacheFile(const Path & file) {
@@ -34,169 +31,169 @@
     fp.close();
 }

-std::string find_dylib_name(FILE *obj_file, struct load_command cmd) {
-  fpos_t pos;
-  fgetpos(obj_file, &pos);
-  struct dylib_command dylc;
-  dylc.cmd = cmd.cmd;
-  dylc.cmdsize = cmd.cmdsize;
-  fread(&dylc.dylib, sizeof(struct dylib), 1, obj_file);
+std::string findDylibName(FILE *obj_file, struct load_command cmd) {
+    fpos_t pos;
+    fgetpos(obj_file, &pos);
+    struct dylib_command dylc;
+    dylc.cmd = cmd.cmd;
+    dylc.cmdsize = cmd.cmdsize;
+    fread(&dylc.dylib, sizeof(struct dylib), 1, obj_file);

-  char *dylib_name = (char*)calloc(cmd.cmdsize, sizeof(char));
-  fseek(obj_file,
-      // offset is calculated from the beginning of the load command, which is two
-      // uint32_t's backwards
-      dylc.dylib.name.offset - (sizeof(uint32_t) * 2) + pos,
-      SEEK_SET);
-  fread(dylib_name, sizeof(char), cmd.cmdsize, obj_file);
-  fseek(obj_file, pos, SEEK_SET);
-  return std::string(dylib_name);
+    char *dylib_name = (char*)calloc(cmd.cmdsize, sizeof(char));
+    fseek(obj_file,
+            // offset is calculated from the beginning of the load command, which is two
+            // uint32_t's backwards
+            dylc.dylib.name.offset - (sizeof(uint32_t) * 2) + pos,
+            SEEK_SET);
+    fread(dylib_name, sizeof(char), cmd.cmdsize, obj_file);
+    fseek(obj_file, pos, SEEK_SET);
+    return std::string(dylib_name);
 }

-bool seek_mach64_blob(FILE *obj_file, enum NXByteOrder end) {
-  struct fat_header head;
-  fread(&head, sizeof(struct fat_header), 1, obj_file);
-  swap_fat_header(&head, end);
-  for(uint32_t narches = 0; narches < head.nfat_arch; narches++) {
-    struct fat_arch arch;
-    fread(&arch, sizeof(struct fat_arch), 1, obj_file);
-    swap_fat_arch(&arch, 1, end);
-    if(arch.cputype == CPU_TYPE_X86_64) {
-      fseek(obj_file, arch.offset, SEEK_SET);
-      return true;
+bool seekMach64Blob(FILE *obj_file, enum NXByteOrder end) {
+    struct fat_header head;
+    fread(&head, sizeof(struct fat_header), 1, obj_file);
+    swap_fat_header(&head, end);
+    for(uint32_t narches = 0; narches < head.nfat_arch; narches++) {
+        struct fat_arch arch;
+        fread(&arch, sizeof(struct fat_arch), 1, obj_file);
+        swap_fat_arch(&arch, 1, end);
+        if(arch.cputype == CPU_TYPE_X86_64) {
+            fseek(obj_file, arch.offset, SEEK_SET);
+            return true;
+        }
     }
-  }
-  return false;
+    return false;
 }

 std::set<std::string> runResolver(const Path & filename) {
-  FILE *obj_file = fopen(filename.c_str(), "rb");
-  uint32_t magic;
-  fread(&magic, sizeof(uint32_t), 1, obj_file);
-  fseek(obj_file, 0, SEEK_SET);
-  enum NXByteOrder endianness;
-  if(magic == 0xBEBAFECA) {
-    endianness = NX_BigEndian;
-    if(!seek_mach64_blob(obj_file, endianness)) {
-      std::cerr << "Could not find any mach64 blobs in file " << filename << ", continuing..." << std::endl;
-      return std::set<string>();
+    FILE *obj_file = fopen(filename.c_str(), "rb");
+    uint32_t magic;
+    fread(&magic, sizeof(uint32_t), 1, obj_file);
+    fseek(obj_file, 0, SEEK_SET);
+    enum NXByteOrder endianness;
+    if(magic == 0xBEBAFECA) {
+        endianness = NX_BigEndian;
+        if(!seekMach64Blob(obj_file, endianness)) {
+            std::cerr << "Could not find any mach64 blobs in file " << filename << ", continuing..." << std::endl;
+            return std::set<string>();
+        }
     }
-  }
-  struct mach_header_64 header;
-  fread(&header, sizeof(struct mach_header_64), 1, obj_file);
-  if(!(header.magic == MH_MAGIC_64 || header.magic == MH_CIGAM_64)) {
-    std::cerr << "Not a mach-o object file: " << filename << std::endl;
-    return std::set<string>();
-  }
-  std::set<string> libs;
-  for(uint32_t i = 0; i < header.ncmds; i++) {
-    struct load_command cmd;
-    fread(&cmd.cmd, sizeof(uint32_t), 1, obj_file);
-    fread(&cmd.cmdsize, sizeof(uint32_t), 1, obj_file);
-    switch(cmd.cmd) {
-      case LC_LOAD_DYLIB:
-      case LC_LOAD_UPWARD_DYLIB:
-      case LC_REEXPORT_DYLIB:
-        libs.insert(find_dylib_name(obj_file, cmd));
-        break;
+    struct mach_header_64 header;
+    fread(&header, sizeof(struct mach_header_64), 1, obj_file);
+    if(!(header.magic == MH_MAGIC_64 || header.magic == MH_CIGAM_64)) {
+        std::cerr << "Not a mach-o object file: " << filename << std::endl;
+        return std::set<string>();
     }
-    fseek(obj_file, cmd.cmdsize - (sizeof(uint32_t) * 2), SEEK_CUR);
-  }
-  fclose(obj_file);
-  libs.erase(filename);
-  return libs;
+    std::set<string> libs;
+    for(uint32_t i = 0; i < header.ncmds; i++) {
+        struct load_command cmd;
+        fread(&cmd.cmd, sizeof(cmd.cmd), 1, obj_file);
+        fread(&cmd.cmdsize, sizeof(cmd.cmdsize), 1, obj_file);
+        switch(cmd.cmd) {
+            case LC_LOAD_DYLIB:
+            case LC_LOAD_UPWARD_DYLIB:
+            case LC_REEXPORT_DYLIB:
+                libs.insert(findDylibName(obj_file, cmd));
+                break;
+        }
+        fseek(obj_file, cmd.cmdsize - (sizeof(uint32_t) * 2), SEEK_CUR);
+    }
+    fclose(obj_file);
+    libs.erase(filename);
+    return libs;
 }

 bool isSymlink(const Path & path) {
-  struct stat st;
-  if(lstat(path.c_str(), &st))
-      throw SysError(format("getting attributes of path ‘%1%’") % path);
+    struct stat st;
+    if(lstat(path.c_str(), &st))
+        throw SysError(format("getting attributes of path ‘%1%’") % path);

-  return S_ISLNK(st.st_mode);
+    return S_ISLNK(st.st_mode);
 }

 Path resolveSymlink(const Path & path) {
     char buf[PATH_MAX];
     ssize_t len = readlink(path.c_str(), buf, sizeof(buf) - 1);
     if(len != -1) {
-      buf[len] = 0;
-      return Path(buf);
+        buf[len] = 0;
+        return Path(buf);
     } else {
-      throw SysError(format("readlink('%1%')") % path);
+        throw SysError(format("readlink('%1%')") % path);
     }
 }

-std::set<string> resolve_tree(const Path & path, PathSet & deps) {
-  std::set<string> results;
-  if(deps.find(path) != deps.end()) {
-    return std::set<string>();
-  }
-  deps.insert(path);
-  for (auto & lib : runResolver(path)) {
-    results.insert(lib);
-    for (auto & p : resolve_tree(lib, deps)) {
-      results.insert(p);
+std::set<string> resolveTree(const Path & path, PathSet & deps) {
+    std::set<string> results;
+    if(deps.find(path) != deps.end()) {
+        return std::set<string>();
     }
-  }
-  return results;
+    deps.insert(path);
+    for (auto & lib : runResolver(path)) {
+        results.insert(lib);
+        for (auto & p : resolveTree(lib, deps)) {
+            results.insert(p);
+        }
+    }
+    return results;
 }

-std::set<string> get_path(const Path & path) {
-  Path cacheFile = resolveCacheFile(path);
-  if(pathExists(cacheFile)) {
-    return readCacheFile(cacheFile);
-  }
+std::set<string> getPath(const Path & path) {
+    Path cacheFile = resolveCacheFile(path);
+    if(pathExists(cacheFile)) {
+        return readCacheFile(cacheFile);
+    }

-  std::set<string> deps;
-  std::set<string> paths;
-  paths.insert(path);
+    std::set<string> deps;
+    std::set<string> paths;
+    paths.insert(path);

-  Path next_path = Path(path);
-  while(isSymlink(next_path)) {
-    next_path = resolveSymlink(next_path);
-    paths.insert(next_path);
-  }
+    Path next_path = Path(path);
+    while(isSymlink(next_path)) {
+        next_path = resolveSymlink(next_path);
+        paths.insert(next_path);
+    }

-  for(auto & t : resolve_tree(next_path, deps)) {
-    paths.insert(t);
-  }
+    for(auto & t : resolveTree(next_path, deps)) {
+        paths.insert(t);
+    }

-  writeCacheFile(cacheFile, paths);
+    writeCacheFile(cacheFile, paths);

-  return paths;
+    return paths;
 }

 int main(int argc, char ** argv) {
     return handleExceptions(argv[0], [&]() {
-        initNix();
+            initNix();

-        struct utsname _uname;
+            struct utsname _uname;

-        uname(&_uname);
+            uname(&_uname);

-        cacheDir = (format("%1%/dependency-maps/%2%-%3%-%4%")
-            % settings.nixStateDir
-            % _uname.machine
-            % _uname.sysname
-            % _uname.release).str();
+            cacheDir = (format("%1%/dependency-maps/%2%-%3%-%4%")
+                    % settings.nixStateDir
+                    % _uname.machine
+                    % _uname.sysname
+                    % _uname.release).str();

-        auto store = openStore();
+            auto store = openStore();

-        auto drv = store->derivationFromPath(Path(argv[1]));
-        Strings impurePaths = tokenizeString<Strings>(get(drv.env, "__impureHostDeps"));
+            auto drv = store->derivationFromPath(Path(argv[1]));
+            Strings impurePaths = tokenizeString<Strings>(get(drv.env, "__impureHostDeps"));

-        std::set<string> all_paths;
+            std::set<string> all_paths;

-        for (auto & path : impurePaths) {
-            for(auto & p : get_path(path)) {
-              all_paths.insert(p);
+            for (auto & path : impurePaths) {
+                for(auto & p : getPath(path)) {
+                    all_paths.insert(p);
+                }
             }
-        }

-        std::cout << "extra-chroot-dirs" << std::endl;
-        for(auto & path : all_paths) {
-          std::cout << path << std::endl;
-        }
-        std::cout << std::endl;
+            std::cout << "extra-chroot-dirs" << std::endl;
+            for(auto & path : all_paths) {
+                std::cout << path << std::endl;
+            }
+            std::cout << std::endl;
     });
 }


Use a reduced queue size for less mem usage.

Doesn't seem to impact perf much.

--- src/output.cpp
+++ src/output.cpp
@@ -6,7 +6,7 @@
 namespace maxcso {

 // TODO: Tune, less may be better.
-static const size_t QUEUE_SIZE = 128;
+static const size_t QUEUE_SIZE = 32;

 Output::Output(uv_loop_t *loop, const Task &task)
 	: loop_(loop), flags_(task.flags), state_(STATE_INIT), srcSize_(-1), index_(nullptr) {


Update output.cpp

Update output.cpp

--- src/output.cpp
+++ src/output.cpp
@@ -8,32 +8,32 @@

 extern int press_rate;
 extern double press_interval;
-extern host_info host;
 extern int press_time;

 //如何使用本工具
 void usage( const char* tool_name )
 {
-	fprintf( stderr, "usage:  %s\n", tool_name );
-	fprintf( stderr, "        -r [or --rate] N                 [REQUIRED] specify the press rate (unit: query per second).\n" );
-	fprintf( stderr, "        -t [or --time] N                 [REQUIRED] test time (unit: second). \n" );
-	fprintf( stderr, "        -h [or --host] XXX.XXX.XXX.XXX   target host ip. The default host ip is 127.0.0.1 .\n" );
-	fprintf( stderr, "        -p [or --port] N                 port number. The default port number is 80.\n" );
-	fprintf( stderr, "        -u [or --uri ] /index.html       uri of the request.\n" );
+	fprintf( stderr, "Usage: %s\n", tool_name );
+	fprintf( stderr, "       -r [--rate] M                                  press rate (unit: query per second).\n" );
+	fprintf( stderr, "       -t [--time] N                                  test time (unit: second). \n" );
+	fprintf( stderr, "       -u [--url ] http://XX.XXX.XXX.XX:80/index.html request url, default port number 80.\n" );
 	exit( 1 );
 }

 //打印读取的参数信息
-void print_info( void )
+void print_info( parameters_set *parameters )
 {
 	fprintf( stdout, "\n" );
 	fprintf( stdout, "This is %s (last updated on %s), an HTTP benchmarking tool.\n", VERSION, LAST_UPDATE );
 	fprintf( stdout, "Copyright © 2014 %s. Email: %s\n\n", AUTHOR, CONTACT );
 	fprintf( stdout, "Test Information\n" );
-	fprintf( stdout, "    Host       : %s\n", host.host_ip );
-	fprintf( stdout, "    Port       : %d\n", host.port );
-	fprintf( stdout, "    URI        : %s\n", host.uri );
-	fprintf( stdout, "    Target QPS : %-6d%-11s\n", press_rate, "[#/second]" );
+	if( parameters->url_number == 1 )
+	{
+		fprintf( stdout, "    Host       : %s\n", parameters->host[0]->host_ip );
+		fprintf( stdout, "    Port       : %d\n", parameters->host[0]->port );
+		fprintf( stdout, "    URI        : %s\n", parameters->host[0]->uri );
+	}
+	fprintf( stdout, "    Target RPS : %-6d%-11s\n", press_rate, "[#/second]" );
 	fprintf( stdout, "    Test Time  : %-6d%-11s\n", press_time, "[second]" );
 	fprintf( stdout, "\n" );
 	return;
@@ -54,6 +54,37 @@
 	}

 	return ;
+}
+
+void check_connect_ontime( const int press_number, const test_connect_ontime *tco )
+{
+	if( press_number < 100 )
+	{
+		return ;
+	}
+	int temptime_us = (tco->test_end).tv_usec - (tco->test_start).tv_usec;
+	int temptime_s = (tco->test_end).tv_sec - (tco->test_start).tv_sec;
+	if ( temptime_us < 0 )
+	{
+		temptime_s--;
+		temptime_us += 1000000;
+	}
+	int actual_rps = (int)( press_number / (temptime_s + temptime_us / 1000000.0) );
+	double err = actual_rps*1.0 / press_rate -1;
+	if( err > 0.05 || err < -0.05)
+	{
+		fprintf( stderr, "ATTENTION: The actual RPS did NOT reach your Target RPS %d [#/second].\n", press_rate );
+		fprintf( stderr, "           Actually, %d requests were sent out within %d.%d seconds.\n", press_number, temptime_s, (temptime_us/1000) );
+		fprintf( stderr, "           Therefore, the actual RPS is about %d [#/second].\n", actual_rps);
+		fprintf( stderr, "\n");
+	}else
+	{
+		fprintf( stdout, "The actual RPS is %d, which is exactly equal to your settings.\n", press_rate );
+		fprintf( stdout, "Please refer to the test results as follows: \n" );
+		fprintf( stdout, "\n");
+	}
+
+	return;
 }

 void statistics_calculation( final_statistics *overall_stat, const request_data test_data[], const int press_number )
@@ -146,7 +177,7 @@
 	fprintf( stdout, "    HTTP Response Fail Count: %-9d%-8s\n", overall_stat->response_fail_count, "[#]" );
 	fprintf( stdout, "    Overall Fail Count:       %-9d%-8s\n", overall_stat->total_fail_count, "[#]" );
 	fprintf( stdout, "    Total Request Number:     %-9d%-8s\n", overall_stat->total_request, "[#]" );
-	fprintf( stdout, "    Fail Percent:             %.3f%%\n", 100*(overall_stat->fail_percent) );
+	fprintf( stdout, "    Fail Percent:             %.3lf%%\n", 100*(overall_stat->fail_percent) );
 	fprintf( stdout, "    Total Bytes Transferred:  %-9lu%-8s\n", overall_stat->total_byte, "[Bytes]" );
 	fprintf( stdout, "\n" );
 	fprintf( stdout, "Request Time [unit: us]\n" );


Removed couts

Removed couts

--- gui/NetClient.cc
+++ gui/NetClient.cc
@@ -67,7 +67,6 @@

     if( not(incompleteCommand.isEmpty())){
         inData = incompleteCommand;
-        cout << "old command exists" << endl;
         incompleteCommand = "";
     }
     QByteArray Data = TcpSocket->readAll();
@@ -77,11 +76,9 @@
     QString rest = "";
     int n = inData.indexOf(breaker);
     int i;
-    int p = 0;

     if(inData.indexOf(breaker) == -1 ){
-        cout << "breaker missing " << endl;
         incompleteCommand = inData;
         return;
     }
@@ -91,7 +88,6 @@
         rest = inData.mid(n+1);
         inData = inData.left(n);
         i = inData.indexOf(compare);
-        cout << p << endl;
         commandName = inData.left(i);

         p = p + 1;


Fix for issue #8, Added a prompt if the files already existed

--- gui/nin10kit.cpp
+++ gui/nin10kit.cpp
@@ -142,12 +142,25 @@
         WarnLog("No images loaded not exporting");
         return;
     }
-    std::string filename = wxSaveFileSelector(_("Export Images"), "", "", this).ToStdString();
-    if (filename.empty())
-    {
-        WarnLog("Filename empty not saving");
-        return;
-    }
+
+    std::string filename;
+    bool save_ok;
+    do
+    {
+        save_ok = true;
+        filename = wxSaveFileSelector(_("Export Images"), "", "", this).ToStdString();
+        if (filename.empty())
+        {
+            WarnLog("Filename empty not saving.");
+            return;
+        }
+        if (wxFile::Exists(filename + ".c") || wxFileExists(filename + ".h"))
+        {
+            int ans = wxMessageBox(wxString::Format(_("Ok to overwrite %s(.c|.h)?"), filename), _("Confirm"), wxYES_NO | wxCANCEL, this);
+            if (ans == wxNO) save_ok = false;
+            if (ans == wxCANCEL) return;
+        }
+    } while (!save_ok);

     InfoLog("Saving exported file to %s", filename.c_str());
     DoExport(mode->GetSelection(), filename, filenames, images);


minor fix

minor fix

git-svn-id: 85872b7afb220dcc64e2b0b512745dae3b5d71ea@30 cbded5de-cc78-e246-76a9-cbce3a6603d9

--- src/parser.cpp
+++ src/parser.cpp
@@ -33,8 +33,8 @@

 Token Parser::code()
 {
-	while (token.getType !=  Sym::END)
-		block() || ifCond() || whileLoop() || read() || print () || stmt();
+	while (token.getType() !=  Sym::END)
+		block() || ifCond() || whileLoop() || read() || print() || stmt();
 }


Added array parsing (sorta)

Added array parsing (sorta)

--- src/parser.cpp
+++ src/parser.cpp
@@ -5,6 +5,7 @@
 #include <istream>
 #include <string>
 #include <vector>
+#include <tuple>

 #include "json.hpp"

@@ -24,6 +25,18 @@
     }

     return false;
+}
+
+// Returns the strings before and after a delimiter character.
+std::tuple<std::string, std::string> untilChar(const std::string& str, char delim) {
+    int n;
+    for (n = 0; n < str.size(); n++)
+        if (str[n] == delim)
+            break;
+
+    if (n + 1 >= str.size())
+        return std::make_tuple(str, "");
+    return std::make_tuple(str.substr(0, n), str.substr(n + 1, str.size() - 1));
 }

 // Checking if a character is a quote.
@@ -49,6 +62,19 @@

 // Trying to specifically parse out a JSON array.
 JValue parseJSONArray(const std::string& str) {
+    if (str[0] == '[' && str[str.size() - 1] == ']') {
+        std::string useStr = str.substr(1, str.size() - 2);
+        if (useStr.compare("") == 0)
+            return JValue();
+
+        std::vector<JValue> jValues;
+        std::tuple<std::string, std::string> tup;
+        for (tup = untilChar(useStr, ','); std::get<0>(tup).compare("") != 0; tup = untilChar(std::get<1>(tup), ','))
+            jValues.push_back(parseJSON(std::get<0>(tup)));
+
+        return JValue(jValues);
+    }
+
     return JValue();
 }


INTEGRATION: CWS geordi2q14 (1.4.40); FILE MERGED 2004/01/29 15:10:12 hr 1.4.40.1: #111934#: merge CWS ooo111fix2

--- cppuhelper/source/macro_expander.cxx
+++ cppuhelper/source/macro_expander.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: macro_expander.cxx,v $
  *
- *  $Revision: 1.4 $
- *
- *  last change: $Author: hr $ $Date: 2003-07-16 17:52:22 $
+ *  $Revision: 1.5 $
+ *
+ *  last change: $Author: hr $ $Date: 2004-02-02 23:15:26 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -111,12 +111,6 @@

 typedef ::cppu::WeakComponentImplHelper3<
     util::XMacroExpander, lang::XServiceInfo, lang::XInitialization > t_uno_impl;
-
-#if defined( MACOSX ) && ( __GNUC__ < 3 )
-// Initialize static template data here to break circular reference to libstatic
-
-cppu::ClassData3 cppu::WeakComponentImplHelper3< com::sun::star::util::XMacroExpander, com::sun::star::lang::XServiceInfo, com::sun::star::lang::XInitialization >::s_aCD(1);
-#endif

 struct mutex_holder
 {


Pass two needed arguments in loadComponentFromFile.

     * src/planner.cc

--- src/planner.cc
+++ src/planner.cc
@@ -28,6 +28,8 @@
 #include <iostream>
 #include <fstream>

+#include <KineoUtility/kitParameterMap.h>
+
 #include "KineoModel/kppDeviceComponent.h"

 #include <hpp/util/debug.hh>
@@ -48,6 +50,7 @@
 #include "KineoModel/kppPathNode.h"
 #include "KineoModel/kppPathComponent.h"
 #include "KineoModel/kppJointComponent.h"
+#include <KineoModel/kppComponentFactoryRegistry.h>

 #include "kwsPlus/roadmap/kwsPlusStopRdmBuilderDelegate.h"

@@ -710,8 +713,11 @@
 	return KD_ERROR;
       }

-      if(KD_ERROR == parser->loadComponentFromFile(inFileName,
-						   modelTreeComponent)) {
+      if(KD_ERROR == parser
+	 ->loadComponentFromFile(inFileName,
+				 modelTreeComponent,
+				 CkppComponentFactoryRegistry::create (),
+				 CkitParameterMap::create ())) {
 	hppDout(error, "Unable to load file " << inFileName);
 	hppDout(error, parser->lastError().errorMessage());
 	return KD_ERROR;


*** empty log message ***

*** empty log message ***

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

--- src/policy.cpp
+++ src/policy.cpp
@@ -342,6 +342,10 @@
 		peer* worst_peer = 0;
 		size_type min_weight = std::numeric_limits<int>::min();

+#ifndef NDEBUG
+		int unchoked_counter = m_num_unchoked;
+#endif
+
 		// TODO: make this selection better

 		for (std::vector<peer>::iterator i = m_peers.begin();
@@ -351,6 +355,9 @@

 			if (c == 0) continue;
 			if (c->is_choked()) continue;
+#ifndef NDEBUG
+			unchoked_counter--;
+#endif
 			// if the peer isn't interested, just choke it
 			if (!c->is_peer_interested())
 				return &(*i);
@@ -360,14 +367,15 @@

 			size_type weight = static_cast<int>(c->statistics().download_rate() * 10.f)
 				+ diff
-				+ (c->has_peer_choked()?-10:10)*1024;
-
-			if (weight > min_weight) continue;
+				+ ((c->is_interesting() && c->has_peer_choked())?-10:10)*1024;
+
+			if (weight >= min_weight && worst_peer) continue;

 			min_weight = weight;
 			worst_peer = &(*i);
 			continue;
 		}
+		assert(unchoked_counter == 0);
 		return worst_peer;
 	}

@@ -732,6 +740,8 @@

 			if (m_torrent->m_uploads_quota.given < m_torrent->num_peers())
 			{
+				assert(m_torrent->m_uploads_quota.given >= 0);
+
 				// make sure we don't have too many
 				// unchoked peers
 				while (m_num_unchoked > m_torrent->m_uploads_quota.given)


*** empty log message ***

*** empty log message ***

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

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

-
 	using namespace libtorrent;

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

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

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

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

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

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


bugfix

bugfix

git-svn-id: 4f0141143c3c635d33f1b9f02fcb2b6c73e45c89@25 a83610d8-ad2a-0410-a6ab-fc0612d85776

--- src/policy.cpp
+++ src/policy.cpp
@@ -131,7 +131,7 @@
 		// from this peer instead)

 		peer_connection* peer = 0;
-		float down_speed = 0.f;
+		float down_speed = -1.f;
 		// find the peer with the lowest download
 		// speed that also has a piece thatt this
 		// peer could send us


*** empty log message ***

*** empty log message ***

--- Recipe.cc
+++ Recipe.cc
@@ -168,7 +168,8 @@

 HmmNetBaumWelch*
-Recipe::Info::init_hmmnet_files(HmmSet *model, FeatureGenerator *fea_gen,
+Recipe::Info::init_hmmnet_files(HmmSet *model, bool den_hmmnet,
+                                FeatureGenerator *fea_gen,
                                 bool raw_audio, HmmNetBaumWelch *hnbw)
 {
   // Open the audio file
@@ -183,7 +184,10 @@
   }

   // Open the HMM network
-  hnbw->open(hmmnet_path);
+  if (den_hmmnet)
+    hnbw->open(den_hmmnet_path);
+  else
+    hnbw->open(hmmnet_path);

   if (start_time > 0 || end_time > 0)
   {


Applications: Fixed vrpn-to-openvibe build on Fedora

Thanks to Theodore Papadopoulo for the patch.

--- applications/examples/vrpn-to-openvibe/src/linux-vrpn_main.cpp
+++ applications/examples/vrpn-to-openvibe/src/linux-vrpn_main.cpp
@@ -4,6 +4,7 @@
 #include "GenericVRPNServer.h"
 #include <iostream>
 #include <cmath>
+#include <unistd.h>

 #define DEFAULT_PORT 50555


Removed printf

Removed printf

--- Scene.cpp
+++ Scene.cpp
@@ -264,7 +264,5 @@
         view.left + cmp.x*(view.right-view.left),
         view.bottom + cmp.y*(view.top-view.bottom));

-    printf("%f, %f\r", mwp.x, mwp.y);
-    fflush(stdout);
     return mwp;
 }


Refuse to play chunk if none is loaded.

Refuse to play chunk if none is loaded.

--- Sound.cpp
+++ Sound.cpp
@@ -41,6 +41,12 @@

 	void Sound::play()
 	{
+		if(chunk == nullptr)
+		{
+			Logger::log("Chunk has not been loaded.", hm::ERROR);
+			return;
+		}
+
 		Mix_PlayChannel(-1, chunk, 0);
 		return;
 	}


Fix resource leak

Fix resource leak

--- src/random.cpp
+++ src/random.cpp
@@ -186,6 +186,7 @@
     do {
         ssize_t n = read(f, ent32 + have, NUM_OS_RANDOM_BYTES - have);
         if (n <= 0 || n + have > NUM_OS_RANDOM_BYTES) {
+            close(f);
             RandFailure();
         }
         have += n;


Avoid unneeded inc/dec rec in RefPtr::operator=

--- src/ref_ptr.hh
+++ src/ref_ptr.hh
@@ -24,11 +24,15 @@

     RefPtr& operator=(const RefPtr& other)
     {
-        release();
-        m_ptr = other.m_ptr;
-        acquire();
+        if (other.m_ptr != m_ptr)
+        {
+            release();
+            m_ptr = other.m_ptr;
+            acquire();
+        }
         return *this;
     }
+
     RefPtr& operator=(RefPtr&& other)
     {
         release();
@@ -40,9 +44,12 @@

     RefPtr& operator=(T* ptr)
     {
-        release();
-        m_ptr = ptr;
-        acquire();
+        if (ptr != m_ptr)
+        {
+            release();
+            m_ptr = ptr;
+            acquire();
+        }
         return *this;
     }


Cleanup

Cleanup

--- src/replob.cpp
+++ src/replob.cpp
@@ -212,7 +212,6 @@

     ServiceAccessor a;
     TrueScheduler s {[&a] {
-        //CHECK3(!a.service<Replob>(0).commited.empty(), "must be commited");
         a.service<Client>(0).test();
     }};
     s.run();


typo fix of booleamn to boolean

typo fix of booleamn to boolean

(cherry picked from commit c15e483f2394e51163ba2514cd56fdba32bb92a4)

--- src/rpcnet.cpp
+++ src/rpcnet.cpp
@@ -96,7 +96,7 @@
             "    \"inbound\": true|false,     (boolean) Inbound (true) or Outbound (false)\n"
             "    \"startingheight\": n,       (numeric) The starting height (block) of the peer\n"
             "    \"banscore\": n,             (numeric) The ban score\n"
-            "    \"syncnode\": true|false     (booleamn) if sync node\n"
+            "    \"syncnode\": true|false     (boolean) if sync node\n"
             "  }\n"
             "  ,...\n"
             "]\n"


[trivial] rpcnet: fix typo

[trivial] rpcnet: fix typo

--- src/rpcnet.cpp
+++ src/rpcnet.cpp
@@ -29,7 +29,7 @@
         throw runtime_error(
             "getconnectioncount\n"
             "\nReturns the number of connections to other nodes.\n"
-            "\nbResult:\n"
+            "\nResult:\n"
             "n          (numeric) The connection count\n"
             "\nExamples:\n"
             + HelpExampleCli("getconnectioncount", "")
@@ -83,7 +83,7 @@
         throw runtime_error(
             "getpeerinfo\n"
             "\nReturns data about each connected network node as a json array of objects.\n"
-            "\nbResult:\n"
+            "\nResult:\n"
             "[\n"
             "  {\n"
             "    \"id\": n,                   (numeric) Peer index\n"


reconstructed PeakForRedirect to fix a bug involving editing &input inside a fork

--- src/rshell.cpp
+++ src/rshell.cpp
@@ -15,6 +15,15 @@
 #include <vector>
 #include <pwd.h>

+enum class RedirectionTypes {
+  OUT_TRUNC,
+  OUT_APPEND,
+  IN,
+  PIPE,
+  NONE
+};
+
+void Redirect(RedirectionTypes r, std::string target);
 const std::multimap<std::string, int> DEFINED_OPS = { std::make_pair("&", 2),
                                                       std::make_pair("|", 2),
                                                       std::make_pair(";", 1),
@@ -23,7 +32,7 @@

 const std::vector<std::string> IMPLEMENTED_OPS{ "&&", "||", ";", "|", ">>", ">", "<" };

-void PeekForRedirection(std::list<std::string> &input);
+RedirectionTypes PeekForRedirection(std::list<std::string> input);
 // handles what to do with finalized input state
 void Execute(std::list<std::string> &input);

@@ -266,6 +275,22 @@

   char **rawcommand = &vectorcommand[0];
   int exitvalue = 0;
+
+  //look ahead for redirection operators
+  RedirectionTypes r = RedirectionTypes::NONE;
+  if (!input.empty()) {
+    r = PeekForRedirection(input);
+  }
+
+  //drop the operator + RHS of the redirection from input list
+  //if a redir op is found. has to be done from outside the fork
+  //or state isn't preserved in parent process
+  std::string target;
+  if (r != RedirectionTypes::NONE) {
+    input.pop_front();
+    target = input.front();
+    input.pop_front();
+  }
   auto pid = fork();
   if (pid == -1) {
     perror("Error on fork");
@@ -273,11 +298,7 @@
   }
   // child state
   else if (pid == 0) {
-    //TODO search operators inplace of input vector?
-    if (!input.empty()) {
-      PeekForRedirection(input);
-    }
-
+    Redirect(r, target);
     execvp(rawcommand[0], rawcommand);
     if (errno != 0) {
       perror("Error in execvp. Likely a nonexisting command?");
@@ -382,23 +403,36 @@
   }
   return false;
 }
-void PeekForRedirection(std::list<std::string> &input) {
+RedirectionTypes PeekForRedirection(std::list<std::string> input) {
   std::string op = input.front();
   input.pop_front();
   std::string target = input.front();
   input.pop_front();
+  if (op == ">") {
+    return RedirectionTypes::OUT_TRUNC;
+  }
+  else if (op == ">>") {
+    return RedirectionTypes::OUT_APPEND;
+  }
+  else if (op == "<") {
+    return RedirectionTypes::IN;
+  }
+
+  return RedirectionTypes::NONE;
+}
+void Redirect(RedirectionTypes r, std::string target) {
   int fd = -1;
-  if (op == ">") {
+  if (r == RedirectionTypes::OUT_TRUNC) {
     fd = open(target.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644);
     close(1);
     dup2(fd, 1);
   }
-  else if (op == ">>") {
+  else if (r == RedirectionTypes::OUT_APPEND) {
     fd = open(target.c_str(), O_RDWR | O_CREAT | O_APPEND, 0644);
     close(1);
     dup2(fd, 1);
   }
-  else if (op == "<") {
+ else if (r == RedirectionTypes::IN) {
     fd = open(target.c_str(), O_RDONLY, 0644);
     close(0);
     dup2(fd, 0);


Does not work well

Does not work well

--- src/rshell.cpp
+++ src/rshell.cpp
@@ -5,10 +5,13 @@
  * CS100 - Rshell - rshell.cpp
  */

+#include <sys/ioctl.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <sys/types.h>
 #include <sys/wait.h>
 #include <iostream>
 #include <string>
@@ -16,20 +19,84 @@
 #include <boost/tokenizer.hpp>
 #include <boost/algorithm/string.hpp>

+#include <dirent.h>
+#include <errno.h>
+#include <algorithm>
+#include <stdio.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <grp.h>
+#include <time.h>
+
 using namespace std;
 using namespace boost;
+
+//Tracks if user uses test
+bool test_mode = 0;
+string test_flag = "";

 char SPACE = ' ';
 string input;
 char ** cmds;

 void print_vec(vector<string>& v){
+    cout << "Printing.... " << endl;
     for(unsigned i = 0; i < v.size(); i++)
-	cout << v[i] << endl;
+	cout << v[i] << " ";
+    cout << endl;
+}
+
+//Use to check if there is an even (modable by 2)
+//number of quotes, parens, braces, brackets
+bool all_occur_closed(string in, string s){
+    int occurence = 0;
+    string clos = "";
+
+    if(s == "\""){
+	int cnt = 0;
+	while(in.find(s, occurence) != string::npos){
+	    cnt++;
+	    occurence = in.find(s, occurence) + 1;
+	}
+	if(cnt%2==0)
+	    return true;
+	return false;
+    }
+    else if(s == "["){
+	clos = "]";
+    }
+    else if(s == "{"){
+ 	clos = "}";
+    }
+    else if(s == "("){
+	clos = ")";
+    }
+
+    int cnt_op = 0, cnt_ed = 0;
+    while(in.find(s, occurence) != string::npos){
+        cnt_op++;
+	occurence = in.find(s, occurence) + 1;
+    }
+    occurence = 0;
+    while(in.find(clos, occurence) != string::npos){
+	cnt_ed++;
+	occurence = in.find(clos, occurence) + 1;
+    }
+    if(cnt_op == cnt_ed)
+	return 1;
+    return 0;
 }

 //Tokenizes a string into passed in vector
 void mystrtok(string& input, vector<string>&all){
+    //Check for occurences of {, [, (, " that all are closed
+    if(!all_occur_closed(input, "{") || !all_occur_closed(input, "\"") ||
+       !all_occur_closed(input, "[") || !all_occur_closed(input, "(")){
+	cout << "Error: Quotes/Parens/Bracket/Braces not closed." << endl;
+	input = "";
+	return;
+    }
+
     //cout << "I'm currently toking..." << endl;
     //CODE TO LOOK FOR CONNECTORS like ; || && and also comments like #
     //FIRST REMOVE ALL COMMENTS BUT CHECK TO SEE THAT ONE MAY POTENTIALLY EXIST FIRST
@@ -102,7 +169,11 @@
 	else
 	    lko+=1;
     }
-
+
+
+    //CHECK FOR [ ] AND CONVERT TO TEST
+    //CHECK FOR " ". IF EVEN NUMBER OF " WE GO ON, IF ODD RETURN ERROR
+
     //Now we can tokenize properly
     split(all, input, is_any_of(" "), token_compress_on);
 }
@@ -120,7 +191,7 @@
 	if(input.find_first_not_of(' ')!=string::npos && input!="quit" && input.at(0)!='#'){
 	    mystrtok(input, allCmds);
 	//////////////TEST
-	//		print_vec(allCmds);
+		print_vec(allCmds);
 	/////////////

 	//cout << "Done toking" << endl;
@@ -153,9 +224,19 @@
 		//cout << "What is c_p" << c_p << endl;
 		//cout << "allCmds" << allCmds.size() << endl;
 		//cout << "Whats at c_c" << c_c << endl;
-
+cout << "    DEBUG The first cmd is: " << allCmds[c_s] << endl;
+cout << "    DEBUG What is success: " << succeeded << endl;
+cout << "    DEBUG What is next conn: " << c_c << endl;
+cout << "    DEBUG What is init " << init << endl;
+cout << "    DEBUG " << (!succeeded && c_c == "||") << endl;
+cout << "    DEBUG What is success and c_c &&:" << (succeeded && c_c == "&&") << endl;
+cout << "    DEBUG if statement evaluates: " << ((init || c_c == ";" || c_c == "end" || (succeeded && c_c == "&&") ||
+		   (!succeeded && c_c == "||")) && allCmds[c_s] != "test") << endl;
+
 		unsigned next_inx = 0;
-	        if(init || c_c == ";" || c_c == "end" || (succeeded && c_c == "&&") || (!succeeded && c_c == "||")){
+	        if((init || c_c == ";" || c_c == "end" || (succeeded && c_c == "&&") ||
+		   (!succeeded && c_c == "||")) && allCmds[c_s] != "test"){
+cout << "    DEBUG WHY ARE WE IN HERE? " << endl;
 		    //Set new connector
 		    if(c_p < allCmds.size())
 		        c_c = allCmds[c_p];
@@ -235,14 +316,87 @@
 		    }
 		    //delete[] cmds;
 	    	}
+		//Implies test was used
+		else if(allCmds[c_s] == "test" ){
+cout << "test detected//////////////////////////////////////////" << endl;
+		    init = 0;
+		    //Set new connector
+		    if(c_p < allCmds.size())
+		        c_c = allCmds[c_p];
+		    else
+		        c_c = "end";
+
+		    //Check for flags. Careful about out of index!
+		    //Flags are -e, -f, -d or no flag which evals to -e
+		    //Args can or may not exist. Args can be one string only. Multiple
+		    //Args will output an error and be counted as a failed execution
+
+		    //c_p is the connector and c_s is the start.
+		    //c_s can at most be one before the next connector c_s < c_p
+		    //and c_s + n where n is the size-1 of this cmd sequence
+		    //must be < size of all Cmd sequences.
+		    if(c_s + 1 < c_p && c_p - c_s <= 3){
+			struct stat sb;
+
+			if(c_s + 2 < c_p){
+			    if(allCmds[c_s + 1] == "-e"){
+cout << "    DEBUG entered e" << endl;
+				if(stat(allCmds[c_s + 2].c_str(), &sb)==-1){
+				    perror("Stat error");
+				    succeeded = 0;
+				}
+				else if((sb.st_mode & S_IFREG) || (sb.st_mode & S_IFDIR))
+				    succeeded = 1;
+			    }
+			    else if(allCmds[c_s + 1] == "-f"){
+cout << "    DEBUG entered f////////////////////////////////////////////" << endl;
+				if(stat(allCmds[c_s + 2].c_str(), &sb)==-1){
+				    perror("Stat error");
+				    succeeded = 0;
+				}
+				else if((sb.st_mode & S_IFREG))
+				    succeeded = 1;
+			    }
+			    else if(allCmds[c_s + 1] == "-d"){
+cout << "    DEBUG entered d" << endl;
+				if(stat(allCmds[c_s + 2].c_str(), &sb)==-1){
+				    perror("Stat error");
+				    succeeded = 0;
+				}
+				else if((sb.st_mode & S_IFDIR))
+				    succeeded = 1;
+			    }
+			}
+			//Deafaults to -e
+			else{
+cout << "    DEBUG default e" << endl;
+			    if(stat(allCmds[c_s + 1].c_str(), &sb)==-1){
+				perror("Stat error");
+			 	succeeded = 0;
+			    }
+			    else if((sb.st_mode & S_IFREG) || (sb.st_mode & S_IFDIR)){
+				    succeeded = 1;
+cout << "    DEBUG default e success" << endl;
+
+			    }
+			}
+		    }
+		    else{
+			cout << "Bash: test error." << endl;
+		        succeeded = 0;
+		    }
+
+		    c_p++;
+		    c_s = c_p;
+		}
+		//Implies failed cmd combo(eg. SUCCESS || CMD, CMD fails)
 		else{
+		    cout << "Welcome to limbo" << endl << endl;
 		    c_p++;
 		    c_s = c_p;
-		}
-
-        }
-
-
+		    succeeded = 0;
+		}
+            }
 	}
 	fflush(stdout);
 	//RESET ALL VALUES


added cd and PATH aspects of rshell

added cd and PATH aspects of rshell

--- src/rshell.cpp
+++ src/rshell.cpp
@@ -1,4 +1,5 @@
 #include<iostream>
+#include<sys/stat.h>
 #include<fcntl.h>
 #include<pwd.h>
 #include<sstream>
@@ -6,6 +7,7 @@
 #include<boost/tokenizer.hpp>
 #include<errno.h>
 #include<string>
+#include<stdlib.h>
 #include<string.h>
 #include<sys/types.h>
 #include<sys/wait.h>
@@ -15,6 +17,9 @@
 using namespace boost;

 typedef tokenizer<char_separator<char> > Tok;
+
+char directory[1024];
+string cwd = "";

 void readCommands(string str);
 int conjunct(int n, stringstream& ss, const Tok::iterator &it, bool didExtra = false);
@@ -23,12 +28,19 @@
 bool ioRedir(const Tok::iterator &it, bool inRedir, bool append);
 void resetIO(int in0, int out1);
 void pipeRedir(int fd[], int fdLoop[], bool pipeOut, bool isFirst, bool isLast, int n, stringstream& ss, const Tok::iterator &it, bool didRedir);
+string findPath(string file);

 int main(){
-
     cout << endl;
     string str = "";
     struct passwd *pass;
+
+    bool hasDirectory = true;
+
+    if((getcwd(directory, 1024)) == NULL){
+        perror("getcwd");
+        hasDirectory = false;
+    }

     pass = getpwuid(getuid());
     if(pass == NULL){
@@ -51,10 +63,15 @@
         userinfo = username + "@" + hostname;
     }

+    if(hasDirectory){
+        cwd = directory;
+        cwd = ":" + cwd;
+    }
+
     bool notExited = true;

     while(notExited){
-        cout << userinfo << "$ ";
+        cout << userinfo << cwd << "$ ";
         getline(cin, str);
         readCommands(str);
     }
@@ -279,29 +296,69 @@

     splitString(args, ss, n);

-    int pid = fork();
-
-    if(pid == -1){
-        perror("There was an error with the fork().");
-        exit(1);
-    }
-    else if(pid == 0){
-        if(-1 == execvp((const char*) args[0], (char* const*) args)){
-            perror(args[0]);
-            exit(3);
-        }
-    }
-    else if(pid > 0){
-
-        if(-1 == wait(&status)){
-            perror("There was an error with wait().");
-            return -1;
-        }
-
-        if(WIFEXITED(status)){
-            if(WEXITSTATUS(status) == 3){
-                delete[] args;
+    if(strcmp(args[0], "cd") == 0){
+        if(n <= 1){
+
+            string home;
+
+            if((home = getenv("HOME")) == ""){
+                perror("getenv");
+            }
+
+            if(chdir((char*) home.c_str()) == -1){
+                perror("chdir");
                 return -1;
+            }
+
+            if((getcwd(directory, 1024)) == NULL){
+                perror("getcwd");
+            }
+            else{
+                cwd = directory;
+                cwd = ":" + cwd;
+            }
+        }
+        else{
+            if(chdir(args[1]) == -1){
+                perror("chdir");
+                return -1;
+            }
+
+            if((getcwd(directory, 1024)) == NULL){
+                perror("getcwd");
+            }
+            else{
+                cwd = directory;
+                cwd = ":" + cwd;
+            }
+        }
+    }
+    else{
+
+        int pid = fork();
+
+        if(pid == -1){
+            perror("There was an error with the fork().");
+            exit(1);
+        }
+        else if(pid == 0){
+            if(-1 == execv((const char*) args[0], (char* const*) args)){
+                perror(args[0]);
+                exit(3);
+            }
+        }
+        else if(pid > 0){
+
+            if(-1 == wait(&status)){
+                perror("There was an error with wait().");
+                return -1;
+            }
+
+            if(WIFEXITED(status)){
+                if(WEXITSTATUS(status) == 3){
+                    delete[] args;
+                    return -1;
+                }
             }
         }
     }
@@ -437,8 +494,8 @@
             }
             //TODO execute command here

-            if(-1 == execvp((const char*) args[0], (char* const*) args)){
-                perror("execvp in pipe");
+            if(-1 == execv((const char*) args[0], (char* const*) args)){
+                perror("execv in pipe");
                 exit(-1);
             }
         }
@@ -498,8 +555,8 @@
                 }
             }

-            if(-1 == execvp((const char*) args[0], (char* const*) args)){
-                perror("execvp in pipe");
+            if(-1 == execv((const char*) args[0], (char* const*) args)){
+                perror("execv in pipe");
                 exit(-1);
             }

@@ -545,6 +602,10 @@

         ss >> str[i];

+        if(str[i] != "cd" && i == 0){
+           str[i] = findPath(str[i]);
+        }
+
         args[i] = (char*) str[i].c_str();
     }

@@ -559,3 +620,30 @@

     delete[] str;
 }
+
+string findPath(string file){
+    string env = "";
+
+    if((env = getenv("PATH")) == ""){
+        perror("getenv findPath");
+        exit(-1);
+    }
+
+    string dir = "";
+    string path = "";
+    struct stat buf;
+
+    int i;
+
+    while((i = env.find(":")) != -1){
+        dir = env.substr(0, i);
+
+        env = env.substr(i + 1, env.size());
+
+        if(stat((dir + "/" + file).c_str(), &buf) != -1){
+            path = dir + "/" + file;
+        }
+    }
+
+    return path;
+}


fixed comments

fixed comments

--- src/rshell.cpp
+++ src/rshell.cpp
@@ -13,7 +13,6 @@
 	"syntax error: connector must be preceded by a command"

 //separate special characters with whitespace for tokenization
-//WARNING: this function calls new
 string preprocess(const string& line) {
 	string processed = "";
 	for (int i = 0; i < line.size(); ++i) {
@@ -55,7 +54,6 @@
 }

 //converts vector of vector of strings to vector of array of cstrings
-//WARNING: calls new
 vector<char**> c_compatible(const vector< vector<string> >& cmd) {
 	vector<char**> c_cmd;
 	for (int i = 0; i < cmd.size(); ++i) {


* initial work on explicit alignments for tuples * alignment/size mismatches are not an error

--- src/scopes.cpp
+++ src/scopes.cpp
@@ -2787,12 +2787,16 @@
     TupleType(const std::vector<Any> &_types)
         : StorageType(TK_Tuple) {
         packed = _types.back().i1;
-        size_t tcount = _types.size() - 1;
+        size_t explicit_alignment = _types[_types.size()-2].sizeval;
+        size_t tcount = _types.size() - 2;
         types.reserve(tcount);
         for (size_t i = 0; i < tcount; ++i) {
             types.push_back(_types[i]);
         }
         std::stringstream ss;
+        if (explicit_alignment) {
+            ss << "[align:" << explicit_alignment << "]";
+        }
         if (packed) {
             ss << "<";
         }
@@ -2810,8 +2814,8 @@
         _name = String::from_stdstring(ss.str());

         offsets.resize(types.size());
+        size_t sz = 0;
         if (packed) {
-            size_t sz = 0;
             for (size_t i = 0; i < types.size(); ++i) {
                 const Type *ET = types[i];
                 offsets[i] = sz;
@@ -2820,7 +2824,6 @@
             size = sz;
             align = 1;
         } else {
-            size_t sz = 0;
             size_t al = 1;
             for (size_t i = 0; i < types.size(); ++i) {
                 const Type *ET = types[i];
@@ -2833,6 +2836,10 @@
             size = ::align(sz, al);
             align = al;
         }
+        if (explicit_alignment) {
+            align = explicit_alignment;
+            size = ::align(sz, align);
+        }
     }

     void *getelementptr(void *src, size_t i) const {
@@ -2854,13 +2861,15 @@
     bool packed;
 };

-static const Type *Tuple(const std::vector<const Type *> &types, bool packed = false) {
+static const Type *Tuple(const std::vector<const Type *> &types,
+    bool packed = false, size_t alignment = 0) {
     static TypeFactory<TupleType> tuples;
     std::vector<Any> atypes;
     atypes.reserve(types.size() + 1);
     for (auto &&arg : types) {
         atypes.push_back(arg);
     }
+    atypes.push_back(alignment);
     atypes.push_back(packed);
     return tuples.insert(atypes);
 }
@@ -6856,28 +6865,40 @@
         if (packed) {
             al = 1;
         }
+        bool explicit_alignment = false;
         if (has_bitfield) {
             // ignore for now and hope that an underlying union fixes the problem
         } else {
-            sz = ::align(sz, al);
             size_t needalign = rl.getAlignment().getQuantity();
             size_t needsize = rl.getSize().getQuantity();
+            #if 0
+            if (!is_union && (needalign != al)) {
+                al = needalign;
+                explicit_alignment = true;
+            }
+            #endif
+            sz = ::align(sz, al);
             bool align_ok = (al == needalign);
             bool size_ok = (sz == needsize);
             if (!(align_ok && size_ok)) {
                 StyledStream ss;
+                auto anchor = anchorFromLocation(rd->getSourceRange().getBegin());
                 if (al != needalign) {
-                    ss << "type " << ST << " alignment mismatch: " << al << " != " << needalign << std::endl;
+                    anchor->stream_source_line(ss);
+                    ss << anchor << " type " << ST << " alignment mismatch: " << al << " != " << needalign << std::endl;
                 }
                 if (sz != needsize) {
-                    ss << "type " << ST << " size mismatch: " << sz << " != " << needsize << std::endl;
+                    anchor->stream_source_line(ss);
+                    ss << anchor << " type " << ST << " size mismatch: " << sz << " != " << needsize << std::endl;
                 }
-                set_active_anchor(anchorFromLocation(rd->getSourceRange().getBegin()));
+                #if 0
+                set_active_anchor(anchor);
                 location_error(String::from("clang-bridge: imported record doesn't fit"));
-            }
-        }
-
-        tni->finalize(is_union?Union(types):Tuple(types, packed));
+                #endif
+            }
+        }
+
+        tni->finalize(is_union?Union(types):Tuple(types, packed, explicit_alignment?al:0));
         tni->field_names = names;
     }


fix postgress bug

fix postgress bug

--- plugins/blockvault_client_plugin/postgres_backend.cpp
+++ plugins/blockvault_client_plugin/postgres_backend.cpp
@@ -66,6 +66,7 @@
       pqxx::work w(conn);

       pqxx::largeobjectaccess obj(w);
+      obj.write(nullptr, 0);
       pqxx::binarystring      block_id_blob(block_id.data(), block_id.size());
       pqxx::binarystring      previous_block_id_blob(previous_block_id.data(), previous_block_id.size());
       w.exec_prepared0("insert_constructed_block", watermark.first, watermark.second, lib, block_id_blob,
@@ -85,6 +86,7 @@
       pqxx::work w(conn);

       pqxx::largeobjectaccess obj(w);
+      obj.write(nullptr, 0);
       pqxx::binarystring      block_id_blob(block_id.data(), block_id.size());
       pqxx::binarystring      previous_block_id_blob(previous_block_id.data(), previous_block_id.size());
       w.exec_prepared0("insert_external_block", block_num, lib, block_id_blob, previous_block_id_blob, obj.id(),
@@ -108,6 +110,7 @@

       pqxx::work              w(conn);
       pqxx::largeobjectaccess obj(w);
+      obj.write(nullptr, 0);

       w.exec_prepared0("insert_snapshot", watermark.first, watermark.second, obj.id());
       auto r = w.exec_prepared("get_snapshot_insertion_result", obj.id());


Remove template matching params from GetOpName()

Since they are not real opcodes, being reported as OP_UNKNOWN is less confusing for human-readable decoding.

Signed-off-by: Huang Le <373bd4647e9675ad4bb4ffd8ee82e636c353434d@gmail.com>

--- src/script.cpp
+++ src/script.cpp
@@ -208,14 +208,13 @@
     case OP_NOP9                   : return "OP_NOP9";
     case OP_NOP10                  : return "OP_NOP10";

-
-
-    // template matching params
-    case OP_PUBKEYHASH             : return "OP_PUBKEYHASH";
-    case OP_PUBKEY                 : return "OP_PUBKEY";
-    case OP_SMALLDATA              : return "OP_SMALLDATA";
-
     case OP_INVALIDOPCODE          : return "OP_INVALIDOPCODE";
+
+    // Note:
+    //  The template matching params OP_SMALLDATA/etc are defined in opcodetype enum
+    //  as kind of implementation hack, they are *NOT* real opcodes.  If found in real
+    //  Script, just let the default: case deal with them.
+
     default:
         return "OP_UNKNOWN";
     }


copyright

copyright

--- src/script.cpp
+++ src/script.cpp
@@ -1,6 +1,7 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
 // Copyright (c) 2009-2012 The Bitcoin developers
 // Copyright (c) 2012 The PPCoin developers
+// Copyright (c) 2015 The Grantcoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
 #include <boost/foreach.hpp>


fail if stack + altstack > 1000

fail if stack + altstack > 1000

--- src/script.cpp
+++ src/script.cpp
@@ -254,6 +254,8 @@
     //log_debug() << "Stack:";
     //for (auto s: stack_)
     //    log_debug() << "[" << pretty_hex(s) << "]";
+    if (stack_.size() + alternate_stack_.size() > 1000)
+        return false;
     return true;
 }


removed easing functions from script.cpp


Use array for holding principal variation

--- src/search.cpp
+++ src/search.cpp
@@ -30,12 +30,22 @@
 // TODO: what is the maximum number of possible moves in a position?
 using Moves = std::vector<Move>; // TODO: change this back to std::array<Move, 256>?

+template <int N>
+struct PrimaryVariation {
+    void push(Move m) noexcept { assert(count < moves.size()); moves[count++] = m; }
+    void pop() noexcept { --count; }
+    Move* begin() noexcept { return &moves[0]; }
+    Move* end() noexcept { return &moves[count]; }
+
+    std::array<Move, N+1> moves;
+    int                   count = 0;
+};
+
 constexpr int MAX_DEPTH = 2;
+using PV = PrimaryVariation<MAX_DEPTH>;

-int negamax(Position& position, int alpha, int beta, int depth, Moves& pv)
+int negamax(Position& position, int alpha, int beta, int depth, PV& pv)
 {
-    // TODO: check if terminal node (mate, stalemate, etc)
-    //       not sure if the fastest way to do that is to check if `nmoves == 0`?
     if (depth == 0) {
         int score = evaluate(position);
         return position.white_to_move() ? -score : score;
@@ -61,9 +71,9 @@
     assert(nmoves > 0);
     for (int i = 0; i < nmoves; ++i) {
         position.make_move(sp, moves[i]);
-        pv.push_back(moves[i]);
+        pv.push(moves[i]);
         value = std::max(value, negamax(position, /*alpha*/-beta, /*beta*/-alpha, depth - 1, pv));
-        pv.pop_back();
+        pv.pop();
         position.undo_move(sp, moves[i]);
         alpha = std::max(alpha, value);
         if (alpha >= beta) {
@@ -80,13 +90,13 @@
     Savepos sp;
     Moves moves{256};
     int nmoves = position.generate_legal_moves(&moves[0]);
-    Moves pv;
+    PV pv;
     for (int i = 0; i < nmoves; ++i) {
         position.make_move(sp, moves[i]);
-        pv.push_back(moves[i]);
+        pv.push(moves[i]);
         int score = negamax(position, /*alpha*/-INFINITY, /*beta*/INFINITY, /*depth*/MAX_DEPTH, pv);
         position.undo_move(sp, moves[i]);
-        pv.pop_back();
+        pv.pop();
         if (score > bestscore) {
             bestscore = score;
             bestmove = i;


Clear the inline query time and make more retries to smooth out JVM performance discrepencies.

--- projects/OG-Language/ConnectorTest/OverlappedTest.cpp
+++ projects/OG-Language/ConnectorTest/OverlappedTest.cpp
@@ -17,7 +17,7 @@
 #define TEST_LANGUAGE		TEXT ("test")
 #define TIMEOUT_STARTUP		30000
 #define TIMEOUT_CALL		3000
-#define RETRIES				10
+#define RETRIES				20

 static CConnector *g_poConnector;
 static double g_tOverlappedQuery = 0;
@@ -62,6 +62,7 @@
 }

 static void QueryAvailableInline () {
+	g_tInlineQuery = 0;
 	int i;
 	for (i = 0; i < RETRIES; i++) {
 		g_tInlineQuery -= GetTickCount ();


fix default ctx manager initialization

fix default ctx manager initialization

--- src/sig-ctx.cc
+++ src/sig-ctx.cc
@@ -121,7 +121,7 @@

 // default context managers
 context_manager<int> __sig_def_ctx_mngr(sig_ctx_default());
-context_manager<CStringPtr> __sig_def_ctx_mngr_s(sig_ctx_sys());
+context_manager<CStringPtr> __sig_def_ctx_mngr_s(sig_ctx_default());

 // explicit instantiation
 template class context_manager<int>;


Add "R = A * B'"

Add "R = A * B'"

--- src/simple.cpp
+++ src/simple.cpp
@@ -281,6 +281,30 @@
     static auto get(){
         T<double> a(D1, D2), b(D2, D3), c(D1, D3);
         return measure_only([&a, &b, &c](){c = a * b;}, a, b);
+    }
+};
+
+template<template<typename> class T, std::size_t D1, std::size_t D2, std::size_t D3, typename Enable = void>
+struct mmul_t {
+    static auto get(){
+        T<double> A(D1, D2), B(D3, D2), R(D1, D3);
+        return measure_only([&](){R = A * etl::transpose(B);}, A, B);
+    }
+};
+
+template<template<typename> class T, std::size_t D1, std::size_t D2, std::size_t D3>
+struct mmul_t <T, D1, D2, D3, std::enable_if_t<std::is_same<T<double>, blaze::DynamicMatrix<double>>::value>> {
+    static auto get(){
+        T<double> A(D1, D2), B(D3, D2), R(D1, D3);
+        return measure_only([&](){R = A * trans(B);}, A, B);
+    }
+};
+
+template<template<typename> class T, std::size_t D1, std::size_t D2, std::size_t D3>
+struct mmul_t <T, D1, D2, D3, std::enable_if_t<is_eigen<Eigen::Matrix,T<double>>::value>> {
+    static auto get(){
+        T<double> A(D1, D2), B(D3, D2), R(D1, D3);
+        return measure_only([&](){R = A * B.transpose();}, A, B);
     }
 };

@@ -351,7 +375,6 @@
     bench_dyn<smart_2, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 128>("R = A * (B * C)");
     bench_dyn<smart_3, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 64>("R = (A + B) * (C - D)");
     bench_dyn<smart_3, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 128>("R = (A + B) * (C - D)");
-
     bench_dyn<add_dynamic, blaze_dyn_vector, eigen_dyn_vector, etl_dyn_vector, 1 * 32768>("r = a + b");
     bench_dyn<add_dynamic, blaze_dyn_vector, eigen_dyn_vector, etl_dyn_vector, 2 * 32768>("r = a + b");
     bench_dyn<add_dynamic, blaze_dyn_vector, eigen_dyn_vector, etl_dyn_vector, 4 * 32768>("r = a + b");
@@ -365,6 +388,12 @@
     bench_dyn<mmul, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 256,256,256>("C = A * B");
     bench_dyn<mmul, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 300,200,400>("C = A * B");
     bench_dyn<mmul, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 512,512,512>("C = A * B");
+    bench_dyn<mmul_t, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 128,32,64>("C = A * B'");
+    bench_dyn<mmul_t, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 128,128,128>("C = A * B'");
+    bench_dyn<mmul_t, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 256,128,256>("C = A * B'");
+    bench_dyn<mmul_t, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 256,256,256>("C = A * B'");
+    bench_dyn<mmul_t, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 300,200,400>("C = A * B'");
+    bench_dyn<mmul_t, blaze_dyn_matrix, eigen_dyn_matrix, etl_dyn_matrix, 512,512,512>("C = A * B'");
     bench_dyn<add_complex, blaze_dyn_vector, eigen_dyn_vector, etl_dyn_vector, 1 * 32768>("dynamic_add_complex");
     bench_dyn<add_complex, blaze_dyn_vector, eigen_dyn_vector, etl_dyn_vector, 2 * 32768>("dynamic_add_complex");
     bench_dyn<add_complex, blaze_dyn_vector, eigen_dyn_vector, etl_dyn_vector, 4 * 32768>("dynamic_add_complex");


Catching all exceptions now.

Catching all exceptions now.

--- src/socket.cpp
+++ src/socket.cpp
@@ -103,8 +103,10 @@
   #ifdef DEBUG
   else std::cout << "[DEBUG] [child       ] Connection closed. Killing child process." << std::endl;
   #endif
- } catch (std::exception &e) {
+ } catch (const std::exception &e) {
   std::cout << "[ERROR] [child       ] Caught an exception: " << e.what() << std::endl;
+ } catch (...) {
+  std::cout << "[ERROR] [child       ] Caught an unknown exception." << std::endl;
  }
  pthread_exit(0); // Kill thread
 }


Fix S.F caused by empty system

Fix S.F caused by empty system

--- src/solver.cpp
+++ src/solver.cpp
@@ -24,12 +24,12 @@
     fgets(input, SIZE, stdin);

     // Remove new line of stop if empty
-    if(input != NULL){
+    if(input[0] != '\n'){
         size_t len = strlen(input);
         if (len > 0 && input[len-1] == '\n')
             input[--len] = '\0';
     } else {
-        cout << "Empty systems..." << endl;
+        cout << "No system..." << endl;
         return 0;
     }

@@ -48,8 +48,8 @@
     }

 	while(systems != NULL) {
+        cout << endl << "+- System : " << systems->value << endl;
         strcpy(indent, "    ");
-        cout << endl << indent << "+- System : " << systems->value << endl;
         systems->value = substr(systems->value, 1, strlen(systems->value) - 2);

         // Reset if old value


refactor: remove precision specifier from zero-padded printf output

--- src/spcdas.cpp
+++ src/spcdas.cpp
@@ -19,13 +19,13 @@
 int i, x, pos = 0, z;
 uint v;
   if(spc.addr == true) {
-    sprintf(ws, "%0.4x: ", spc.pc);
+    sprintf(ws, "%04x: ", spc.pc);
   } else {
     sprintf(ws, "");
   }
   if(spc.hex == true) {
     for(i=0;i<o;i++) {
-      sprintf(t, "%0.2x ", spc.mem[spc.pc+i]);
+      sprintf(t, "%02x ", spc.mem[spc.pc+i]);
       strcat(ws, t);
     }
     for(;i<3;i++) {
@@ -43,21 +43,21 @@
         else if(pos == 2)v=spc.mem[spc.pc+c];
         else if(pos == 3)v=spc.mem[spc.pc+d];
         pos++;
-        sprintf(t, "%0.2x", v&0xff);
+        sprintf(t, "%02x", v&0xff);
       } else if(x=='w') {
         if     (pos == 0)v=spc.mem[spc.pc+a]|(spc.mem[spc.pc+a+1]<<8);
         else if(pos == 1)v=spc.mem[spc.pc+b]|(spc.mem[spc.pc+b+1]<<8);
         else if(pos == 2)v=spc.mem[spc.pc+c]|(spc.mem[spc.pc+c+1]<<8);
         else if(pos == 3)v=spc.mem[spc.pc+d]|(spc.mem[spc.pc+d+1]<<8);
         pos++;
-        sprintf(t, "%0.4x", v&0xffff);
+        sprintf(t, "%04x", v&0xffff);
       } else if(x=='m') {
         if     (pos == 0)v=spc.mem[spc.pc+a]|(spc.mem[spc.pc+a+1]<<8);
         else if(pos == 1)v=spc.mem[spc.pc+b]|(spc.mem[spc.pc+b+1]<<8);
         else if(pos == 2)v=spc.mem[spc.pc+c]|(spc.mem[spc.pc+c+1]<<8);
         else if(pos == 3)v=spc.mem[spc.pc+d]|(spc.mem[spc.pc+d+1]<<8);
         pos++;
-        sprintf(t, "%0.4x,%d", v&0x1fff, v>>13);
+        sprintf(t, "%04x,%d", v&0x1fff, v>>13);
       } else if(x=='r') {
         if     (pos == 0)v=spc.mem[spc.pc+a];
         else if(pos == 1)v=spc.mem[spc.pc+b];
@@ -66,9 +66,9 @@
         pos++;
         if(spc.rel == true) {
           v=(spc.pc+o)+(signed char)v;
-          sprintf(t, "%0.4x", v&0xffff);
+          sprintf(t, "%04x", v&0xffff);
         } else {
-          sprintf(t, "%0.2x", v&0xff);
+          sprintf(t, "%02x", v&0xff);
         }
       }
       ws[z]=0;


Cleanup.

Cleanup.

--- src/string.cpp
+++ src/string.cpp
@@ -557,7 +557,7 @@
 				return StringView(eol.getTerm(), _str.getTerm() );
 			}

-			eol = strFind(str, "\n");
+			eol = strFind(str, '\n');
 			if (!eol.isEmpty() )
 			{
 				return StringView(eol.getTerm(), _str.getTerm() );
@@ -581,7 +581,7 @@
 				return StringView(eol.getPtr(), _str.getTerm() );
 			}

-			eol = strFind(str, "\n");
+			eol = strFind(str, '\n');
 			if (!eol.isEmpty() )
 			{
 				return StringView(eol.getPtr(), _str.getTerm() );


strmap: use "default" move constructor

strmap: use "default" move constructor

--- src/strmap.hxx
+++ src/strmap.hxx
@@ -60,8 +60,7 @@

     strmap(const strmap &) = delete;

-    strmap(strmap &&src)
-        :pool(src.pool), map(std::move(src.map)) {}
+    strmap(strmap &&src) = default;

     const_iterator begin() const {
         return map.begin();


enabled -> enable

enabled -> enable

--- searchlib/src/vespa/searchlib/fef/indexproperties.cpp
+++ searchlib/src/vespa/searchlib/fef/indexproperties.cpp
@@ -175,7 +175,7 @@

 namespace softtimeout {

-const vespalib::string Enabled::NAME("vespa.softtimeout.enabled");
+const vespalib::string Enabled::NAME("vespa.softtimeout.enable");
 const bool Enabled::DEFAULT_VALUE(false);

 bool Enabled::lookup(const Properties &props) {


Display several possible answers

Display several possible answers

--- src/sudoku.cpp
+++ src/sudoku.cpp
@@ -306,6 +306,10 @@
                 std::cout << std::endl;
             }
         } else {
+            std::vector<std::tuple<std::size_t, std::size_t, double>> next;
+
+            std::array<std::array<int, 9>, 9> matrix;
+
             for(size_t i = 0; i < 9; ++i){
                 for(size_t j = 0; j < 9; ++j){
                     auto& cell_mat = mats[i * 9 + j];
@@ -316,13 +320,48 @@
                     if(fill == 1.0f){
                         answer = 0;
                     } else {
-                        answer = dbn->predict(mat_to_image(cell_mat))+1;
-                    }
-
-                    std::cout << answer << " ";
+                        auto weights = dbn->predict_weights(mat_to_image(cell_mat));
+                        answer = dbn->predict_final(weights)+1;
+                        for(std::size_t x = 0; x < weights.size(); ++x){
+                            if(answer != x + 1 && weights(x) > 1e-5){
+                                next.push_back(std::make_tuple(i * 9 + j, x + 1, weights(x)));
+                            }
+                        }
+                    }
+                    matrix[i][j] = answer;
+                }
+            }
+
+            for(size_t i = 0; i < 9; ++i){
+                for(size_t j = 0; j < 9; ++j){
+                    std::cout << matrix[i][j] << " ";
                 }
                 std::cout << std::endl;
             }
+
+            if(!next.empty()){
+                std::sort(next.begin(), next.end(), [](auto& lhs, auto& rhs){
+                        return std::get<2>(lhs) > std::get<2>(rhs);
+                    });
+
+                for(int n = 0; n < next.size() && n < 5; ++n){
+                    std::cout << std::endl;
+
+                    auto change = next[n];
+
+                    for(size_t i = 0; i < 9; ++i){
+                        for(size_t j = 0; j < 9; ++j){
+                            if(std::get<0>(change) == i * 9 + j){
+                                std::cout << std::get<1>(change) << " ";
+                            } else {
+                                std::cout << matrix[i][j] << " ";
+                            }
+                        }
+                        std::cout << std::endl;
+                    }
+                }
+            }
+
         }
     } else if(command == "test"){
         auto ds = get_dataset(argc, argv);


src/target.cpp: UEFI improvements

src/target.cpp: UEFI improvements

--- src/target.cpp
+++ src/target.cpp
@@ -989,7 +989,7 @@
 }

 bool target_allows_addr_zero(const ZigTarget *target) {
-    return target->os == OsFreestanding;
+    return target->os == OsFreestanding || target->os == OsUefi;
 }

 const char *target_o_file_ext(const ZigTarget *target) {
@@ -1414,12 +1414,12 @@
 }

 bool target_supports_stack_probing(const ZigTarget *target) {
-    return target->os != OsWindows && (target->arch == ZigLLVM_x86 || target->arch == ZigLLVM_x86_64);
+    return target->os != OsWindows && target->os != OsUefi && (target->arch == ZigLLVM_x86 || target->arch == ZigLLVM_x86_64);
 }

 bool target_requires_pic(const ZigTarget *target, bool linking_libc) {
   // This function returns whether non-pic code is completely invalid on the given target.
-  return target->os == OsWindows || target_os_requires_libc(target->os) ||
+  return target->os == OsWindows || target->os == OsUefi || target_os_requires_libc(target->os) ||
       (linking_libc && target_is_glibc(target));
 }


Disable registration of atexit handlers on ARMCC.

This prevent destructors for global C++ objects to be invoked at exit.
By default atexit handlers registration involved dynamic allocation.

--- hal/common/retarget.cpp
+++ hal/common/retarget.cpp
@@ -629,6 +629,31 @@
 } //namespace std
 #endif

+#if defined(TOOLCHAIN_ARM)
+
+// This series of function disable the registration of global destructors
+// in a dynamic table which will be called when the application exit.
+// In mbed, program never exit properly, it dies.
+// More informations about this topic for ARMCC here:
+// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/6449.html
+extern "C" {
+int __aeabi_atexit(void *object, void (*dtor)(void* /*this*/), void *handle) {
+    return 1;
+}
+
+int __cxa_atexit(void (*dtor)(void* /*this*/), void *object, void *handle) {
+    return 1;
+}
+
+void __cxa_finalize(void *handle) {
+}
+
+} // end of extern "C"
+
+
+#endif
+
+

 namespace mbed {


switched back zdistort

switched back zdistort

--- mazegenerator/maze.cpp
+++ mazegenerator/maze.cpp
@@ -47,7 +47,7 @@
       for (int k = 0; k <= length; k++){
         double distortx = (double)(rand() % maxDistort)/(1.8*maxDistort/tileSize);
         double distorty = (double)(rand() % maxDistort)/(1.8*maxDistort/tileSize);
-        double distortz = (double)(rand() % maxDistort)/(2*maxDistort/tileSize);
+        double distortz = (double)(rand() % maxDistort)/(1.8*maxDistort/tileSize);
         if (k != length-1 && (k%2==1 || k == 0)) distortx = -distortx;
         if (j != width-1 && (j%2==1 || j == 0)) distortz = -distortz;
         if (i != height-1 && (i%2==1 || i == 0)) distorty = -distorty;


Minor refactoring in handleRpcCall

Minor refactoring in handleRpcCall

--- src/rpc/rpcconnection.cpp
+++ src/rpc/rpcconnection.cpp
@@ -153,11 +153,7 @@

 void RpcConnection::handleRpcCall(QTcpSocket *socket, const QVariantMap &map)
 {
-    QVariantList list = map["params"].toList();
-    QVarLengthArray<void *, 10> args(list.count()+1);
-    for (int i = 0; i < list.count(); i++) {
-        args[i+1] = list[i].data();
-    }
+    QVariantList params = map["params"].toList();

     QString rpcMethod = map["method"].toString();
     int idx = rpcMethod.indexOf('.');
@@ -183,6 +179,7 @@
         return;
     }

+    QVarLengthArray<void *, 10> args(params.count()+1);
     QVariant result;
     if (mm.typeName()) {
         result = QVariant(QVariant::nameToType(mm.typeName()), (void *)0);
@@ -191,6 +188,10 @@
         args[0] = 0;
     }

+    for (int i = 0; i < params.count(); i++) {
+        args[i+1] = params[i].data();
+    }
+
     QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, idx, args.data());

     sendResponse(socket, map["id"].toString(), args[0] ? *static_cast<QVariant *>(args[0]) : QVariant());