initial fix for #99 (issue w/script:name
when not running a script; will now report "<none>" instead of garbage)
FossilOrigin-Name: 003f7b2e0650a004cc264cafdb29c5634a32d260cb137a08835a982557e0e48e
This commit is contained in:
parent
81a70edd50
commit
565d567523
2 changed files with 9 additions and 1 deletions
|
@ -51,6 +51,8 @@
|
|||
- formatting cleanups
|
||||
- added ioctl device
|
||||
- new "-p" option to run non-Unu format source files
|
||||
- now report "<none>" for `script:name` if no file is being
|
||||
run
|
||||
|
||||
Future Notes
|
||||
|
||||
|
|
|
@ -563,7 +563,10 @@ V scripting_include_plain(NgaState *vm) {
|
|||
}
|
||||
|
||||
V scripting_name(NgaState *vm) {
|
||||
stack_push(vm, string_inject(vm, vm->sys_argv[1], stack_pop(vm)));
|
||||
if ((vm->sys_argc - 2) <= 0)
|
||||
stack_push(vm, string_inject(vm, "<none>", stack_pop(vm)));
|
||||
else
|
||||
stack_push(vm, string_inject(vm, vm->sys_argv[1], stack_pop(vm)));
|
||||
}
|
||||
|
||||
/* addeded in scripting i/o device, revision 1 */
|
||||
|
@ -1123,6 +1126,9 @@ int main(int argc, char **argv) {
|
|||
vm->sys_argc = argc; /* Point the global argc and */
|
||||
vm->sys_argv = argv; /* argv to the actual ones */
|
||||
|
||||
strlcpy(vm->scripting_sources[0], "<none>", 8192);
|
||||
|
||||
|
||||
/* Check arguments. If no flags were passed, load & run the
|
||||
file specified and exit. */
|
||||
if (argc >= 2 && argv[1][0] != '-') {
|
||||
|
|
Loading…
Reference in a new issue