Quellcode durchsuchen

Small fixes and code refactoring to work with the switch bug found and somehow fixed now.

mingodad vor 12 Jahren
Ursprung
Commit
c3eaa1ba81

+ 5 - 7
SquiLu-ourbiz/happyhttp.nut

@@ -140,13 +140,11 @@ class HappyHttpConnection {
 		if( !datawaiting( m_Sock, milisec) ) return;	// recv will block
 
 		local rc = m_Sock.receive(8192); //2048
-		switch(rc[1]){
-			case socket.IO_DONE:
-			case socket.IO_TIMEOUT:
+		local rc_status = rc[1];
+		if( (rc_status == socket.IO_DONE) || rc_status == socket.IO_TIMEOUT) {
 			//case socket.IO_CLOSED:
-				break;
-			default:
-				if(rc[0].len() == 0) throw(format("socket io error %d", rc[1]));
+		} else {
+			if(rc[0].len() == 0) throw(format("socket io error %d", rc_status));
 		}
 		local buf = rc[0];
 		local a = buf.len();
@@ -421,7 +419,7 @@ class HappyHttpResponse {
 				data_idx += bytesused;
 				count -= bytesused;
 			}
-			//os.sleep(0.001);
+			//os.sleep(1);
 		}
 		// return number of bytes used
 		return datasize - count;

+ 1 - 1
SquiLu-ourbiz/ourbiz-client.nut

@@ -170,7 +170,7 @@ class HTTPConnAuthBase extends HTTPConnBase
                 {
                     if(globals.rawget("Fl", false)) Fl.check();//check_idle();
                     pump();
-		    //os.sleep(0.01);
+		    //os.sleep(10);
                 }
                 break;
             }

+ 8 - 7
SquiLu-ourbiz/ourbiz-fltk.nut

@@ -385,9 +385,10 @@ class Base_Window extends Fl_Window {
 	function handle(event){
 		if(event == FL_KEYBOARD && Fl.event_command() == 0){
 			local key = Fl.event_key();
-			switch(key){
-				//case FL_Menu:  menu_bar_navigate();break;
-				case FL_F+1: show_help_window(); break;
+			if(key == (FL_F+1)){
+				show_help_window();
+			} else if(key == FL_Menu){
+				//menu_bar_navigate();
 			}
 		}
 		return base.handle(event);
@@ -2992,12 +2993,12 @@ class MyEditOrderWindow extends EditOrderWindow {
 			local key = Fl.event_key();
 			switch(key)
 			{
-			case FL_F+5:
+			case FL_F5:
 				show_dynamic_data(_tr("Entity past products"),
 					appServer.entity_past_products_list,
 					db_orders_entity_id->value());
 			break;
-			case FL_F+6:
+			case FL_F6:
 			if(grid_lines->row() >=0)
 			{
 				show_dynamic_data(_tr("Product last 20 order lines"),
@@ -3006,7 +3007,7 @@ class MyEditOrderWindow extends EditOrderWindow {
 						grid_lines->row(), 1));
 			}
 			break;
-			case FL_F+7:
+			case FL_F7:
 			if(grid_lines->row() >=0)
 			{
 				show_dynamic_data(_tr("Appear together"),
@@ -3015,7 +3016,7 @@ class MyEditOrderWindow extends EditOrderWindow {
 						grid_lines->row(), 1));
 			}
 			break;
-			case FL_F+8:
+			case FL_F8:
 			if(grid_lines->row() >=0)
 			{
 				show_dynamic_data(_tr("Order lines onhand"),

+ 13 - 21
SquiLu-ourbiz/ourbiz.nut

@@ -302,27 +302,19 @@ local function get_sql_bar_chart_statistics_periodes (periode_count, periode_typ
 	local periodeMultiplier = 1;
 	local speriode;
 
-	switch(periode_type){
-		case TimePeriode.is_years:{
-			speriode2 = "%Y";
-			speriode = C_years;
-		}
-		break;
-		case TimePeriode.is_weeks:{
-			periodeMultiplier = 7;
-			speriode2 = "%Y-%W";
-			speriode = C_days;
-		}
-		break;
-		case TimePeriode.is_days:{
-			speriode2 = "%Y-%m-%d";
-			speriode = C_days;
-		}
-		break;
-		default:{
-			speriode2 = "%Y-%m";
-			speriode = C_months;
-		}
+	if(periode_type == TimePeriode.is_years) {
+		speriode2 = "%Y";
+		speriode = C_years;
+	} else if(periode_type ==  TimePeriode.is_weeks) {
+		periodeMultiplier = 7;
+		speriode2 = "%Y-%W";
+		speriode = C_days;
+	}else if(periode_type ==  TimePeriode.is_days) {
+		speriode2 = "%Y-%m-%d";
+		speriode = C_days;
+	} else {
+		speriode2 = "%Y-%m";
+		speriode = C_months;
 	}
 
 	periode_count = periode_count * periodeMultiplier;

+ 1 - 1
SquiLu-ourbiz/s/ourbiz/index.html

@@ -254,7 +254,7 @@ input[type=checkbox]:focus + label, input[type=radio]:focus + label {
 
 </head>
 <body>
-<script language="javascript">
+<script type="text/javascript">
 if(dad.isIE) alert("Sorry but this application is not yet supported on Internet Explorer\nPlease try again with Firefox, Opera, Chrome.");
 </script>
 <div id="logShow"></div>

+ 1 - 0
SquiLu-ourbiz/sq-server.nut

@@ -64,6 +64,7 @@ local mongoose_start_params = {
 		debug_print("done user_callback_exit\n");
 	},
 	user_callback = function(event, request){
+		//debug_print("\nevent :\n", event);
 		if(event == "MG_NEW_REQUEST"){
 			//debug_print("\n", request.get_option("num_threads"), request.get_conn_buf());
 			if(AT_DEV_DBG || !this.get("handle_request", false)) {

+ 10 - 6
SquiLu/Makefile-SquiLu

@@ -1,6 +1,7 @@
 
 #INC =  -Iinclude -Isqstdlib -I../myaxtls -I../discount -I/usr/include/postgresql -I/usr/lib/jvm/default-java/include -I/usr/lib/llvm-3.1/include -I../SquiLu-ext/threadObject -I..
-INC =  -Iinclude -Isqstdlib -I../myaxtls -I../discount -I..
+#INC =  -Iinclude -Isqstdlib -I../myaxtls -I../discount -I..
+INC =  -Iinclude -Isqstdlib -I../discount -I../gumbo -I..
 #CFLAGS =  -Wall -fno-strict-aliasing -DSQ_JIT_LLVM44=1 -D_DEBUG_DUMP33=1 -DWITH_DAD_EXTRAS=1 -DSQ_SUBLATIN=1 -DNEED_SUBLATIN_C2=1 -DSQUSEDOUBLE=1 -DSQUSEDECIMAL642=1 -DNO_EXCEPTION_KEY_NOT_FOUND0=1 -D_SQ642=1 -DNO_GARBAGE_COLLECTOR00=1 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_DEFAULT_AUTOVACUUM=1 -DSQLITE_DEFAULT_FOREIGN_KEYS=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_EXTENSION_FUNCTIONS=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_STAT3=1 -DSQLITE_HAS_CODEC=1 -DSQLITE_OMIT_TCL_VARIABLE=1 -DSQLITE_USE_URI=1 -DSQLITE_SOUNDEX=1 -DNO_POPEN=1 -DNO_SSL_DL=1 -DHAVE_STDINT=1 -DUSE_AXTLS=1 -DUSE_AXTLS_ON_MEMORY=1 -D_FILE_OFFSET_BITS=64 -DSSL_STATIC_LIBRARY=1 -DPDF_USING_ZLIB=1 -DRS232_STATIC=1
 CFLAGS = $(INC) -O3 -Wall -fno-strict-aliasing -DNDEBUG -DWITH_DAD_EXTRAS=1 -DSQ_SUBLATIN=1 \
 	-DSQUSEDOUBLE=1  -D_SQ642=1 \
@@ -10,14 +11,17 @@ CFLAGS = $(INC) -O3 -Wall -fno-strict-aliasing -DNDEBUG -DWITH_DAD_EXTRAS=1 -DSQ
 	-DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 \
 	-DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_STAT3=1 -DSQLITE_HAS_CODEC=1 \
 	-DSQLITE_OMIT_TCL_VARIABLE=1 -DSQLITE_USE_URI=1 -DSQLITE_SOUNDEX=1 \
-	-DNO_POPEN=1 -DNO_SSL_DL=1 -DHAVE_STDINT=1 -DUSE_AXTLS=1 \
+	-DNO_POPEN=1 -DNO_SSL_DL2=1 -DHAVE_STDINT=1 -DUSE_AXTLS2=1 -DNO_SSL2=1\
 	-DUSE_AXTLS_ON_MEMORY=1 -D_FILE_OFFSET_BITS=64 \
-	-DSSL_STATIC_LIBRARY=1 -DPDF_USING_ZLIB=1 -DRS232_STATIC=1
+	-DSSL_STATIC_LIBRARY=1 -DPDF_USING_ZLIB=1 -DRS232_STATIC=1 \
+	-DUSE_SIGNAL_HANDLER=1
 
 RESINC = 
-LIBDIR =  -Llib -L../myaxtls -L../mpdecimal -L../discount
+#LIBDIR =  -Llib -L../myaxtls -L../mpdecimal -L../discount
+LIBDIR =  -Llib -L../mpdecimal -L../discount -L../gumbo
 LIB =  -lm
-LDFLAGS =  -lpthread -lrt -ldl -laxtls -lmpdecimal -ldiscount -lz
+#LDFLAGS =  -lpthread -lrt -ldl -laxtls -lmpdecimal -ldiscount -lz
+LDFLAGS =  -lpthread -lrt -ldl -lmpdecimal -ldiscount -lgumbo -lz
 CC = gcc
 CXX = g++
 
@@ -33,7 +37,7 @@ SOURCES=  sq/sq.c  sqstdlib/sqstdaux.cpp  sqstdlib/sqstdblob.cpp  sqstdlib/sqstd
 	../SquiLu-ext/sq_rs232.c  ../SquiLu-ext/sq_slave_vm.cpp  \
 	../SquiLu-ext/sq_socket.cpp  ../SquiLu-ext/sq_sqlite3.cpp  \
 	../SquiLu-ext/sq_tinyxml2.cpp  ../SquiLu-ext/sq_zlib.cpp  \
-	../SquiLu-ext/tinyxml2.cpp  \
+	../SquiLu-ext/tinyxml2.cpp ../SquiLu-ext/sq_gumbo.cpp  \
 	squirrel/lua-regex.c  squirrel/sqdebug.cpp  squirrel/sqapi.cpp  \
 	squirrel/sqbaselib.cpp  squirrel/sqclass.cpp  squirrel/sqcompiler.cpp  \
 	squirrel/sqfuncstate.cpp  squirrel/sqlexer.cpp  squirrel/sqmem.cpp  \

+ 3 - 2
SquiLu/samples/test-socket-unix-client.nut

@@ -1,7 +1,8 @@
+local socket_name = "/tmp/foo";
 local client = socket.unix();
-client.connect("/tmp/foo");
+client.connect(socket_name);
 //while (true) {
     local c = stdin.readn('c');
     client.send(c + " : Hello !\n");
 //}
-client.close();
+client.close();

+ 6 - 5
SquiLu/samples/test-socket-unix-server.nut

@@ -10,16 +10,17 @@ print(server);
 server.listen();
 local c = server.accept();
 print(c);
-//while(true) {
+while(true) {
   try {
-	local resp = c.receive();
-	print(resp[0], resp[1]);
+	local rc = c.receive();
+	if(rc[1]) break;
+	print(rc[0], rc[1]);
   }
    catch(e){
 	print(e);
-	//break;
+	break;
   }
-//}
+}
 c.close();
 server.close();
 os.remove(socket_name);

+ 17 - 0
SquiLu/samples/test-switch.nut

@@ -0,0 +1,17 @@
+local n = 10;
+local b = 10;
+
+for(local i=0; i < 5; ++i) {
+	print(i, n, b);
+	switch(n) {
+		case 1:
+			print(n);
+		break;
+		case -2:
+			print(n);
+		break;
+		case 10:
+			print(n);
+		break;
+	}
+}