Fixed sendsms bug, needed to move to non-interactive version

git-svn-id: 504cad4147f1e500be0a169b9f46375eaf875953@3728 19bc5d8c-e614-43d4-8b26-e1612bc8e597

--- CLI/CLI.cpp
+++ CLI/CLI.cpp
@@ -282,17 +282,38 @@
 	return SUCCESS;
 }

+int isIMSI(const char *imsi)
+{
+	int i = 0;
+
+	if (!imsi)
+		return 0;
+	if (strlen(imsi) != 15)
+		return 0;
+
+	for (i = 0; i < strlen(imsi); i++) {
+		if (!isdigit(imsi[i]))
+			return 0;
+	}
+
+	return 1;
+}

 /** Submit an SMS for delivery to an IMSI. */
 int sendsimple(int argc, char** argv, ostream& os)
 {
-	if (argc!=3) return BAD_NUM_ARGS;
-
-	os << "enter text to send: ";
-	char txtBuf[161];
-	cin.getline(txtBuf,160,'\n');
+	if (argc<4) return BAD_NUM_ARGS;
+
 	char *IMSI = argv[1];
 	char *srcAddr = argv[2];
+	string rest = "";
+	for (int i=3; i<argc; i++) rest = rest + argv[i] + " ";
+	const char *txtBuf = rest.c_str();
+
+	if (!isIMSI(IMSI)) {
+		os << "Invalid IMSI. Enter 15 digits only.";
+		return BAD_VALUE;
+	}

 	static UDPSocket sock(0,"127.0.0.1",gConfig.getNum("SIP.Local.Port"));

@@ -311,6 +332,7 @@
 		IMSI, (unsigned)random(), srcAddr,srcAddr,sock.port(),(unsigned)random(), IMSI, (unsigned)random(),sock.port(), strlen(txtBuf), txtBuf);
 	sock.write(buffer);

+	os << "message submitted for delivery" << endl;

 #if 0
 	int numRead = sock.read(buffer,10000);
@@ -325,17 +347,21 @@
 	return SUCCESS;
 }

-
 /** Submit an SMS for delivery to an IMSI. */
 int sendsms(int argc, char** argv, ostream& os)
 {
-	if (argc!=3) return BAD_NUM_ARGS;
-
-	os << "enter text to send: ";
-	char txtBuf[161];
-	cin.getline(txtBuf,160,'\n');
+	if (argc<4) return BAD_NUM_ARGS;
+
 	char *IMSI = argv[1];
 	char *srcAddr = argv[2];
+	string rest = "";
+	for (int i=3; i<argc; i++) rest = rest + argv[i] + " ";
+	const char *txtBuf = rest.c_str();
+
+	if (!isIMSI(IMSI)) {
+		os << "Invalid IMSI. Enter 15 digits only.";
+		return BAD_VALUE;
+	}

 	Control::TransactionEntry *transaction = new Control::TransactionEntry(
 		gConfig.getStr("SIP.Proxy.SMS").c_str(),
@@ -740,8 +766,8 @@
 	addCommand("help", showHelp, "[command] -- list available commands or gets help on a specific command.");
 	addCommand("exit", exit_function, "[wait] -- exit the application, either immediately, or waiting for existing calls to clear with a timeout in seconds");
 	addCommand("tmsis", tmsis, "[\"clear\"] or [\"dump\" filename] -- print/clear the TMSI table or dump it to a file.");
-	addCommand("sendsms", sendsms, "<IMSI> <src> -- send direct SMS to <IMSI>, addressed from <src>, after prompting.");
-	addCommand("sendsimple", sendsimple, "<IMSI> <src> -- send SMS to <IMSI> via SIP interface, addressed from <src>, after prompting.");
+	addCommand("sendsms", sendsms, "IMSI src# message... -- send direct SMS to IMSI, addressed from source number src#.");
+	addCommand("sendsimple", sendsimple, "IMSI src# message... -- send SMS to IMSI via SIP interface, addressed from source number src#.");
 	//apparently non-function now -kurtis
 	//addCommand("sendrrlp", sendrrlp, "<IMSI> <hexstring> -- send RRLP message <hexstring> to <IMSI>.");
 	addCommand("load", printStats, "-- print the current activity loads.");


potentially speed up multi-class svm working set selection

--- src/libshogun/classifier/svm/SVM_libsvm.cpp
+++ src/libshogun/classifier/svm/SVM_libsvm.cpp
@@ -1200,7 +1200,6 @@
 		biases[i]=0;
 	}

-
 	for (int32_t i=0; i<active_size; i++)
 	{
 		update_alpha_status(i);
@@ -1307,80 +1306,87 @@
 	//    (if quadratic coefficient <= 0, replace it with tau)
 	//    -y_j*grad(f)_j < -y_i*grad(f)_i, j in I_low(\alpha)

-	schar *tmp_y;
-	clone(tmp_y,y,active_size);
-
-
+	int32_t retval=0;
 	float64_t best_gap=0;
 	int32_t best_out_i=-1;
 	int32_t best_out_j=-1;

+	float64_t* Gmaxp = new float64_t[nr_class];
+	float64_t* Gmaxp2 = new float64_t[nr_class];
+	int32_t* Gmaxp_idx = new float64_t[nr_class];
+
+	float64_t* Gmaxn = new float64_t[nr_class];
+	float64_t* Gmaxn2 = new float64_t[nr_class];
+	int32_t* Gmaxn_idx = new float64_t[nr_class];
+
+	int32_t* Gmin_idx = new float64_t[nr_class];
+	float64_t* obj_diff_min = new float64_t[nr_class];
+
+	for (int32_t i=0; i<nr_class; i++)
+	{
+		Gmaxp[i]=-INF;
+		Gmaxp2[i]=-INF;
+		Gmaxp_idx[i]=-1;
+		Gmaxn[i]=-INF;
+		Gmaxn2[i]=-INF;
+		Gmaxn_idx[i]=-1;
+		Gmin_idx[i]=-1;
+		obj_diff_min[i]=INF;
+	}
+
+	for(int32_t t=0;t<active_size;t++)
+	{
+		int32_t cidx=y[t];
+		if(!is_upper_bound(t))
+		{
+			if(-G[t] >= Gmaxp[cidx])
+			{
+				Gmaxp[cidx] = -G[t];
+				Gmaxp_idx[cidx] = t;
+			}
+		}
+	}
+
+	int32_t ip = Gmaxp_idx;
+	int32_t in = Gmaxn_idx;
+	const Qfloat *Q_ip = NULL;
+	const Qfloat *Q_in = NULL;
+	if(ip != -1) // NULL Q_ip not accessed: Gmaxp=-INF if ip=-1
+		Q_ip = Q->get_Q(ip,active_size);
+	if(in != -1)
+		Q_in = Q->get_Q(in,active_size);
+
+	for(int32_t j=0;j<active_size;j++)
+	{
+		int32_t cidx=y[j];
+
+		if (!is_lower_bound(j))
+		{
+			float64_t grad_diff=Gmaxp[cidx]+G[j];
+			if (G[j] >= Gmaxp2[cidx])
+				Gmaxp2[cidx] = G[j];
+			if (grad_diff > 0)
+			{
+				float64_t obj_diff;
+				float64_t quad_coef = Q_ip[ip]+QD[j]-2*Q_ip[j];
+				if (quad_coef > 0)
+					obj_diff = -(grad_diff*grad_diff)/quad_coef;
+				else
+					obj_diff = -(grad_diff*grad_diff)/TAU;
+
+				if (obj_diff <= obj_diff_min[cidx])
+				{
+					Gmin_idx[cidx]=j;
+					obj_diff_min[cidx] = obj_diff;
+				}
+			}
+		}
+	}
+
 	for (int32_t c=0; c<nr_class; c++)
 	{
-		for (int32_t i=0; i<active_size; i++)
-			tmp_y[i] = (y[i] == c) ? 1 : 0;
-
-		float64_t Gmaxp = -INF;
-		float64_t Gmaxp2 = -INF;
-		int32_t Gmaxp_idx = -1;
-
-		float64_t Gmaxn = -INF;
-		float64_t Gmaxn2 = -INF;
-		int32_t Gmaxn_idx = -1;
-
-		int32_t Gmin_idx = -1;
-		float64_t obj_diff_min = INF;
-
-		for(int32_t t=0;t<active_size;t++)
-			if(tmp_y[t]==+1)
-			{
-				if(!is_upper_bound(t))
-					if(-G[t] >= Gmaxp)
-					{
-						Gmaxp = -G[t];
-						Gmaxp_idx = t;
-					}
-			}
-
-		int32_t ip = Gmaxp_idx;
-		int32_t in = Gmaxn_idx;
-		const Qfloat *Q_ip = NULL;
-		const Qfloat *Q_in = NULL;
-		if(ip != -1) // NULL Q_ip not accessed: Gmaxp=-INF if ip=-1
-			Q_ip = Q->get_Q(ip,active_size);
-		if(in != -1)
-			Q_in = Q->get_Q(in,active_size);
-
-		for(int32_t j=0;j<active_size;j++)
-		{
-			if(tmp_y[j]==+1)
-			{
-				if (!is_lower_bound(j))
-				{
-					float64_t grad_diff=Gmaxp+G[j];
-					if (G[j] >= Gmaxp2)
-						Gmaxp2 = G[j];
-					if (grad_diff > 0)
-					{
-						float64_t obj_diff;
-						float64_t quad_coef = Q_ip[ip]+QD[j]-2*Q_ip[j];
-						if (quad_coef > 0)
-							obj_diff = -(grad_diff*grad_diff)/quad_coef;
-						else
-							obj_diff = -(grad_diff*grad_diff)/TAU;
-
-						if (obj_diff <= obj_diff_min)
-						{
-							Gmin_idx=j;
-							obj_diff_min = obj_diff;
-						}
-					}
-				}
-			}
-		}
-		gap=CMath::max(Gmaxp+Gmaxp2,Gmaxn+Gmaxn2);
-
-		if (gap>=best_gap && Gmin_idx>=0 && Gmin_idx<active_size)
+		gap=CMath::max(Gmaxp[c]+Gmaxp2[c],Gmaxn[c]+Gmaxn2[c]);
+		if (gap>=best_gap && Gmin_idx[c]>=0 && Gmin_idx[c]<active_size)
 		{
 			if (tmp_y[Gmin_idx] == +1)
 				out_i = Gmaxp_idx;
@@ -1402,13 +1408,18 @@

 	if(gap < eps)
-	{
-		delete[] tmp_y;
-		return 1;
-	}
-
-	delete[] tmp_y;
-	return 0;
+		retval=1;
+
+	delete[] Gmaxp;
+	delete[] Gmaxp2;
+	delete[] Gmaxp_idx;
+	delete[] Gmaxn;
+	delete[] Gmaxn2;
+	delete[] Gmaxn_idx;
+	delete[] Gmin_idx;
+	delete[] obj_diff_min;
+
+	return retval;
 }

 bool Solver_NUMC::be_shrunk(


frame rate and image size

frame rate and image size

--- Capture.cpp
+++ Capture.cpp
@@ -4,10 +4,9 @@
 #include <time.h>

-static const int cameraWidth = 848, cameraHeight = 480;
-
-//static const int videoFileFPS = 60; // Set frame rate to 60 fps for ffmpeg.
-static const int videoFileFPS = -1; // Let GStreamer control its own frame rate.
+static const int cameraWidth = 160, cameraHeight = 120;
+static const float cameraFPS  = -1.;
+static const int videoFileFPS = -1;

 Capture::Capture(int device)
@@ -15,11 +14,21 @@
     , fps(-1)
     , canDropFrame(true)
 {
+#if 0
+    imageWidth  = cap.get(cv::CAP_PROP_FRAME_WIDTH);
+    imageHeight = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
+    std::cerr << "camera: " << imageWidth << " x " << imageHeight << std::endl;
+#else
     imageWidth  = cameraWidth;
     imageHeight = cameraHeight;

     cap.set(cv::CAP_PROP_FRAME_WIDTH,  cameraWidth);
     cap.set(cv::CAP_PROP_FRAME_HEIGHT, cameraHeight);
+#endif
+
+    if (cameraFPS > 0) {
+        cap.set(cv::CAP_PROP_FPS, cameraFPS);
+    }
 }

 Capture::Capture(const char* filename)


Replaced strncpy with memcpy (#684)

Replaced strncpy with memcpy (#684)

* Replaced strncpy with memcpy

Signed-off-by: ivanpauno <f493a283e6aff807b3cc3b53203cbbb64f272da1@ekumenlabs.com>

--- rclcpp/include/rclcpp/intra_process_manager_impl.hpp
+++ rclcpp/include/rclcpp/intra_process_manager_impl.hpp
@@ -25,6 +25,7 @@
 #include <memory>
 #include <mutex>
 #include <set>
+#include <stdexcept>
 #include <string>
 #include <unordered_map>
 #include <utility>
@@ -283,9 +284,21 @@
   fixed_size_string(const char * str) const
   {
     FixedSizeString ret;
-    std::strncpy(ret.data(), str, ret.size());
+    size_t size = std::strlen(str) + 1;
+    if (size > ret.size()) {
+      throw std::runtime_error("failed to copy topic name");
+    }
+    std::memcpy(ret.data(), str, size);
     return ret;
   }
+  struct strcmp_wrapper
+  {
+    bool
+    operator()(const FixedSizeString lhs, const FixedSizeString rhs) const
+    {
+      return std::strcmp(lhs.data(), rhs.data()) < 0;
+    }
+  };

   template<typename T>
   using RebindAlloc = typename std::allocator_traits<Allocator>::template rebind_alloc<T>;
@@ -301,7 +314,7 @@
   using IDTopicMap = std::map<
     FixedSizeString,
     AllocSet,
-    std::less<FixedSizeString>,
+    strcmp_wrapper,
     RebindAlloc<std::pair<const FixedSizeString, AllocSet>>>;

   SubscriptionMap subscriptions_;


Replace use of FILE* with std::ostream* in Console.

--- Console.cpp
+++ Console.cpp
@@ -152,49 +152,48 @@
     return Run(pool, client, CYUTF8String(code.c_str(), code.size()));
 }

-FILE *fout_;
-
-static void Output(CYUTF8String json, FILE *fout, bool expand = false) {
+static std::ostream *out_;
+
+static void Output(CYUTF8String json, std::ostream *out, bool expand = false) {
     const char *data(json.data);
     size_t size(json.size);

-    if (data == NULL || fout == NULL)
+    if (data == NULL || out == NULL)
         return;

     if (!expand ||
         data[0] != '@' && data[0] != '"' && data[0] != '\'' ||
         data[0] == '@' && data[1] != '"' && data[1] != '\''
     )
-        fputs(data, fout);
+        out->write(data, size);
     else for (size_t i(0); i != size; ++i)
         if (data[i] != '\\')
-            fputc(data[i], fout);
+            *out << data[i];
         else switch(data[++i]) {
             case '\0': goto done;
-            case '\\': fputc('\\', fout); break;
-            case '\'': fputc('\'', fout); break;
-            case '"': fputc('"', fout); break;
-            case 'b': fputc('\b', fout); break;
-            case 'f': fputc('\f', fout); break;
-            case 'n': fputc('\n', fout); break;
-            case 'r': fputc('\r', fout); break;
-            case 't': fputc('\t', fout); break;
-            case 'v': fputc('\v', fout); break;
-            default: fputc('\\', fout); --i; break;
+            case '\\': *out << '\\'; break;
+            case '\'': *out << '\''; break;
+            case '"': *out << '"'; break;
+            case 'b': *out << '\b'; break;
+            case 'f': *out << '\f'; break;
+            case 'n': *out << '\n'; break;
+            case 'r': *out << '\r'; break;
+            case 't': *out << '\t'; break;
+            case 'v': *out << '\v'; break;
+            default: *out << '\\'; --i; break;
         }

   done:
-    fputs("\n", fout);
-    fflush(fout);
-}
-
-static void Run(int client, const char *data, size_t size, FILE *fout = NULL, bool expand = false) {
+    *out << std::endl;
+}
+
+static void Run(int client, const char *data, size_t size, std::ostream *out = NULL, bool expand = false) {
     CYPool pool;
-    Output(Run(pool, client, CYUTF8String(data, size)), fout, expand);
-}
-
-static void Run(int client, std::string &code, FILE *fout = NULL, bool expand = false) {
-    Run(client, code.c_str(), code.size(), fout, expand);
+    Output(Run(pool, client, CYUTF8String(data, size)), out, expand);
+}
+
+static void Run(int client, std::string &code, std::ostream *out = NULL, bool expand = false) {
+    Run(client, code.c_str(), code.size(), out, expand);
 }

 int (*append_history$)(int, const char *);
@@ -307,8 +306,8 @@
     CYArray *array(dynamic_cast<CYArray *>(result));

     if (array == NULL) {
-        fprintf(fout_, "\n");
-        Output(json, fout_);
+        *out_ << '\n';
+        Output(json, out_);
         rl_forced_update_display();
         return NULL;
     }
@@ -399,7 +398,7 @@
     bool debug(false);
     bool expand(false);

-    fout_ = stdout;
+    out_ = &std::cout;

     // rl_completer_word_break_characters is broken in libedit
     rl_basic_word_break_characters = break_;
@@ -423,8 +422,7 @@

         if (setjmp(ctrlc_) != 0) {
             mode_ = Working;
-            fputs("\n", fout_);
-            fflush(fout_);
+            *out_ << std::endl;
             goto restart;
         }

@@ -443,16 +441,13 @@
                 std::string data(line + 1);
                 if (data == "bypass") {
                     bypass = !bypass;
-                    fprintf(fout_, "bypass == %s\n", bypass ? "true" : "false");
-                    fflush(fout_);
+                    *out_ << "bypass == " << (bypass ? "true" : "false") << std::endl;
                 } else if (data == "debug") {
                     debug = !debug;
-                    fprintf(fout_, "debug == %s\n", debug ? "true" : "false");
-                    fflush(fout_);
+                    *out_ << "debug == " << (debug ? "true" : "false") << std::endl;
                 } else if (data == "expand") {
                     expand = !expand;
-                    fprintf(fout_, "expand == %s\n", expand ? "true" : "false");
-                    fflush(fout_);
+                    *out_ << "expand == " << (expand ? "true" : "false") << std::endl;
                 }
                 add_history(line);
                 ++histlines;
@@ -542,7 +537,7 @@
         if (debug)
             std::cout << code << std::endl;

-        Run(client_, code, fout_, expand);
+        Run(client_, code, out_, expand);
     }

     if (append_history$ != NULL) {
@@ -552,8 +547,7 @@
         write_history(histfile);
     }

-    fputs("\n", fout_);
-    fflush(fout_);
+    *out_ << std::endl;
 }

 static void *Map(const char *path, size_t *psize) {
@@ -814,7 +808,7 @@
             if (client_ != -1) {
                 // XXX: this code means that you can't pipe to another process
                 std::string code(start, end-start);
-                Run(client_, code, stdout);
+                Run(client_, code, &std::cout);
             } else {
                 std::ostringstream str;
                 CYOutput out(str, options);
@@ -824,7 +818,7 @@
                 if (compile)
                     std::cout << code;
                 else
-                    Run(client_, code, stdout);
+                    Run(client_, code, &std::cout);
             }
     }


Zapomniany średnik

Zapomniany średnik

--- Console.cpp
+++ Console.cpp
@@ -302,7 +302,7 @@
 				double temp = (((((Global::fCalibrateOut[x][5] * y) + Global::fCalibrateOut[x][4]) * y +
 					Global::fCalibrateOut[x][3]) * y + Global::fCalibrateOut[x][2]) * y +
 					Global::fCalibrateOut[x][1]) * y +
-					Global::fCalibrateOut[x][0] // zakres <0;1>
+					Global::fCalibrateOut[x][0]; // zakres <0;1>
 				PoKeys55[0]->PWM(x, temp);
 				if (x == 6)
 				{


DCCSock: Make sure we don't cache too much data in memory

This now only reads new data from disk if there is less than 1 MiB left to be
sent, which is still a lot. Before this there was no limit and the other end of
the socket could try to make us run out of memory.

git-svn-id: 3ad904ec35b89a071badd9cb0113dfe58093e920@1463 726aef4b-f618-498e-8847-2d620e286838

--- DCCSock.cpp
+++ DCCSock.cpp
@@ -111,6 +111,14 @@
 		return;
 	}

+	if (GetInternalWriteBuffer().size() > 1024 * 1024) {
+		// There is still enough data to be written, don't add more
+		// stuff to that buffer.
+		DEBUG("SendPacket(): Skipping send, buffer still full enough [" << GetInternalWriteBuffer().size() << "]["
+				<< m_sRemoteNick << "][" << m_sFileName << "]");
+		return;
+	}
+
 	char szBuf[4096];
 	int iLen = m_pFile->Read(szBuf, 4096);


Bugfix: correctly copy constants in dagshrink.

--- DagShrink.C
+++ DagShrink.C
@@ -623,6 +623,7 @@

     // Copy inputs (including flop gates):
     c.adjustMapSize(map, sig_Undef);
+    map[gate_True] = sig_True;
     for (int i = 0; i < b.inps.size(); i++) map[b.inps[i]] = tmp_circ.mkInp();
     for (int i = 0; i < flp   .size(); i++) map[flp   [i]] = tmp_circ.mkInp();


Fix comment.

Fix comment.

--- DataSet.cpp
+++ DataSet.cpp
@@ -65,7 +65,7 @@
     // the 3rd line : the number of words
     fin >> N;

-    // the following lines : docID vocab wordID count
+    // the following lines : docID wordID count
     int m, v, cnt;
     while ( fin >> m >> v >> cnt ) {
         for (int i = 0; i < cnt; i++) {


correct missing #elif define for ATtiny85

--- EmonLib.cpp
+++ EmonLib.cpp
@@ -220,8 +220,9 @@
   #elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
   ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
   #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
-    ADMUX = _BV(MUX5) | _BV(MUX0);
+  ADMUX = _BV(MUX5) | _BV(MUX0);
   #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
+  ADMUX = _BV(MUX3) | _BV(MUX2);
   #endif

   delay(2);					// Wait for Vref to settle


divided by 512

divided by 512

--- FATData.cpp
+++ FATData.cpp
@@ -24,7 +24,7 @@
   totalSectors32 = bytesToUnsigned(&BPB[BPB_TOT_SEC_32_OFFSET],BPB_TOT_SEC_32_SIZE);

   FATSz = BPB_NUM_FATS * FATSz16;
-  ROOTSz = rootEntityCount * ROOT_ENT_SZ;
+  ROOTSz = rootEntityCount * ROOT_ENT_SZ / 512; //Dividing by 512 is black magic from a handout
   FAT = new uint8_t[FATSz];
   ROOT = new uint8_t[ROOTSz];
   imageFile.read((char*)FAT, FATSz);


new histos

new histos


Remove a useless lookup

Remove a useless lookup

All the places that add entries to the CTCPReplies map use CString::Token(0) to
split the first token away. This means it is impossible for this to contain
spaces. Now this means that it is pointless to look up the full CTCP request in
the CTCPReplies map because it can't contain any matching item.

Signed-off-by: Uli Schlachter <346c0ad49ac8427b61b3b55abbe37dc0ebd524f2@znc.in>

--- IRCSock.cpp
+++ IRCSock.cpp
@@ -822,14 +822,10 @@

 bool CIRCSock::OnGeneralCTCP(CNick& Nick, CString& sMessage) {
 	const MCString& mssCTCPReplies = m_pUser->GetCTCPReplies();
-	MCString::const_iterator it = mssCTCPReplies.find(sMessage.AsUpper());
 	CString sQuery = sMessage.Token(0).AsUpper();
+	MCString::const_iterator it = mssCTCPReplies.find(sQuery);
 	bool bHaveReply = false;
 	CString sReply;
-
-	if (it == mssCTCPReplies.end()) {
-		it = mssCTCPReplies.find(sQuery);
-	}

 	if (it != mssCTCPReplies.end()) {
 		sReply = m_pUser->ExpandString(it->second);


[C++] Remove low value comment.

[C++] Remove low value comment.

--- aeron-client/src/main/cpp/ClientConductor.cpp
+++ aeron-client/src/main/cpp/ClientConductor.cpp
@@ -271,7 +271,6 @@
     SubscriptionStateDefn &state = *it;
     std::shared_ptr<Subscription> sub = state.m_subscription.lock();

-    // now remove the cached value
     if (state.m_subscriptionCache)
     {
         state.m_subscriptionCache.reset();


add try catch

add try catch

--- player.cpp
+++ player.cpp
@@ -7,18 +7,26 @@

 int Player::betRequest(json::Value game_state)
 {
-    std::cerr<<json::Serialize(game_state)<<std::endl;
-    std::string s = json::Serialize(game_state);
-    std::string delimiter = "},{";
-    std::string token;
-    size_t pos = 0;
-    while ((pos = s.find(delimiter)) != std::string::npos) {
-        token = s.substr(0,pos);
-        std::cerr << token << std::endl;
-        s.erase(0, pos + delimiter.length());
+
+    try {
+        std::cerr<<json::Serialize(game_state)<<std::endl;
+        std::string s = json::Serialize(game_state);
+        std::string delimiter = "},{";
+        std::string token;
+        size_t pos = 0;
+        while ((pos = s.find(delimiter)) != std::string::npos) {
+            token = s.substr(0,pos);
+            std::cerr << token << std::endl;
+            s.erase(0, pos + delimiter.length());
+        }
+
+        return 100;
+
+
+    } catch(const std::exception& e) {
+        // in case it crashes
+        return 100;
     }
-
-    return 100;

 }


Fix sorting code.

Fix sorting code.

Was taking the object type instead of an instance...

git-svn-id: 0a20d38d1bcdb3210d244a647211d61b0aabf366@270 5b8196f7-c1c0-4be6-8b13-4feed349168d

--- Clipper.cpp
+++ Clipper.cpp
@@ -112,11 +112,12 @@
   return newVertices;
 }

-struct {
-  bool operator() (const FLOATVECTOR3& i, const FLOATVECTOR3& j) {
-    return i.x < j.x || (i.x == j.x && i.y < j.y) || (i.x == j.x && i.y == j.y && i.z < j.z);
+struct CompSorter {
+  bool operator() (const FLOATVECTOR3& i, const FLOATVECTOR3& j) const {
+    return i.x < j.x || (i.x == j.x && i.y < j.y) ||
+           (i.x == j.x && i.y == j.y && i.z < j.z);
   }
-} CompSorter;
+};

 static bool AngleSorter(const FLOATVECTOR3& i, const FLOATVECTOR3& j, const FLOATVECTOR3& center, const FLOATVECTOR3& refVec, const FLOATVECTOR3& normal) {
   FLOATVECTOR3 vecI = (i-center).normalized();
@@ -140,8 +141,9 @@
   if (newVertices.size() < 3) return;

   // remove duplicate vertices
-  std::sort(newVertices.begin(), newVertices.end(), CompSorter);
-  newVertices.erase(std::unique(newVertices.begin(), newVertices.end()), newVertices.end());
+  std::sort(newVertices.begin(), newVertices.end(), CompSorter());
+  newVertices.erase(std::unique(newVertices.begin(), newVertices.end()),
+                    newVertices.end());

   // sort counter clockwise
   using namespace std::placeholders;


WIP: save work.

WIP: save work.

--- cpp/src/DO/Sara/Core/Math/JenkinsTraub.cpp
+++ cpp/src/DO/Sara/Core/Math/JenkinsTraub.cpp
@@ -1,5 +1,6 @@
+#include <DO/Sara/Core/EigenExtension.hpp>
+#include <DO/Sara/Core/Math/NewtonRaphson.hpp>
 #include <DO/Sara/Core/Math/UnivariatePolynomial.hpp>
-#include <DO/Sara/Core/Math/NewtonRaphson.hpp>

 #include <complex>
 #include <ctime>
@@ -23,84 +24,117 @@
     return x;
   }

+  // Sigma is a real polynomial. So (s1, s2) is a pair of identical real numbers
+  // or a conjugate complex pair.
+  auto sigma_generic_formula(const std::complex<double>& s1)
+      -> UnivariatePolynomial<double>
+  {
+    const auto a = std::real(s1);
+    const auto b = std::imag(s1);
+    return Z.pow<double>(2) - 2 * a * Z + (a * a + b * b);
+  }
+
+  // See formula (2.2) at page 547.
+  // Don't use because overflow and underflow problems would occur (page 563).
+  auto K1_generic_recurrence_formula(const UnivariatePolynomial<double>& K0,
+                                     const UnivariatePolynomial<double>& P,
+                                     const UnivariatePolynomial<double>& sigma,
+                                     const std::complex<double>& s1)
+      -> UnivariatePolynomial<double>
+  {
+    const auto s2 = std::conj(s1);
+
+    Matrix2cd a, b, c;
+    a <<  P(s1),  P(s2),  //
+         K0(s1), K0(s2);
+
+    b <<     K0(s1),     K0(s2),  //
+         s1 * P(s1), s2 * P(s2);
+
+    c << s1 * P(s1), s2 * P(s2),  //
+              P(s1),      P(s2);
+
+    const auto m = std::real(a.determinant() / c.determinant());
+    const auto n = std::real(b.determinant() / c.determinant());
+
+    return ((K0 + (m * Z + n)*P) / sigma).first;
+  }
+
+  // See formula (2.7) at page 548.
+  auto
+  sigma_formula_from_shift_polynomials(const UnivariatePolynomial<double>& K0,
+                                       const UnivariatePolynomial<double>& K1,
+                                       const UnivariatePolynomial<double>& K2,
+                                       const std::complex<double>& s1)
+      -> UnivariatePolynomial<double>
+  {
+    const auto s2 = std::conj(s1);
+    const auto a2 = std::real(K1(s1) * K2(s2) - K1(s2) * K2(s1));
+    const auto a1 = std::real(K0(s2) * K2(s1) - K0(s1) * K2(s2));
+    const auto a0 = std::real(K0(s1) * K1(s2) - K0(s2) * K1(s1));
+
+    // return (a2 * Z.pow(2) + a1 * Z + a0) / a2;
+    return Z.pow<double>(2) + (a1 / a2) * Z + (a0 / a2);
+  }
+
+  // See formula at "Stage 1: no-shift process" at page 556.
   auto K1_no_shift_polynomial(const UnivariatePolynomial<double>& K0,
                               const UnivariatePolynomial<double>& P)
       -> UnivariatePolynomial<double>
   {
-    // See stage 1 formula: no-shift process (page 556).
     auto K1 = (K0 - (K0(0) / P(0)) * P) / Z;
     return K1.first;
   }

-  auto K1_fixed_shift_polynomial(const UnivariatePolynomial<double>& K0,
-                                 const UnivariatePolynomial<double>& P,
-                                 const UnivariatePolynomial<double>& sigma,
-                                 const std::complex<double>& s1,
-                                 const std::complex<double>& s2)
-      -> UnivariatePolynomial<double>
-  {
-    return K0[Z] + P[Z]
-  }
-
-  auto K0_(const UnivariatePolynomial<double>& P)
-      -> UnivariatePolynomial<double>
-  {
-    // Write the scaled recurrence formula (page 563).
-    const auto n = P.degree();
-    auto K0 = UnivariatePolynomial<double>{n - 1};
-
-    for (int i = 0; i < n; ++i)
-      K0[n - 1 - i] = ((n - i) * P[n - i]) / n;
-
-    return K0;
-  }
-
-  auto K1_stage1(const UnivariatePolynomial<double>& K0,
-                 const UnivariatePolynomial<double>& P)
-      -> UnivariatePolynomial<double>
-  {
-    // See stage 1 formula: no-shift process (page 556).
-    auto K1 = (K0 - (K0(0) / P(0)) * P) / Z;
-    return K1.first;
-  }
-
-  auto K1_stage2(const UnivariatePolynomial<double>& K0,
-                 const UnivariatePolynomial<double>& P,
-                 const UnivariatePolynomial<double>& sigma,
-                 const std::complex<double>& s1, const std::complex<double>& s2)
-    -> UnivariatePolynomial<double>
-  {
-    return {};
-  }
-
-  //auto K1_stage2(const UnivariatePolynomial<double>& K0,
-  //               const UnivariatePolynomial<double>& P,
-  //               const UnivariatePolynomial<double>& sigma,
-  //               const std::complex<double>& s1, const std::complex<double>& s2)
-  //  -> std::array<double, 6>
-  //{
-  //  // See stage 2 formula (9.7) (page 563).
-  //  Matrix4cd M;
-  //  Vector4cd y;
-
-  //  M << 1, -s2, 0,   0,
-  //       0,   0, 1,  -1,
-  //       1, -s1, 0,   0,
-  //       0,   0, 1, -s1;
-
-  //  y << P(s1), P(s2), K0(s1), K0(s2);
-  //  Vector4cd x = M.colPivHouseholderQr().solve(y);
-
-  //  const auto a = std::real(x[0]);
-  //  const auto b = std::real(x[1]);
-  //  const auto c = std::real(x[2]);
-  //  const auto d = std::real(x[3]);
-
-  //  const auto u = - std::real(s1 + s2);
-  //  const auto v = - std::real(s1 * s2);
-
-  //  return {a, b, c, d, u, v};
-  //}
+
+  // This is the scaled recurrence formula (page 563).
+  auto K0_polynomial(const UnivariatePolynomial<double>& P)
+      -> UnivariatePolynomial<double>
+  {
+    return derivative(P) / P.degree();
+  }
+
+  // Return linear polynomial remainder of division of:
+  // - P  / sigma
+  // - K0 / sigma
+  //
+  // Used for stage 2 (fixed-shift process).
+  // TODO: For stage 2, P(s1) and P(s2) are evaluated only once.
+  //
+  // Used for stage 3 (variable-shift process).
+  // TODO: s1 and s2 are updated every time.
+  auto calculate_remainders(const UnivariatePolynomial<double>& P,
+                            const UnivariatePolynomial<double>& K0,
+                            const UnivariatePolynomial<double>& sigma,
+                            const std::complex<double>& s1)
+      -> std::pair<UnivariatePolynomial<double>, UnivariatePolynomial<double>>
+  {
+    const auto s2 = std::conj(s1);
+
+    // See stage 2 formula (9.7) (page 563).
+    Matrix4cd M;
+    Vector4cd y;
+
+    M << 1, -s2, 0,   0,
+         0,   0, 1,  -1,
+         1, -s1, 0,   0,
+         0,   0, 1, -s1;
+
+    y << P(s1), P(s2), K0(s1), K0(s2);
+    Vector4cd x = M.colPivHouseholderQr().solve(y);
+
+    const auto a = std::real(x[0]);
+    const auto b = std::real(x[1]);
+    const auto c = std::real(x[2]);
+    const auto d = std::real(x[3]);
+
+    const auto u = - std::real(s1 + s2);
+
+    const auto P_remainder = b * (Z + u) + a;
+    const auto K0_remainder = d * (Z + u) + c;
+
+    return {P_remainder, K0_remainder};
+  }

   //auto stage2(const UnivariatePolynomial<double>& K0_,


fix the bug due to failure to initialize the   setQuantityUnit(mQuantityUnit); // set the factors   setVolumeUnit(mVolumeUnit); // set the factors

--- copasi/model/CModel.cpp
+++ copasi/model/CModel.cpp
@@ -1,9 +1,9 @@
 /* Begin CVS Header
    $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/model/CModel.cpp,v $
-   $Revision: 1.152 $
+   $Revision: 1.153 $
    $Name:  $
-   $Author: shoops $
-   $Date: 2003/12/12 22:20:54 $
+   $Author: lixu1 $
+   $Date: 2003/12/16 02:59:58 $
    End CVS Header */

 /////////////////////////////////////////////////////////////////////////////
@@ -93,6 +93,12 @@
   initializeMetabolites();

   compile();
+
+  /* This following 2 lines added by Liang Xu
+  Becaues of the failure to initialize the parameter when creating a new models
+  */
+  setQuantityUnit(mQuantityUnit); // set the factors
+  setVolumeUnit(mVolumeUnit); // set the factors

   CONSTRUCTOR_TRACE;
 }


little formatting clean-up

little formatting clean-up

Change-Id: I3f30e2b69933f740a9938ac1ed93e7f7727b78bc

--- xmloff/source/chart/PropertyMap.hxx
+++ xmloff/source/chart/PropertyMap.hxx
@@ -106,7 +106,7 @@
 {
     // chart subtypes
     MAP_ENTRY( "UpDown", CHART, XML_JAPANESE_CANDLE_STICK, XML_TYPE_BOOL ), // formerly XML_STOCK_UPDOWN_BARS
-     MAP_CONTEXT( "Volume", CHART, XML_STOCK_WITH_VOLUME, XML_TYPE_BOOL, XML_SCH_CONTEXT_STOCK_WITH_VOLUME ),
+    MAP_CONTEXT( "Volume", CHART, XML_STOCK_WITH_VOLUME, XML_TYPE_BOOL, XML_SCH_CONTEXT_STOCK_WITH_VOLUME ),
     MAP_ENTRY( "Dim3D", CHART, XML_THREE_DIMENSIONAL, XML_TYPE_BOOL ),
     MAP_ENTRY( "Deep", CHART, XML_DEEP, XML_TYPE_BOOL ),
     MAP_ENTRY( "Lines", CHART, XML_LINES, XML_TYPE_BOOL ),
@@ -125,7 +125,7 @@
     MAP_ENTRY( "Vertical", CHART, XML_VERTICAL, XML_TYPE_BOOL ),
     // #i32368# property should no longer be used as XML-property (in OASIS
     // format), but is still ex-/imported for compatibility with the OOo file format
-      MAP_CONTEXT( "NumberOfLines", CHART, XML_LINES_USED, XML_TYPE_NUMBER, XML_SCH_CONTEXT_LINES_USED  ),
+    MAP_CONTEXT( "NumberOfLines", CHART, XML_LINES_USED, XML_TYPE_NUMBER, XML_SCH_CONTEXT_LINES_USED  ),
     MAP_ENTRY( "StackedBarsConnected", CHART, XML_CONNECT_BARS, XML_TYPE_BOOL ),

     MAP_ENTRY_ODF12( "GroupBarsPerAxis", CHART, XML_GROUP_BARS_PER_AXIS, XML_TYPE_BOOL ),
@@ -156,7 +156,7 @@
     MAP_CONTEXT( "Max", CHART, XML_MAXIMUM, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_MAX ),
     MAP_CONTEXT( "Origin", CHART, XML_ORIGIN, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_ORIGIN ),
     MAP_CONTEXT( "StepMain", CHART, XML_INTERVAL_MAJOR, XML_TYPE_DOUBLE, XML_SCH_CONTEXT_STEP_MAIN ),
-     MAP_CONTEXT( "StepHelpCount", CHART, XML_INTERVAL_MINOR_DIVISOR, XML_TYPE_NUMBER, XML_SCH_CONTEXT_STEP_HELP_COUNT ),
+    MAP_CONTEXT( "StepHelpCount", CHART, XML_INTERVAL_MINOR_DIVISOR, XML_TYPE_NUMBER, XML_SCH_CONTEXT_STEP_HELP_COUNT ),
     MAP_ENTRY( "GapWidth", CHART, XML_GAP_WIDTH, XML_TYPE_NUMBER ),
     MAP_ENTRY( "Overlap", CHART, XML_OVERLAP, XML_TYPE_NUMBER ),
     MAP_ENTRY( "TextCanOverlap", CHART, XML_TEXT_OVERLAP, XML_TYPE_BOOL ),
@@ -167,10 +167,10 @@
     MAP_ENTRY( "LinkNumberFormatToSource", CHART, XML_LINK_DATA_STYLE_TO_SOURCE, XML_TYPE_BOOL ),
     MAP_ENTRY( "Visible", CHART, XML_VISIBLE, XML_TYPE_BOOL ),

-    MAP_FULL( "CrossoverPosition",   CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY,                                                              0, SvtSaveOptions::ODFVER_012 ),
-    MAP_FULL( "CrossoverValue",   CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION_VALUE|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY,                                                              0, SvtSaveOptions::ODFVER_012 ),
-    MAP_FULL( "LabelPosition",   CHART, XML_AXIS_LABEL_POSITION, XML_SCH_TYPE_AXIS_LABEL_POSITION,                                                              0, SvtSaveOptions::ODFVER_012 ),
-    MAP_FULL( "MarkPosition",   CHART, XML_TICK_MARK_POSITION, XML_SCH_TYPE_TICK_MARK_POSITION,                                                              0, SvtSaveOptions::ODFVER_012 ),
+    MAP_FULL( "CrossoverPosition", CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, 0, SvtSaveOptions::ODFVER_012 ),
+    MAP_FULL( "CrossoverValue", CHART, XML_AXIS_POSITION, XML_SCH_TYPE_AXIS_POSITION_VALUE|MID_FLAG_MERGE_ATTRIBUTE|MID_FLAG_MULTI_PROPERTY, 0, SvtSaveOptions::ODFVER_012 ),
+    MAP_FULL( "LabelPosition", CHART, XML_AXIS_LABEL_POSITION, XML_SCH_TYPE_AXIS_LABEL_POSITION, 0, SvtSaveOptions::ODFVER_012 ),
+    MAP_FULL( "MarkPosition", CHART, XML_TICK_MARK_POSITION, XML_SCH_TYPE_TICK_MARK_POSITION, 0, SvtSaveOptions::ODFVER_012 ),

     // statistical properties

@@ -183,11 +183,11 @@
     MAP_ENTRY( "ConstantErrorHigh", CHART, XML_ERROR_UPPER_LIMIT, XML_TYPE_DOUBLE ),
     MAP_ENTRY( "ErrorIndicator", CHART, XML_ERROR_UPPER_INDICATOR, XML_SCH_TYPE_ERROR_INDICATOR_UPPER | MID_FLAG_MERGE_PROPERTY ),  // convert one constant
     MAP_ENTRY( "ErrorIndicator", CHART, XML_ERROR_LOWER_INDICATOR, XML_SCH_TYPE_ERROR_INDICATOR_LOWER | MID_FLAG_MERGE_PROPERTY ),  // to two bools
-      MAP_ENTRY( "ErrorBarStyle", CHART, XML_ERROR_CATEGORY, XML_SCH_TYPE_ERROR_BAR_STYLE ),
-      MAP_ENTRY( "PercentageError", CHART, XML_ERROR_PERCENTAGE, XML_TYPE_DOUBLE ),
-      MAP_ENTRY( "RegressionCurves", CHART, XML_REGRESSION_TYPE, XML_SCH_TYPE_REGRESSION_TYPE ),
-      MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ),
-      MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ),
+    MAP_ENTRY( "ErrorBarStyle", CHART, XML_ERROR_CATEGORY, XML_SCH_TYPE_ERROR_BAR_STYLE ),
+    MAP_ENTRY( "PercentageError", CHART, XML_ERROR_PERCENTAGE, XML_TYPE_DOUBLE ),
+    MAP_ENTRY( "RegressionCurves", CHART, XML_REGRESSION_TYPE, XML_SCH_TYPE_REGRESSION_TYPE ),
+    MAP_ENTRY_ODF12( "ErrorBarRangePositive", CHART, XML_ERROR_UPPER_RANGE, XML_TYPE_STRING ),
+    MAP_ENTRY_ODF12( "ErrorBarRangeNegative", CHART, XML_ERROR_LOWER_RANGE, XML_TYPE_STRING ),

     // errorbars properties (chart2)
     MAP_ENTRY_ODF_EXT( "PositiveError", CHART, XML_ERROR_LOWER_LIMIT, XML_TYPE_DOUBLE),


INTEGRATION: CWS vgbugs07 (1.20.84); FILE MERGED 2007/06/04 13:23:24 vg 1.20.84.1: #i76605# Remove -I .../inc/module hack introduced by hedaburemove01

--- xmloff/source/draw/shapeexport3.cxx
+++ xmloff/source/draw/shapeexport3.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: shapeexport3.cxx,v $
  *
- *  $Revision: 1.20 $
- *
- *  last change: $Author: ihi $ $Date: 2006-12-19 17:26:22 $
+ *  $Revision: 1.21 $
+ *
+ *  last change: $Author: hr $ $Date: 2007-06-27 15:06:34 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -69,7 +69,7 @@
 #endif

 #ifndef _XMLOFF_SHAPEEXPORT_HXX
-#include "shapeexport.hxx"
+#include <xmloff/shapeexport.hxx>
 #endif

 #ifndef _SDPROPLS_HXX
@@ -85,11 +85,11 @@
 #endif

 #ifndef _XMLOFF_XMLEXP_HXX
-#include "xmlexp.hxx"
+#include <xmloff/xmlexp.hxx>
 #endif

 #ifndef _XMLOFF_XMLUCONV_HXX
-#include "xmluconv.hxx"
+#include <xmloff/xmluconv.hxx>
 #endif

 #ifndef _XEXPTRANSFORM_HXX
@@ -97,7 +97,7 @@
 #endif

 #ifndef _XMLOFF_XMLTOKEN_HXX
-#include "xmltoken.hxx"
+#include <xmloff/xmltoken.hxx>
 #endif

 #ifndef _BGFX_VECTOR_B3DVECTOR_HXX


Update for some missing enums added in late SPIR-V revisions

--- renderdoc/driver/shaders/spirv/spirv_disassemble.cpp
+++ renderdoc/driver/shaders/spirv/spirv_disassemble.cpp
@@ -1440,6 +1440,7 @@
 			case spv::OpImageSparseFetch:
 			case spv::OpImageSparseGather:
 			case spv::OpImageSparseDrefGather:
+			case spv::OpImageSparseRead:
 			case spv::OpAtomicStore:
 			case spv::OpAtomicExchange:
 			case spv::OpAtomicCompareExchange:
@@ -4905,6 +4906,7 @@
 			case spv::OpImageSparseFetch:
 			case spv::OpImageSparseGather:
 			case spv::OpImageSparseDrefGather:
+			case spv::OpImageSparseRead:
 			{
 				uint32_t idx = 1;

@@ -4943,6 +4945,7 @@
 					case spv::OpImageSparseFetch:
 					case spv::OpImageSparseGather:
 					case spv::OpImageSparseDrefGather:
+					case spv::OpImageSparseRead:
 						image = true;
 						break;
 					default:
@@ -5885,10 +5888,11 @@
 		case spv::OpNoLine:                                   return "NoLine";
 		case spv::OpAtomicFlagTestAndSet:                     return "AtomicFlagTestAndSet";
 		case spv::OpAtomicFlagClear:                          return "AtomicFlagClear";
+		case spv::OpImageSparseRead:                          return "ImageSparseRead";
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedOp{%u}", (uint32_t)el);
 }

 template<>
@@ -5896,15 +5900,16 @@
 {
 	switch(el)
 	{
-		case spv::SourceLanguageUnknown: return "Unknown";
-		case spv::SourceLanguageESSL:    return "ESSL";
-		case spv::SourceLanguageGLSL:    return "GLSL";
+		case spv::SourceLanguageUnknown:    return "Unknown";
+		case spv::SourceLanguageESSL:       return "ESSL";
+		case spv::SourceLanguageGLSL:       return "GLSL";
 		case spv::SourceLanguageOpenCL_C:   return "OpenCL C";
 		case spv::SourceLanguageOpenCL_CPP: return "OpenCL C++";
+		case spv::SourceLanguageHLSL:       return "HLSL";
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedLanguage{%u}", (uint32_t)el);
 }

 template<>
@@ -5964,10 +5969,14 @@
 		case spv::CapabilityDerivativeControl:                         return "DerivativeControl";
 		case spv::CapabilityInterpolationFunction:                     return "InterpolationFunction";
 		case spv::CapabilityTransformFeedback:                         return "TransformFeedback";
+		case spv::CapabilityGeometryStreams:                           return "GeometryStreams";
+		case spv::CapabilityStorageImageReadWithoutFormat:             return "StorageImageReadWithoutFormat";
+		case spv::CapabilityStorageImageWriteWithoutFormat:            return "StorageImageWriteWithoutFormat";
+		case spv::CapabilityMultiViewport:                             return "MultiViewport";
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedCap{%u}", (uint32_t)el);
 }

 template<>
@@ -6009,7 +6018,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedMode{%u}", (uint32_t)el);
 }

 template<>
@@ -6023,7 +6032,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedModel{%u}", (uint32_t)el);
 }

 template<>
@@ -6037,7 +6046,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedModel{%u}", (uint32_t)el);
 }

 template<>
@@ -6055,7 +6064,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedModel{%u}", (uint32_t)el);
 }

 template<>
@@ -6109,7 +6118,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedDecoration{%u}", (uint32_t)el);
 }

 template<>
@@ -6123,6 +6132,7 @@
 		case spv::DimCube:   return "Cube";
 		case spv::DimRect:   return "Rect";
 		case spv::DimBuffer: return "Buffer";
+		case spv::DimSubpassData: return "Subpass Data";
 		default: break;
 	}

@@ -6149,7 +6159,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedClass{%u}", (uint32_t)el);
 }

 template<>
@@ -6200,7 +6210,7 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedFormat{%u}", (uint32_t)el);
 }

 template<>
@@ -6252,7 +6262,8 @@
 		default: break;
 	}

-	return StringFormat::Fmt("Unrecognised{%u}", (uint32_t)el);
+	return StringFormat::Fmt("UnrecognisedBuiltIn{%u}", (uint32_t)el);
+}

 template<>
 string ToStrHelper<false, spv::Scope>::Get(const spv::Scope &el)
@@ -6319,8 +6330,9 @@
 {
 	string ret;

-	if(el & spv::MemoryAccessVolatileMask)     ret += ", Volatile";
+	if(el & spv::MemoryAccessVolatileMask) ret += ", Volatile";
 	if(el & spv::MemoryAccessAlignedMask) ret += ", Aligned";
+	if(el & spv::MemoryAccessNontemporalMask) ret += ", Nontemporal";

 	if(!ret.empty())
 		ret = ret.substr(2);


Add brackets around math ops where needed

--- renderdoc/driver/shaders/spirv/spirv_disassemble.cpp
+++ renderdoc/driver/shaders/spirv/spirv_disassemble.cpp
@@ -1499,6 +1499,9 @@
 								ret += ", ";
 							string arg;
 							op->GetArg(ids, vec, arg);
+
+							if((op->inlineArgs & (1<<vec)) && op->arguments[vec]->op && op->arguments[vec]->op->mathop)
+								arg = "(" + arg + ")";
 							ret += arg;
 							ret += ".";
 						}
@@ -1544,7 +1547,7 @@
 				string a;
 				op->GetArg(ids, 0, a);

-				if(op->arguments[0]->op && op->arguments[0]->op->mathop)
+				if((op->inlineArgs & 1) && op->arguments[0]->op && op->arguments[0]->op->mathop)
 					a = "(" + a + ")";

 				if(inlineOp)


- Fix a typo in the MemCheck doc

- Fix a typo in the MemCheck doc

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

--- core/base/src/TROOT.cxx
+++ core/base/src/TROOT.cxx
@@ -1846,7 +1846,7 @@
 //______________________________________________________________________________
 Bool_t TROOT::MemCheck()
 {
-   // Return kTRUE if the memory leak checke is on.
+   // Return kTRUE if the memory leak checker is on.
    return fgMemCheck;
 }


Delete all JIT instances in Unload()

Delete all JIT instances in Unload()

--- plugin.cpp
+++ plugin.cpp
@@ -85,7 +85,9 @@
 }

 PLUGIN_EXPORT void PLUGIN_CALL Unload() {
-	// nothing
+	for (JITMap::iterator it = jit_map.begin(); it != jit_map.end(); ++it) {
+		delete it->second;
+	}
 }

 PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx) {


Fix shadowed variables

Fix shadowed variables

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

--- core/cont/src/TBits.cxx
+++ core/cont/src/TBits.cxx
@@ -282,7 +282,7 @@

    UInt_t i;
    if (startBit == 0) {
-      for(UInt_t i=0; i<fNbytes; i++) {
+      for(i=0; i<fNbytes; i++) {
          if (fAllBits[i] != 255) return 8*i + fbits[fAllBits[i]];
       }
       return fNbits;
@@ -327,7 +327,7 @@

    UInt_t i;
    if (startBit == 0) {
-      for(UInt_t i=0; i<fNbytes; i++) {
+      for(i=0; i<fNbytes; i++) {
          if (fAllBits[i] != 0) return 8*i + fbits[fAllBits[i]];
       }
       return fNbits;


EKF: Fix bug preventing saved declination being used for first alignment

--- EKF/ekf.cpp
+++ EKF/ekf.cpp
@@ -257,6 +257,8 @@
 		Vector3f mag_init = _mag_filt_state;

 		// calculate the initial magnetic field and yaw alignment
+		// Get the magnetic declination
+		calcMagDeclination();
 		_control_status.flags.yaw_align = resetMagHeading(mag_init);

 		if (_control_status.flags.rng_hgt) {


Correct comment for the ST7576 Vop equation.

--- PCD8544.cpp
+++ PCD8544.cpp
@@ -177,7 +177,7 @@

     // The ST7576 datasheet specifies a minimum Vop of 4V.
     if (this->model == CHIP_ST7576 && level < 36) {
-        level = 36;  // Vop = 2.94 + 36 * 0.06 = 4.02V
+        level = 36;  // Vop = 2.94 + 36 * 0.03 = 4.02V
     }

     this->send(PCD8544_CMD, 0x21);  // extended instruction set control (H=1)


fix(kernel/metavar): improve error messages by propagating the tag when we execute instantiate_all

This is the real fix for commit ededf4fc6c63b0dd21268ca2a10cd982ae52174b

--- src/kernel/metavar.cpp
+++ src/kernel/metavar.cpp
@@ -185,7 +185,7 @@
         if (!modified)
             return e;
         else
-            return mk_rev_app(new_f, new_args);
+            return mk_rev_app(new_f, new_args, e.get_tag());
     }

     expr save_result(expr const & e, expr && r) {


Typo

Typo

Former-commit-id: 11cd4820512f0962f491e860ae461f7ba9237595

--- src/kraken-db/converter.cpp
+++ src/kraken-db/converter.cpp
@@ -104,7 +104,7 @@
 	uint64_t kmer_id = 1;

 	for(uint64_t* temp_offsets = offsets+1;
-			temp_offsets < offsets+300; temp_offsets++)
+			temp_offsets < n_bins; temp_offsets++)
 	{

 		temp_kmers = kmers;


fix wrong indentation mistakenly introduced by tackat

svn path=/trunk/KDE/kdeedu/marble/; revision=694820

--- src/lib/Quaternion.cpp
+++ src/lib/Quaternion.cpp
@@ -194,7 +194,7 @@
     else if ( y < -1.0 )
         y = -1.0;

-        beta = -asin( y );
+    beta = -asin( y );

     if(v[Q_X] * v[Q_X] + v[Q_Z] * v[Q_Z] > 0.00005)
         alpha = -atan2(v[Q_X], v[Q_Z]);


Fix env_dfs log

Fix env_dfs log

--- src/leveldb/util/env_dfs.cc
+++ src/leveldb/util/env_dfs.cc
@@ -289,10 +289,8 @@
         uint64_t diff = EnvDfs()->NowMicros() - t;
         dfs_sync_delay_counter.Add(diff);
         if (diff > 2000000) {
-            char buf[128];
-            get_time_str(buf, 128);
-            Log("[env_dfs] %s dfs sync for %s use %.2fms\n",
-                buf, filename_.c_str(), diff / 1000.0);
+            Log("[env_dfs] dfs sync for %s use %.2fms\n",
+                filename_.c_str(), diff / 1000.0);
         }
         return s;
     }


do not process text placeholders for now

--- src/lib/KNCollectorBase.cpp
+++ src/lib/KNCollectorBase.cpp
@@ -178,7 +178,7 @@
 {
   if (m_collecting)
   {
-    assert(!m_objectsStack.empty());
+    // assert(!m_objectsStack.empty());

     KNTextBodyPtr_t textBody(new KNTextBody(title));
     textBody->geometry = m_currentGeometry;
@@ -187,7 +187,7 @@
       m_dict.titlePlaceholders[id] = textBody;
     else
       m_dict.bodyPlaceholders[id] = textBody;
-    m_objectsStack.top().push_back(makeObject(textBody));
+    // m_objectsStack.top().push_back(makeObject(textBody));

     m_currentGeometry.reset();
     m_currentText.reset();


x -> r in sem.cpp

x -> r in sem.cpp

--- src/lib/common/sem.cpp
+++ src/lib/common/sem.cpp
@@ -70,13 +70,13 @@
 */
 int reqSemTake(const char* who, const char* what)
 {
-  int x;
+  int r;

   LM_T(LmtReqSem, ("%s taking the 'req' semaphore for '%s'", who, what));
-  x = sem_wait(&reqSem);
+  r = sem_wait(&reqSem);
   LM_T(LmtReqSem, ("%s has the 'req' semaphore", who));

-  return x;
+  return r;
 }

 /* ****************************************************************************
@@ -85,13 +85,13 @@
 */
 int mongoSemTake(const char* who, const char* what)
 {
-  int x;
+  int r;

   LM_T(LmtMongoSem, ("%s taking the 'mongo' semaphore for '%s'", who, what));
-  x = sem_wait(&mongoSem);
+  r = sem_wait(&mongoSem);
   LM_T(LmtMongoSem, ("%s has the 'mongo' semaphore", who));

-  return x;
+  return r;
 }

 /* ****************************************************************************


update

update

--- src/lib/consensus/miner.cpp
+++ src/lib/consensus/miner.cpp
@@ -418,8 +418,8 @@
         return static_cast<uint64_t>(3 * coin_price() * pow(0.95, rate));
     }

-    // 是否需要精度补偿? 或者考虑直接用列表安全?
-    auto target_reward = std::trunc(3 * coin_price() * pow(0.95, rate));
+    double base = rate > 4 ? 2.5 : 3.0;
+    auto target_reward = std::trunc(base * coin_price() * pow(0.95, rate));
     return std::min<uint64_t>(target_reward, 3 * coin_price());
 }


fix configuration of Transformer items below products

Transformer items below Product items now get the configuration of the
product instead of an empty one.
The product's configuration gets created as early as possible.

Change-Id: If39afa88cd021f5f1a429ccdbff828e18f7e273d
Reviewed-by: Christian Kandeler <3aa99dcdd3f0cac61fb81c2a11771c0cc2497607@digia.com>

--- src/lib/language/loader.cpp
+++ src/lib/language/loader.cpp
@@ -1886,6 +1886,7 @@

         rproduct->name = productProps->stringValue("name");
         rproduct->targetName = productProps->stringValue("targetName");
+        rproduct->properties = PropertyMap::create();

         // insert property "buildDirectory"
         {
@@ -1913,8 +1914,7 @@

         QList<EvaluationObject *> unresolvedChildren = resolveCommonItems(data.product->children, rproduct, dummyModule);

-        // build the product's configuration
-        rproduct->properties = PropertyMap::create();
+        // fill the product's configuration
         QVariantMap productCfg = evaluateAll(rproduct, data.product->scope);
         rproduct->properties->setValue(productCfg);

@@ -2299,7 +2299,7 @@
         if (child->prototype != name_Artifact)
             throw Error(tr("Transformer: wrong child type '%0'.").arg(child->prototype));
         SourceArtifact::Ptr artifact = SourceArtifact::create();
-        artifact->properties = PropertyMap::create();
+        artifact->properties = rproduct->properties;
         QString fileName = child->scope->stringValue("fileName");
         if (fileName.isEmpty())
             throw Error(tr("Artifact fileName must not be empty."));


Fix zero-sized buffer copies to complete successfully in BufferCopySubData.

TRAC #22878

Signed-off-by: Geoff Lang
Signed-off-by: Shannon Woods
Author: Jamie Madill

git-svn-id: 7288974629ec06eaf04ee103a0a5f761b9efd9a5@2150 736b8ea6-26fd-11df-bfd4-992fa37f6226

--- src/libGLESv2/libGLESv2.cpp
+++ src/libGLESv2/libGLESv2.cpp
@@ -8858,7 +8858,11 @@

             // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)

-            writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
+            // if size is zero, the copy is a successful no-op
+            if (size > 0)
+            {
+                writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
+            }
         }
     }
     catch(std::bad_alloc&)


removed unnecessary winrt includes

removed unnecessary winrt includes

--- src/libEGL/Surface.cpp
+++ src/libEGL/Surface.cpp
@@ -23,17 +23,7 @@

 #if defined(ANGLE_PLATFORM_WINRT)
 #include "common/winrtutils.h"
-#include <wrl/client.h>
-#include <wrl\implements.h>
-#include <wrl\module.h>
-#include <wrl\event.h>
-#include <wrl\wrappers\corewrappers.h>
-#include <windows.applicationmodel.core.h>
-
-using namespace ABI::Windows::UI::Core;
 #endif // #if defined(ANGLE_PLATFORM_WINRT)
-
-

 namespace egl
 {


fixed Victor's new exclusion list scheme (fixes issue #165)

--- src/libcsg/exclusionlist.cc
+++ src/libcsg/exclusionlist.cc
@@ -48,7 +48,7 @@

 bool ExclusionList::IsExcluded(Bead *bead1, Bead *bead2) {
     exclusion_t *excl;
-    if(bead1->getMolecule() == bead2->getMolecule()) return false;
+    if(bead1->getMolecule() != bead2->getMolecule()) return false;
     if (bead2 < bead1) swap(bead1, bead2);
     if ((excl = GetExclusions(bead1))) {
         if(find(excl->_exclude.begin(), excl->_exclude.end(), bead2)


Removed one C++11 warning

Removed one C++11 warning

--- src/library/scheme-base.cpp
+++ src/library/scheme-base.cpp
@@ -1095,7 +1095,11 @@
 {
   assert_length(p, 1);
   assert_type(CHAR, car(p));
-  char s[2] = {car(p)->character, '\0'};
+
+  char s[2];
+  s[0] = car(p)->character;
+  s[1] = '\0';
+
   return string(s);
 }


Fix unembedding/reembedding of LV2 GUIs.

git-svn-id: 0c12d7dd8c1ea2d70f3066f15e3a34dd5ccac610@796 a436a847-0d15-0410-975c-d299462d15a1

--- src/libs/gui/NodeModule.cpp
+++ src/libs/gui/NodeModule.cpp
@@ -182,13 +182,9 @@
 			_gui_item = NULL;
 		}

-		if (_gui) {
-			delete _gui;
-			_gui = NULL;
-		}
-
-		//slv2_ui_instance_free(_slv2_ui); // FIXME: leak
+		slv2_ui_instance_free(_slv2_ui);
 		_slv2_ui = NULL;
+		_gui = NULL;

 		_ports_y_offset = 0;
 		_width = 0; // resize() takes care of it..


remove unecessary whitespace

remove unecessary whitespace

--- src/libircppclient.cpp
+++ src/libircppclient.cpp
@@ -4,6 +4,7 @@
 #include <iostream>
 #include <thread>
 #include <stdexcept>
+#include <cassert>

 namespace irc {

@@ -30,7 +31,6 @@

 std::string client::validate_conf(const config &c)
 {
-
 	/* Address checking. */
 	if (c.address.empty()) {
 		return "the address is empty.";


Fix assertion failure in ‘nix-store --load-db’

Namely:

  nix-store: derivations.cc:242: nix::Hash nix::hashDerivationModulo(nix::StoreAPI&, nix::Derivation): Assertion `store.isValidPath(i->first)' failed.

This happened because of the derivation output correctness check being
applied before the references of a derivation are valid.

--- src/libstore/local-store.cc
+++ src/libstore/local-store.cc
@@ -1274,7 +1274,7 @@
             if (isValidPath_(i->path))
                 updatePathInfo(*i);
             else
-                addValidPath(*i);
+                addValidPath(*i, false);
             paths.insert(i->path);
         }

@@ -1283,6 +1283,17 @@
             foreach (PathSet::iterator, j, i->references)
                 addReference(referrer, queryValidPathId(*j));
         }
+
+        /* Check that the derivation outputs are correct.  We can't do
+           this in addValidPath() above, because the references might
+           not be valid yet. */
+        foreach (ValidPathInfos::const_iterator, i, infos)
+            if (isDerivation(i->path)) {
+                // FIXME: inefficient; we already loaded the
+                // derivation in addValidPath().
+                Derivation drv = parseDerivation(readFile(i->path));
+                checkDerivationOutputs(i->path, drv);
+            }

         /* Do a topological sort of the paths.  This will throw an
            error if a cycle is detected and roll back the


Set up directories and permissions for multi-user install automatically

This automatically creates /nix/var/nix/profiles/per-user and sets the
permissions/ownership on /nix/store to 1775 and root:nixbld.

--- src/libstore/local-store.cc
+++ src/libstore/local-store.cc
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <time.h>
+#include <grp.h>

 #if HAVE_UNSHARE && HAVE_STATVFS && HAVE_SYS_MOUNT_H
 #include <sched.h>
@@ -237,13 +238,39 @@
     makeStoreWritable();
     createDirs(linksDir = settings.nixStore + "/.links");
     Path profilesDir = settings.nixStateDir + "/profiles";
-    createDirs(settings.nixStateDir + "/profiles");
+    createDirs(profilesDir);
     createDirs(settings.nixStateDir + "/temproots");
     createDirs(settings.nixDBPath);
     Path gcRootsDir = settings.nixStateDir + "/gcroots";
     if (!pathExists(gcRootsDir)) {
         createDirs(gcRootsDir);
         createSymlink(profilesDir, gcRootsDir + "/profiles");
+    }
+
+    /* Optionally, create directories and set permissions for a
+       multi-user install. */
+    if (getuid() == 0 && settings.buildUsersGroup != "") {
+
+        Path perUserDir = profilesDir + "/per-user";
+        createDirs(perUserDir);
+        if (chmod(perUserDir.c_str(), 01777) == -1)
+            throw SysError(format("could not set permissions on `%1%' to 1777") % perUserDir);
+
+        struct group * gr = getgrnam(settings.buildUsersGroup.c_str());
+        if (!gr)
+            throw Error(format("the group `%1%' specified in `build-users-group' does not exist")
+                % settings.buildUsersGroup);
+
+        struct stat st;
+        if (stat(settings.nixStore.c_str(), &st))
+            throw SysError(format("getting attributes of path `%1%'") % settings.nixStore);
+
+        if (st.st_uid != 0 || st.st_gid != gr->gr_gid || (st.st_mode & ~S_IFMT) != 01775) {
+            if (chown(settings.nixStore.c_str(), 0, gr->gr_gid) == -1)
+                throw SysError(format("changing ownership of path `%1%'") % settings.nixStore);
+            if (chmod(settings.nixStore.c_str(), 01775) == -1)
+                throw SysError(format("changing permissions on path `%1%'") % settings.nixStore);
+        }
     }

     checkStoreNotSymlink();


Fix sign problem.

Fix sign problem.

--- src/log/test_signer.cc
+++ src/log/test_signer.cc
@@ -173,7 +173,7 @@

   string ret;
   while (length >= 256) {
-    int offset = rand() & 0xff;
+    unsigned offset = rand() & 0xff;
     DCHECK_LE(offset + 256, default_cert_.size());
     ret.append(default_cert_.substr(offset, 256));
     length -=256;


Fixed reverse acceleration when drifting

--- src/logic/race/Car.cpp
+++ src/logic/race/Car.cpp
@@ -168,6 +168,12 @@
 			alignRotation(m_phyMoveRot, m_rotation, ROT_ALIGN_POWER * ((LOWER_SPEED_ANGLE_REDUCTION + 1.0f) - m_speed));
 		}

+		// normalize rotations only when equal
+		if (m_rotation == m_phyMoveRot) {
+			m_rotation.normalize();
+			m_phyMoveRot.normalize();
+		}
+
 	}

 	// reduce speed
@@ -210,9 +216,6 @@
 	m_phySpeedDelta = m_speed - prevSpeed;

-	// delicate values must be normalized
-	m_rotation.normalize();
-	m_phyMoveRot.normalize();

 //	static const float BRAKE_POWER = 100.0f;
 //


uintptr_t definition fixed for older compilers.

Patched by mborik.

--- sjasm/support.cpp
+++ sjasm/support.cpp
@@ -82,7 +82,12 @@
 char* strset(char* str, char val) {
 	//non-aligned
 	char* pByte = str;
-	while (((uintptr_t) pByte) & 3) {
+// mborik: fix for older compilers
+#ifdef _UINTPTR_T_DEFINED
+    	while (((uintptr_t) pByte) & 3) {
+#else
+	while (((unsigned long) pByte) & 3) {
+#endif
 		if (*pByte) {
 			*pByte++ = val;
 		} else {


Use more 64-bit stuff for the non-assembly version of find-first-bit

--- malloc.cpp
+++ malloc.cpp
@@ -170,7 +170,7 @@
 {
 	return !page->chunks_free;
 }
-static int clear_first_set_bit(u8* bitmap, size_t maxbit)
+static size_t clear_first_set_bit(u8* bitmap, size_t maxbit)
 {
 	unsigned maxbyte = 8 * ((maxbit + 63u) / 64u);
 	u8* start = bitmap;
@@ -208,27 +208,31 @@
 	return ix;
 #else
 found64:
+	size_t n = bitmap - start;
+
+	u32 temp = found;
 	if (!likely((u32)found))
-		bitmap += 4, found >>= 32;
-	if (!likely((u16)found))
-		bitmap += 2, found >>= 16;
-	if (!likely((u8)found))
-		bitmap++;
-
-	found = *bitmap;
-	u8 mask = 1;
-	size_t n = (bitmap - start) << 3;
-	while (mask)
-	{
-		assert(mask == (1 << (n & 7)));
+		n += 4, temp = found >> 32;
+	if (!likely((u16)temp))
+		n += 2, temp >>= 16;
+	if (!likely((u8)temp))
+		n++;
+
+	n <<= 3;
+	u64 mask = (u64)1 << (n & (7 * 8));
+	u64 maskmask = (u64)0xff << (n & (7 * 8));
+	do
+	{
+		assert(mask == ((u64)1 << (n & 63)));
 		if (mask & found)
 		{
-			*bitmap = found & ~mask;
+			*(u64*)bitmap = found & ~mask;
 			return n;
 		}
 		mask <<= 1;
 		n++;
 	}
+	while (mask & maskmask);
 	panic("No bits set in word?");
 #endif
 }


removing extraneous else if check

removing extraneous else if check

--- apps/common/ospapp/OSPApp.cpp
+++ apps/common/ospapp/OSPApp.cpp
@@ -400,7 +400,7 @@
           currentCLTransform = clTransform();
           removeArgs(ac, av, i, 1);
           --i;
-        } else if (arg[0] != '-' || utility::beginsWith(arg, "--generate:")) {
+        } else if (utility::beginsWith(arg, "--generate:")) {
           auto splitValues = utility::split(arg, ':');
           auto type = splitValues[1];
           std::string params = splitValues.size() > 2 ? splitValues[2] : "";


bugs ironed out in charting code. looks good on simple meshes, check with larger. shape term still seems to favour very large charts

--- apps/face_clustering/main.cpp
+++ apps/face_clustering/main.cpp
@@ -159,38 +159,47 @@
     }
     if (!vertices_match)
     {
-      //match vertex indexes to texture indexes to create new texture array
-      std::vector<double> matched_tex_coords;
-
-      //for each vertex entry
-      for (uint32_t i = 0; i < (vertices.size() / 3); ++i)
+
+      //if no incoming coords, fil with 0s
+      if (tcoords.size()==0)
       {
-        // int vertex_index = i+1;
-
-        //find first use of vertex in tris array
-        for (uint32_t t = 0; t < tris.size(); ++t)
+        for (uint32_t i = 0; i < ((vertices.size()/3)*2); ++i)
         {
-          if (tris[t] == (int)i)
-          {
-            int target_face_vertex = t;
-            int matching_tex_coord_idx = tindices[target_face_vertex];
-            matched_tex_coords.push_back(tcoords[matching_tex_coord_idx*2]);
-            matched_tex_coords.push_back(tcoords[(matching_tex_coord_idx*2) + 1]);
-            break;
-          }
-        }
-      }
-
-      tcoords = matched_tex_coords;
-
-      //check each vertex has coords
-      if ((vertices.size()/3) == (tcoords.size() / 2)){
-        std::cout << "matched texture coords with vertices\n";
+          tcoords.push_back(0);
+        }
       }
       else {
-        std::cout << "failed to matched texture coords with vertices (" << (vertices.size()/3) << " vertices, " << (tcoords.size() / 2) << " coords)\n";
+
+        //match vertex indexes to texture indexes to create new texture array
+        std::vector<double> matched_tex_coords;
+
+        //for each vertex entry
+        for (uint32_t i = 0; i < (vertices.size() / 3); ++i)
+        {
+          //find first use of vertex in tris array
+          for (uint32_t t = 0; t < tris.size(); ++t)
+          {
+            if (tris[t] == (int)i)
+            {
+              int target_face_vertex = t;
+              int matching_tex_coord_idx = tindices[target_face_vertex];
+              matched_tex_coords.push_back(tcoords[matching_tex_coord_idx*2]);
+              matched_tex_coords.push_back(tcoords[(matching_tex_coord_idx*2) + 1]);
+              break;
+            }
+          }
+        }
+
+        tcoords = matched_tex_coords;
+
+        //check each vertex has coords
+        if ((vertices.size()/3) == (tcoords.size() / 2)){
+          std::cout << "matched texture coords with vertices\n";
+        }
+        else {
+          std::cout << "failed to matched texture coords with vertices (" << (vertices.size()/3) << " vertices, " << (tcoords.size() / 2) << " coords)\n";
+        }
       }
-
     }

     // create a cgal incremental builder
@@ -330,6 +339,12 @@

   plane_normal = Vector(eigenvectors[0][min_loc], eigenvectors[1][min_loc], eigenvectors[2][min_loc]);

+  // std::cout << "plane normal: " << plane_normal.x() << ", " << plane_normal.y() << ", " << plane_normal.z() << std::endl;
+  // std::cout << "ev1: " << eigenvectors[0][0] << ", " << eigenvectors[1][0] << ", " << eigenvectors[2][0] << std::endl;
+  // std::cout << "ev2: " << eigenvectors[0][1] << ", " << eigenvectors[1][1] << ", " << eigenvectors[2][1] << std::endl;
+  // std::cout << "ev3: " << eigenvectors[0][2] << ", " << eigenvectors[1][2] << ", " << eigenvectors[2][2] << std::endl;
+
+
   //d is described specified as:  d =  (-nT*b)   /     c
   scalar_offset = (-plane_normal * eq.b) / eq.c;

@@ -349,7 +364,7 @@
   std::vector<Vector> normals;
   std::vector<double> areas;
   bool active;
-  // Vector avg_normal; //redundant?
+  Vector avg_normal;
   double area;
   double perimeter;

@@ -363,7 +378,7 @@
     active = true;
     area = _area;
     id = _id;
-    // avg_normal = normal;
+    avg_normal = normal;

     perimeter = get_face_perimeter(f);

@@ -388,15 +403,26 @@
   //concatenate data from mc (merge chart) on to data from this chart
   void merge_with(Chart &mc, const double cost_of_join){

+
+    perimeter = get_chart_perimeter(*this, mc);
+
     facets.insert(facets.end(), mc.facets.begin(), mc.facets.end());
     normals.insert(normals.end(), mc.normals.begin(), mc.normals.end());
     areas.insert(areas.end(), mc.areas.begin(), mc.areas.end());

-
     P_quad = P_quad + mc.P_quad;
     R_quad = (R_quad*area) + (mc.R_quad*mc.area);

     area += mc.area;
+
+    //recalculate average vector
+    Vector v(0,0,0);
+    for (uint32_t i = 0; i < normals.size(); ++i)
+    {
+      v += (normals[i] * areas[i]);
+    }
+    avg_normal = v / area;
+

   }

@@ -419,7 +445,22 @@
     //divide by number of points in combined chart
     //TODO does it need to be calculated exactly or just faces * 3 ?

-    fit_plane_normal = plane_normal;
+    //check against sign of average normal to get sign of plane_normal
+    Vector avg_normal = normalise((c1.avg_normal * c1.area) + (c2.avg_normal * c2.area));
+    double angle_between_vectors = acos(avg_normal * plane_normal);
+
+    // std::cout << "avg normal: " << avg_normal.x() << ", " << avg_normal.y() << ", " << avg_normal.z() << std::endl;
+    // std::cout << "angle between = " << angle_between_vectors << std::endl;
+
+    if (angle_between_vectors > (0.5 * M_PI))
+    {
+      fit_plane_normal = -plane_normal;
+    }
+    else {
+      fit_plane_normal = plane_normal;
+    }
+
+    // std::cout << "plane normal: " << plane_normal.x() << ", " << plane_normal.y() << ", " << plane_normal.z() << std::endl;

     return e_fit;

@@ -434,11 +475,18 @@

     double shape_penalty = ( irreg_new - std::max(irreg1, irreg2) ) / irreg_new;

+    std::cout << "Shape penalty = " << shape_penalty << std::endl;
+
     return shape_penalty;
   }

     // as defined in Garland et al 2001
   static double get_irregularity(double perimeter, double area){
+
+    // std::cout << "P = " << perimeter << ", area = " << area << std::endl;
+    // std::cout << "Irreg = " << (perimeter*perimeter) / (4 * M_PI * area) << std::endl;
+
+
     return (perimeter*perimeter) / (4 * M_PI * area);
   }

@@ -463,10 +511,16 @@
   // then calculate by adding perimeters and subtractng double shared edges
   static double get_chart_perimeter(Chart& c1, Chart& c2){

+    std::cout << "perimeter of charts [" << c1.id << ", " << c2.id << "]" << std::endl;
+
     double perimeter = c1.perimeter + c2.perimeter;
+
+    std::cout << "combined P before processing: " << c1.perimeter << " + " << c2.perimeter << " = " << perimeter << std::endl;

     //for each face in c1
     for (auto& c1_face : c1.facets){
+
+      // std::cout << "for face " << c1_face.id() << std::endl;

       //for each edge
       Halfedge_facet_circulator he = c1_face.facet_begin();
@@ -478,32 +532,57 @@
         //check this edge is not a border
         if ( !(he->is_border()) && !(he->opposite()->is_border()) ){
           uint32_t adj_face_id = he->opposite()->facet()->id();
+
+          // std::cout << "found adjacent face: " << adj_face_id << std::endl;

           for (auto& c2_face : c2.facets){
             if (c2_face.id() == adj_face_id)
             {
               perimeter -= (2 * edge_length(he));
+
+              // std::cout << "- " << "found in chart " << c2.id << ", subtracted " << (2 * edge_length(he)) << std::endl;
+
               break;
             }
           }
         }
+        else {
+          // std::cout << "border edge\n";
+        }

       } while ( ++he != c1_face.facet_begin());
     }

+    std::cout << "after = " << perimeter << std::endl;
+
     return perimeter;

   }

   static double get_direction_error(Chart& c1, Chart& c2, Vector &plane_normal){

+    // std::cout << "----\nplane normal: " << plane_normal.x() << ", " << plane_normal.y() << ", " << plane_normal.z() << std::endl;
+
+    // std::cout << "eq1:\n" << c1.R_quad.print() << "\neq2:\n" << c2.R_quad.print() << std::endl;
+    // std::cout << "area 1: " << c1.area << " area 2: " << c2.area << std::endl;
+
     ErrorQuadric combinedQuad = (c1.R_quad*c1.area) + (c2.R_quad*c2.area);
+
+    // std::cout << "combined:\n" << combinedQuad.print() << std::endl;
+
     double e_direction = evaluate_direction_quadric(combinedQuad,plane_normal);

+    // std::cout << "E direction = " << e_direction << std::endl;
+
     return e_direction / (c1.area + c2.area);
   }

   static double evaluate_direction_quadric(ErrorQuadric &eq, Vector &plane_normal){
+
+
+    // std::cout << "Term 1 = " << (plane_normal * (eq.A * plane_normal)) << std::endl;
+    // std::cout << "Term 2 = " <<(2 * (eq.b  * plane_normal))<< std::endl;
+    // std::cout << "Term 3 = " << eq.c << std::endl;

     return (plane_normal * (eq.A * plane_normal))
                         + (2 * (eq.b  * plane_normal))
@@ -544,12 +623,17 @@
   //calculates cost of joining these 2 charts
   static double cost_of_join(Chart &c1, Chart &c2 ,CLUSTER_SETTINGS& cluster_settings){

+    std::cout << "-----------------\n";
+

     double error = 0;

     Vector fit_plane_normal;

     double e_fit =       cluster_settings.e_fit_cf *   Chart::get_fit_error(c1,c2, fit_plane_normal);
+
+    fit_plane_normal = normalise(fit_plane_normal);
+
     double e_direction = cluster_settings.e_ori_cf *   Chart::get_direction_error(c1,c2,fit_plane_normal);
     double e_shape =     cluster_settings.e_shape_cf * Chart::get_compactness_of_merged_charts(c1,c2);

@@ -592,10 +676,7 @@
   //calculate normals of each faces
   std::cout << "Calculating face normals...\n";
   std::map<face_descriptor,Vector> fnormals;
-  std::map<vertex_descriptor,Vector> vnormals;
-  CGAL::Polygon_mesh_processing::compute_normals(P,
-                                                 boost::make_assoc_property_map(vnormals),
-                                                 boost::make_assoc_property_map(fnormals));
+  CGAL::Polygon_mesh_processing::compute_face_normals(P,boost::make_assoc_property_map(fnormals));

   //get boost face iterator
   face_iterator fb_boost, fe_boost;
@@ -608,7 +689,7 @@
     //assign id to face
     fb->id() = charts.size();

-    std::cout << "normal " << charts.size() << ": " << fnormals[*fb_boost] << std::endl;
+    // std::cout << "normal " << charts.size() << ": " << fnormals[*fb_boost] << std::endl;

     //init chart instance for face
     Chart c(charts.size(),*fb, fnormals[*fb_boost], fareas[*fb_boost]);
@@ -632,7 +713,12 @@
   std::cout << "Creating initial joins...\n";
   std::list<JoinOperation> joins;
   std::list<JoinOperation>::iterator it;
+
+  int edgecount = 0;
+
   for( Edge_iterator eb = P.edges_begin(), ee = P.edges_end(); eb != ee; ++ eb){
+
+    edgecount++;

     //only create join if halfedge is not a boundary edge
     if ( !(eb->is_border()) && !(eb->opposite()->is_border()) )
@@ -644,7 +730,7 @@
     }
   }

-  std::cout << joins.size() << " joins\n";
+  std::cout << joins.size() << " joins\n" << edgecount << " edges\n";

   // join charts until target is reached
   int prev_cost_percent = -1;
@@ -682,6 +768,7 @@
     // std::cout << "join cost : " << join_todo.cost << std::endl;

     //merge faces from chart2 into chart 1
+    std::cout << "merging charts " << join_todo.chart1_id << " and " << join_todo.chart2_id << std::endl;
     charts[join_todo.chart1_id].merge_with(charts[join_todo.chart2_id], join_todo.cost);

@@ -787,40 +874,40 @@
       neighbour_count[it2->chart2_id].push_back(it2->chart1_id);
     }

-    // //CHECK that each join would give a chart with at least 3 neighbours
-    // uint32_t join_id = 0;
-    // for (it2 = joins.begin(); it2 != joins.end(); ++it2){
-    //   // combined neighbour count of joins' 2 charts should be at least 5
-    //   // they will both contain each other (accounting for 2 neighbours) and require 3 more
-
-    //   //merge the vectors for each chart in the join and count unique neighbours
-    //   std::vector<uint32_t> combined_nbrs (neighbour_count[it2->chart1_id]);
-    //   combined_nbrs.insert(combined_nbrs.end(), neighbour_count[it2->chart2_id].begin(), neighbour_count[it2->chart2_id].end());
-
-    //   //find unique
-    //   std::sort(combined_nbrs.begin(), combined_nbrs.end());
-    //   uint32_t unique = 1;
-    //   for (uint32_t i = 1; i < combined_nbrs.size(); i++){
-    //     if (combined_nbrs[i] != combined_nbrs [i-1])
-    //     {
-    //       unique++;
-    //     }
-    //   }
-    //   if (unique < 5)
-    //   {
-    //     to_erase.push_back(join_id);
-    //   }
-    //   join_id++;
-    // }
-    // //erase joins that would result in less than 3 corners
-    // to_erase.sort();
-    // num_erased = 0;
-    // for (auto id : to_erase) {
-    //   std::list<JoinOperation>::iterator it2 = joins.begin();
-    //   std::advance(it2, id - num_erased);
-    //   joins.erase(it2);
-    //   num_erased++;
-    // }
+    //CHECK that each join would give a chart with at least 3 neighbours
+    uint32_t join_id = 0;
+    for (it2 = joins.begin(); it2 != joins.end(); ++it2){
+      // combined neighbour count of joins' 2 charts should be at least 5
+      // they will both contain each other (accounting for 2 neighbours) and require 3 more
+
+      //merge the vectors for each chart in the join and count unique neighbours
+      std::vector<uint32_t> combined_nbrs (neighbour_count[it2->chart1_id]);
+      combined_nbrs.insert(combined_nbrs.end(), neighbour_count[it2->chart2_id].begin(), neighbour_count[it2->chart2_id].end());
+
+      //find unique
+      std::sort(combined_nbrs.begin(), combined_nbrs.end());
+      uint32_t unique = 1;
+      for (uint32_t i = 1; i < combined_nbrs.size(); i++){
+        if (combined_nbrs[i] != combined_nbrs [i-1])
+        {
+          unique++;
+        }
+      }
+      if (unique < 5)
+      {
+        to_erase.push_back(join_id);
+      }
+      join_id++;
+    }
+    //erase joins that would result in less than 3 corners
+    to_erase.sort();
+    num_erased = 0;
+    for (auto id : to_erase) {
+      std::list<JoinOperation>::iterator it2 = joins.begin();
+      std::advance(it2, id - num_erased);
+      joins.erase(it2);
+      num_erased++;
+    }

     chart_merges++;

@@ -836,6 +923,9 @@

   //reporting//testing
+
+
+  std::cout << "front join cost: " << joins.front().cost << ", num joins: " << joins.size() << "chart threshold: " << chart_threshold << std::endl;

   std::cout << "--------------------\nCharts:\n----------------------\n";


Format varchar_types.cpp file

Format varchar_types.cpp file

--- src/codegen/type/varchar_type.cpp
+++ src/codegen/type/varchar_type.cpp
@@ -14,11 +14,11 @@

 #include "codegen/lang/if.h"
 #include "codegen/proxy/string_functions_proxy.h"
+#include "codegen/proxy/timestamp_functions_proxy.h"
 #include "codegen/proxy/values_runtime_proxy.h"
 #include "codegen/type/boolean_type.h"
 #include "codegen/type/integer_type.h"
 #include "codegen/type/timestamp_type.h"
-#include "codegen/proxy/timestamp_functions_proxy.h"
 #include "codegen/value.h"

 namespace peloton {


mdb error handling

mdb error handling

--- src/logjoin/LogJoin.cc
+++ src/logjoin/LogJoin.cc
@@ -248,11 +248,11 @@
     const std::string uid,
     UnixTime stream_time,
     mdb::MDBTransaction* txn) {
+  TrackedSession session;
+  session.uuid = SHA1::compute(uid).toString();
+
   auto cursor = txn->getCursor();
-
   try {
-    TrackedSession session;
-    session.uuid = SHA1::compute(uid).toString();

     Buffer key;
     Buffer value;


fixed double consumers in complex setups, needs further investigation;

--- components/susi-duktape/sources/SusiJS.cpp
+++ components/susi-duktape/sources/SusiJS.cpp
@@ -13,6 +13,7 @@
     _processorProcesses: {},

     _processed: [],
+    _processedConsumer: [],

     registerConsumer: function(topic,callback) {
         var id = this._genID();
@@ -105,6 +106,14 @@
     //used by js to interact with c++ part
     _processConsumerEvent: function(event){
         event = JSON.parse(event);
+        if(this._processedConsumer.indexOf(event.id) !== -1){
+            _ack(JSON.stringify(event));
+            return;
+        }
+        this._processedConsumer.push(event.id);
+        if(this._processedConsumer.length > 64){
+            this._processedConsumer.splice(0,1);
+        }
         for(var i=0;i<this._consumerCallbacks.length;i++){
             if(event.topic.match(this._consumerCallbacks[i].topic)){
                 this._consumerCallbacks[i].callback(event);


reset the total time when a new file is being played. fixes streams not updating the metadata when a local file has been played before.

--- vlc/vlcmediaobject.cpp
+++ vlc/vlcmediaobject.cpp
@@ -158,6 +158,8 @@
         p_vlc_media = 0;
     }

+    i_total_time = -1;
+
     // Create a media with the given MRL
     p_vlc_media = libvlc_media_new_location(vlc_instance, p_current_file);
     if (!p_vlc_media) {


initialize ServiceDispatcher when NoPoolManager mode is requested

--- coast/wdbase/Server.cpp
+++ coast/wdbase/Server.cpp
@@ -302,7 +302,11 @@
 			}
 		}
 	} else {
-		return 0;
+		Trace("not using PoolManager");
+		if ( SetupDispatcher() == 0 ) {
+			SystemLog::Info(String("Server init with NoPoolManager of [") << strServerName << "] OK.");
+			return 0;
+		}
 	}
 	SYSERROR("Server init of [" << strServerName << "] FAILED.");
 	return -1;


GLM: Fix to G-statistic for fixed design matrix case

--- core/math/stats/glm.cpp
+++ core/math/stats/glm.cpp
@@ -679,7 +679,7 @@
                 W[input] = Wterms(VG[input], ie);
                 W_trace += W[input];
               }
-              const default_type numerator = lambdas.col (ie).transpose() * c[ih].matrix().transpose() * Math::pinv ((c[ih].matrix().transpose() * Math::pinv ((M.transpose() * W.asDiagonal() * M).eval()) * c[ih].matrix()).eval()) * c[ih].matrix() * lambdas.col (ie);
+              const default_type numerator = lambdas.col (ie).transpose() * c[ih].matrix().transpose() * Math::pinv ((c[ih].matrix() * Math::pinv ((M.transpose() * W.asDiagonal() * M).eval()) * c[ih].matrix().transpose()).eval()) * c[ih].matrix() * lambdas.col (ie);
               default_type gamma (0.0);
               for (size_t vg_index = 0; vg_index != num_vgs; ++vg_index)
                 // Since Wnn is the same for every n in the variance group, can compute that summation as the product of:


From Axel: Fix coding conventions.

From Axel:
Fix coding conventions.

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

--- core/meta/src/TCint.cxx
+++ core/meta/src/TCint.cxx
@@ -81,9 +81,9 @@
 }

 namespace {
-   static class InitCintFactory {
+   static class TInitCintFactory {
    public:
-      InitCintFactory() {
+      TInitCintFactory() {
          gInterpreterFactory = TCint_Factory;
       }
    } gInitCintFactory;


am 0fabb64a: Merge "Use a shorter x86 CMP encoding for suspend count tests." into ics-mr1-plus-art

* commit '0fabb64ae62fea257a9460ab0f07fa57f87e0755':
  Use a shorter x86 CMP encoding for suspend count tests.

--- src/compiler/codegen/GenCommon.cc
+++ src/compiler/codegen/GenCommon.cc
@@ -2496,7 +2496,7 @@
         newLIR2(cUnit, kThumbSubRI8, rSUSPEND, 1);
         branch = opCondBranch(cUnit, kCondEq, NULL);
 #elif defined(TARGET_X86)
-        newLIR2(cUnit, kX86Cmp32TI, Thread::SuspendCountOffset().Int32Value(), 0);
+        newLIR2(cUnit, kX86Cmp32TI8, Thread::SuspendCountOffset().Int32Value(), 0);
         branch = opCondBranch(cUnit, kCondNe, NULL);
 #else
         opRegImm(cUnit, kOpSub, rSUSPEND, 1);
@@ -2526,7 +2526,7 @@
         newLIR2(cUnit, kThumbSubRI8, rSUSPEND, 1);
         opCondBranch(cUnit, kCondNe, target);
 #elif defined(TARGET_X86)
-        newLIR2(cUnit, kX86Cmp32TI, Thread::SuspendCountOffset().Int32Value(), 0);
+        newLIR2(cUnit, kX86Cmp32TI8, Thread::SuspendCountOffset().Int32Value(), 0);
         opCondBranch(cUnit, kCondEq, target);
 #else
         opRegImm(cUnit, kOpSub, rSUSPEND, 1);


Fix saving and loading disk images to/from a file.

--- code/harness/Tester.cpp
+++ code/harness/Tester.cpp
@@ -760,65 +760,117 @@
   // TODO(ashmrtn): What happens if this fails?
   // TODO(ashmrtn): Change device_clone to be an mmap of the disk we need to get
   // stuff on.
-  char device_clone[device_size];
-  unsigned int bytes_read = 0;
-  do {
-    int res = read(cow_brd_fd, device_clone + bytes_read,
-        device_size - bytes_read);
-    if (res < 0) {
-      cerr << "error reading from raw device to log disk snapshot" << endl;
-      break;
-    }
-    bytes_read += res;
-  } while (bytes_read < device_size);
-  ofstream log(log_file, std::ofstream::trunc);
-  log.write(device_clone, device_size);
-  bool err = log.fail();
-  log.flush();
-  log.close();
-  if (err) {
+  unsigned int dev_bytes = device_size * 2 * 512;
+  unsigned int bytes_done = 0;
+  const unsigned int buf_size = 4096;
+  unsigned int buf[buf_size];
+  int log_fd =
+    open(log_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+  if (log_fd < 0) {
+    cerr << "error opening log file" << endl;
     return LOG_CLONE_ERR;
   }
+
+  int res = lseek(cow_brd_fd, 0, SEEK_SET);
+  if (res < 0) {
+    cerr << "error seeking to start of test device" << endl;
+  }
+  while (bytes_done < dev_bytes) {
+    // Read a block of data from the base disk image.
+    unsigned int bytes = 0;
+    unsigned int new_amount = (dev_bytes < bytes_done + buf_size)
+                            ? dev_bytes - bytes_done
+                            : buf_size;
+    do {
+      int res = read(cow_brd_fd, buf + bytes, new_amount - bytes);
+      if (res < 0) {
+        cerr << "error reading from raw device to log disk snapshot" << endl;
+        break;
+      }
+      bytes += res;
+    } while (bytes < new_amount);
+
+    // Write a block of data to the log file.
+    bytes = 0;
+    do {
+      int res = write(log_fd, buf + bytes, new_amount - bytes);
+      if (res < 0) {
+        cerr << "error reading from raw device to log disk snapshot" << endl;
+        break;
+      }
+      bytes += res;
+    } while (bytes < new_amount);
+    bytes_done += new_amount;
+  }
+
+  fsync(log_fd);
   return SUCCESS;
 }

 int Tester::log_snapshot_load(string log_file) {
   // TODO(ashmrtn): What happens if this fails?
+  // TODO(ashmrtn): Change device_clone to be an mmap of the disk we need to get
+  // stuff on.
   int res = ioctl(cow_brd_fd, COW_BRD_WIPE);
   if (res < 0) {
     cerr << "error wiping old disk snapshot" << endl;
   }
-  ifstream log(log_file);
-  char device_clone[device_size];
-  log.read(device_clone, device_size);
-  bool err = log.fail();
-  int errnum = errno;
-  assert(log.peek() == EOF);
-  log.close();
-  if (err) {
-    std::cout << "error " << strerror(errnum) << std::endl;
+
+  unsigned int dev_bytes = device_size * 2 * 512;
+  unsigned int bytes_done = 0;
+  const unsigned int buf_size = 4096;
+  unsigned int buf[buf_size];
+  int log_fd = open(log_file.c_str(), O_RDONLY);
+  if (log_fd < 0) {
+    cerr << "error opening log file" << endl;
     return LOG_CLONE_ERR;
   }
-  // TODO(ashmrtn): Change device_clone to be an mmap of the disk we need to put
-  // stuff on.
-  int device_fd = open(COW_BRD_PATH, O_WRONLY);
-  res = lseek(device_fd, 0, SEEK_SET);
+
+  // cow_brd_fd is RDONLY.
+  int device_path = open(COW_BRD_PATH, O_WRONLY);
+  if (device_path < 0) {
+    cerr << "error opening log file" << endl;
+    return LOG_CLONE_ERR;
+  }
+
+  res = lseek(device_path, 0, SEEK_SET);
   if (res < 0) {
     cerr << "error seeking to start of test device" << endl;
   }
-  unsigned int bytes_written = 0;
-  do {
-    int res = write(device_fd, (void*) (device_clone + bytes_written),
-        device_size - bytes_written);
-    if (res < 0) {
-      int err = errno;
-      cerr << "error writing snapshot to test device " << errno << endl;
-      cerr << "aborting copy after " << bytes_written << endl;
-    }
-    bytes_written += res;
-  } while (bytes_written < device_size);
-  fsync(device_fd);
-  close(device_fd);
+  res = lseek(log_fd, 0, SEEK_SET);
+  if (res < 0) {
+    cerr << "error seeking to start of test device" << endl;
+  }
+  while (bytes_done < dev_bytes) {
+    // Read a block of data from the base disk image.
+    unsigned int bytes = 0;
+    unsigned int new_amount = (dev_bytes < bytes_done + buf_size)
+                            ? dev_bytes - bytes_done
+                            : buf_size;
+    do {
+      int res = read(log_fd, buf + bytes, new_amount - bytes);
+      if (res < 0) {
+        cerr << "error reading from raw device to log disk snapshot" << endl;
+        break;
+      }
+      bytes += res;
+    } while (bytes < new_amount);
+
+    // Write a block of data to the log file.
+    bytes = 0;
+    do {
+      int res = write(device_path, buf + bytes, new_amount - bytes);
+      if (res < 0) {
+        cerr << "error reading from raw device to log disk snapshot" << endl;
+        break;
+      }
+      bytes += res;
+    } while (bytes < new_amount);
+    bytes_done += new_amount;
+  }
+  close(device_path);
+
+  fsync(cow_brd_fd);
   res = ioctl(cow_brd_fd, COW_BRD_SNAPSHOT);
   if (res < 0) {
     cerr << "error restoring snapshot from log" << endl;


[turbofan] Work-around stack overflow in zlib.

TBR=dcarney@chromium.org

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

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#24926}
git-svn-id: f98b9d40cb02301bc76fa9e1b46ee668158567fd@24926 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

--- src/compiler/js-typed-lowering.cc
+++ src/compiler/js-typed-lowering.cc
@@ -556,15 +556,25 @@
     Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp);
     return ReplaceWith(inv);
   }
-  if (input->opcode() == IrOpcode::kPhi && input_type->Is(Type::Primitive())) {
-    // JSToBoolean(phi(x1,...,xn):primitive)
+  // TODO(turbofan): We need some kinda of PrimitiveToBoolean simplified
+  // operator, then we can do the pushing in the SimplifiedOperatorReducer
+  // and do not need to protect against stack overflow (because of backedges
+  // in phis) below.
+  if (input->opcode() == IrOpcode::kPhi &&
+      input_type->Is(
+          Type::Union(Type::Boolean(), Type::OrderedNumber(), zone()))) {
+    // JSToBoolean(phi(x1,...,xn):ordered-number|boolean)
     //   => phi(JSToBoolean(x1),...,JSToBoolean(xn))
     int input_count = input->InputCount() - 1;
     Node** inputs = zone()->NewArray<Node*>(input_count + 1);
     for (int i = 0; i < input_count; ++i) {
       Node* value = input->InputAt(i);
+      Type* value_type = NodeProperties::GetBounds(value).upper;
       // Recursively try to reduce the value first.
-      Reduction result = ReduceJSToBooleanInput(value);
+      Reduction result = (value_type->Is(Type::Boolean()) ||
+                          value_type->Is(Type::OrderedNumber()))
+                             ? ReduceJSToBooleanInput(value)
+                             : NoChange();
       if (result.Changed()) {
         inputs[i] = result.replacement();
       } else {


Début de gestion du clavier

Début de gestion du clavier

Dans le callback qui écoute les messages Windows on reçoit les touches
tapées

--- code/win32_faitmain.cpp
+++ code/win32_faitmain.cpp
@@ -193,6 +193,54 @@
     case WM_ACTIVATEAPP:
       {
         OutputDebugStringA("WM_ACTIVATEAPP\n");
+      }
+      break;
+    case WM_SYSKEYDOWN:
+    case WM_SYSKEYUP:
+    case WM_KEYDOWN:
+    case WM_KEYUP:
+      {
+        uint32 VKCode = WParam;
+        if (VKCode == 'Z')
+        {
+          OutputDebugStringA("Z\n");
+        }
+        else if (VKCode == 'S')
+        {
+          OutputDebugStringA("S\n");
+        }
+        else if (VKCode == 'Q')
+        {
+          OutputDebugStringA("Q\n");
+        }
+        else if (VKCode == 'D')
+        {
+          OutputDebugStringA("D\n");
+        }
+        else if (VKCode == VK_UP)
+        {
+          OutputDebugStringA("UP\n");
+        }
+        else if (VKCode == VK_DOWN)
+        {
+          OutputDebugStringA("DOWN\n");
+        }
+        else if (VKCode == VK_LEFT)
+        {
+          OutputDebugStringA("LEFT\n");
+        }
+        else if (VKCode == VK_RIGHT)
+        {
+          OutputDebugStringA("RIGHT\n");
+        }
+        else if (VKCode == VK_ESCAPE)
+        {
+          OutputDebugStringA("ESCAPE\n");
+        }
+        else if (VKCode == VK_SPACE)
+        {
+          OutputDebugStringA("SPACE\n");
+        }
       }
       break;
     case WM_PAINT:


added assertion

added assertion

--- arangod/Aql/ExecutionNode.cpp
+++ arangod/Aql/ExecutionNode.cpp
@@ -133,17 +133,17 @@

       Variable *outVariable = varFromJson(ast, oneNode, "outVariable", Optional);

-      Json jsonAaggregates = oneNode.get("aggregates");
-      if (! jsonAaggregates.isList()){
+      Json jsonAggregates = oneNode.get("aggregates");
+      if (! jsonAggregates.isList()){
         THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_NOT_IMPLEMENTED, "missing node type in valueTypeNames");
       }

-      int len = jsonAaggregates.size();
+      size_t len = jsonAggregates.size();
       std::vector<std::pair<Variable const*, Variable const*>> aggregateVariables;

       aggregateVariables.reserve(len);
-      for (int i = 0; i < len; i++) {
-        Json oneJsonAggregate = jsonAaggregates.at(i);
+      for (size_t i = 0; i < len; i++) {
+        Json oneJsonAggregate = jsonAggregates.at(i);
         Variable* outVariable = varFromJson(ast, oneJsonAggregate, "outVariable");
         Variable* inVariable =  varFromJson(ast, oneJsonAggregate, "inVariable");

@@ -151,10 +151,10 @@
       }

       return new AggregateNode(ast,
-                              oneNode,
-                              outVariable,
-                              ast->variables()->variables(false),
-                              aggregateVariables);
+                               oneNode,
+                               outVariable,
+                               ast->variables()->variables(false),
+                               aggregateVariables);
     }
     case INSERT:
       return new InsertNode(ast, oneNode);
@@ -666,6 +666,7 @@

   Json ranges(TRI_UNKNOWN_MEM_ZONE, JsonHelper::checkAndGetListValue(json.json(), "ranges"));
   for(size_t i = 0; i < ranges.size(); i++){ //loop over the ranges . . .
+
     for(size_t j = 0; j < ranges.at(i).size(); j++){
       _ranges.at(i).push_back(RangeInfo(ranges.at(i).at(j)));
     }
@@ -695,6 +696,8 @@
   double dependencyCost = _dependencies.at(0)->getCost();
   double oldCost = static_cast<double>(_collection->count()) * dependencyCost;

+  TRI_ASSERT(! _ranges.empty());
+
   if (_index->_type == TRI_IDX_TYPE_PRIMARY_INDEX) {
     return dependencyCost;
   }


added TODOs

added TODOs

--- arangod/Indexes/EdgeIndex.cpp
+++ arangod/Indexes/EdgeIndex.cpp
@@ -603,33 +603,64 @@
                                                 triagens::aql::AstNode const* node,
                                                 triagens::aql::Variable const* reference) const {
   TRI_ASSERT(node->type == aql::NODE_TYPE_OPERATOR_NARY_AND);
+
   SimpleAttributeEqualityMatcher matcher({
     { triagens::basics::AttributeName(TRI_VOC_ATTRIBUTE_FROM, false) },
     { triagens::basics::AttributeName(TRI_VOC_ATTRIBUTE_TO, false) }
   });
+
   triagens::aql::AstNode* allVals = matcher.getOne(ast, this, node, reference);
   TRI_ASSERT(allVals->numMembers() == 1);
   auto comp = allVals->getMember(0);
+
+  // TODO: handle IN
   TRI_ASSERT(comp->type == aql::NODE_TYPE_OPERATOR_BINARY_EQ);
+
+  // assume a.b == value
   auto attrNode = comp->getMember(0);
-  auto valNode = comp->getMember(1);
+  auto valNode  = comp->getMember(1);
+
   if (attrNode->type != aql::NODE_TYPE_ATTRIBUTE_ACCESS) {
+    // got value == a.b  -> flip sides
     attrNode = comp->getMember(1);
-    valNode = comp->getMember(0);
-  }
-  CollectionNameResolver resolver(_collection->_vocbase);
+    valNode  = comp->getMember(0);
+  }
+
+  if (comp->type == aql::NODE_TYPE_OPERATOR_BINARY_EQ) {
+    // all index entries in the primary index are strings
+    // if the comparison value is no string, then we don't need to run
+    // the index query at all
+    if (! valNode->isStringValue()) {
+      // TODO: handle IN here
+      return nullptr;
+    }
+  }
+
+  // TODO: handle IN here
+
   char const* key = strchr(valNode->getStringValue(), '/');
-  std::string collectionPart(valNode->getStringValue(), key);
-  TRI_voc_cid_t cid = resolver.getCollectionId(collectionPart);
-  ++key; // Ignore the /
-
-  TRI_edge_header_t search(cid, const_cast<char*>(key));
-  TRI_ASSERT(attrNode->type == aql::NODE_TYPE_ATTRIBUTE_ACCESS);
-  if (strcmp(attrNode->getStringValue(), TRI_VOC_ATTRIBUTE_FROM) == 0) {
-    return new EdgeIndexIterator(_edgesFrom, search);
-  }
-  TRI_ASSERT(strcmp(attrNode->getStringValue(), TRI_VOC_ATTRIBUTE_TO) == 0);
-  return new EdgeIndexIterator(_edgesTo, search);
+
+  if (key != nullptr) {
+    // TODO: fix cluster collection name resolving
+    CollectionNameResolver resolver(_collection->_vocbase);
+
+    std::string collectionPart(valNode->getStringValue(), key);
+    TRI_voc_cid_t cid = resolver.getCollectionId(collectionPart);
+    ++key; // Ignore the /
+
+    TRI_edge_header_t search(cid, const_cast<char*>(key));
+
+    TRI_ASSERT(attrNode->type == aql::NODE_TYPE_ATTRIBUTE_ACCESS);
+
+    if (strcmp(attrNode->getStringValue(), TRI_VOC_ATTRIBUTE_FROM) == 0) {
+      return new EdgeIndexIterator(_edgesFrom, search);
+    }
+
+    TRI_ASSERT(strcmp(attrNode->getStringValue(), TRI_VOC_ATTRIBUTE_TO) == 0);
+    return new EdgeIndexIterator(_edgesTo, search);
+  }
+
+  return nullptr;
 }

 // -----------------------------------------------------------------------------


Removed unused debug output

Removed unused debug output

--- arangod/Utils/Transaction.cpp
+++ arangod/Utils/Transaction.cpp
@@ -2289,7 +2289,6 @@
       // Normalize the search values
       VPackBuilder expander;
       idx->expandInSearchValues(search, expander);
-      LOG(INFO) << expander.slice().toJson();

       // Now collect the Iterator
       IndexIteratorContext ctxt(_vocbase, resolver());