Sfoglia il codice sorgente

Because of the change on vargv for the main script, this scripts are updated to work with it.

mingodad 13 anni fa
parent
commit
5152b724b7

+ 2 - 2
SquiLu-ourbiz/fluid2SquiLu.nut

@@ -666,7 +666,7 @@ function WriteScript(tree){
 
 function DecodeOption(arg){
 	local config = {};
-	for(local i=0, len=arg.len(); i < len; i +=2){
+	for(local i=1, len=arg.len(); i < len; i +=2){
 		if (arg[i].slice(0,1) != "-") {
 			local ar = [config];
 			for(local iv = i, ivlen = arg.len(); iv < ivlen; ++iv) ar.push(arg[iv]);
@@ -709,7 +709,7 @@ function Fluid2SquiLu(infile, outfile, config){
 	return outdata;
 }
 
-if (vargv.len() > 0){ 
+if (vargv.len() > 1){ 
 	local rc = DecodeOption(vargv);
 	local config = rc[0], infile = rc[1], outfile = rc.get(2, "-"); 
 	Fluid2SquiLu(infile, outfile, config);

+ 2 - 0
SquiLu-ourbiz/ourbiz-fltk.nut

@@ -7,6 +7,8 @@
 local WIN32 = os.getenv("WINDIR") != null
 socket.open();
 
+//foreach(i, arg in vargv) print(i, arg);
+
 dofile("ourbiz-client.nut");
 dofile("db-updater.nut");
 local appServer = AppServer.getAppServer();

+ 4 - 4
SquiLu-ourbiz/squilufreeze.nut

@@ -38,14 +38,14 @@ function Usage(){
 // The main() program to run
 function main(){
 
-    if ( vargv.len() != 3) {
+    if ( vargv.len() != 4) {
         Usage();
         return;
     }
 
-    local in_squiluFreeze  = vargv[0];
-    local in_squiluScript  = vargv[1];
-    local out_squiluFreeze = vargv[2];
+    local in_squiluFreeze  = vargv[1];
+    local in_squiluScript  = vargv[2];
+    local out_squiluFreeze = vargv[3];
 
     if (!FileExists(in_squiluFreeze)) {
         printf("Input squiluFreeze program '%s' does not exist! Aborting.\n", in_squiluFreeze);

+ 3 - 3
SquiLu-ourbiz/unify-code.nut

@@ -17,9 +17,9 @@ function unify_code(fname){
 
 //print(unify_code("ourbiz-fltk.nut"));
 
-if (vargv.len() > 0){ 
-	local infile = vargv[0], outfile = "-";
-	if(vargv.len() > 1) outfile = vargv[1];
+if (vargv.len() > 1){ 
+	local infile = vargv[1], outfile = "-";
+	if(vargv.len() > 2) outfile = vargv[2];
 	local unified = unify_code(infile);
 	if(outfile == "-") print(unified);
 	else

+ 2 - 2
SquiLu/samples/array.nut

@@ -5,8 +5,8 @@
 */
 local n, i, k;
 
-if(vargv.len()!=0) {
-   n = vargv[0].tointeger();
+if(vargv.len() > 1) {
+   n = vargv[1].tointeger();
   if(n < 1) n = 1;
 } else {   
   n = 1;

+ 4 - 4
SquiLu/samples/axssl.nut

@@ -47,7 +47,7 @@
 
 local vargv_len = vargv.len();
 // print version?
-if (vargv_len == 1 && vargv[0] == "version"){
+if (vargv_len == 2 && vargv[1] == "version"){
     print("axssl.nut " + axtls.ssl_version());
     os.exit(1);
 }
@@ -508,11 +508,11 @@ function display_session_id(ssl){
 // Main entry point. Doesn't do much except works out whether we are a client
 // or a server.
 //
-if (vargv_len == 0 || (vargv[0] != "s_server" && vargv[0] != "s_client")){
-    print_options(vargv_len > 0 && vargv[0] || "");
+if (vargv_len == 1 || (vargv[1] != "s_server" && vargv[1] != "s_client")){
+    print_options(vargv_len > 1 && vargv[1] || "");
 }
 
 local build_mode = axtls.get_config(axtls.SSL_BUILD_MODE);
-local xx = vargv[0] == "s_server" && do_server(build_mode) || do_client(build_mode);
+local xx = vargv[1] == "s_server" && do_server(build_mode) || do_client(build_mode);
 os.exit(0);
 

+ 1 - 1
SquiLu/samples/fibonacci.nut

@@ -10,6 +10,6 @@ function fib(n)
     return fib(n-2) + fib(n-1) 
 }
 
-local n = vargv.len()!=0?vargv[0].tointeger():1
+local n = vargv.len()>1?vargv[1].tointeger():1
 
 print(fib(n)+"\n")

+ 1 - 1
SquiLu/samples/hello.nut

@@ -1 +1 @@
-print("Hello World!")
+print("Hello World!")

+ 1 - 1
SquiLu/samples/list.nut

@@ -28,7 +28,7 @@ function test()
 	return null;
 }
 
-local n = vargv.len()!=0?vargv[0].tointeger():1
+local n = vargv.len()>1?vargv[1].tointeger():1
 for(local i=0;i<n;i+=1)
 	if(!test())
 	{

+ 1 - 1
SquiLu/samples/matrix.nut

@@ -31,7 +31,7 @@ function mmult(rows, cols,  m1, m2, m3) {
   return m3;
 }
 
-local n = vargv.len()!=0?vargv[0].tointeger():1
+local n = vargv.len()>1?vargv[1].tointeger():1
 
 local m1 = mkmatrix(SIZE, SIZE);
 local m2 = mkmatrix(SIZE, SIZE);

+ 1 - 1
SquiLu/samples/methcall.nut

@@ -41,7 +41,7 @@ function NthToggle::activate ()
 
 
 function main() {
-	local n = vargv.len()!=0?vargv[0].tointeger():1
+	local n = vargv.len()>1?vargv[1].tointeger():1
 	
 	
 	

+ 2 - 1
SquiLu/samples/test-match.nut

@@ -5,7 +5,8 @@ print(str.match("Fl_Input"));
 print(str.substr(0,1), str.substr(2,3))
 print(str.slice(0,1), str.slice(2,3))
 
-local str2 = "Another day in paradize or another day in heaven ?";
+local str2 = "Another day in paradize or another day in heaven?";
+print(str2.slice(0,-1), str2.slice(0,-2))
 
 local rc = str2.match("(day).-(paradize)")
 print(type(rc));

+ 2 - 6
SquiLu/samples/test-socket-udp-echo-client.nut

@@ -4,12 +4,8 @@
 // Author: Diego Nehab
 // RCS ID: $Id: echoclnt.lua,v 1.10 2005/01/02 22:44:00 diego Exp $
 ////////////////////////////////////////////////////////////////////////////-
-local host = "localhost"
-local port = 20007;
-if (vargv.len() > 0){
-    host = vargv[0] || host;
-    port = vargv[1] || port;
-}
+local host = vargv.len() > 1 ? vargv[1] : "localhost";
+local port = vargv.len() > 2 ? vargv[2] : 20007;
 host = socket.toip(host);
 print(host.address)
 foreach(k,v in host.resolved) {

+ 2 - 6
SquiLu/samples/test-socket.nut

@@ -4,12 +4,8 @@
 // Author: Diego Nehab
 // RCS ID: $Id: echoclnt.lua,v 1.10 2005/01/02 22:44:00 diego Exp $
 ////////////////////////////////////////////////////////////////////////////-
-local host = "localhost"
-local port = 7
-if (vargv.len() > 0){
-    host = vargv[0] || host;
-    port = vargv[1] || port;
-}
+local host = vargv.len() > 1 ? vargv[1] : "localhost"
+local port = vargv.len() > 2 ? vargv[2] : 7
 host = socket.toip(host);
 print(host.address)
 foreach(k,v in host.resolved) {