"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/vm/moar/runner/main.c" between
rakudo-2020.09.tar.gz and rakudo-2020.10.tar.gz

About: Rakudo is a compiler for the Raku Pogramming Language (formerly known as Perl 6).

main.c  (rakudo-2020.09):main.c  (rakudo-2020.10)
skipping to change at line 161 skipping to change at line 161
check_file_path = (char*)malloc(home_size + check_file_size + 1); check_file_path = (char*)malloc(home_size + check_file_size + 1);
strncpy(check_file_path, *out_home, home_size + check_file_size); strncpy(check_file_path, *out_home, home_size + check_file_size);
strncat(check_file_path, check_file, check_file_size); strncat(check_file_path, check_file, check_file_size);
ret = file_exists(check_file_path); ret = file_exists(check_file_path);
free(check_file_path); free(check_file_path);
return ret; return ret;
} }
#ifndef _WIN32 #if defined(_WIN32) && defined(SUBSYSTEM_WINDOWS)
int main(int argc, char *argv[]) int set_std_handle_to_nul(FILE *file, int fd, BOOL read, int std_handle_type) {
/* Found on https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference
"When stdin, stdout, and stderr aren't associated with a stream (for exam
ple, in a Windows
application without a console window), the file descriptor values for the
se streams are
returned from _fileno as the special value -2. Similarly, if you use a 0,
1, or 2 as the
file descriptor parameter instead of the result of a call to _fileno, _ge
t_osfhandle also
returns the special value -2 when the file descriptor is not associated w
ith a stream, and
does not set errno. However, this is not a valid file handle value, and s
ubsequent calls
that attempt to use it are likely to fail."
See https://jdebp.eu/FGA/redirecting-standard-io.html
https://stackoverflow.com/a/50358201 (Especially the comments of Eryk
FILE *stream;
HANDLE new_handle;
if (_fileno(file) != -2 || _get_osfhandle(fd) != -2)
// The handles are initialized. Don't touch!
return 1;
/* FD 1 is in an error state (_get_osfhandle(1) == -2). Close it. The FD num
ber is up for grabs
after this call. */
if (_close(fd) != 0)
return 0;
/* FILE *stdout is in an error state (_fileno(stdout) == -2). Reopen it to a
"NUL:" file. This
will take the next free FD number. So it's important to call this sequent
ially for FD 0, 1
and 2. */
if (freopen_s(&stream, "NUL:", read ? "r" : "w", file) != 0)
return 0;
/* Set the underlying Windows handle as the STD handler. */
new_handle = (HANDLE)_get_osfhandle(fd);
if (!SetStdHandle(std_handle_type, new_handle))
return 0;
return 1;
#if defined(_WIN32) && defined(SUBSYSTEM_WINDOWS)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nC
mdShow) {
int argc;
LPWSTR *wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
char **argv = MVM_UnicodeToUTF8_argv(argc, wargv);
#elif defined(_WIN32) && !defined(SUBSYSTEM_WINDOWS)
int wmain(int argc, wchar_t *wargv[]) {
char **argv = MVM_UnicodeToUTF8_argv(argc, wargv);
#else #else
int wmain(int argc, wchar_t *wargv[]) int main(int argc, char *argv[]) {
#endif #endif
MVMInstance *instance; MVMInstance *instance;
char *exec_path; char *exec_path;
size_t exec_path_size; size_t exec_path_size;
char *exec_dir_path_temp; char *exec_dir_path_temp;
char *exec_dir_path; char *exec_dir_path;
size_t exec_dir_path_size; size_t exec_dir_path_size;
char *nqp_home; char *nqp_home;
skipping to change at line 196 skipping to change at line 244
char *static_rakudo_home = 0; char *static_rakudo_home = 0;
char *option_rakudo_home = 0; char *option_rakudo_home = 0;
const char perl6_rel_path[16] = "/../share/perl6"; const char perl6_rel_path[16] = "/../share/perl6";
const size_t perl6_rel_path_size = 15; const size_t perl6_rel_path_size = 15;
const char perl6_check_path[22] = "/runtime/perl6.moarvm"; const char perl6_check_path[22] = "/runtime/perl6.moarvm";
const size_t perl6_check_path_size = 21; const size_t perl6_check_path_size = 21;
char *lib_path[3]; char *lib_path[3];
char *perl6_file; char *perl6_file;
#ifdef _WIN32
char **argv = MVM_UnicodeToUTF8_argv(argc, wargv);
int full_cleanup = 0; int full_cleanup = 0;
int argi = 1; int argi = 1;
int flag; int flag;
int new_argc = 0; int new_argc = 0;
MVMuint32 debugserverport = 0; MVMuint32 debugserverport = 0;
int start_suspended = 0; int start_suspended = 0;
#if defined(_WIN32) && defined(SUBSYSTEM_WINDOWS)
/* When using the 'windows' subsystem the standard IO handles are not
connected. This causes a program abort when accessing the handles. To
prevent these aborts, we redirect the handles to NUL in this case.
/* Set our own handles. */
if (!set_std_handle_to_nul(stdin, 0, 1, STD_INPUT_HANDLE)) return EXIT_FAI
if (!set_std_handle_to_nul(stdout, 1, 0, STD_OUTPUT_HANDLE)) return EXIT_FAI
if (!set_std_handle_to_nul(stderr, 2, 0, STD_ERROR_HANDLE)) return EXIT_FAI
/* MoarVM - as a DLL, and the way it's compiled (/MT) has it's own CRT and t
hus it's own CRT STD handles.
So MoarVM also needs to fix up its CRT STD handles.
See: https://docs.microsoft.com/de-de/cpp/c-runtime-library/potential-err
if (!MVM_set_std_handles_to_nul()) return EXIT_FAILURE;
/* Retrieve the executable directory path. */ /* Retrieve the executable directory path. */
exec_path_size = strlen(exec_path); exec_path_size = strlen(exec_path);
#else #else
int res; int res;
exec_path_size = 4096; exec_path_size = 4096;
exec_path = (char*)malloc(exec_path_size); exec_path = (char*)malloc(exec_path_size);
res = MVM_exepath(exec_path, &exec_path_size); res = MVM_exepath(exec_path, &exec_path_size);
 End of changes. 5 change blocks. 
8 lines changed or deleted 89 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)