develooper Front page | perl.perl5.porters | Postings from August 2008

Re: [perl #30660][PATCH] Repeated spaces on shebang line stops optionparsing

Thread Previous | Thread Next
From:
=?ISO-8859-1?Q?Ren=E9e_B=E4cker?=
Date:
August 25, 2008 23:44
Subject:
Re: [perl #30660][PATCH] Repeated spaces on shebang line stops optionparsing
Message ID:
48B3A62B.5040103@smart-websolutions.de
Nicholas Clark wrote:
> On Mon, Aug 25, 2008 at 10:47:31AM +0200, Rene Bcker wrote:
>   
>> Make perl recognize additional switches when more than one space is used...
>>     
>
> Do you have an example of what this is solving? It seems a logical change to
> make, but I'm guessing as to what the problem is.
>   

Attached is a small script. Without this patch it just recognizes the -s
switch but not the -w switch.

>   
>> --- perl.c.old	2008-08-25 10:35:38.000000000 +0200
>> +++ perl.c	2008-08-25 10:26:22.000000000 +0200
>> @@ -3370,8 +3370,10 @@
>>  	return s;
>>      case '*':
>>      case ' ':
>> -	if (s[1] == '-')	/* Additional switches on #! line. */
>> -	    return s+2;
>> +        while( *s && isSPACE(*s) )
>> +          ++s;
>>     
>
> That can be
>
>        while( isSPACE(*s) )
>          ++s;
>
> because isSPACE('\0') is going to be false.
>
>
> But is using isSPACE() correct, given that '\r', '\n' and particularly '\t'
> are handled differently in code below?
> (And no, I'm not intimately familiar with what it is doing, or why)
>   

So this should be rewritten as

  while( *s && ( s[0] == ' ' ) )
      ++s;

>
> Nicholas Clark
>
>
>   

Renee


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About