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

Q&A's, tips, howto's
Locked
nanxiao
Posts: 7
Joined: Mon Jun 25, 2018 1:28 pm

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

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

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

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

nanxiao
Posts: 7
Joined: Mon Jun 25, 2018 1:28 pm

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

Post by nanxiao »

@Lutz:

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

Locked