Page 1 of 1

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

Posted: Wed Jun 27, 2018 7:01 am
by nanxiao
Hi all,

Greeting from me!

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

Code: Select all

#!/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:

Code: Select all

$ ./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:

Code: Select all

......
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

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

Posted: Wed Jun 27, 2018 2:55 pm
by Lutz
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:

Code: Select all

~> 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)
~> 

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

Posted: Thu Jun 28, 2018 5:14 am
by nanxiao
@Lutz:

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