Home | History | Annotate | Line # | Download | only in indent
opt_bl_br.c revision 1.9
      1 /* $NetBSD: opt_bl_br.c,v 1.9 2023/05/21 10:18:44 rillig Exp $ */
      2 
      3 //indent input
      4 void
      5 standard_style(int n)
      6 {
      7 	if (n > 99) {
      8 		print("large");
      9 	} else if (n > 9) {
     10 		print("double-digit");
     11 	} else if (n > 0)
     12 		print("positive");
     13 	else {
     14 		print("negative");
     15 	}
     16 }
     17 //indent end
     18 
     19 //indent run-equals-input -br
     20 
     21 //indent run -bl
     22 void
     23 standard_style(int n)
     24 {
     25 	if (n > 99)
     26 	{
     27 		print("large");
     28 	} else if (n > 9)
     29 	{
     30 		print("double-digit");
     31 	} else if (n > 0)
     32 		print("positive");
     33 	else
     34 	{
     35 		print("negative");
     36 	}
     37 }
     38 //indent end
     39 
     40 
     41 /*
     42  * In this very condensed style, the additional newline between '}' and 'else'
     43  * is kept.
     44  */
     45 //indent input
     46 void
     47 condensed_style(int n)
     48 {
     49 	if (n > 99) { print("large"); }
     50 	else if (n > 9) { print("double-digit"); }
     51 	else if (n > 0) print("positive");
     52 	else { print("negative"); }
     53 }
     54 //indent end
     55 
     56 //indent run -bl
     57 void
     58 condensed_style(int n)
     59 {
     60 	if (n > 99)
     61 	{
     62 		print("large");
     63 	}
     64 	else if (n > 9)
     65 	{
     66 		print("double-digit");
     67 	}
     68 	else if (n > 0)
     69 		print("positive");
     70 	else
     71 	{
     72 		print("negative");
     73 	}
     74 }
     75 //indent end
     76 
     77 //indent run -br
     78 void
     79 condensed_style(int n)
     80 {
     81 	if (n > 99) {
     82 		print("large");
     83 	}
     84 	else if (n > 9) {
     85 		print("double-digit");
     86 	}
     87 	else if (n > 0)
     88 		print("positive");
     89 	else {
     90 		print("negative");
     91 	}
     92 }
     93 //indent end
     94 
     95 
     96 /*
     97  * An end-of-line comment after 'if (expr)' forces the '{' to go to the next
     98  * line.
     99  */
    100 //indent input
    101 void
    102 eol_comment(void)
    103 {
    104 	if (expr) // C99 comment
    105 		stmt();
    106 
    107 	if (expr) // C99 comment
    108 	{
    109 		stmt();
    110 	}
    111 }
    112 //indent end
    113 
    114 //indent run -br
    115 void
    116 eol_comment(void)
    117 {
    118 	if (expr)		// C99 comment
    119 		stmt();
    120 
    121 	if (expr)		// C99 comment
    122 	{
    123 		stmt();
    124 	}
    125 }
    126 //indent end
    127 
    128 //indent run-equals-prev-output -bl
    129 
    130 
    131 /*
    132  * Test multiple mixed comments after 'if (expr)'.
    133  */
    134 //indent input
    135 void
    136 function(void)
    137 {
    138 	if (expr)	// C99 comment 1
    139 			// C99 comment 2
    140 			// C99 comment 3
    141 		stmt();
    142 }
    143 //indent end
    144 
    145 //indent run
    146 void
    147 function(void)
    148 {
    149 	if (expr)		// C99 comment 1
    150 		// C99 comment 2
    151 		// C99 comment 3
    152 		stmt();
    153 }
    154 //indent end
    155 
    156 
    157 /*
    158  * The combination of the options '-br' and '-ei' (both active by default)
    159  * removes extra newlines between the tokens '}', 'else' and 'if'.
    160  */
    161 //indent input
    162 void
    163 function(void)
    164 {
    165 	if (cond)
    166 	{
    167 		stmt();
    168 	}
    169 	else
    170 	if (cond)
    171 	{
    172 		stmt();
    173 	}
    174 }
    175 //indent end
    176 
    177 /* TODO: Remove the newline between ')' and '{'. */
    178 //indent run-equals-input -br
    179 
    180 
    181 //indent input
    182 void
    183 comments(void)
    184 {
    185 	if(cond){}
    186 
    187 	if (cond)
    188 	{}
    189 
    190 	if (cond) /* comment */
    191 	{}
    192 
    193 	if (cond)
    194 	/* comment */
    195 	{}
    196 
    197 	if (cond)
    198 	// comment1
    199 	// comment2
    200 	{}
    201 
    202 	if (cond) // comment
    203 	{}
    204 }
    205 //indent end
    206 
    207 //indent run -bl
    208 void
    209 comments(void)
    210 {
    211 	if (cond)
    212 	{
    213 	}
    214 
    215 	if (cond)
    216 	{
    217 	}
    218 
    219 	if (cond)		/* comment */
    220 	{
    221 	}
    222 
    223 	if (cond)
    224 		/* comment */
    225 	{
    226 	}
    227 
    228 	if (cond)
    229 		// comment1
    230 		// comment2
    231 	{
    232 	}
    233 
    234 	if (cond)		// comment
    235 	{
    236 	}
    237 }
    238 //indent end
    239 
    240 //indent run -br
    241 void
    242 comments(void)
    243 {
    244 	if (cond) {
    245 	}
    246 
    247 	if (cond)
    248 	{
    249 	}
    250 
    251 	if (cond)		/* comment */
    252 	{
    253 	}
    254 
    255 	if (cond)
    256 		/* comment */
    257 	{
    258 	}
    259 
    260 	if (cond)
    261 		// comment1
    262 		// comment2
    263 	{
    264 	}
    265 
    266 	if (cond)		// comment
    267 	{
    268 	}
    269 }
    270 //indent end
    271