Home | History | Annotate | Line # | Download | only in indent
opt_psl.c revision 1.4
      1  1.4  rillig /* $NetBSD: opt_psl.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */
      2  1.1  rillig /* $FreeBSD$ */
      3  1.1  rillig 
      4  1.3  rillig /*
      5  1.3  rillig  * Tests for the options '-psl' and '-npsl'.
      6  1.3  rillig  *
      7  1.3  rillig  * The option '-psl' starts a new line for the function name in a function
      8  1.3  rillig  * definition.
      9  1.3  rillig  *
     10  1.3  rillig  * The option '-npsl' puts the function name in the same line as its return
     11  1.3  rillig  * type.
     12  1.3  rillig  */
     13  1.3  rillig 
     14  1.3  rillig /* Single-line function declarations are not affected by these options. */
     15  1.1  rillig #indent input
     16  1.1  rillig void function_declaration(void);
     17  1.3  rillig #indent end
     18  1.3  rillig 
     19  1.3  rillig #indent run -psl
     20  1.3  rillig void		function_declaration(void);
     21  1.3  rillig #indent end
     22  1.3  rillig 
     23  1.4  rillig #indent run-equals-prev-output -npsl
     24  1.3  rillig 
     25  1.3  rillig /*
     26  1.3  rillig  * Multi-line function declarations are affected by these options since indent
     27  1.3  rillig  * wrongly assumes they were function definitions, not declarations.
     28  1.3  rillig  */
     29  1.3  rillig #indent input
     30  1.3  rillig void function_declaration(
     31  1.3  rillig void);
     32  1.3  rillig #indent end
     33  1.1  rillig 
     34  1.3  rillig #indent run -psl
     35  1.3  rillig void
     36  1.3  rillig function_declaration(
     37  1.3  rillig 		     void);
     38  1.3  rillig #indent end
     39  1.3  rillig 
     40  1.3  rillig /*
     41  1.3  rillig  * In a function definition (which indent wrongly assumes here), in contrast
     42  1.3  rillig  * to a declaration, the function name is not indented to column 17.
     43  1.3  rillig  */
     44  1.3  rillig #indent run -npsl
     45  1.3  rillig void function_declaration(
     46  1.3  rillig 			  void);
     47  1.3  rillig #indent end
     48  1.3  rillig 
     49  1.3  rillig /*
     50  1.3  rillig  * In a function definition, in contrast to a declaration, the function name
     51  1.3  rillig  * is not indented to column 17 since the other function definitions are too
     52  1.3  rillig  * far away.
     53  1.3  rillig  */
     54  1.3  rillig #indent input
     55  1.1  rillig void function_definition(void) {}
     56  1.1  rillig #indent end
     57  1.1  rillig 
     58  1.1  rillig #indent run -psl
     59  1.1  rillig void
     60  1.1  rillig function_definition(void)
     61  1.1  rillig {
     62  1.1  rillig }
     63  1.1  rillig #indent end
     64  1.1  rillig 
     65  1.1  rillig #indent run -npsl
     66  1.1  rillig void function_definition(void)
     67  1.1  rillig {
     68  1.1  rillig }
     69  1.1  rillig #indent end
     70