1 /* $NetBSD: indent_off_on.c,v 1.2 2021/10/19 20:41:42 rillig Exp $ */ 2 /* $FreeBSD$ */ 3 4 /* 5 * Tests for the comments 'INDENT OFF' and 'INDENT ON', which temporarily 6 * disable formatting. 7 */ 8 9 #indent input 10 {} 11 12 /*INDENT OFF*/ 13 /*INDENT ON*/ 14 15 {} 16 #indent end 17 18 /* 19 * XXX: It is asymmetric that 'INDENT OFF' is kept as is, while 'INDENT ON' 20 * gets enclosed with spaces. 21 */ 22 #indent run 23 { 24 } 25 /* $ FIXME: This empty line must stay. */ 26 /*INDENT OFF*/ 27 /* INDENT ON */ 28 29 { 30 } 31 #indent end 32 33 34 #indent input 35 {} 36 /* INDENT OFF */ 37 /* INDENT ON */ 38 {} 39 #indent end 40 41 /* 42 * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON' 43 * is aligned. 44 */ 45 #indent run 46 { 47 } 48 /* INDENT OFF */ 49 /* INDENT ON */ 50 { 51 } 52 #indent end 53 54 55 #indent input 56 {} 57 /* INDENT OFF */ 58 /* INDENT ON */ 59 {} 60 #indent end 61 62 /* 63 * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON' 64 * is aligned. 65 */ 66 #indent run 67 { 68 } 69 /* INDENT OFF */ 70 /* INDENT ON */ 71 { 72 } 73 #indent end 74 75 /* 76 * The INDENT comments can be written without space between the words, but 77 * nobody does this. 78 */ 79 #indent input 80 int decl ; 81 /*INDENTOFF*/ 82 int decl ; 83 /*INDENTON*/ 84 int decl ; 85 #indent end 86 87 #indent run -di0 88 int decl; 89 /*INDENTOFF*/ 90 int decl ; 91 /* INDENTON */ 92 int decl; 93 #indent end 94 95 96 /* 97 * Any whitespace around the 'INDENT ON/OFF' is ignored, as is any whitespace 98 * between the two words. 99 */ 100 #indent input 101 int decl; 102 /* INDENT OFF */ 103 int decl ; 104 /* INDENT ON */ 105 int decl; 106 #indent end 107 108 /* 109 * XXX: It is asymmetric that 'INDENT OFF' is indented, while 'INDENT ON' 110 * is aligned. 111 */ 112 #indent run -di0 113 int decl; 114 /* INDENT OFF */ 115 int decl ; 116 /* INDENT ON */ 117 int decl; 118 #indent end 119 120 121 #indent input 122 /*INDENT OFF*/ 123 /* No formatting takes place here. */ 124 int format( void ) {{{ 125 /*INDENT ON*/ 126 }}} 127 #indent end 128 129 #indent run 130 /*INDENT OFF*/ 131 /* No formatting takes place here. */ 132 int format( void ) {{{ 133 /* $ XXX: Why is the INDENT ON comment indented? */ 134 /* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */ 135 /* INDENT ON */ 136 } 137 } 138 } 139 #indent end 140 141 142 #indent input 143 /* INDENT OFF */ 144 void indent_off ( void ) ; 145 /* INDENT */ 146 void indent_on ( void ) ; 147 /* INDENT OFF */ 148 void indent_off ( void ) ; 149 /* INDENT ON */ 150 void indent_on ( void ) ; /* the comment may be indented */ 151 /* INDENT OFF */ 152 void indent_off ( void ) ; 153 /* INDENTATION ON */ 154 void indent_still_off ( void ) ; /* due to the word 'INDENTATION' */ 155 /* INDENT ON * */ 156 void indent_still_off ( void ) ; /* due to the extra '*' at the end */ 157 /* INDENT ON */ 158 void indent_on ( void ) ; 159 /* INDENT: OFF */ 160 void indent_still_on ( void ) ; /* due to the colon in the middle */ 161 /* INDENT OFF */ /* extra comment */ 162 void indent_still_on ( void ) ; /* due to the extra comment to the right */ 163 #indent end 164 165 #indent run 166 /* INDENT OFF */ 167 void indent_off ( void ) ; 168 /* $ XXX: The double space from the below comment got merged to a single */ 169 /* $ XXX: space even though the comment might be regarded to be still in */ 170 /* $ XXX: the OFF section. */ 171 /* INDENT */ 172 void 173 indent_on(void); 174 /* INDENT OFF */ 175 void indent_off ( void ) ; 176 /* $ XXX: The below comment got moved from column 9 to column 1. */ 177 /* INDENT ON */ 178 void 179 indent_on(void); /* the comment may be indented */ 180 /* INDENT OFF */ 181 void indent_off ( void ) ; 182 /* INDENTATION ON */ 183 void indent_still_off ( void ) ; /* due to the word 'INDENTATION' */ 184 /* INDENT ON * */ 185 void indent_still_off ( void ) ; /* due to the extra '*' at the end */ 186 /* INDENT ON */ 187 void 188 indent_on(void); 189 /* INDENT: OFF */ 190 void 191 indent_still_on(void); /* due to the colon in the middle */ 192 /* $ The extra comment got moved to the left since there is no code in */ 193 /* $ that line. */ 194 /* INDENT OFF *//* extra comment */ 195 void 196 indent_still_on(void); /* due to the extra comment to the right */ 197 #indent end 198