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: <422CFC84.2000604@mscha.nl> Date: Tue, 08 Mar 2005 02:14:44 +0100 From: Michael Schaap User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: cygstart patch References: <49D88D820A7BC0479A7B0932D4219EFE1A4BD0 AT NAEAPAXREX04VA DOT nadsusea DOT nads DOT navy DOT mil> <4227D42B DOT 8040904 AT cwilson DOT fastmail DOT fm> <422CFC2C DOT 1000706 AT mscha DOT org> In-Reply-To: <422CFC2C.1000706@mscha.org> Content-Type: multipart/mixed; boundary="------------080303040504090902010805" Note-from-DJ: This may be spam --------------080303040504090902010805 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit This time with patch. :-[ – Michael On 8-Mar-2005 2:13, Michael Schaap wrote: > Hi Anthony, Chuck, all, > > On 4-Mar-2005 4:21, Charles Wilson wrote: > >> Anthony -- >> >> I've applied this patch. Thanks! > > > > Sorry for jumping in so late... > > While I agree that the revised patch looks good and does the job, I'm > not too happy with the constant reallocation that's going on. (I know, > there won't be a measurable performance impact, but it, well, just > looks wring to me. ;-) ) > > In any case, here's a proposed alternative patch (against the version > containing Anthony's patch already) which calculates the actual total > argument size in advance, before allocating. > (In addition, I've taken the opportunity to change the listed email > address (cygwin_start at mscha dot org), which I had to block long ago > due to the ongoing stream of spam and viruses, to a new one, obscured > this time. Plus, I changed the feedback address to the mailing list > address (also obscured), since the list is obviously much more > responsive than I am. :-/ ) > > Chuck, if this looks OK to you, can you apply this patch? > > Thanks, also to Anthony and all for everything you've done. > > – Michael > > PS: That free() bug was very embarrassing... :-[ (Hmm... why do I even > draw attention to that again? ;-) ) > > -- > 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/ > --------------080303040504090902010805 Content-Type: text/plain; name="cygstart_args_v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cygstart_args_v2.patch" diff -u ORIG/cygstart.1 ./cygstart.1 --- ORIG/cygstart.1 2002-03-15 04:51:30.000000000 +0100 +++ ./cygstart.1 2005-03-08 01:42:09.214625000 +0100 @@ -194,7 +194,7 @@ .\"{{{ Author .SH AUTHOR -Michael Schaap +Michael Schaap .\"}}} .\"{{{ See also .SH "SEE ALSO" diff -u ORIG/cygstart.c ./cygstart.c --- ORIG/cygstart.c 2005-03-08 01:22:15.422250000 +0100 +++ ./cygstart.c 2005-03-08 01:41:21.167750000 +0100 @@ -1,7 +1,7 @@ /* * cygstart - Let Windows start a program, or open a file or URL * - * (c) 2002 Michael Schaap + * (c) 2002 Michael Schaap * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -74,6 +74,8 @@ int ret; char *action = NULL; char *file = NULL; + size_t argLength; + const char **tmp; char *args = NULL; char *workDir = NULL; int show = SW_SHOWNORMAL; @@ -102,7 +104,7 @@ { NULL, '\0', 0, NULL, 0, NULL, NULL } }; - /* SHow options */ + /* Show options */ struct poptOption showOptionsTable[] = { { "hide", '\0', POPT_ARG_NONE, NULL, 'H', \ "Hides the window and activates another window", NULL}, @@ -340,16 +342,17 @@ /* Retrieve any arguments */ if (rest && *rest) { - if ((args = (char *) malloc(strlen(*rest)+1)) == NULL) { + tmp = rest; + argLength = strlen(*tmp); + while (tmp++ && *tmp) { + argLength += 1 + strlen(*tmp); + } + if ((args = (char *) malloc(argLength+1)) == NULL) { fprintf(stderr, "%s: memory allocation error\n", argv[0]); exit(1); - } + } strcpy(args, *rest); while (rest++ && *rest) { - if ((args = (char *) realloc(args, strlen(args)+strlen(*rest)+2)) == NULL) { - fprintf(stderr, "%s: memory allocation error\n", argv[0]); - exit(1); - } strcat(args, " "); strcat(args, *rest); } @@ -464,7 +467,7 @@ { fprintf(f, "\n"); fprintf(f, "With thanks to MSDN: <%s>\n\n", MSDN_URL); - fprintf(f, "Please report any bugs to .\n"); + fprintf(f, "Please report any bugs to .\n"); } static printLicense(FILE *f, char *name) --------------080303040504090902010805 Content-Type: text/plain; charset=us-ascii -- 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/ --------------080303040504090902010805--