Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Thu, 9 Dec 2004 15:56:12 -0500
From: Christopher Faylor <cgf-no-personal-reply-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Incorrectly prepared lpCmdLine parameter of WinMain()
Message-ID: <20041209205612.GD14051@trixie.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
References: <41B8ACF0.4080208@mff.cuni.cz> <20041209203652.GC14051@trixie.casa.cgf.cx>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20041209203652.GC14051@trixie.casa.cgf.cx>
User-Agent: Mutt/1.4.1i

On Thu, Dec 09, 2004 at 03:36:52PM -0500, Christopher Faylor wrote:
>On Thu, Dec 09, 2004 at 08:52:16PM +0100, Pavel Kudrna wrote:
>> 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 <windows.h>
>>>>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.
>
>Right.  We're talking about *UNIX* here.  That's what Cygwin is all about.
>main is rather implied.

Apologies.  After another 30 seconds of deep thought I realized that the above
statement was completely clueless.

If we are going to provide a WinMain, it should do the right thing.  I'll look
at fixing libcmain.c and generating a new snapshot.

Unfortunately, this will require relinking your software.

cgf

--
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/

