implemented File::acquire_block

implemented File::acquire_block

--- src/file.cc
+++ src/file.cc
@@ -130,12 +130,24 @@
 	bool success = false;
 	while(!success) {
 		std::shared_ptr<Block> block = client->get_client_info()->get_block();
+		// put in client request
 		block->enqueue(client->get_id(), client->get_client_info());
-		this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->lock();
+		// lock the approprate cache block -- allocate the block if the block is not in cache
 		try {
+			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->lock();
+			this->cache.at(block->get_id());
+		} catch(const std::out_of_range& e) {
+			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->unlock();
+			// side effect of blocking the block cache line here
+			this->allocate(block);
+		}
+		try {
+			// see if the block reference has changed for this client during the time taken to acquire
+			//	the block cache line lock
 			block->dequeue(client->get_id(), client->get_client_info());
 			success = true;
 		} catch(const giga::RuntimeError& e) {
+			// client block reference has moved since Block::enqueue has been called
 			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->unlock();
 		}
 	}
@@ -163,31 +175,27 @@

 	std::shared_ptr<giga::ClientInfo> info = client->get_client_info();

-	// EOF check
-	if(info->get_block_offset() == info->get_block()->get_size()) {
-		client->unlock_client();
-		return(0);
-	}
-
 	giga::giga_size n = 0;
 	giga::giga_size offset = 0;

 	while(n < n_bytes) {
+		this->acquire_block(client);
+
 		// backup copy of the block being referenced in the cache
 		std::shared_ptr<giga::Block> block = info->get_block();

-		try {
-			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->lock();
-			this->cache.at(block->get_id());
-		} catch(const std::out_of_range& e) {
-			// this->allocate() automatically locks the cache line
-			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->unlock();
-			this->allocate(block);
+		// EOF check
+		if(info->get_block_offset() == block->get_size()) {
+			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->unlock();
+			client->unlock_client();
+			return(n);
 		}

 		try {
 			this->cache.at(block->get_id())->increment();
 		} catch(const std::out_of_range& e) {
+			this->cache_entry_locks.at(block->get_id() % this->n_cache_entries)->unlock();
+			client->unlock_client();
 			throw(giga::RuntimeError("giga::File::read", "std::out_of_range thrown while incrementing block access count"));
 		}


Cleaned up jocs file listing and some other related style issues

--- src/gcs.cpp
+++ src/gcs.cpp
@@ -79,7 +79,6 @@
 }

 void send_file_list() {
-	std::vector<std::string> jocsFilePaths;
 	json j;

 	j["type"] = "list_reply";
@@ -89,21 +88,15 @@
 	if ((dir = opendir ("data")) != NULL) {
 		while ((ent = readdir (dir)) != NULL) {
 			if(ent->d_type == DT_REG && std::string(ent->d_name).find(".jocs") != std::string::npos)
-			files.push_back(std::string(ent->d_name));
+				files.push_back(std::string(ent->d_name));
 		}
 		closedir (dir);
 	} else {
 		/* could not open directory */
+		//TODO Do something intelligent here
 	}
 	j["files"] = files;
 	tansa::send_message(j);
-//	sio::message::ptr obj = sio::object_message::create();
-//	obj->get_map()["type"] = sio::string_message::create("status");
-//	obj->get_map()["time"] = sio::double_message::create(t.seconds());
-
-//	sio::message::list li(obj);
-//	tansa::send_message(li);
-
 }

@@ -114,14 +107,12 @@
 	if(type == "prepare") {
 		printf("Preparing...\n");
 		player->prepare();
-	}
-	else if(type == "play") {		printf("Playing...\n");
+	} else if(type == "play") {
+		printf("Playing...\n");
 		playMode = true;
-	}
-	else if(type == "land") {
+	} else if(type == "land") {
 		player->land();
-	}
-	else if (type == "pause") {
+	} else if (type == "pause") {
 		printf("Pausing...\n");
 		pauseMode = true;
 	} else if (type == "stop") {
@@ -130,18 +121,18 @@
 	} else if (type == "reset") {
 		printf("Resetting...\n");
 	} else if (type == "list"){
+		printf("Sending file list...\n");
 		send_file_list();
-	}
-	else if(type == "kill") {
+	} else if (type == "load"){
+		printf("Loading jocs file...\n")
+	} else if(type == "kill") {
 		bool enabled = data["enabled"];
 		printf("Killing...\n");
 		killmode = enabled;
-	}
-	else {
+	} else {
 		// TODO: Send an error message back to the browser
 		printf("Unexpected message type recieved!\n");
 	}
-
 }


Fallback to stat() if DT_DIR is not available

--- src/glob.cc
+++ src/glob.cc
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <dirent.h>
+#include <sys/stat.h>
 #include <errno.h>
 #include <unistd.h>

@@ -203,7 +204,19 @@
     while ((entry = readdir(dir))) {
         const char* name = entry->d_name;
         size_t nameLength = strlen(entry->d_name);
-        bool isDir = entry->d_type == DT_DIR;
+
+        bool isDir;
+
+        if (entry->d_type == DT_UNKNOWN) {
+            struct stat statbuf;
+            if (fstatat(dirfd(dir), entry->d_name, &statbuf, 0) == 0)
+                isDir = (statbuf.st_mode & S_IFMT) == S_IFDIR;
+            else
+                isDir = false;
+        }
+        else {
+            isDir = entry->d_type == DT_DIR;
+        }

         if (isHiddenDir(name, nameLength))
             continue;
@@ -239,7 +252,19 @@
     while ((entry = readdir(dir))) {
         const char* name = entry->d_name;
         size_t nameLength = strlen(entry->d_name);
-        bool isDir = entry->d_type == DT_DIR;
+
+        bool isDir;
+
+        if (entry->d_type == DT_UNKNOWN) {
+            struct stat statbuf;
+            if (fstatat(dirfd(dir), entry->d_name, &statbuf, 0) == 0)
+                isDir = (statbuf.st_mode & S_IFMT) == S_IFDIR;
+            else
+                isDir = false;
+        }
+        else {
+            isDir = entry->d_type == DT_DIR;
+        }

         if (isHiddenDir(name, nameLength))
             continue;


Delete useless files

Delete useless files

--- src/gui.hpp
+++ src/gui.hpp
@@ -1,4 +0,0 @@
-#ifndef GUI_HPP
-#define GUI_HPP
-
-#endif // GUI_HPP


Fix build error

Fix build error

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

--- src/heap.cc
+++ src/heap.cc
@@ -73,7 +73,7 @@
 int Heap::semispace_size_  = 512*KB;
 int Heap::old_generation_size_ = 128*MB;
 int Heap::initial_semispace_size_ = 128*KB;
-#elseif defined(V8_TARGET_ARCH_X64)
+#elif defined(V8_TARGET_ARCH_X64)
 int Heap::semispace_size_  = 8*MB;
 int Heap::old_generation_size_ = 1*GB;
 int Heap::initial_semispace_size_ = 1*MB;


added comments

added comments

--- src/hw0.cpp
+++ src/hw0.cpp
@@ -15,7 +15,7 @@
     tmp = strtok(x, " ");
     while(tmp != NULL){
         v.push_back(tmp);
-        //cout << "*" << tmp << "*" << endl;
+        //cout << tmp << endl;
         tmp = strtok(NULL, " ");
     }
 }
@@ -36,6 +36,19 @@
         k++;
     }
     return true;
+}
+
+string commentRemoval(string x){
+    int comm = x.find('#');
+    if(comm == -1){
+        return x;
+    }
+    else if(comm == 0){
+        return "";
+    }
+    else{
+        return x.substr(0, comm);
+    }
 }

 bool run(char str[]){
@@ -82,10 +95,9 @@
         //cout << "execvp executes" << endl;
             int pid = fork();
             if(pid == -1){
-                perror("fork");
                 exit(1);
             }
-            if(pid == 0){
+            else if(pid == 0){
                 parse(pch, cmd);
                 char* argc[cmd.size() + 1];
                  for(int i = 0 ; i < cmd.size(); i++ ){
@@ -129,6 +141,7 @@
        string input;
        cout << "$ ";
        getline(cin, input);
+       input = commentRemoval(input);
        char str[input.size()+1];
        strcpy(str, input.c_str());
        goon = run(str);


:construction: chore(chunk): updated the chunk disassemble

--- cplusplus/cnyx/chunk.cc
+++ cplusplus/cnyx/chunk.cc
@@ -50,25 +50,27 @@
 }

 int Chunk::disassemble_instruction(int i) {
-  static auto simple_instruction = [](const char* name) {
+  static auto simple_instruction = [](int i, const char* name) -> int {
     std::cout << name << std::endl;
+    return i;
   };

-  static auto simple_instructionN = [](const char* name, int n) {
+  static auto simple_instructionN = [](int i, const char* name, int n) -> int {
     std::cout << name << n << std::endl;
+    return i;
   };

   static auto code_instruction = [](Chunk& c, int i, const char* name) -> int {
-    u8_t slot = c.get_code(i++);
+    u8_t slot = c.get_code(i);
     fprintf(stdout, "%-16s %4d\n", name, slot);
-    return i;
+    return i + 1;
   };

   static auto const_instruction = [](Chunk& c, int i, const char* name) -> int {
     u8_t constant = c.get_code(i);
     fprintf(stdout, "%-16s %4d ", name, constant);
     std::cout << "`" << c.get_constant(constant) << "`" << std::endl;
-    return i;
+    return i + 1;
   };

   static auto const_instructionN = [](
@@ -77,15 +79,15 @@
     fprintf(stdout, "%s%-*d %4d ",
         name, 15 - static_cast<int>(strlen(name)), n, constant);
     std::cout << "`" << c.get_constant(constant) << "`" << std::endl;
-    return i;
+    return i + 1;
   };

   static auto jump_instruction = [](
       Chunk& c, int i, const char* name, int sign = 1) -> int {
-    u16_t offset = static_cast<u16_t>(c.get_code(i++) << 8);
-    offset |= c.get_code(i++);
+    u16_t offset = static_cast<u16_t>(c.get_code(i) << 8);
+    offset |= c.get_code(i + 1);
     fprintf(stdout, "%-16s %4d -> %d\n", name, offset, i + offset * sign);
-    return i;
+    return i + 2;
   };

   fprintf(stdout, "%04d ", i);
@@ -96,50 +98,36 @@

   const u8_t* codes = codes_.data();
   switch (auto instruction = codes[i++]; instruction) {
-  case OpCode::OP_CONSTANT:
-    i = const_instruction(*this, i, "OP_CONSTANT"); break;
-  case OpCode::OP_NIL: simple_instruction("OP_NIL"); break;
-  case OpCode::OP_TRUE: simple_instruction("OP_TRUE"); break;
-  case OpCode::OP_FALSE: simple_instruction("OP_FALSE"); break;
-  case OpCode::OP_POP: simple_instruction("OP_POP"); break;
-  case OpCode::OP_GET_LOCAL:
-    i = code_instruction(*this, i, "OP_GET_LOCAL"); break;
-  case OpCode::OP_SET_LOCAL:
-    i = code_instruction(*this, i, "OP_SET_LOCAL"); break;
-  case OpCode::OP_DEF_GLOBAL:
-    i = const_instruction(*this, i, "OP_DEF_GLOBAL"); break;
-  case OpCode::OP_GET_GLOBAL:
-    i = const_instruction(*this, i, "OP_GET_GLOBAL"); break;
-  case OpCode::OP_SET_GLOBAL:
-    i = const_instruction(*this, i, "OP_SET_GLOBAL"); break;
-  case OpCode::OP_GET_UPVALUE:
-    i = code_instruction(*this, i, "OP_GET_UPVALUE"); break;
-  case OpCode::OP_SET_UPVALUE:
-    i = code_instruction(*this, i, "OP_SET_UPVALUE"); break;
-  case OpCode::OP_GET_FIELD:
-    i = const_instruction(*this, i, "OP_GET_FIELD"); break;
-  case OpCode::OP_SET_FIELD:
-    i = const_instruction(*this, i, "OP_SET_FIELD"); break;
-  case OpCode::OP_GET_SUPER:
-    i = const_instruction(*this, i, "OP_GET_SUPER"); break;
-  case OpCode::OP_EQ: simple_instruction("OP_EQ"); break;
-  case OpCode::OP_NE: simple_instruction("OP_NE"); break;
-  case OpCode::OP_GT: simple_instruction("OP_GT"); break;
-  case OpCode::OP_GE: simple_instruction("OP_GE"); break;
-  case OpCode::OP_LT: simple_instruction("OP_LT"); break;
-  case OpCode::OP_LE: simple_instruction("OP_LE"); break;
-  case OpCode::OP_ADD: simple_instruction("OP_ADD"); break;
-  case OpCode::OP_SUB: simple_instruction("OP_SUB"); break;
-  case OpCode::OP_MUL: simple_instruction("OP_MUL"); break;
-  case OpCode::OP_DIV: simple_instruction("OP_DIV"); break;
-  case OpCode::OP_NOT: simple_instruction("OP_NOT"); break;
-  case OpCode::OP_NEG: simple_instruction("OP_NEG"); break;
-  case OpCode::OP_JUMP:
-    i = jump_instruction(*this, i, "OP_JUMP"); break;
-  case OpCode::OP_JUMP_IF_FALSE:
-    i = jump_instruction(*this, i, "OP_JUMP_IF_FALSE"); break;
-  case OpCode::OP_LOOP:
-    i = jump_instruction(*this, i, "OP_LOOP", -1); break;
+  case OpCode::OP_CONSTANT: return const_instruction(*this, i, "OP_CONSTANT");
+  case OpCode::OP_NIL: return simple_instruction(i, "OP_NIL");
+  case OpCode::OP_TRUE: return simple_instruction(i, "OP_TRUE");
+  case OpCode::OP_FALSE: return simple_instruction(i, "OP_FALSE");
+  case OpCode::OP_POP: return simple_instruction(i, "OP_POP");
+  case OpCode::OP_GET_LOCAL: return code_instruction(*this, i, "OP_GET_LOCAL");
+  case OpCode::OP_SET_LOCAL: return code_instruction(*this, i, "OP_SET_LOCAL");
+  case OpCode::OP_DEF_GLOBAL: return const_instruction(*this, i, "OP_DEF_GLOBAL");
+  case OpCode::OP_GET_GLOBAL: return const_instruction(*this, i, "OP_GET_GLOBAL");
+  case OpCode::OP_SET_GLOBAL: return const_instruction(*this, i, "OP_SET_GLOBAL");
+  case OpCode::OP_GET_UPVALUE: return code_instruction(*this, i, "OP_GET_UPVALUE");
+  case OpCode::OP_SET_UPVALUE: return code_instruction(*this, i, "OP_SET_UPVALUE");
+  case OpCode::OP_GET_FIELD: return const_instruction(*this, i, "OP_GET_FIELD");
+  case OpCode::OP_SET_FIELD: return const_instruction(*this, i, "OP_SET_FIELD");
+  case OpCode::OP_GET_SUPER: return const_instruction(*this, i, "OP_GET_SUPER");
+  case OpCode::OP_EQ: return simple_instruction(i, "OP_EQ");
+  case OpCode::OP_NE: return simple_instruction(i, "OP_NE");
+  case OpCode::OP_GT: return simple_instruction(i, "OP_GT");
+  case OpCode::OP_GE: return simple_instruction(i, "OP_GE");
+  case OpCode::OP_LT: return simple_instruction(i, "OP_LT");
+  case OpCode::OP_LE: return simple_instruction(i, "OP_LE");
+  case OpCode::OP_ADD: return simple_instruction(i, "OP_ADD");
+  case OpCode::OP_SUB: return simple_instruction(i, "OP_SUB");
+  case OpCode::OP_MUL: return simple_instruction(i, "OP_MUL");
+  case OpCode::OP_DIV: return simple_instruction(i, "OP_DIV");
+  case OpCode::OP_NOT: return simple_instruction(i, "OP_NOT");
+  case OpCode::OP_NEG: return simple_instruction(i, "OP_NEG");
+  case OpCode::OP_JUMP: return jump_instruction(*this, i, "OP_JUMP");
+  case OpCode::OP_JUMP_IF_FALSE: return jump_instruction(*this, i, "OP_JUMP_IF_FALSE");
+  case OpCode::OP_LOOP: return jump_instruction(*this, i, "OP_LOOP", -1);
   case OpCode::OP_CALL_0:
   case OpCode::OP_CALL_1:
   case OpCode::OP_CALL_2:
@@ -149,7 +137,7 @@
   case OpCode::OP_CALL_6:
   case OpCode::OP_CALL_7:
   case OpCode::OP_CALL_8:
-    simple_instructionN("OP_CALL_", instruction - OpCode::OP_CALL_0); break;
+    return simple_instructionN(i, "OP_CALL_", instruction - OpCode::OP_CALL_0);
   case OpCode::OP_INVOKE_0:
   case OpCode::OP_INVOKE_1:
   case OpCode::OP_INVOKE_2:
@@ -159,8 +147,7 @@
   case OpCode::OP_INVOKE_6:
   case OpCode::OP_INVOKE_7:
   case OpCode::OP_INVOKE_8:
-    i = const_instructionN(*this, i, "OP_INVOKE_", instruction - OpCode::OP_INVOKE_0);
-    break;
+    return const_instructionN(*this, i, "OP_INVOKE_", instruction - OpCode::OP_INVOKE_0);
   case OpCode::OP_SUPER_0:
   case OpCode::OP_SUPER_1:
   case OpCode::OP_SUPER_2:
@@ -170,8 +157,7 @@
   case OpCode::OP_SUPER_6:
   case OpCode::OP_SUPER_7:
   case OpCode::OP_SUPER_8:
-    i = const_instructionN(*this, i, "OP_SUPER_", instruction - OpCode::OP_SUPER_0);
-    break;
+    return const_instructionN(*this, i, "OP_SUPER_", instruction - OpCode::OP_SUPER_0);
   case OpCode::OP_CLOSURE:
     {
       u8_t constant = codes[i++];
@@ -187,16 +173,13 @@
             i - 2, is_local ? "local" : "upvalue", index);
       }
     } break;
-  case OpCode::OP_CLOSE_UPVALUE: simple_instruction("OP_CLOSE_UPVALUE"); break;
-  case OpCode::OP_RETURN: simple_instruction("OP_RETURN"); break;
-  case OpCode::OP_CLASS:
-    i = const_instruction(*this, i, "OP_CLASS"); break;
-  case OpCode::OP_SUBCLASS:
-    i = const_instruction(*this, i, "OP_SUBCLASS"); break;
-  case OpCode::OP_METHOD:
-    i = const_instruction(*this, i, "OP_METHOD"); break;
+  case OpCode::OP_CLOSE_UPVALUE: return simple_instruction(i, "OP_CLOSE_UPVALUE");
+  case OpCode::OP_RETURN: return simple_instruction(i, "OP_RETURN");
+  case OpCode::OP_CLASS: return const_instruction(*this, i, "OP_CLASS");
+  case OpCode::OP_SUBCLASS: return const_instruction(*this, i, "OP_SUBCLASS");
+  case OpCode::OP_METHOD: return const_instruction(*this, i, "OP_METHOD");
   }
-  return i;
+  return 0;
 }

 }


fix some bugs in decode kernel (not fully tested yet)

--- cpp/assembled_chunk.cpp
+++ cpp/assembled_chunk.cpp
@@ -109,6 +109,7 @@
 #endif

+#if 1
 inline void _unpack(__m256i &out0, __m256i &out1, __m256i &out2, __m256i &out3, __m256i x)
 {
     // FIXME is there a better way to initialize this?
@@ -127,10 +128,10 @@
     y2 = _mm256_srli_epi32(y2, 16);
     y3 = _mm256_srli_epi32(y3, 24);

-    out0 = _mm256_permute2f128_ps(y0, y1, 0x20);
-    out1 = _mm256_permute2f128_ps(y2, y3, 0x20);
-    out2 = _mm256_permute2f128_ps(y0, y1, 0x31);
-    out3 = _mm256_permute2f128_ps(y2, y3, 0x31);
+    out0 = _mm256_permute2f128_si256(y0, y1, 0x20);
+    out1 = _mm256_permute2f128_si256(y2, y3, 0x20);
+    out2 = _mm256_permute2f128_si256(y0, y1, 0x31);
+    out3 = _mm256_permute2f128_si256(y2, y3, 0x31);
 }

@@ -149,7 +150,7 @@
     _mm256_storeu_ps(wtp, w);
     _mm256_storeu_ps(wtp+8, w);
     _mm256_storeu_ps(wtp+16, w);
-    _mm256_storeu_ps(wtp+25, w);
+    _mm256_storeu_ps(wtp+24, w);
 }

@@ -222,11 +223,11 @@
 	    float *int_f = intensity + if_fine * stride;
 	    float *wt_f = weights + if_fine * stride;

-	    for (int it_coarse = 0; it_coarse < nt_coarse; it_coarse++)
-		_kernel(int_f, wt_f, src_f, scales_f, offsets_f);
+	    _kernel(int_f, wt_f, src_f, scales_f, offsets_f);
 	}
     }
 }
+#endif

 }  // namespace ch_frb_io


Set m_size at initialization time, and schedule a view update. Should fix render sizing issues at startup.

--- src/horde3dwindow.cpp
+++ src/horde3dwindow.cpp
@@ -256,6 +256,9 @@
 	printHordeMessages();
 	qDebug() << "--------- Initialization Finished ---------";

+	m_size = size() * screen()->devicePixelRatio();
+	m_dirtyView = true;
+
 	m_initialized = true;
 	emit initFinished();
 } // end init


feature #3028: Fix PCI device assignment

--- src/host/HostShare.cc
+++ src/host/HostShare.cc
@@ -76,10 +76,10 @@
     {
         PCIDevice * dev = it->second;

-        if (dev->class_id  == class_id  &&
-            dev->vendor_id == vendor_id &&
-            dev->device_id == device_id &&
-            dev->vmid      == -1 &&
+        if ((class_id  == 0 || dev->class_id  == class_id)  &&
+		    (vendor_id == 0 || dev->vendor_id == vendor_id) &&
+            (device_id == 0 || dev->device_id == device_id) &&
+            dev->vmid  == -1 &&
             assigned.find(dev->address) == assigned.end())
         {
             assigned.insert(dev->address);


cleaned up comments in isCollisionFree_mex

--- systems/onlinePlanning/isCollisionFree_mex.cpp
+++ systems/onlinePlanning/isCollisionFree_mex.cpp
@@ -22,10 +22,6 @@
 #include <math.h>
 #include <matrix.h>

-// Timer functions
-// #include <chrono>
-// #include <ctime>
-// #include <time.h>

 // Internal access to bullet
 #include "LinearMath/btTransform.h"
@@ -96,144 +92,105 @@
     for(int i=0;i<nRows;i++){
         for(int j=0;j<nCols;j++){
             vertsT[j*nRows+i] = dcSk[i]*(verts[j*nRows+0]-dx0[k*nRows+0]-dx[0]) + dcSk[nRows+i]*(verts[j*nRows+1]-dx0[k*nRows+1]-dx[1]) + dcSk[2*nRows+i]*(verts[j*nRows+2]-dx0[k*nRows+2]-dx[2]);
-            // mexPrintf("i: %d, j: %d, val: %f\n", i, j, vertsT[j*nRows+i]);
         }
     }
-

     return vertsT;

 }
-
-

 /* Checks if a given funnel number funnelIdx is collision free if executed beginning at state x. Returns a boolean (true if collision free, false if not).
 */
 bool isCollisionFree(int funnelIdx, const mxArray *x, const mxArray *funnelLibrary, const mxArray *forest, mwSize numObs, double *min_dist)
 {

-// Initialize some variables
-double *verts; // cell element (i.e. vertices)
-mxArray *x0 = mxGetField(funnelLibrary, funnelIdx, "xyz"); // all points on trajectory
-mxArray *obstacle;
-mxArray *cS = mxGetField(funnelLibrary, funnelIdx, "cS");
-mxArray *cSk;
-size_t nCols;
-size_t nRows;
-double distance;
-
-// Get number of time samples
-mwSize N = mxGetNumberOfElements(mxGetField(funnelLibrary, funnelIdx, "cS"));
-
-// Initialize collFree to true
-bool collFree = true;
-
-
-// For each time sample, we need to check if we are collision free
-// mxArray *collisions = mxCreateLogicalMatrix(numObs,N);
-
-for(int k=0;k<N;k++)
-{
-
-    // Get pointer to cholesky factorization of S at this time
-    cSk = mxGetCell(cS,k);
-
-    for(mwIndex jForest=0;jForest<numObs;jForest++)
-    {
-
-    // Get vertices of this obstacle
-    obstacle = mxGetCell(forest, jForest);
-    verts = mxGetPr(mxGetCell(forest, jForest)); // Get vertices
-    nCols = mxGetN(obstacle);
-    nRows = mxGetM(obstacle);
-
-    double *vertsT = mxGetPr(mxCreateDoubleMatrix(nRows, nCols, mxREAL));
-
-    // Shift vertices so that point on trajectory is at origin and transform by cholesky of S
-    vertsT = shiftAndTransform(verts, vertsT, x, x0, k, cSk, nRows, nCols);
-
-    // Call bullet to do point to polytope distance computation
-    distance = ptToPolyBullet(vertsT, nRows, nCols);
-
-    // Update min_dist
-    if(distance < *min_dist){
-        *min_dist = distance;
-    }
-
-    // mexPrintf("distance: %f\n", distance);
-
-    // Check if distance is less than 1 (i.e. not collision free). If so, return
-     //if(distance < 1){
-       //collFree = false;
-      // return collFree;
-    //}
-
-    }
-}
-
-if(*min_dist < 1){
-    collFree = false;
-}
-
-return collFree;
-
+    // Initialize some variables
+    double *verts; // cell element (i.e. vertices)
+    mxArray *x0 = mxGetField(funnelLibrary, funnelIdx, "xyz"); // all points on trajectory
+    mxArray *obstacle;
+    mxArray *cS = mxGetField(funnelLibrary, funnelIdx, "cS");
+    mxArray *cSk;
+    size_t nCols;
+    size_t nRows;
+    double distance;
+
+    // Get number of time samples
+    mwSize N = mxGetNumberOfElements(mxGetField(funnelLibrary, funnelIdx, "cS"));
+
+    // Initialize collFree to true
+    bool collFree = true;
+
+    // For each time sample, we need to check if we are collision free
+    for(int k=0;k<N;k++)
+    {
+        // Get pointer to cholesky factorization of S at this time
+        cSk = mxGetCell(cS,k);
+        for(mwIndex jForest=0;jForest<numObs;jForest++)
+        {
+            // Get vertices of this obstacle
+            obstacle = mxGetCell(forest, jForest);
+            verts = mxGetPr(mxGetCell(forest, jForest)); // Get vertices
+            nCols = mxGetN(obstacle);
+            nRows = mxGetM(obstacle);
+
+            double *vertsT = mxGetPr(mxCreateDoubleMatrix(nRows, nCols, mxREAL));
+
+            // Shift vertices so that point on trajectory is at origin and transform by cholesky of S
+            vertsT = shiftAndTransform(verts, vertsT, x, x0, k, cSk, nRows, nCols);
+
+            // Call bullet to do point to polytope distance computation
+            distance = ptToPolyBullet(vertsT, nRows, nCols);
+
+            // Update min_dist
+            if(distance < *min_dist){
+                *min_dist = distance;
+            }
+        }
+    }
+
+    if(*min_dist < 1){
+        collFree = false;
+    }
+
+    return collFree;
 }

 /* Main mex funtion*/
 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 {

-// Get x (state) from which funnel is to be executed
-const mxArray *x;
-x = prhs[0];
-// x = mxGetPr(prhs[0]);
-
-
-// Deal with forest cell (second input)
-const mxArray *forest; // Cell array containing forest (pointer)
-
-forest = prhs[1]; // Get forest cell (second input)
-mwSize numObs = mxGetNumberOfElements(forest); // Number of obstacles
-
-
-// Now deal with funnel library object (third input)
-const mxArray *funnelLibrary; // Funnel library (pointer)
-
-funnelLibrary = prhs[2]; // Get funnel library (third input)
-
-// Get funnelIdx (subtract 1 since index is coming from matlab)
-int funnelIdx;
-funnelIdx = (int )mxGetScalar(prhs[3]);
-funnelIdx = funnelIdx-1;
-
-// Initialize min_dist
-// double min_dist_init = 1000000.0;
-double min_dist = 1000000.0;
-/*// Return min_dist if asked for
-if (nlhs > 1){
-        plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL);
-        min_dist = mxGetPr(plhs[1]);
-}*/
-// &min_dist = &min_dist_init;
-
-// mexPrintf("min_dist: %f", min_dist);
-
-
-// Initialize next funnel (output of this function)
-bool collFree = isCollisionFree(funnelIdx, x, funnelLibrary, forest, numObs, &min_dist);
-
-
-// Return collFree
-plhs[0] = mxCreateLogicalScalar(collFree);
-
-// mexPrintf("min_dist: %f", min_dist);
-
-// Return min_dist if asked for
-if (nlhs > 1){
+    // Get x (state) from which funnel is to be executed
+    const mxArray *x;
+    x = prhs[0];
+
+    // Deal with forest cell (second input)
+    const mxArray *forest; // Cell array containing forest (pointer)
+
+    forest = prhs[1]; // Get forest cell (second input)
+    mwSize numObs = mxGetNumberOfElements(forest); // Number of obstacles
+
+    // Now deal with funnel library object (third input)
+    const mxArray *funnelLibrary; // Funnel library (pointer)
+
+    funnelLibrary = prhs[2]; // Get funnel library (third input)
+
+    // Get funnelIdx (subtract 1 since index is coming from matlab)
+    int funnelIdx;
+    funnelIdx = (int )mxGetScalar(prhs[3]);
+    funnelIdx = funnelIdx-1;
+
+    // Initialize min_dist
+    double min_dist = 1000000.0;
+
+    // Initialize next funnel (output of this function)
+    bool collFree = isCollisionFree(funnelIdx, x, funnelLibrary, forest, numObs, &min_dist);
+
+    plhs[0] = mxCreateLogicalScalar(collFree);
+
+    // Return min_dist if asked for
+    if (nlhs > 1) {
         plhs[1] = mxCreateDoubleScalar(min_dist);
-}
-
-
+    }

 return;
 }


don't propagate enter/leave events coming from pointer grabs to TCanvas.

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

--- gui/src/TRootCanvas.cxx
+++ gui/src/TRootCanvas.cxx
@@ -1,4 +1,4 @@
-// @(#)root/gui:$Name:  $:$Id: TRootCanvas.cxx,v 1.2 2000/09/08 07:41:00 brun Exp $
+// @(#)root/gui:$Name:  $:$Id: TRootCanvas.cxx,v 1.3 2000/10/04 23:40:07 rdm Exp $
 // Author: Fons Rademakers   15/01/98

 /*************************************************************************
@@ -955,7 +955,9 @@
    Int_t x = event->fX;
    Int_t y = event->fY;

-   if (event->fType == kLeaveNotify)
+   // pointer grabs create also an enter and leave event but with fCode
+   // either kNotifyGrab or kNotifyUngrab, don't propagate these events
+   if (event->fType == kLeaveNotify && event->fCode == kNotifyNormal)
       fCanvas->HandleInput(kMouseLeave, x, y);

    return kTRUE;


FIX: cpplint

FIX: cpplint

--- cvmfs/catalog_sql.cc
+++ cvmfs/catalog_sql.cc
@@ -1134,7 +1134,8 @@
       "FROM chunks, catalog WHERE "
       "chunks.md5path_1=catalog.md5path_1 AND "
       "chunks.md5path_2=catalog.md5path_2 AND "
-      "(catalog.flags & " + StringifyInt(SqlDirent::kFlagFileExternal) + " = 0)";
+      "(catalog.flags & " + StringifyInt(SqlDirent::kFlagFileExternal) +
+      " = 0)";
   }
   sql += ";";
   Init(database.sqlite_db(), sql);


Modify SelectParticlesBy function, remove unnecessary header

--- src/lhef.cc
+++ src/lhef.cc
@@ -1,7 +1,6 @@
+#include "lhef.h"
 #include <algorithm>
 #include <functional>
-#include <utility>
-#include "lhef.h"

 namespace lhef {
 Particles SelectParticlesBy(std::function<bool(const Particle&)> pred,
@@ -9,8 +8,8 @@
     Particles ps;
     auto entry = lhe.particle_entries();
     std::for_each(entry.cbegin(), entry.cend(),
-                  [&] (const std::pair<int, Particle>& pmap) {
-                      Particle p = pmap.second;
+                  [&] (const EventEntry::value_type& pmap) {
+                      auto p = pmap.second;
                       if (pred(p)) {
                           ps.push_back(p);
                       }});
@@ -49,7 +48,7 @@
     ParticleLines line;
     auto entry = lhe.particle_entries();
     for (const auto& e : entry) {
-        Particle p = e.second;
+        auto p = e.second;
         if (ParticleExists(pid, p)) {
             line.push_back(e.first);
         }


Separate the GPU/CPU fused_batch_norm

Separate the GPU/CPU fused_batch_norm

--- tensorflow/core/kernels/fused_batch_norm_op.cc
+++ tensorflow/core/kernels/fused_batch_norm_op.cc
@@ -19,8 +19,9 @@
 #define EIGEN_USE_GPU
 #include "cuda/include/cudnn.h"
 #include "tensorflow/core/kernels/conv_2d.h"
+#include "tensorflow/core/platform/stream_executor.h"
 #include "tensorflow/core/util/stream_executor_util.h"
-#endif
+#endif // GOOGLE_CUDA

 #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
 #include "tensorflow/core/framework/op_kernel.h"
@@ -29,15 +30,16 @@
 #include "tensorflow/core/framework/tensor_types.h"
 #include "tensorflow/core/kernels/fill_functor.h"
 #include "tensorflow/core/kernels/fused_batch_norm_op.h"
-#include "tensorflow/core/platform/stream_executor.h"
 #include "tensorflow/core/util/tensor_format.h"

 namespace tensorflow {
 using CPUDevice = Eigen::ThreadPoolDevice;
 using GPUDevice = Eigen::GpuDevice;
+
+namespace functor {
+
+#if GOOGLE_CUDA
 using se::Stream;
-
-namespace functor {
 using se::DeviceMemory;
 using se::ScratchAllocator;
 using se::port::StatusOr;
@@ -174,6 +176,7 @@
   int output_index_;
   bool output_allocated = false;
 };
+#endif // GOOGLE_CUDA

 template <typename T, typename U>
 struct FusedBatchNorm<CPUDevice, T, U> {
@@ -184,8 +187,8 @@
                   Tensor* y_output, Tensor* batch_mean_output,
                   Tensor* batch_var_output, Tensor* saved_mean_output,
                   Tensor* saved_var_output, TensorFormat tensor_format,
-                  ScratchAllocator* reserve_space_allocator,
-                  ScratchAllocator* workspace_allocator, bool is_training) {
+                  void* reserve_space_allocator,
+                  void* workspace_allocator, bool is_training) {
     OP_REQUIRES(context, tensor_format == FORMAT_NHWC,
                 errors::Internal("The CPU implementation of FusedBatchNorm "
                                  "only supports NHWC tensor format for now."));
@@ -271,8 +274,8 @@
                   const Tensor& mean_input, const Tensor& variance_input,
                   U epsilon, Tensor* x_backprop_output,
                   Tensor* scale_backprop_output, Tensor* offset_backprop_output,
-                  const Tensor* reserve_space,
-                  ScratchAllocator* workspace_allocator,
+                  const void* reserve_space,
+                  void* workspace_allocator,
                   TensorFormat tensor_format) {
     OP_REQUIRES(context, tensor_format == FORMAT_NHWC,
                 errors::Internal("The CPU implementation of FusedBatchNormGrad "
@@ -361,8 +364,8 @@
                   const Tensor& estimated_variance, U epsilon, Tensor* y,
                   Tensor* batch_mean, Tensor* batch_var, Tensor* saved_mean,
                   Tensor* saved_inv_var, TensorFormat tensor_format,
-                  ScratchAllocator* reserve_space_allocator,
-                  ScratchAllocator* workspace_allocator, bool is_training) {
+                  void* reserve_space_allocator,
+                  void* workspace_allocator, bool is_training) {
     auto* stream = context->op_device_context()->stream();
     OP_REQUIRES(context, stream, errors::Internal("No GPU stream available"));

@@ -483,8 +486,9 @@
                   static_cast<double>(epsilon), &y_ptr, &batch_mean_ptr,
                   &batch_var_ptr, &saved_mean_ptr, &saved_inv_var_ptr,
                   is_training, std::move(var_to_inv_var),
-                  std::move(inv_var_to_var), reserve_space_allocator,
-                  workspace_allocator)
+                  std::move(inv_var_to_var),
+                  (ScratchAllocator*)reserve_space_allocator,
+                  (ScratchAllocator*)workspace_allocator)
               .ok();

     if (!cudnn_launch_status) {
@@ -507,8 +511,8 @@
                   const Tensor& x, const Tensor& scale, const Tensor& mean,
                   const Tensor& inv_variance, U epsilon, Tensor* x_backprop,
                   Tensor* scale_backprop, Tensor* offset_backprop,
-                  const Tensor* reserve_space,
-                  ScratchAllocator* workspace_allocator,
+                  const void* reserve_space_ptr,
+                  void* workspace_allocator,
                   TensorFormat tensor_format) {
     auto* stream = context->op_device_context()->stream();
     OP_REQUIRES(context, stream, errors::Internal("No GPU stream available"));
@@ -605,6 +609,7 @@
     // the cudnn kernel outputs inverse variance in forward and reuse it in
     // backward
     DeviceMemory<uint8>* reserve_space_data = nullptr;
+    const Tensor* reserve_space = (const Tensor*)reserve_space_ptr;
     if (reserve_space != nullptr && reserve_space->dims() != 0) {
       auto reserve_space_uint8 = functor::CastDeviceMemory<uint8, U>(
           const_cast<Tensor*>(reserve_space));
@@ -616,7 +621,7 @@
                   y_backprop_ptr, x_ptr, scale_ptr, mean_ptr, inv_variance_ptr,
                   x_desc, scale_offset_desc, static_cast<double>(epsilon),
                   &x_backprop_ptr, &scale_backprop_ptr, &offset_backprop_ptr,
-                  reserve_space_data, workspace_allocator)
+                  reserve_space_data, (ScratchAllocator*)workspace_allocator)
               .ok();

     if (!cudnn_launch_status) {
@@ -719,6 +724,7 @@
     OP_REQUIRES_OK(context, context->allocate_output(4, scale.shape(),
                                                      &saved_maybe_inv_var));

+#if GOOGLE_CUDA
     if (!use_reserved_space) {
       functor::FusedBatchNorm<Device, T, U>()(
           context, x, scale, offset, estimated_mean, estimated_variance,
@@ -732,9 +738,15 @@
       functor::FusedBatchNorm<Device, T, U>()(
           context, x, scale, offset, estimated_mean, estimated_variance,
           epsilon_, y, batch_mean, batch_var, saved_mean, saved_maybe_inv_var,
-          tensor_format_, &reserve_space_allocator, &workspace_allocator,
-          is_training_);
-    }
+          tensor_format_, (void**)&reserve_space_allocator,
+          (void**)&workspace_allocator, is_training_);
+    }
+#else
+    functor::FusedBatchNorm<Device, T, U>()(
+        context, x, scale, offset, estimated_mean, estimated_variance,
+        epsilon_, y, batch_mean, batch_var, saved_mean, saved_maybe_inv_var,
+        tensor_format_, nullptr, nullptr, is_training_);
+#endif // GOOGLE_CUDA
   }

  private:
@@ -846,26 +858,31 @@
       return;
     }

-    const Tensor* reserve_space_data = nullptr;
-    functor::CudnnBatchNormAllocatorInTemp<uint8>* workspace_allocator_ptr
-        = nullptr;
-
+    if (is_training_) {
+#if GOOGLE_CUDA
+      const Tensor* reserve_space_data = nullptr;
+      functor::CudnnBatchNormAllocatorInTemp<uint8>* workspace_allocator_ptr
+          = nullptr;
 #if CUDNN_VERSION >= 7402
-    if (use_reserved_space) {
-      const Tensor& reserve_space = context->input(5);
-      reserve_space_data = &reserve_space;
-      functor::CudnnBatchNormAllocatorInTemp<uint8> workspace_allocator(
-          context);
-      workspace_allocator_ptr = &workspace_allocator;
-    }
+      if (use_reserved_space) {
+        const Tensor& reserve_space = context->input(5);
+        reserve_space_data = &reserve_space;
+        functor::CudnnBatchNormAllocatorInTemp<uint8> workspace_allocator(
+            context);
+        workspace_allocator_ptr = &workspace_allocator;
+      }
 #endif // CUDNN_VERSION >= 7402
-
-    if (is_training_) {
       functor::FusedBatchNormGrad<Device, T, U>()(
           context, y_backprop, x, scale, saved_mean_or_pop_mean,
           saved_maybe_inv_var_or_pop_var, epsilon_, x_backprop, scale_backprop,
-          offset_backprop, reserve_space_data, workspace_allocator_ptr,
-          tensor_format_);
+          offset_backprop, (void*)reserve_space_data,
+          (void*)workspace_allocator_ptr, tensor_format_);
+#else
+      functor::FusedBatchNormGrad<Device, T, U>()(
+          context, y_backprop, x, scale, saved_mean_or_pop_mean,
+          saved_maybe_inv_var_or_pop_var, epsilon_, x_backprop, scale_backprop,
+          offset_backprop, nullptr, nullptr, tensor_format_);
+#endif // GOOGLE_CUDA
     } else {
       // Necessary layout conversion is currently done in python.
       CHECK(tensor_format_ == FORMAT_NHWC)


simplified operator << (no change in semantics)

--- ctoolhu/typesafe/id.hpp
+++ ctoolhu/typesafe/id.hpp
@@ -47,8 +47,7 @@

 			friend std::ostream &operator <<(std::ostream &out, const self_type &storage)
 			{
-				out << storage._id;
-				return out;
+				return out << storage._id;
 			}

 		  protected:


+ let user decide to use equality constraint or independent radii

--- src/Mod/Sketcher/Gui/CommandConstraints.cpp
+++ src/Mod/Sketcher/Gui/CommandConstraints.cpp
@@ -1479,14 +1479,46 @@
             QObject::tr("Select one or more arcs or circles from the sketch."));
     }
     else {
-        // Create the radius constraints now
-        openCommand("Add radius constraint");
-        for (std::vector< std::pair<int, double> >::iterator it = geoIdRadiusMap.begin(); it != geoIdRadiusMap.end(); ++it) {
+        bool constrainEqual = false;
+        if (geoIdRadiusMap.size() > 1) {
+            int ret = QMessageBox::question(Gui::getMainWindow(), QObject::tr("Constrain equal"),
+                QObject::tr("Do you want to share the same radius for all selected elements?"),
+                QMessageBox::Yes, QMessageBox::No);
+            // use an equality constraint
+            if (ret == QMessageBox::Yes) {
+                constrainEqual = true;
+            }
+        }
+
+        if (constrainEqual) {
+            // Create the one radius constraint now
+            int refGeoId = geoIdRadiusMap.front().first;
+            double radius = geoIdRadiusMap.front().second;
+            openCommand("Add radius constraint");
             Gui::Command::doCommand(
                 Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Radius',%d,%f)) ",
-                selection[0].getFeatName(),it->first,it->second);
-        }
-        commitCommand();
+                selection[0].getFeatName(),refGeoId,radius);
+            commitCommand();
+
+            // Add the equality constraints
+            openCommand("Add equality constraint");
+            for (std::vector< std::pair<int, double> >::iterator it = geoIdRadiusMap.begin()+1; it != geoIdRadiusMap.end(); ++it) {
+                Gui::Command::doCommand(
+                    Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Equal',%d,%d)) ",
+                    selection[0].getFeatName(),refGeoId,it->first);
+            }
+            commitCommand();
+        }
+        else {
+            // Create the radius constraints now
+            openCommand("Add radius constraint");
+            for (std::vector< std::pair<int, double> >::iterator it = geoIdRadiusMap.begin(); it != geoIdRadiusMap.end(); ++it) {
+                Gui::Command::doCommand(
+                    Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Radius',%d,%f)) ",
+                    selection[0].getFeatName(),it->first,it->second);
+            }
+            commitCommand();
+        }

         const std::vector<Sketcher::Constraint *> &ConStr = Obj->Constraints.getValues();
         std::size_t indexConstr = ConStr.size() - geoIdRadiusMap.size();
@@ -1527,10 +1559,17 @@

                 try {
                     openCommand("Modify radius constraint");
-                    for (std::size_t i=0; i<geoIdRadiusMap.size();i++) {
+                    if (constrainEqual) {
                         doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setDatum(%i,App.Units.Quantity('%f %s'))",
                                     Obj->getNameInDocument(),
-                                    indexConstr+i, newRadius, (const char*)newQuant.getUnit().getString().toUtf8());
+                                    indexConstr, newRadius, (const char*)newQuant.getUnit().getString().toUtf8());
+                    }
+                    else {
+                        for (std::size_t i=0; i<geoIdRadiusMap.size();i++) {
+                            doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setDatum(%i,App.Units.Quantity('%f %s'))",
+                                        Obj->getNameInDocument(),
+                                        indexConstr+i, newRadius, (const char*)newQuant.getUnit().getString().toUtf8());
+                        }
                     }
                     commitCommand();
                     updateActive();


IO/File: Add exists constructor method

IO/File: Add exists constructor method

--- src/io/file_class.cpp
+++ src/io/file_class.cpp
@@ -1,6 +1,6 @@
 // vim:ts=2:sw=2:expandtab:autoindent:filetype=cpp:
 /*
-Copyright (c) 2008 Aristid Breitkreuz, Ruediger Sonderfeld
+Copyright (c) 2008 Aristid Breitkreuz, Ruediger Sonderfeld, Ash Berlin

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -29,6 +29,7 @@
 #include "flusspferd/string_io.hpp"
 #include "flusspferd/create.hpp"
 #include <boost/scoped_array.hpp>
+#include <boost/filesystem.hpp>
 #include <fstream>
 #include <iostream>
 #include <sys/types.h>
@@ -43,6 +44,7 @@
   std::fstream stream;

   static void create(char const *name, boost::optional<int> mode);
+  static bool exists(char const *name);
 };

 file_class::file_class(object const &obj, call_context &x)
@@ -63,6 +65,7 @@

 void file_class::class_info::augment_constructor(object constructor) {
   create_native_function(constructor, "create", &impl::create);
+  create_native_function(constructor, "exists", &impl::exists);
 }

 object file_class::class_info::create_prototype() {
@@ -72,6 +75,7 @@

   create_native_method(proto, "open", 1);
   create_native_method(proto, "close", 0);
+  create_native_method(proto, "exists", 0);

   return proto;
 }
@@ -84,12 +88,17 @@

   p->stream.open(name);

+  define_property("fileName", string(name),
+                  permanent_property | read_only_property );
+
   if (!p->stream)
+    // TODO: Include some sort of system error message here
     throw exception("Could not open file");
 }

 void file_class::close() {
   p->stream.close();
+  delete_property("fileName");
 }

 void file_class::impl::create(char const *name, boost::optional<int> mode) {
@@ -101,3 +110,8 @@
   if (creat(name, mode.get_value_or(0666)) < 0)
     throw exception("Could not create file");
 }
+
+bool file_class::impl::exists(char const *name) {
+  return boost::filesystem::exists(name);
+}
+


Part: [skip ci] move grid handling from ViewProvider2DObject to ViewProvider2DObjectGrid

--- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
+++ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
@@ -1487,7 +1487,7 @@
     if (isEditing())
         return false;
     else
-        return PartGui::ViewProvider2DObject::isSelectable();
+        return PartGui::ViewProvider2DObjectGrid::isSelectable();
 }

 void ViewProviderSketch::onSelectionChanged(const Gui::SelectionChanges& msg)
@@ -5567,7 +5567,7 @@

 void ViewProviderSketch::updateData(const App::Property *prop)
 {
-    ViewProvider2DObject::updateData(prop);
+    ViewProvider2DObjectGrid::updateData(prop);

     // In the case of an undo/redo transaction, updateData is triggered by SketchObject::onUndoRedoFinished() in the solve()
     // In the case of an internal transaction, touching the geometry results in a call to updateData.
@@ -5603,7 +5603,7 @@
 void ViewProviderSketch::onChanged(const App::Property *prop)
 {
     // call father
-    PartGui::ViewProvider2DObject::onChanged(prop);
+    PartGui::ViewProvider2DObjectGrid::onChanged(prop);
 }

 void ViewProviderSketch::attach(App::DocumentObject *pcFeat)
@@ -5720,7 +5720,7 @@

     TightGrid.setValue(false);

-    ViewProvider2DObject::setEdit(ModNum); // notify to handle grid according to edit mode property
+    ViewProvider2DObjectGrid::setEdit(ModNum); // notify to handle grid according to edit mode property

     float transparency;

@@ -6157,7 +6157,7 @@
         e.ReportException();
     }

-    ViewProvider2DObject::unsetEdit(ModNum); // notify grid that edit mode is being left
+    ViewProvider2DObjectGrid::unsetEdit(ModNum); // notify grid that edit mode is being left
 }

 void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int ModNum)


tidy and rename some objects

tidy and rename some objects

--- prolog.cpp
+++ prolog.cpp
@@ -111,7 +111,7 @@

 struct parser_state {
     set<string> names; // global name table
-    map<string const*, type_variable*> variables;
+    map<string const*, type_variable*> variables;
     set<type_variable*> repeated;
     set<type_variable*> repeated_in_goal;

@@ -132,10 +132,8 @@
 //----------------------------------------------------------------------------
 // Grammar

-class return_variable {
-public:
+struct return_variable {
     return_variable() {}
-
     void operator() (type_variable** res, string const& name, parser_state* st) const {
         name_t const n = st->get_name(name);
         var_t i = st->variables.find(&(*n));
@@ -172,20 +170,20 @@
     }
 } const return_struct;

-struct return_goal {
-    return_goal() {}
+struct return_head {
+    return_head() {}
     void operator() (type_struct** res, type_struct* str, parser_state* st) const {
         *res = str;
         st->repeated_in_goal = st->repeated;
     }
-} const return_goal;
-
-struct return_impl {
-    return_impl() {}
+} const return_head;
+
+struct return_goal {
+    return_goal() {}
     void operator() (vector<type_struct*>* res, type_struct* impl, parser_state*) const {
         res->push_back(impl);
     }
-} const return_impl;
+} const return_goal;

 struct return_clause {
     return_clause() {}
@@ -197,8 +195,8 @@
     }
 } const return_clause;

-struct return_clause2 {
-    return_clause2() {}
+struct return_goals {
+    return_goals() {}
     void operator() (vector<clause*>* res, vector<type_struct*>& impl, parser_state* st) const {
         vector<type_expression*> vars;
         for (auto v : st->variables) {
@@ -212,7 +210,7 @@
         st->repeated.clear();
         st->repeated_in_goal.clear();
     }
-} const return_clause2;
+} const return_goals;

 //----------------------------------------------------------------------------
 // Parser
@@ -237,9 +235,9 @@

 pstream_handle<type_struct*, parser_state> const goal = structure(reference("structure", goal));

-auto const clause = all(return_clause, all(return_goal, goal),
-    option(discard(impl_tok) && sep_by(all(return_impl, goal), discard(sep_tok))) && discard(end_tok))
-    || discard(impl_tok) && all(return_clause2, sep_by(all(return_impl, goal), discard(sep_tok)) && discard(end_tok))
+auto const clause = all(return_clause, all(return_head, goal),
+    option(discard(impl_tok) && sep_by(all(return_goal, goal), discard(sep_tok))) && discard(end_tok))
+    || discard(impl_tok) && all(return_goals, sep_by(all(return_goal, goal), discard(sep_tok)) && discard(end_tok))
     || discard(comment_tok);

 struct expression_parser;


ensure consistent initialization

ensure consistent initialization

--- src/job/FRViewJob.cpp
+++ src/job/FRViewJob.cpp
@@ -80,7 +80,7 @@
       m_renderlist_initialized( false ),
       m_renderlist_update_revision( true ),
       m_has_pipeline( false ),
-      m_show_wells( false )
+      m_show_wells( m_renderconfig.renderWells() )
 {

     // Triggers release of all sources.


fix scientific number parsing

fix scientific number parsing

--- 3rdParty/velocypack/src/Parser.cpp
+++ 3rdParty/velocypack/src/Parser.cpp
@@ -116,7 +116,7 @@
     scanDigits(numberValue);
   }
   i = consume();
-  if (i < 0 || i != '.') {
+  if (i < 0 || (i != '.' && i != 'e' && i != 'E')) {
     if (i >= 0) {
       unconsume();
     }
@@ -144,22 +144,34 @@
     }
     return;
   }
-  i = getOneOrThrow("Incomplete number");
-  if (i < '0' || i > '9') {
-    throw Exception(Exception::ParseError, "Incomplete number");
-  }
-  unconsume();
-  double fractionalPart = scanDigitsFractional();
-  if (negative) {
-    fractionalPart = - numberValue.asDouble() - fractionalPart;
+  double fractionalPart;
+  if (i == '.') {
+    // fraction. skip over '.'
+    i = getOneOrThrow("Incomplete number");
+    if (i < '0' || i > '9') {
+      throw Exception(Exception::ParseError, "Incomplete number");
+    }
+    unconsume();
+    fractionalPart = scanDigitsFractional();
+    if (negative) {
+      fractionalPart = - numberValue.asDouble() - fractionalPart;
+    }
+    else {
+      fractionalPart = numberValue.asDouble() + fractionalPart;
+    }
+    i = consume();
+    if (i < 0) {
+      _b.addDouble(fractionalPart);
+      return;
+    }
   }
   else {
-    fractionalPart = numberValue.asDouble() + fractionalPart;
-  }
-  i = consume();
-  if (i < 0) {
-    _b.addDouble(fractionalPart);
-    return;
+    if (negative) {
+      fractionalPart = - numberValue.asDouble();
+    }
+    else {
+      fractionalPart = numberValue.asDouble();
+    }
   }
   if (i != 'e' && i != 'E') {
     unconsume();


Shhhh, linter

Shhhh, linter

--- src/log.cpp
+++ src/log.cpp
@@ -167,17 +167,17 @@

 string Logger::to_file(const char *filename)
 {
-  return replace_logger(new FileLogger(filename));
+  return replace_logger(new FileLogger(filename)); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
 }

 string Logger::to_stderr()
 {
-  return replace_logger(new StderrLogger());
+  return replace_logger(new StderrLogger()); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
 }

 string Logger::to_stdout()
 {
-  return replace_logger(new StdoutLogger());
+  return replace_logger(new StdoutLogger()); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
 }

 string Logger::disable()


getNewTargets: Add some consts for clarity.

Signed-off-by: Patrick Vacek <a38520cbbe2e974bc8b7ea86877dd3c7115ca2d7@gmail.com>

--- src/libaktualizr/primary/sotauptaneclient.cc
+++ src/libaktualizr/primary/sotauptaneclient.cc
@@ -452,22 +452,22 @@
 }

 void SotaUptaneClient::getNewTargets(std::vector<Uptane::Target> *new_targets, unsigned int *ecus_count) {
-  std::vector<Uptane::Target> targets = director_repo.getTargets().targets;
-  Uptane::EcuSerial primary_ecu_serial = primaryEcuSerial();
+  const std::vector<Uptane::Target> targets = director_repo.getTargets().targets;
+  const Uptane::EcuSerial primary_ecu_serial = primaryEcuSerial();
   if (ecus_count != nullptr) {
     *ecus_count = 0;
   }
   for (const Uptane::Target &target : targets) {
     bool is_new = false;
     for (const auto &ecu : target.ecus()) {
-      Uptane::EcuSerial ecu_serial = ecu.first;
-      Uptane::HardwareIdentifier hw_id = ecu.second;
+      const Uptane::EcuSerial ecu_serial = ecu.first;
+      const Uptane::HardwareIdentifier hw_id = ecu.second;

       // 5.4.4.6.8. If checking Targets metadata from the Director repository,
       // and the ECU performing the verification is the Primary ECU, check that
       // all listed ECU identifiers correspond to ECUs that are actually present
       // in the vehicle.
-      auto hw_id_known = ecuHwId(ecu_serial);
+      const auto hw_id_known = ecuHwId(ecu_serial);
       if (!hw_id_known) {
         LOG_ERROR << "Unknown ECU ID in Director Targets metadata: " << ecu_serial.ToString();
         throw Uptane::BadEcuId(target.filename());


Support vpiObjTypeVal for vec4Stack values.

Also allow vpi_get_value outside of scope. (Return 'x)

--- vvp/vpi_vthr_vector.cc
+++ vvp/vpi_vthr_vector.cc
@@ -348,8 +348,10 @@

 void __vpiVThrVec4Stack::vpi_get_value(p_vpi_value vp)
 {
-      assert(vpip_current_vthread);
-      vvp_vector4_t val = vthread_get_vec4_stack(vpip_current_vthread, depth_);
+      vvp_vector4_t val;
+
+      if (vpip_current_vthread)
+	    val = vthread_get_vec4_stack(vpip_current_vthread, depth_);

       switch (vp->format) {

@@ -371,6 +373,8 @@
 	  case vpiStringVal:
 	    vpi_get_value_string_(vp, val);
 	    break;
+	  case vpiObjTypeVal:
+	    vp->format = vpiVectorVal;
 	  case vpiVectorVal:
 	    vpi_get_value_vector_(vp, val);
 	    break;


Refactor

Refactor

--- src/Modules/Python/PythonInterfaceParser.cc
+++ src/Modules/Python/PythonInterfaceParser.cc
@@ -108,7 +108,9 @@
 PythonCode PythonInterfaceParser::extractSpecialBlocks(const std::string& code) const
 {
   PythonCode blocks;
-  static boost::regex matlabBlock("(.*)%%\\n(.*)\\n%%(.*)");
+  static std::string matlabBlockRegex = std::string("(.*)") + PythonCodeBlock::delimiter
+    + "\\n(.*)\\n" + PythonCodeBlock::delimiter + "(.*)";
+  static boost::regex matlabBlock(matlabBlockRegex);

   boost::smatch what;
   if (regex_match(code, what, matlabBlock))
@@ -138,7 +140,7 @@
 {
   if (!part.empty())
   {
-    if (part.find("%%") != std::string::npos)
+    if (part.find(PythonCodeBlock::delimiter) != std::string::npos)
     {
       auto rec = extractSpecialBlocks(part);
       blocks.insert(blocks.begin(), rec.begin(), rec.end());


hello

hello

--- src/main.cc
+++ src/main.cc
@@ -1,6 +1,7 @@
 #include <iostream>
 #include <string>
 #include <unistd.h>
+using namespace std;

 int main(){
   char HOSTNAME[128];
@@ -12,6 +13,8 @@
     cout << getlogin() << "@" << HOSTNAME << "$ ";
     getline(cin, input);

-    cout << input << endl;
+    if (input == "exit"){
+		REPEAT = false;
+	}
   }
 }


Support the vim behaviour for +line syntax

* Ommitting the linenumber will move to buffer end

--- src/main.cc
+++ src/main.cc
@@ -819,6 +819,11 @@
         {
             if (not name.empty() and name[0_byte] == '+')
             {
+                if (name == "+" or name  == "+:")
+                {
+                    init_cmds = init_cmds + "; exec gj";
+                    continue;
+                }
                 auto colon = find(name, ':');
                 if (auto line = str_to_int_ifp({name.begin()+1, colon}))
                 {


add commandline support

add commandline support

--- src/main.cc
+++ src/main.cc
@@ -1,6 +1,6 @@
 /*
  * $File: main.cc
- * $Date: Tue Dec 10 16:43:56 2013 +0800
+ * $Date: Tue Dec 10 18:20:51 2013 +0800
  * $Author: Xinyu Zhou <zxytim[at]gmail[dot]com>
  */

@@ -19,16 +19,6 @@

 typedef std::vector<std::vector<real_t>> DenseDataset;

-static void svm2vec(const std::vector<std::pair<int, real_t>> &input,
-		std::vector<real_t> &output, int dim) {
-	output = std::vector<real_t>(dim, 0);
-	for (auto &item: input) {
-		if (item.first > dim) // ignore out bounded values
-			continue;
-		output[item.first] = item.second;
-	}
-}
-
 vector<real_t> string_to_double_vector(string line) {
 	vector<real_t> x;
 	int begin = 0, end = 0;
@@ -45,23 +35,14 @@
 	return x;
 }

-void Dataset2DenseDataset(Dataset &X0, DenseDataset &X1) {
-	int n, m;
-	get_data_metric(X0, n, m);
-
-	X1.resize(X0.size());
-	for (size_t i = 0; i < X0.size(); i ++)
-		svm2vec(X0[i], X1[i], m);
-}
-
-
-
 struct Args {
 	int concurrency;
 	int K;
+	int iteration;
+	real_t min_covar = 1e-3;

 	string input_file;
-	string output_file;
+	string model_file;
 };

 Args parse_args(int argc, char *argv[]) {
@@ -71,22 +52,30 @@

 		ValueArg<int> arg_concurrency("w", "concurrency", "number of workers", false, 1, "NUMBER");
 		ValueArg<int> arg_K("k", "K", "number of gaussians", true, 10, "NUMBER");
+		ValueArg<double> arg_min_covar("c", "mincovar", "minimum covariance to avoid overfitting, default 1e-3.", false, 1e-3, "FLOAT");

 		ValueArg<string> arg_input_file("i", "input", "intput file", true, "", "FILE");
-		ValueArg<string> arg_output_file("o", "output", "intput file", true, "", "FILE");
+		ValueArg<string> arg_model_file("m", "model", "model file", true, "", "FILE");
+		ValueArg<int> arg_iteration("r", "iteration", "number of iterations",
+				false, 200, "NUMBER");

 		cmd.add(arg_concurrency);
 		cmd.add(arg_K);
+		cmd.add(arg_min_covar);
 		cmd.add(arg_input_file);
-		cmd.add(arg_output_file);
+		cmd.add(arg_model_file);
+		cmd.add(arg_iteration);
+

 		cmd.parse(argc, argv);

 #define GET_VALUE(name) args.name = arg_##name.getValue();
 		GET_VALUE(concurrency);
 		GET_VALUE(K);
+		GET_VALUE(min_covar);
 		GET_VALUE(input_file);
-		GET_VALUE(output_file);
+		GET_VALUE(model_file);
+		GET_VALUE(iteration);

 	} catch (ArgException &e) {
 		cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
@@ -111,67 +100,19 @@
 	}
 }

-void fill_gaussian(DenseDataset &X, Gaussian *gaussian, int nr_point) {
-	for (int i = 0; i < nr_point; i ++)
-		X.push_back(gaussian->sample());
-}
-
-static vector<real_t> random_vector(int dim, real_t range, Random &random) {
-	vector<real_t> vec(dim);
-	for (auto &v: vec) v = random.rand_real() * range;
-	return vec;
-}
-
-void gen_high_dim_gaussian_mixture(DenseDataset &X, int dim, int nr_gaussian, int nr_point_per_gaussian) {
-	Random random;
-	for (int i = 0; i < nr_gaussian; i ++) {
-		Gaussian g(dim);
-		g.mean = random_vector(dim, 1, random);
-		g.sigma = random_vector(dim, 0.05 + random.rand_real() * 0.1, random);
-		fill_gaussian(X, &g, nr_point_per_gaussian);
-	}
-}
-
-void gen_gaussian_mixture(DenseDataset &X, int nr_point_per_gaussian = 1000) {
-	int nr_gaussian = 3;
-	Gaussian g0(2);
-	g0.mean = {0, 0};
-	g0.sigma = {0.1, 0.1};
-
-	Gaussian g1(2);
-	g1.mean = {1, 1};
-	g1.sigma = {0.1, 0.1};
-
-	Gaussian g2(2);
-	g2.mean = {2, 1};
-	g2.sigma = {0.2, 0.2};
-
-	fill_gaussian(X, &g0, nr_point_per_gaussian);
-	fill_gaussian(X, &g1, nr_point_per_gaussian);
-	fill_gaussian(X, &g2, nr_point_per_gaussian);
-}
-
 int main(int argc, char *argv[]) {
-	srand(42); // Answer to The Ultimate Question of Life, the Universe, and Everything
-//    Args args = parse_args(argc, argv);
+//    srand(42); // Answer to The Ultimate Question of Life, the Universe, and Everything
+	Args args = parse_args(argc, argv);

 	DenseDataset X;
-//    read_dense_dataset(X, "test.data");
-	gen_gaussian_mixture(X, 100);
-//    gen_high_dim_gaussian_mixture(X, 13, 10, 68000);
+	read_dense_dataset(X, args.input_file.c_str());

-	write_dense_dataset(X, "test.data");
-
-
-	int concurrency = 4;
-	int nr_mixture = 3;
-
-	GMMTrainerBaseline trainer(1, 1e-3, concurrency);
-	GMM gmm(nr_mixture, COVTYPE_DIAGONAL, &trainer);
+	GMMTrainerBaseline trainer(args.iteration, args.min_covar, args.concurrency);
+	GMM gmm(args.K, COVTYPE_DIAGONAL, &trainer);
 	printf("start training ...\n"); fflush(stdout);
 	gmm.fit(X);

-	ofstream fout("gmm-test.model");
+	ofstream fout(args.model_file);
 	gmm.dump(fout);

 	return 0;


Fix double z3 solver check call

Fix double z3 solver check call

--- src/libtriton/engines/solver/z3/z3Solver.cpp
+++ src/libtriton/engines/solver/z3/z3Solver.cpp
@@ -86,8 +86,7 @@
           this->writeBackStatus(solver, res, status);

           /* Check if it is sat */
-          for (; res == z3::sat && limit >= 1; res = solver.check()) {
-
+          while (res == z3::sat && limit >= 1) {
             /* Get model */
             z3::model m = solver.get_model();

@@ -123,18 +122,22 @@
               /* Uniq result */
               if (exp.get_sort().is_bv())
                 args.push_back(ctx.bv_const(varName.c_str(), bvSize) != ctx.bv_val(svalue.c_str(), bvSize));
-
             }

-            /* Escape last models */
-            solver.add(triton::engines::solver::mk_or(args));
-
-            /* If there is model available */
-            if (smodel.size() > 0)
-              ret.push_back(smodel);
-
-            /* Decrement the limit */
-            limit--;
+            /* Check that model is available */
+            if (smodel.empty())
+              break;
+
+            /* Push model */
+            ret.push_back(smodel);
+
+            if (--limit) {
+              /* Escape last models */
+              solver.add(triton::engines::solver::mk_or(args));
+
+              /* Get next model */
+              res = solver.check();
+            }
           }
         }
         catch (const z3::exception& e) {


Fixed Model "Mesh" loader not using mesh parameters

Former-commit-id: 5fd20c30c3d9afa2651ddd17ca74dabf025ec826

--- src/Nazara/Graphics/Loaders/Mesh/Loader.cpp
+++ src/Nazara/Graphics/Loaders/Mesh/Loader.cpp
@@ -25,7 +25,7 @@

 		std::unique_ptr<NzMesh> mesh(new NzMesh);
 		mesh->SetPersistent(false);
-		if (!mesh->LoadFromStream(stream))
+		if (!mesh->LoadFromStream(stream, parameters.mesh))
 		{
 			NazaraError("Failed to load model mesh");
 			return false;


Little-endian hex encoding.

Little-endian hex encoding.

--- src/main.cc
+++ src/main.cc
@@ -94,7 +94,7 @@

 std::string BinaryToHexString(const unsigned char *bin_data, size_t size) {
   std::stringstream ss_hex;
-  for (unsigned int i = 0; i < size; ++i) {
+  for (unsigned int i = size - 1; i > 0; --i) {
     ss_hex << std::hex << std::setw(2) << std::setfill('0')
            << static_cast<int>(bin_data[i]);
   }


Datadistrib volume would return 0 to indicate success which is wrong

--- ospray/volume/DataDistributedBlockedVolume.cpp
+++ ospray/volume/DataDistributedBlockedVolume.cpp
@@ -172,7 +172,7 @@
     MPI_CALL(Reduce(&voxelRange.y, &globalVoxelRange.y, 1, MPI_FLOAT, MPI_MAX, 0, mpi::worker.comm));
     set("voxelRange", globalVoxelRange);
 #endif
-    return 0;
+    return true;
   }

   void DataDistributedBlockedVolume::createEquivalentISPC()
@@ -275,7 +275,7 @@
               volume->findParam("scaleFactor",1)->set(scaleFactor);
             }

-            printf("rank %li owns block %i,%i,%i (ID %i), dims %i %i %i\n",
+            printf("worker rank %li owns block %i,%i,%i (ID %i), dims %i %i %i\n",
                    (size_t)core::getWorkerRank(),ix,iy,iz,
                    blockID,blockDims.x,blockDims.y,blockDims.z);
             block->cppVolume = volume;


Make produced ship more variable

Make produced ship more variable

--- Source/HeliumRain/Game/AI/FlareCompanyAI.cpp
+++ Source/HeliumRain/Game/AI/FlareCompanyAI.cpp
@@ -16,10 +16,13 @@
 #define STATION_CONSTRUCTION_PRICE_BONUS 1.2

 // TODO, make it depend on company's nature
-#define AI_CARGO_DIVERSITY_THRESHOLD 10
-#define AI_CARGO_SIZE_DIVERSITY_THRESHOLD 15
-#define AI_MILITARY_DIVERSITY_THRESHOLD 4
-#define AI_MILITARY_SIZE_DIVERSITY_THRESHOLD 15
+#define AI_CARGO_DIVERSITY_THRESHOLD 1
+#define AI_CARGO_SIZE_DIVERSITY_THRESHOLD 5
+#define AI_CARGO_SIZE_DIVERSITY_THRESHOLD_BASE 15
+
+#define AI_MILITARY_DIVERSITY_THRESHOLD 1
+#define AI_MILITARY_SIZE_DIVERSITY_THRESHOLD 5
+#define AI_MILITARY_SIZE_DIVERSITY_THRESHOLD_BASE 5

 // TODO, make it depend on company's nature
 #define AI_CARGO_PEACE_MILILTARY_THRESHOLD 10
@@ -2584,8 +2587,9 @@
 	// Choose which size to pick
 	int32 Diversity = (Military ? AI_MILITARY_DIVERSITY_THRESHOLD : AI_CARGO_DIVERSITY_THRESHOLD);
 	int32 SizeDiversity = (Military ? AI_MILITARY_SIZE_DIVERSITY_THRESHOLD : AI_CARGO_SIZE_DIVERSITY_THRESHOLD);
+	int32 SizeDiversityBase = (Military ? AI_MILITARY_SIZE_DIVERSITY_THRESHOLD_BASE : AI_CARGO_SIZE_DIVERSITY_THRESHOLD_BASE);
 	bool PickLShip = true;
-	if ((ShipLCount+1) * SizeDiversity > ShipSCount)
+	if (SizeDiversityBase + (ShipLCount) * SizeDiversity > ShipSCount)
 	{
 		PickLShip = false;
 	}
@@ -2673,11 +2677,11 @@
 		bool BestBigger = (Military ? BestShipDescription->Mass > Description-> Mass : BestShipDescription->GetCapacity() > Description->GetCapacity());

 		bool Select = false;
-		if (BestBigger && BestCount * Diversity > CandidateCount)
+		if (BestBigger && BestCount + Diversity > CandidateCount)
 		{
 			Select = true;
 		}
-		else if (!BestBigger && CandidateCount * Diversity < BestCount)
+		else if (!BestBigger && CandidateCount + Diversity < BestCount)
 		{
 			Select = true;
 		}


Print the result path.

Print the result path.

--- src/main.cc
+++ src/main.cc
@@ -7,6 +7,19 @@
 #include <fstream>
 #include <stdexcept>
 #include <cassert>
+
+char ActionToChar(Action a) {
+    switch (a) {
+        case Action::MOVE_LEFT: return 'E';
+        case Action::MOVE_UP: return 'C';
+        case Action::MOVE_RIGHT: return 'D';
+        case Action::MOVE_DOWN: return 'B';
+        case Action::PICK_GOLD: return 'P';
+        default: break;
+    }
+    throw input_error("Converting Action with no textual representation.");
+    return '\0';
+}

 Strategy ConvertToStrategy(const std::string& identifier) {
     if(identifier.size() == 1) {
@@ -91,7 +104,9 @@
     auto result = env.Run();

     printf("%d pontos\n", env.data().CalculateScore(*result));
-
+    for (Action a : result->CreateActionList())
+        printf("%c ", ActionToChar(a));
+    puts("");
     return 0;

 } catch(const input_error& err) {


bug: Fix SELinux events rebase (#4684)

bug: Fix SELinux events rebase (#4684)

--- osquery/tables/events/linux/selinux_events.cpp
+++ osquery/tables/events/linux/selinux_events.cpp
@@ -12,6 +12,7 @@

 #include <osquery/flags.h>
 #include <osquery/logger.h>
+#include <osquery/registry_factory.h>

 #include "osquery/core/conversions.h"
 #include "osquery/events/linux/auditeventpublisher.h"


Make code more understandable

Make code more understandable

--- Source/HeliumRain/Game/FlareSectorHelper.cpp
+++ Source/HeliumRain/Game/FlareSectorHelper.cpp
@@ -452,7 +452,7 @@
 				float CurrentRefillRatio = FMath::Min(MAX_REFILL_RATIO_BY_DAY * (Spacecraft->GetSize() == EFlarePartSize::L ? 0.2f : 1.f) , (1.f - FillRatio));
 				float TotalRefillRatio = 1.f - FillRatio;

-				int64 Duration =  FMath::CeilToInt(TotalRefillRatio / MAX_REFILL_RATIO_BY_DAY * (Spacecraft->GetSize() == EFlarePartSize::L ? 0.2f : 1.f));
+				int64 Duration =  FMath::CeilToInt(TotalRefillRatio / (MAX_REFILL_RATIO_BY_DAY * (Spacecraft->GetSize() == EFlarePartSize::L ? 0.2f : 1.f)));
 				if(Duration > MaxDuration)
 				{
 					MaxDuration = Duration;


Fix potential missed redraws

Fix potential missed redraws

--- src/main.cc
+++ src/main.cc
@@ -681,13 +681,16 @@
         {
             client_manager.redraw_clients();

-            // Loop a
+            // Loop so that eventual inputs happening during the processing are handled as
+            // well, avoiding unneeded redraws.
             bool allow_blocking = not client_manager.has_pending_inputs();
             while (event_manager.handle_next_events(EventMode::Normal, nullptr, allow_blocking))
             {
                 client_manager.process_pending_inputs();
                 allow_blocking = false;
             }
+            client_manager.process_pending_inputs();
+
             client_manager.clear_client_trash();
             client_manager.clear_window_trash();
             buffer_manager.clear_buffer_trash();


Include weekends on the kernel_panics table (#5298)

Summary:
The set accidentally missed Saturday and Sunday days of the week. This just adds them in.

Fixes #5297.
Pull Request resolved: https://github.com/facebook/osquery/pull/5298

Reviewed By: guliashvili

Differential Revision: D13690812

Pulled By: fmanco

fbshipit-source-id: 1859d32ad635d63548435fed8e9da131530be5ce

--- osquery/tables/system/darwin/kernel_panics.cpp
+++ osquery/tables/system/darwin/kernel_panics.cpp
@@ -38,7 +38,8 @@
 };

 /// List of the days of the Week, used to grab our timestamp.
-const std::set<std::string> kDays = {"Mon", "Tue", "Wed", "Thu", "Fri"};
+const std::set<std::string> kDays = {
+    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

 /// Map of the values we currently parse out of the log file
 const std::map<std::string, std::string> kKernelPanicKeys = {


Don't try to use QCoreApplication::arguments before an app is created

--- src/main.cc
+++ src/main.cc
@@ -145,11 +145,19 @@

     // Set our own OpenGL buglist
     qputenv("QT_OPENGL_BUGLIST", ":/opengl/resources/opengl/buglist.json");
-    if (QCoreApplication::arguments().contains(QStringLiteral("-angle"))) {
-        QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
-    } else if (QCoreApplication::arguments().contains(QStringLiteral("-swrast"))) {
-        QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
-    }
+
+    // Allow for command line override of renderer
+    for (int i = 0; i < argc; i++) {
+        const QString arg(argv[i]);
+        if (arg == QStringLiteral("-angle")) {
+            QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
+            break;
+        } else if (arg == QStringLiteral("-swrast")) {
+            QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
+            break;
+        }
+    }
+
 #endif

     // The following calls to qRegisterMetaType are done to silence debug output which warns


update classes and ids

update classes and ids

--- src/main.cc
+++ src/main.cc
@@ -193,7 +193,7 @@
         }

         {
-            scene::Group meridians{"meridians", "meridians_container", {}};
+            scene::Group meridians{"grid", "meridians", {}};
             for (double x(0); x < 360.1; x += 15.)
             {
                 std::vector<ln_equ_posn> path;
@@ -215,7 +215,7 @@
         }

         {
-            scene::Group parallels{"parallels", "parallels_container", {}};
+            scene::Group parallels{"grid", "parallels", {}};
             for (double y(-60); y < 60.1; y += 10.)
             {
                 std::vector<ln_equ_posn> path;
@@ -249,7 +249,7 @@
             }
             drawer.draw(path, 0.2);

-            scene::Group ecliptic{"ecliptic", "ecliptic_container", {}};
+            scene::Group ecliptic{"grid", "ecliptic", {}};
             auto bezier{create_bezier_from_path(projection, path)};
             for (auto const b : bezier)
             {
@@ -270,7 +270,7 @@
             }
             drawer.draw(path, 0.3);

-            scene::Group horizon{"horizon", "horizon_container", {}};
+            scene::Group horizon{"grid", "horizon", {}};
             auto bezier{create_bezier_from_path(projection, path)};
             for (auto const b : bezier)
             {


correct -v

correct -v

--- src/main.cc
+++ src/main.cc
@@ -153,8 +153,8 @@
 	};

 	int ch, longIndex;
-	while ((ch = getopt_long(argc, argv, "Vh", longOpts, &longIndex)) != -1) {
-		if (ch=='V') {
+	while ((ch = getopt_long(argc, argv, "vh", longOpts, &longIndex)) != -1) {
+		if (ch=='v') {
 			showVersion();
 			exit(0);
 		} else if (ch=='h') {


Do not support general commands in filter mode

--- src/main.cc
+++ src/main.cc
@@ -714,20 +714,17 @@
     return local_client_exit;
 }

-int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView> files, bool quiet, StringView suffix_backup)
+int run_filter(StringView keystr, ConstArrayView<StringView> files, bool quiet, StringView suffix_backup)
 {
     StringRegistry  string_registry;
     GlobalScope     global_scope;
     EventManager    event_manager;
     ShellManager    shell_manager{builtin_env_vars};
-    CommandManager  command_manager;
     RegisterManager register_manager;
-    ClientManager   client_manager;
     BufferManager   buffer_manager;

     register_options();
     register_registers();
-    register_commands();

     try
     {
@@ -741,10 +738,6 @@
                     { buffer, Selection{{0,0}, buffer.back_coord()} },
                     Context::Flags::Transient
                 };
-
-                if (not commands.empty())
-                    command_manager.execute(commands, input_handler.context(),
-                                            ShellContext{});

                 for (auto& key : keys)
                     input_handler.handle_key(key);
@@ -942,8 +935,7 @@
             for (size_t i = 0; i < parser.positional_count(); ++i)
                 files.emplace_back(parser[i]);

-            return run_filter(*keys, client_init, files,
-                              (bool)parser.get_switch("q"),
+            return run_filter(*keys, files, (bool)parser.get_switch("q"),
                               parser.get_switch("i").value_or(StringView{}));
         }


retrieveFrameWithGlobalObjectCheck should check contextHasCorrectPrototype()

retrieveFrameWithGlobalObjectCheck crashes in the following scenario:

(1) V8WindowShell calls createContext().
(2) createContext() calls v8::Context::New().
(3) Inside v8::Context::New(), v8::internal::Debugger::ProcessDebugEvent is triggered and retrieveFrameWithGlobalObjectCheck is called.
(4) Because the context holder hasn't yet created, retrieveFrameWithGlobalObjectCheck crashes when calling worldTypeInMainThread().

To address the issue, this CL makes retrieveFrameWithGlobalObjectCheck return immediately when the context does not have a correct shape. We can do the check by calling contextHasCorrectPrototype().

BUG=345014

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

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@167509 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/bindings/v8/PageScriptDebugServer.cpp
+++ Source/bindings/v8/PageScriptDebugServer.cpp
@@ -57,11 +57,10 @@
         return 0;

     // Test that context has associated global dom window object.
-    v8::Handle<v8::Object> global = context->Global();
-    if (global.IsEmpty())
-        return 0;
-
-    global = global->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
+    if (!V8WindowShell::contextHasCorrectPrototype(context))
+        return 0;
+
+    v8::Handle<v8::Value> global = context->Global()->FindInstanceInPrototypeChain(V8Window::domTemplate(context->GetIsolate(), worldTypeInMainThread(context->GetIsolate())));
     if (global.IsEmpty())
         return 0;


update

update


Call toWebCoreAtomicString() in V8Window::namedSecurityCheckCustom()

Call toWebCoreAtomicString() in V8Window::namedSecurityCheckCustom() instead
of toWebCoreString(). This avoids uselessly creating a String and then
convert it to an AtomicString since FrameTree::scopedChild() takes an
AtomicString in argument.

R=haraken
BUG=323739

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

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@162731 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/bindings/v8/custom/V8WindowCustom.cpp
+++ Source/bindings/v8/custom/V8WindowCustom.cpp
@@ -475,9 +475,9 @@
         target->loader().didAccessInitialDocument();

     if (key->IsString()) {
-        DEFINE_STATIC_LOCAL(AtomicString, nameOfProtoProperty, ("__proto__", AtomicString::ConstructFromLiteral));
-
-        String name = toWebCoreString(key.As<v8::String>());
+        DEFINE_STATIC_LOCAL(const AtomicString, nameOfProtoProperty, ("__proto__", AtomicString::ConstructFromLiteral));
+
+        AtomicString name = toWebCoreAtomicString(key.As<v8::String>());
         Frame* childFrame = target->tree().scopedChild(name);
         // Notice that we can't call HasRealNamedProperty for ACCESS_HAS
         // because that would generate infinite recursion.


Add figcaption case at 'computeAccessibilityIsIgnored()'
to keep figcation infomation on accessibility tree.

BUG=None

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

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@181681 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/core/accessibility/AXRenderObject.cpp
+++ Source/core/accessibility/AXRenderObject.cpp
@@ -677,6 +677,9 @@
     if (roleValue() == DialogRole)
         return false;

+    if (roleValue() == FigcaptionRole)
+        return false;
+
     if (roleValue() == FigureRole)
         return false;


Avoid a DCHECK.  Check if the interface is already patched before patching.

TEST=This avoids a DCHECK that could happen when viewing the source of an html page.
BUG=none
TBR=robertshield

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

git-svn-id: http://src.chromium.org/svn/trunk/src@37044 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 9e0e878099af1a55243ea2fec84ff203a3dcee7f

--- chrome_frame/bho.cc
+++ chrome_frame/bho.cc
@@ -370,8 +370,10 @@

 void PatchHelper::PatchBrowserService(IBrowserService* browser_service) {
   DCHECK(state_ == PATCH_IBROWSER);
-  vtable_patch::PatchInterfaceMethods(browser_service,
-                                      IBrowserService_PatchInfo);
+  if (!IS_PATCHED(IBrowserService)) {
+    vtable_patch::PatchInterfaceMethods(browser_service,
+                                        IBrowserService_PatchInfo);
+  }
 }

 void PatchHelper::UnpatchIfNeeded() {


Add more Windows-specific fonts to fallback path

MS Shell Dlg is the aliased font name that means "the one font that
shall always be available" per http://msdn.microsoft.com/en-us/library/windows/desktop/dd374112(v=vs.85).aspx
DirectWrite doesn't like that name, but we add the two fonts that it
can map to so that we can be very certain to succeed on retreiving a
font, even if Arial has gone missing.

R=eae@chromium.org
BUG=383542

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

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@178380 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/platform/fonts/skia/FontCacheSkia.cpp
+++ Source/platform/fonts/skia/FontCacheSkia.cpp
@@ -148,6 +148,17 @@
         DEFINE_STATIC_LOCAL(const FontFaceCreationParams, arialCreationParams, (AtomicString("Arial", AtomicString::ConstructFromLiteral)));
         fontPlatformData = getFontPlatformData(description, arialCreationParams);
     }
+#if OS(WIN)
+    // Try some more Windows-specific fallbacks.
+    if (!fontPlatformData) {
+        DEFINE_STATIC_LOCAL(const FontFaceCreationParams, msuigothicCreationParams, (AtomicString("MS UI Gothic", AtomicString::ConstructFromLiteral)));
+        fontPlatformData = getFontPlatformData(description, msuigothicCreationParams);
+    }
+    if (!fontPlatformData) {
+        DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationParams, (AtomicString("Microsoft Sans Serif", AtomicString::ConstructFromLiteral)));
+        fontPlatformData = getFontPlatformData(description, mssansserifCreationParams);
+    }
+#endif

     ASSERT(fontPlatformData);
     return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);


kernel: Disable plugin construction on MacOS

--- src/kernel/kernel.cpp
+++ src/kernel/kernel.cpp
@@ -130,9 +130,11 @@
   // Seed rand with 32 bits from RNG
   srand(rng_extract_uint32());

+#ifndef __MACH__
   // Custom initialization functions
   MYINFO("Initializing plugins");
   kernel::run_ctors(&__plugin_ctors_start, &__plugin_ctors_end);
+#endif

   // Run plugins
   PROFILE("Plugins init");


allow build with icu 4.2

allow build with icu 4.2

Change-Id: I4bbcff7963520426d4c04e15d2239431aff65b56

--- i18npool/source/collator/collator_unicode.cxx
+++ i18npool/source/collator/collator_unicode.cxx
@@ -333,6 +333,10 @@
             if (func && funclen) {
                 const sal_uInt8* ruleImage=func();
                 size_t ruleImageSize = funclen();
+
+#if (U_ICU_VERSION_MAJOR_NUM == 4) && (U_ICU_VERSION_MINOR_NUM <= 2)
+                uca_base = new RuleBasedCollator(static_cast<UChar*>(NULL), status);
+#else
                 // Not only changed ICU 53.1 the API behavior that a negative
                 // length (ruleImageSize) now leads to failure, but also that
                 // the base RuleBasedCollator passed as uca_base here needs to
@@ -344,6 +348,7 @@
                 // NULL (default) locale does not.
                 uca_base = static_cast<RuleBasedCollator*>(icu::Collator::createInstance(
                             icu::Locale::getRoot(), status));
+#endif
                 if (! U_SUCCESS(status)) throw RuntimeException();
                 collator = new RuleBasedCollator(
                         reinterpret_cast<const uint8_t*>(ruleImage), ruleImageSize, uca_base, status);


remove a const declaration in one constructor

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@11571 27541ba8-7e3a-0410-8455-c3a389f83636


Remove export behavior - no longer needed - leads to major speedup

--- brawlls.cpp
+++ brawlls.cpp
@@ -214,11 +214,6 @@
 			if (isinst<MDL0GroupNode^>(node) || isinst<BRESGroupNode^>(node)) {
 				// concat children data and use that instead
 				md5 = "Children:" + MD5::MD5Str(node->Children);
-			} else if (isinst<BRESEntryNode^>(node)) {
-				String^ tmp = Path::GetTempFileName();
-				node->Export(tmp);
-				md5 = "MD5(Ex):" + MD5::MD5Str(tmp);
-				File::Delete(tmp);
 			} else {
 				md5 = "MD5:" + MD5::MD5Str(node);
 			}


Delete 1.cpp

Delete 1.cpp

--- src/leveldb/doc/1.cpp
+++ src/leveldb/doc/1.cpp
@@ -1 +0,0 @@
-


adding resolutions for video

adding resolutions for video

--- fractal/sierpinski.cpp
+++ fractal/sierpinski.cpp
@@ -177,7 +177,8 @@
         bg_clr = black;
     }

-    double text_size = 40;
+    double text_size = 100;
+    double ball_size = (level*2);
     std::vector<vec> square_pts = {{0,0},{0,1},{1,1},{1,0}};
     std::vector<vec> square_midpts = {0.5*(square_pts[0]+square_pts[1]),
                                       0.5*(square_pts[1]+square_pts[2]),
@@ -255,8 +256,6 @@

     int draw_frame = 120;

-    double ball_size = level;
-
     // This is creating all the children
     for(int i = 0; i < ((pow(4,level)-1)/3)-1; i++){
         if (i == diff){
@@ -265,7 +264,10 @@
             diff += pow(4,tmp_level);
             draw_frame += 60;
             if (ball_size > 1){
-                ball_size -= 1;
+                ball_size /= 1.4;
+            }
+            else{
+                ball_size = 1;
             }
         }
         value = increment_quit(value);
@@ -350,7 +352,8 @@
         bg_clr = black;
     }

-    double text_size = 40;
+    double text_size = 100;
+    double ball_size = (level*2);

     std::vector<vec> triangle_pts = {{0,0},{0.5,sqrt(0.75)},{1,0}};
     std::vector<vec> triangle_midpts = {0.5*(triangle_pts[0]+triangle_pts[1]),
@@ -388,7 +391,8 @@
         triangle[i] = std::make_shared<ellipse>(pt_clr, loc, vec{0,0}, 0, 1);
         triangle[i]->add_animator<vec_animator>(0+i*10,30+i*10,
                                                 &triangle[i]->size,
-                                                vec{0,0}, vec{10,10});
+                                                vec{0,0},
+                                                vec{ball_size, ball_size});

         label = std::make_shared<text>(bg_clr, loc+label_offset, text_size,
                                        letter, 0);
@@ -418,7 +422,8 @@
         midtriangle[i] = std::make_shared<ellipse>(pt_clr, loc, vec{0,0}, 0, 1);
         midtriangle[i]->add_animator<vec_animator>(60+i*10,90+i*10,
                                                 &midtriangle[i]->size,
-                                                vec{0,0}, vec{10,10});
+                                                vec{0,0},
+                                                vec{ball_size, ball_size});

         label = std::make_shared<text>(bg_clr, loc+label_offset, text_size,
                                        letter, 0);
@@ -440,7 +445,6 @@
     std::string value_string = "", parent_string;

     int draw_frame = 120;
-    double ball_size = level-1;

     // This is creating all the children
     for(int i = 0; i < ((pow(3,level)-1)/2)-1; i++){
@@ -450,7 +454,10 @@
             diff += pow(3,tmp_level);
             draw_frame += 60;
             if (ball_size > 1){
-                ball_size -= 1;
+                ball_size /= 1.4;
+            }
+            else{
+                ball_size = 1;
             }
         }
         value = increment(value);
@@ -524,7 +531,8 @@
         bg_clr = black;
     }

-    double text_size = 40;
+    double text_size = 100;
+    double ball_size = (14);

     std::vector<vec> triangle_pts = {{0,0},{0.5,sqrt(0.75)},{1,0}};
     std::vector<std::shared_ptr<ellipse>> triangle(3);
@@ -560,7 +568,8 @@
         triangle[i] = std::make_shared<ellipse>(pt_clr, loc, vec{0,0}, 0, 1);
         triangle[i]->add_animator<vec_animator>(0+i*10,30+i*10,
                                                 &triangle[i]->size,
-                                                vec{0,0}, vec{10,10});
+                                                vec{0,0},
+                                                vec{ball_size, ball_size});

         label = std::make_shared<text>(bg_clr, loc+label_offset, text_size,
                                        letter, 0);
@@ -597,7 +606,7 @@
                    - triangle_size*pt.y};

         if (i < 20){
-            double ball_size = 7;
+            double ball_size = 14;
             color ball_color = {0, 1.0-i/20.0, i/20.0, 1};
             auto ball = std::make_shared<ellipse>(ball_color,
                                                   loc, vec{0,0}, 0, 1);
@@ -627,7 +636,7 @@
             world.add_object(arrow,2);
         }
         else{
-            double ball_size = 1;
+            double ball_size = 2;
             color ball_color = {1-(double)i/n, 0, 1-((double)n-i)/n,1};
             auto ball = std::make_shared<ellipse>(ball_color,
                                                   loc, vec{0,0}, 0, 1);
@@ -664,16 +673,16 @@

 int main(){

-    camera cam(vec{0.5*1920, 0.5*1080});
-    scene world = scene({0.5*1920, 0.5*1080}, {0, 0, 0, 1});
+    camera cam(vec{2*1920, 2*1080});
+    scene world = scene({2*1920, 2*1080}, {0, 0, 0, 1});
     //camera cam(vec{1920, 1080});
     //scene world = scene({1920, 1080}, {0, 0, 0, 1});
-    world.bg_clr = {1, 1, 1, 1};
+    //world.bg_clr = {1, 1, 1, 1};

     cam.add_encoder<video_encoder>("/tmp/video.mp4", cam.size, 60);
     //cam.add_encoder<png_encoder>();
-    //square_hutchinson(cam, world, 7, 1000, true);
-    sierpinski_hutchinson(cam, world, 8, 1000, true);
-    //sierpinski_chaos(cam, world, 200000, 1000, 1000, true);
+    //square_hutchinson(cam, world, 7, 1000, false);
+    //sierpinski_hutchinson(cam, world, 8, 1000, false);
+    sierpinski_chaos(cam, world, 200000, 1000, 1000, false);
     cam.clear_encoders();
 }


avoid reallocations

avoid reallocations

Change-Id: Ibf3a9908df5acd1afe0ebc1d9491d59e6dd40e43

--- src/lib/CDRParser.cpp
+++ src/lib/CDRParser.cpp
@@ -3155,6 +3155,8 @@
     numChars = getRemainingLength(input) / 12;
   std::vector<unsigned char> textData;
   std::vector<unsigned char> charDescriptions;
+  textData.reserve(numChars);
+  charDescriptions.reserve(numChars);
   for (i=0; i<numChars; ++i)
   {
     input->seek(4, librevenge::RVNG_SEEK_CUR);


Fix minor compile error.

Fix minor compile error.

--- cvd_src/Win32/win32.cpp
+++ cvd_src/Win32/win32.cpp
@@ -32,7 +32,7 @@

 	//tempres is in 100ns increments
 	//Convert it to ns
-	tmpres *= 100
+	tmpres *= 100;

 	/*converting file time to unix epoch*/
 	tmpres -= DELTA_EPOCH_IN_MICROSECS * (long long)1000;


parse shadow

parse shadow

Change-Id: I20bc7045d5d7cb51d1aafd038645a164997b7af7

--- src/lib/IWAParser.cpp
+++ src/lib/IWAParser.cpp
@@ -443,9 +443,15 @@

 void IWAParser::readShadow(const IWAMessage &msg, IWORKShadow &shadow)
 {
-  // TODO: read shadow
-  (void) msg;
-  (void) shadow;
+  const optional<IWORKColor> &color = readColor(msg, 1);
+  if (color)
+    shadow.m_color = get(color);
+  if (msg.float_(2))
+    shadow.m_angle = get(msg.float_(2));
+  if (msg.float_(3))
+    shadow.m_offset = get(msg.float_(3));
+  if (msg.float_(5))
+    shadow.m_opacity = get(msg.float_(5));
 }

 bool IWAParser::dispatchShape(const unsigned id)


Fix memory leak

Fix memory leak

--- cvmfs/notify/cmd_pub.cc
+++ cvmfs/notify/cmd_pub.cc
@@ -64,11 +64,13 @@
     if (retval != download::kFailOk) {
       LogCvmfs(kLogCvmfs, kLogError, "Failed to download manifest (%d - %s)",
                retval, download::Code2Ascii(retval));
+      download_manager->Fini();
       return 6;
     }
     manifest_contents = std::string(download_manifest.destination_mem.data,
                                     download_manifest.destination_mem.pos);
     free(download_manifest.destination_mem.data);
+    download_manager->Fini();
   } else {
     int fd = open(manifest_url.c_str(), O_RDONLY);
     if (fd == -1) {


cid#1219708 sanitize loop bound

cid#1219708 sanitize loop bound

Change-Id: I60bd5e3862ea1cca18089c0f65c40e4cc3173832

--- src/lib/VSDParser.cpp
+++ src/lib/VSDParser.cpp
@@ -1623,6 +1623,7 @@
     unsigned char xType = readU8(input);
     unsigned char yType = readU8(input);
     unsigned pointCount = readU32(input);
+    sanitizeListLength(pointCount, 16, input);

     for (unsigned i = 0; i < pointCount; i++)
     {
@@ -1647,6 +1648,7 @@
     unsigned char xType = readU8(input);
     unsigned char yType = readU8(input);
     unsigned pointCount = readU32(input);
+    sanitizeListLength(pointCount, 32, input);

     std::vector<double> knotVector;
     std::vector<std::pair<double, double> > controlPoints;


Fix nonce bug

Fix nonce bug

--- include/asio_sodium/detail/message_writer.hpp
+++ include/asio_sodium/detail/message_writer.hpp
@@ -74,6 +74,9 @@
         return error::message_encrypt;
       }

+      nonce temp_followup_nonce;
+      header.copy_followup_nonce(temp_followup_nonce);
+
       if (
         !header.encrypt_to(
           session_.encrypt_nonce
@@ -84,7 +87,11 @@
         return error::message_header_encrypt;
       }

-      header.copy_followup_nonce(session_.encrypt_nonce);
+      std::copy(
+        temp_followup_nonce.begin()
+      , temp_followup_nonce.end()
+      , session_.encrypt_nonce.begin()
+      );

       return {};
     }


Throw exception on out of bounds access in layout::Selecting

--- include/cppurses/widget/layouts/selecting.hpp
+++ include/cppurses/widget/layouts/selecting.hpp
@@ -63,6 +63,12 @@
     /// Return the currently selected child, UB if no children in Layout.
     auto selected_child() -> typename Layout_t::Child_t&
     {
+        if (selected_ >= this->child_count()) {
+            // Getting intermitent crash because of outside access.
+            throw std::runtime_error{
+                "Selecting::selected_child();" + std::to_string(selected_) +
+                ">= " + std::to_string(this->child_count())};
+        }
         return this->get_children()[selected_];
     }


Define the rest of the block functions.

Define the rest of the block functions.

--- include/mdds/multi_type_matrix_block_func.hpp
+++ include/mdds/multi_type_matrix_block_func.hpp
@@ -29,6 +29,7 @@
 #define __MULTI_TYPE_MATRIX_BLOCK_FUNC_HPP__

 #include "multi_type_vector_types.hpp"
+#include "multi_type_vector_trait.hpp"

 namespace mdds { namespace __mtm {

@@ -38,7 +39,7 @@
 struct trait
 {
     typedef _StringType string_type;
-    typedef mdds::mtv::default_element_block<element_type_mtx_string, string_type> string_cell_block;
+    typedef mdds::mtv::default_element_block<element_type_mtx_string, string_type> string_elem_block;

     static mdds::mtv::element_t mdds_mtv_get_element_type(const string_type&)
     {
@@ -47,47 +48,47 @@

     static void mdds_mtv_set_value(mtv::base_element_block& block, size_t pos, const string_type& val)
     {
-        string_cell_block::set_value(block, pos, val);
+        string_elem_block::set_value(block, pos, val);
     }

     static void mdds_mtv_get_value(const mtv::base_element_block& block, size_t pos, string_type& val)
     {
-        string_cell_block::get_value(block, pos, val);
+        string_elem_block::get_value(block, pos, val);
     }

     template<typename _Iter>
     static void mdds_mtv_set_values(
         mtv::base_element_block& block, size_t pos, const string_type&, const _Iter& it_begin, const _Iter& it_end)
     {
-        string_cell_block::set_values(block, pos, it_begin, it_end);
+        string_elem_block::set_values(block, pos, it_begin, it_end);
     }

     static void mdds_mtv_append_value(mtv::base_element_block& block, const string_type& val)
     {
-        string_cell_block::append_value(block, val);
+        string_elem_block::append_value(block, val);
     }

     static void mdds_mtv_prepend_value(mtv::base_element_block& block, const string_type& val)
     {
-        string_cell_block::prepend_value(block, val);
+        string_elem_block::prepend_value(block, val);
     }

     template<typename _Iter>
     static void mdds_mtv_prepend_values(mtv::base_element_block& block, const string_type&, const _Iter& it_begin, const _Iter& it_end)
     {
-        string_cell_block::prepend_values(block, it_begin, it_end);
+        string_elem_block::prepend_values(block, it_begin, it_end);
     }

     template<typename _Iter>
     static void mdds_mtv_append_values(mtv::base_element_block& block, const string_type&, const _Iter& it_begin, const _Iter& it_end)
     {
-        string_cell_block::append_values(block, it_begin, it_end);
+        string_elem_block::append_values(block, it_begin, it_end);
     }

     template<typename _Iter>
     static void mdds_mtv_assign_values(mtv::base_element_block& dest, const string_type&, const _Iter& it_begin, const _Iter& it_end)
     {
-        string_cell_block::assign_values(dest, it_begin, it_end);
+        string_elem_block::assign_values(dest, it_begin, it_end);
     }

     static void mdds_mtv_get_empty_value(string_type& val)
@@ -99,8 +100,166 @@
     static void mdds_mtv_insert_values(
         mtv::base_element_block& block, size_t pos, string_type, const _Iter& it_begin, const _Iter& it_end)
     {
-        string_cell_block::insert_values(block, pos, it_begin, it_end);
-    }
+        string_elem_block::insert_values(block, pos, it_begin, it_end);
+    }
+
+    struct elem_block_func
+    {
+        static mdds::mtv::base_element_block* create_new_block(
+            mdds::mtv::element_t type, size_t init_size)
+        {
+            switch (type)
+            {
+                case element_type_mtx_string:
+                    return string_elem_block::create_block(init_size);
+                default:
+                    return mdds::mtv::cell_block_func_base::create_new_block(type, init_size);
+            }
+        }
+
+        static mdds::mtv::base_element_block* clone_block(const mdds::mtv::base_element_block& block)
+        {
+            switch (mtv::get_block_type(block))
+            {
+                case element_type_mtx_string:
+                    return string_elem_block::clone_block(block);
+                default:
+                    return mdds::mtv::cell_block_func_base::clone_block(block);
+            }
+        }
+
+        static void delete_block(mdds::mtv::base_element_block* p)
+        {
+            if (!p)
+                return;
+
+            switch (mtv::get_block_type(*p))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::delete_block(p);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::delete_block(p);
+            }
+        }
+
+        static void resize_block(mdds::mtv::base_element_block& block, size_t new_size)
+        {
+            switch (mtv::get_block_type(block))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::resize_block(block, new_size);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::resize_block(block, new_size);
+            }
+        }
+
+        static void print_block(const mdds::mtv::base_element_block& block)
+        {
+            switch (mtv::get_block_type(block))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::print_block(block);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::print_block(block);
+            }
+        }
+
+        static void erase(mdds::mtv::base_element_block& block, size_t pos)
+        {
+            switch (mtv::get_block_type(block))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::erase_block(block, pos);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::erase(block, pos);
+            }
+        }
+
+        static void erase(mdds::mtv::base_element_block& block, size_t pos, size_t size)
+        {
+            switch (mtv::get_block_type(block))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::erase_block(block, pos, size);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::erase(block, pos, size);
+            }
+        }
+
+        static void append_values_from_block(
+            mdds::mtv::base_element_block& dest, const mdds::mtv::base_element_block& src)
+        {
+            switch (mtv::get_block_type(dest))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::append_values_from_block(dest, src);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::append_values_from_block(dest, src);
+            }
+        }
+
+        static void append_values_from_block(
+            mdds::mtv::base_element_block& dest, const mdds::mtv::base_element_block& src,
+            size_t begin_pos, size_t len)
+        {
+            switch (mtv::get_block_type(dest))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::append_values_from_block(dest, src, begin_pos, len);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::append_values_from_block(dest, src, begin_pos, len);
+            }
+        }
+
+        static void assign_values_from_block(
+            mdds::mtv::base_element_block& dest, const mdds::mtv::base_element_block& src,
+            size_t begin_pos, size_t len)
+        {
+            switch (mtv::get_block_type(dest))
+            {
+                case element_type_mtx_string:
+                    string_elem_block::assign_values_from_block(dest, src, begin_pos, len);
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::assign_values_from_block(dest, src, begin_pos, len);
+            }
+        }
+
+        static bool equal_block(
+            const mdds::mtv::base_element_block& left, const mdds::mtv::base_element_block& right)
+        {
+            if (mtv::get_block_type(left) == element_type_mtx_string)
+            {
+                if (mtv::get_block_type(right) != element_type_mtx_string)
+                    return false;
+
+                return string_elem_block::get(left) == string_elem_block::get(right);
+            }
+            else if (mtv::get_block_type(right) == element_type_mtx_string)
+                return false;
+
+            return mdds::mtv::cell_block_func_base::equal_block(left, right);
+        }
+
+        static void overwrite_values(mdds::mtv::base_element_block& block, size_t pos, size_t len)
+        {
+            switch (mtv::get_block_type(block))
+            {
+                case element_type_mtx_string:
+                    // Do nothing.  The client code manages the life cycle of these cells.
+                break;
+                default:
+                    mdds::mtv::cell_block_func_base::overwrite_values(block, pos, len);
+            }
+        }
+    };
 };

 }}


Fix OpenGL error when deleting index buffer

--- src/RenderSystem.GL4/GraphicsContextGL4.cpp
+++ src/RenderSystem.GL4/GraphicsContextGL4.cpp
@@ -191,6 +191,7 @@
     constantLayout.reset();
     pipelineState.reset();
     vertexBuffers.clear();
+    indexBuffer.reset();
     textures.clear();
     renderTargets.clear();