Commit a41dee14 authored by John van Groningen's avatar John van Groningen
Browse files

Merge branch 'windows-fixes' into 'master'

Fix quoting of imported object files in calls to spawn

See merge request !12
parents 3fe92219 f077ebe7
Pipeline #45959 passed with stage
in 14 seconds
......@@ -3261,7 +3261,7 @@ static char **add_imported_object_files (P_NODE first_project_node,char *o_file_
}
}
#ifdef _WINDOWS_
#ifdef QUOTE_SPAWN_ARGUMENTS
file_name=memory_allocate (strlen (o_file_name)+3);
file_name[0]='\"';
......@@ -3826,7 +3826,80 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
return r>=0 && status==0;
}
# else
r=spawnv (_P_WAIT,linker_file_name_,argv);
{
static char linkerrs_file_name[]="linkerrs.$$$";
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE linkerrs;
char buffer[32767];
char *cmd=buffer;
sa.nLength=sizeof (SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor=NULL;
sa.bInheritHandle=TRUE;
linkerrs=CreateFile (linkerrs_file_name,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,&sa,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
si.cb=sizeof (STARTUPINFO);
si.lpReserved=NULL;
si.lpReserved2=NULL;
si.cbReserved2=0;
si.lpDesktop=NULL;
si.lpTitle=NULL;
si.dwFlags=STARTF_USESTDHANDLES;
si.hStdInput=GetStdHandle (STD_INPUT_HANDLE);
si.hStdOutput=linkerrs;
si.hStdError=linkerrs;
*cmd++='"';
for (char *c=linker_file_name_; *c; c++)
*cmd++=*c;
*cmd++='"';
for (arg=argv+1; *arg; arg++){
if (cmd+3+strlen(arg) > &buffer[32766]){
fprintf (stderr,"Linker command line requires more than 32767 characters (use cpm instead)\n");
exit (1);
}
*cmd++=' ';
*cmd++='"';
for (char *c=*arg; *c; c++)
*cmd++=*c;
*cmd++='"';
}
*cmd='\0';
if (!CreateProcess (linker_file_name_,buffer,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi)){
fprintf (stderr,"CreateProcess failed\n");
exit (1);
}
CloseHandle (pi.hThread);
CloseHandle (linkerrs);
if (WaitForSingleObject (pi.hProcess,INFINITE)!=WAIT_OBJECT_0){
fprintf (stderr,"WaitForSingleObject failed\n");
exit (1);
}
if (!GetExitCodeProcess (pi.hProcess,&r)){
fprintf (stderr,"GetExitCodeProcess failed\n");
exit (1);
}
CloseHandle (pi.hProcess);
if ((linkerrs=fopen (linkerrs_file_name,"r"))==NULL){
fprintf (stderr,"Failed to open %s\n",linkerrs_file_name);
exit (1);
}
while (fgets (buffer,32767,linkerrs)!=NULL)
fputs (buffer,stderr);
fclose (linkerrs);
unlink (linkerrs_file_name);
}
# endif
# else
r=dos_exec (linker_file_name,argv,1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment