mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
On some operating systems, e.g. Linux, it is possible to enter main()
with argv[0] == NULL if the parent process calls execve() with
argv[0] == NULL, or equivalently, passing NULL for the argv parameter.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Do not assume argc > 0 and argv[0] != NULL in MR_process_args.
If argv[0] is NULL then set MR_progname to the empty string
so users of MR_progname can assume it points to a valid string.
Add a new global variable MR_progname_is_known to indicate if
argv[0] was NULL or not.
library/io.m:
Make io.progname return the default program name if argv[0] was
NULL.
util/mkinit.c:
Set MR_progname to a valid string if argv[0] is NULL.
This is not actually necessary, since, in that case, the subsequent
call to parse_options() would immediately exit the program
as no file names will be found in argv.