Home | History | Annotate | Line # | Download | only in indent
opt_sob.c revision 1.8
      1 /* $NetBSD: opt_sob.c,v 1.8 2023/05/23 06:18:00 rillig Exp $ */
      2 
      3 /*
      4  * Tests for the options '-sob' and '-nsob'.
      5  *
      6  * The option '-sob' swallows optional blank lines.
      7  *
      8  * XXX: The manual page says: "You can use this to get rid of blank lines
      9  * after declarations."; double check this.
     10  *
     11  * The option '-nsob' keeps optional blank lines as is.
     12  */
     13 
     14 /*
     15  * FIXME: There are lots of 'optional blank lines' here that should be
     16  *  swallowed.
     17  */
     18 //indent input
     19 void		function_declaration(void);
     20 
     21 
     22 int
     23 function_with_0_blank_lines(void)
     24 {
     25 	int		var;
     26 	var = value;
     27 	if (var > 0)
     28 		var--;
     29 	if (var > 0) {
     30 		var--;
     31 	}
     32 	return var;
     33 }
     34 
     35 int
     36 function_with_1_blank_line(void)
     37 {
     38 
     39 	int		var;
     40 
     41 	var = value;
     42 
     43 	if (var > 0)
     44 /* $ The following line is "optional" and is removed due to '-sob'. */
     45 
     46 		var--;
     47 
     48 	if (var > 0) {
     49 /* $ The following line is "optional" and is removed due to '-sob'. */
     50 
     51 		var--;
     52 
     53 	}
     54 
     55 	return var;
     56 
     57 }
     58 
     59 
     60 int
     61 function_with_2_blank_lines(void)
     62 {
     63 
     64 
     65 	int		var;
     66 
     67 
     68 	var = value;
     69 
     70 
     71 	if (var > 0)
     72 /* $ The following 2 lines are "optional" and are removed due to '-sob'. */
     73 
     74 
     75 		var--;
     76 
     77 
     78 	if (var > 0) {
     79 
     80 
     81 		var--;
     82 
     83 
     84 	}
     85 
     86 
     87 	return var;
     88 
     89 
     90 }
     91 //indent end
     92 
     93 //indent run -sob
     94 void		function_declaration(void);
     95 
     96 
     97 int
     98 function_with_0_blank_lines(void)
     99 {
    100 	int		var;
    101 	var = value;
    102 	if (var > 0)
    103 		var--;
    104 	if (var > 0) {
    105 		var--;
    106 	}
    107 	return var;
    108 }
    109 
    110 int
    111 function_with_1_blank_line(void)
    112 {
    113 
    114 	int		var;
    115 
    116 	var = value;
    117 
    118 	if (var > 0)
    119 		var--;
    120 
    121 	if (var > 0) {
    122 		var--;
    123 // $ XXX: The following blank line may be considered optional.
    124 
    125 	}
    126 
    127 	return var;
    128 
    129 }
    130 
    131 
    132 int
    133 function_with_2_blank_lines(void)
    134 {
    135 
    136 	int		var;
    137 
    138 	var = value;
    139 
    140 	if (var > 0)
    141 		var--;
    142 
    143 	if (var > 0) {
    144 		var--;
    145 // $ XXX: The following blank line may be considered optional.
    146 
    147 	}
    148 
    149 	return var;
    150 
    151 }
    152 //indent end
    153 
    154 //indent run-equals-input -nsob
    155