From: Steve Hancock Date: Sun, 20 Sep 2020 19:45:13 +0000 (-0700) Subject: added note about possible parsing problems with -sfp X-Git-Tag: 20201001~26 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c1439a8a8deb00704f542da515b5bb747002effd;p=perltidy.git added note about possible parsing problems with -sfp --- diff --git a/bin/perltidy b/bin/perltidy index 35cecf7f..4c0a4097 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -1198,12 +1198,12 @@ use the command: B<-skp> or B<--space-keyword-paren> -You will probably also want to use the flag B<-sfp> (next item) too. +You may also want to use the flag B<-sfp> (next item) too. =item Space between all function names and opening parens -When an opening paren follows a function the default is not to introduce -a space. To cause a space to be introduced use: +When an opening paren follows a function the default and recommended formatting +is not to introduce a space. To cause a space to be introduced use: B<-sfp> or B<--space-function-paren> @@ -1212,6 +1212,17 @@ B<-sfp> or B<--space-function-paren> You will probably also want to use the flag B<-skp> (previous item) too. +The reason this is not recommended is that spacing a function paren can make a +program vulnerable to parsing problems by Perl. For example, the following +two-line program will run as written but will have a syntax error if +reformatted with -sfp: + + if ( -e filename() ) { print "exists\n"; } + sub filename { return $0 } + +The syntax error can be removed if the line order is reversed, so that +Perl parses 'sub filename' first. + =item B<-spp=n> or B<--space-prototype-paren=n> This flag can be used to control whether a function prototype is preceded by a space. For example, the following prototype does not have a space. @@ -2164,7 +2175,7 @@ There are several points to note about this flag: =item * This parameter only applies if the opening brace is preceded by an '=' -or '=>' or ','. +or '=>'. =item *