Compare commits

...

2 commits

Author SHA1 Message Date
crc
704d400029 [nga-c] corrected fix for script:name (issue #99)
FossilOrigin-Name: eca3b588f990932f2161d869df338c8cb4f96bd17b13a1fcd741526661ea3e4a
2024-07-18 10:28:00 +00:00
crc
25420eea5d [nga-c] now report 0 for script:arguments count if not running a program
FossilOrigin-Name: 926e685b338c07722000d4d4d659674fdbcfb77c5f970283596f10ec18ad8b1a
2024-07-18 10:24:37 +00:00
2 changed files with 6 additions and 2 deletions

View file

@ -53,6 +53,7 @@
- new "-p" option to run non-Unu format source files
- now report "<none>" for `script:name` if no file is being
run
- now report 0 for `script:arguments` if not running a program
Future Notes

View file

@ -551,7 +551,10 @@ V scripting_arg(NgaState *vm) {
}
V scripting_arg_count(NgaState *vm) {
stack_push(vm, vm->sys_argc - 2);
if ((vm->sys_argc - 2) <= 0)
stack_push(vm, 0);
else
stack_push(vm, vm->sys_argc - 2);
}
V scripting_include(NgaState *vm) {
@ -563,7 +566,7 @@ V scripting_include_plain(NgaState *vm) {
}
V scripting_name(NgaState *vm) {
if ((vm->sys_argc - 2) <= 0)
if (vm->sys_argc == 1)
stack_push(vm, string_inject(vm, "<none>", stack_pop(vm)));
else
stack_push(vm, string_inject(vm, vm->sys_argv[1], stack_pop(vm)));