]> git.donarmstrong.com Git - perltidy.git/commitdiff
added note about possible parsing problems with -sfp
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 20 Sep 2020 19:45:13 +0000 (12:45 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 20 Sep 2020 19:45:13 +0000 (12:45 -0700)
bin/perltidy

index 35cecf7fbba6bf5ebe7741836b5dab9f45aeb94a..4c0a40974fbd6249b9ef5b8b3c352601d5b97d72 100755 (executable)
@@ -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 *