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

Q&A's, tips, howto's

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

Postby nanxiao » Wed Jun 27, 2018 7:01 am

Hi all,

Greeting from me!

I try arg-test program in http://www.newlisp.org/downloads/CodePatterns.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
nanxiao
 
Posts: 7
Joined: Mon Jun 25, 2018 1:28 pm

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

Postby Lutz » Wed Jun 27, 2018 2:55 pm

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)
~>
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

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

Postby nanxiao » Thu Jun 28, 2018 5:14 am

@Lutz:

Got it! Thanks very much for your time and response!
nanxiao
 
Posts: 7
Joined: Mon Jun 25, 2018 1:28 pm


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 3 guests

cron