Home | History | Annotate | Line # | Download | only in indent
opt_badp.c revision 1.12
      1 /* $NetBSD: opt_badp.c,v 1.12 2023/06/04 19:28:54 rillig Exp $ */
      2 
      3 /*
      4  * Tests for the options '-badp' and '-nbadp'.
      5  *
      6  * The option '-badp' forces a blank line between the first set of declarations
      7  * in a function and the next comment or statement. It produces a blank line
      8  * even if there are no declarations.
      9  */
     10 
     11 //indent input
     12 void
     13 empty(void)
     14 {
     15 }
     16 //indent end
     17 
     18 //indent run-equals-input -badp
     19 
     20 //indent run-equals-input -nbadp
     21 
     22 
     23 //indent input
     24 void
     25 blank(void)
     26 {
     27 
     28 }
     29 //indent end
     30 
     31 //indent run-equals-input -badp
     32 
     33 //indent run-equals-input -nbadp
     34 
     35 
     36 //indent input
     37 void
     38 declaration(void)
     39 {
     40 	int		decl;
     41 }
     42 //indent end
     43 
     44 //indent run-equals-input -badp
     45 
     46 //indent run-equals-input -nbadp
     47 
     48 
     49 //indent input
     50 void
     51 statement(void)
     52 {
     53 	stmt();
     54 }
     55 //indent end
     56 
     57 /* TODO: add blank line */
     58 //indent run-equals-input -badp
     59 
     60 //indent run-equals-input -nbadp
     61 
     62 
     63 //indent input
     64 void
     65 declaration_statement(void)
     66 {
     67 	int		decl;
     68 	stmt();
     69 }
     70 //indent end
     71 
     72 //indent run -badp
     73 void
     74 declaration_statement(void)
     75 {
     76 	int		decl;
     77 	/* $ FIXME: missing empty line */
     78 	stmt();
     79 }
     80 //indent end
     81 
     82 //indent run-equals-input -nbadp
     83 
     84 
     85 //indent input
     86 static void
     87 declaration_blank_statement(void)
     88 {
     89 	int		decl;
     90 
     91 	stmt();
     92 }
     93 //indent end
     94 
     95 //indent run-equals-input -badp
     96 
     97 //indent run-equals-input -nbadp
     98 
     99 
    100 //indent input
    101 static void
    102 declaration_blank_blank_statement(void)
    103 {
    104 	int		decl;
    105 
    106 
    107 
    108 	stmt();
    109 }
    110 //indent end
    111 
    112 //indent run-equals-input -badp
    113 
    114 //indent run-equals-input -nbadp
    115 
    116 
    117 /*
    118  * A struct declaration or an initializer are not function bodies, so don't
    119  * add a blank line after them.
    120  */
    121 //indent input
    122 struct {
    123 	int member[2];
    124 } s = {
    125 	{
    126 		0,
    127 		0,
    128 	}
    129 };
    130 //indent end
    131 
    132 //indent run-equals-input -di0 -badp
    133 
    134 //indent run-equals-input -di0 -nbadp
    135