Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <41B8ACF0.4080208@mff.cuni.cz> Date: Thu, 09 Dec 2004 20:52:16 +0100 From: Pavel Kudrna Organization: Charles University in Prague, Faculty of Mathematics and Physics User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Incorrectly prepared lpCmdLine parameter of WinMain() Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Christopher Faylor wrote:// > On Thu, Dec 09, 2004 at 12:41:22PM +0100, Pavel Kudrna wrote: > >> The caller of WinMain() incorrectly parses the command line if e.g. >> the space is present in the path or filename of the executable. >> The lpCmdLine then contains part of the filename at the beginning. >> >> /* program.c*/ >> #include >> int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, >> LPSTR lpCmdLine, int nCmdShow ) >> { >> MessageBox(NULL, lpCmdLine, "lpCmdLine:", MB_OK ); >> return 0; >> } >> >> $ gcc program.c -mwin32 >> $ mv a.exe "a a.exe" >> $ "./a a.exe" "1st parameter" 2nd\ parameter >> >> Then MessageBox shows that lpCmdLine contains: >> a.exe" "1st parameter" "2nd parameter" >> >> If program is compiled with -mno-cygwin the bug is not present and >> lpCmdLine is ok: >> "1st parameter" "2nd parameter" > > Sounds like you should be using argv[] rather than lpCmdLine. Yes, but that means to create main() function. As temporary solution it is ok, but I think that more correct solution would be to replace the content of the file ...\cygwin-1.5.12-1\winsup\cygwin\lib\libcmain.c with the content of ...\cygwin-1.5.12-1\winsup\mingw\main.c Can you do it? Thanks Pavel Kudrna -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/