Why doesn't "-m" option take effect?

Started by nanxiao, June 27, 2018, 12:01:55 AM

Previous topic - Next topic

nanxiao

Hi all,



Greeting from me!



I try arg-test program in http://www.newlisp.org/downloads/CodePatterns.html#toc-2">//http://www.newlisp.org/downloads/CodePatterns.html#toc-2:  



#!/usr/bin/newlisp -s 100000 -m 10
     
(println (main-args))
(println (sys-info))

(exit) ; important


Using current stable 10.7.1, the result of running arg-test is like this:  

$ ./arg-test.lsp
("/usr/bin/newlisp" "-s 100000 -m 10" "./arg-test.lsp")
(491 576460752303423488 410 2 0 100000 0 102774 10701 385)


The "Maximum number of Lisp cells constant" of sys-info is 576460752303423488 , but from the source code:



......
if(strncmp(argv[idx], "-m", 2) == 0)
        {
#ifndef NEWLISP64
        MAX_CELL_COUNT =  abs(0x0010000 * atoi(getArg(argv, argc, &idx)));
#else
        MAX_CELL_COUNT =  abs(0x0008000 * atoi(getArg(argv, argc, &idx)));
#endif
        continue;
        }
......


It seems MAX_CELL_COUNT is not changed and "-m" option doesn't take effect.



Best Regards

Nan Xiao

Lutz

#1
Most OS (e.g. Linux and FreeBSD) only parse the first parameter given on the commandline inside a shell script, but macOS does it correctly:



~> cat test
#!/usr/bin/env newlisp -s 100000 -m 10
     
(println (main-args))
(println (sys-info))

(exit) ; important

~> ./test
("newlisp" "-s" "100000" "-m" "10" "./test")
(495 327680 411 2 0 100000 0 9428 10704 1411)
~>

nanxiao

#2
@Lutz:



Got it! Thanks very much for your time and response!