1*47306038Srillig /* $NetBSD: opt_di.c,v 1.8 2022/04/24 09:04:12 rillig Exp $ */ 232fe626bSrillig 337369abeSrillig /* 495e11159Srillig * Test the option '-di', which specifies the indentation of the first 595e11159Srillig * variable name in a declaration. 637369abeSrillig */ 737369abeSrillig 8*47306038Srillig //indent input 932fe626bSrillig int space; 1032fe626bSrillig int tab; 1132fe626bSrillig int tab16; 1232fe626bSrillig 1332fe626bSrillig struct long_name long_name; 14*47306038Srillig //indent end 1532fe626bSrillig 16*47306038Srillig //indent run -di8 1732fe626bSrillig int space; 1832fe626bSrillig int tab; 1932fe626bSrillig int tab16; 2032fe626bSrillig 2132fe626bSrillig struct long_name long_name; 22*47306038Srillig //indent end 2337369abeSrillig 2437369abeSrillig 2537369abeSrillig /* 2637369abeSrillig * The declarator can be a simple variable name. It can also be prefixed by 2737369abeSrillig * asterisks, for pointer variables. These asterisks are placed to the left of 2837369abeSrillig * the indentation line, so that the variable names are aligned. 2937369abeSrillig * 3037369abeSrillig * There can be multiple declarators in a single declaration, separated by 3137369abeSrillig * commas. Only the first of them is aligned to the indentation given by 3237369abeSrillig * '-di', the others are separated with a single space. 3337369abeSrillig */ 34*47306038Srillig //indent input 3537369abeSrillig int var; 3637369abeSrillig int *ptr, *****ptr; 37*47306038Srillig //indent end 3837369abeSrillig 39*47306038Srillig //indent run -di12 4037369abeSrillig int var; 4137369abeSrillig int *ptr, *****ptr; 42*47306038Srillig //indent end 4337369abeSrillig 4437369abeSrillig 4537369abeSrillig /* 4637369abeSrillig * Test the various values for indenting. 4737369abeSrillig */ 48*47306038Srillig //indent input 4937369abeSrillig int decl ; 50*47306038Srillig //indent end 5137369abeSrillig 5237369abeSrillig /* 5337369abeSrillig * An indentation of 0 columns uses a single space between the declaration 5437369abeSrillig * specifiers (in this case 'int') and the declarator. 5537369abeSrillig */ 56*47306038Srillig //indent run -di0 5737369abeSrillig int decl; 58*47306038Srillig //indent end 5937369abeSrillig 6037369abeSrillig /* 6137369abeSrillig * An indentation of 7 columns uses spaces for indentation since in the 6237369abeSrillig * default configuration, the next tab stop would be at indentation 8. 6337369abeSrillig */ 64*47306038Srillig //indent run -di7 6537369abeSrillig int decl; 66*47306038Srillig //indent end 6737369abeSrillig 6837369abeSrillig /* The indentation consists of a single tab. */ 69*47306038Srillig //indent run -di8 7037369abeSrillig int decl; 71*47306038Srillig //indent end 7237369abeSrillig 7337369abeSrillig /* The indentation consists of a tab and a space. */ 74*47306038Srillig //indent run -di9 7537369abeSrillig int decl; 76*47306038Srillig //indent end 7737369abeSrillig 78*47306038Srillig //indent run -di16 7937369abeSrillig int decl; 80*47306038Srillig //indent end 8137369abeSrillig 8237369abeSrillig 8337369abeSrillig /* 8437369abeSrillig * Ensure that all whitespace is normalized to be indented by 8 columns, 8537369abeSrillig * which in the default configuration amounts to a single tab. 8637369abeSrillig */ 87*47306038Srillig //indent input 8837369abeSrillig int space; 8937369abeSrillig int tab; 9037369abeSrillig int tab16; 9137369abeSrillig struct long_name long_name; 92*47306038Srillig //indent end 9337369abeSrillig 94*47306038Srillig //indent run -di8 9537369abeSrillig int space; 9637369abeSrillig int tab; 9737369abeSrillig int tab16; 9837369abeSrillig struct long_name long_name; 99*47306038Srillig //indent end 100e48be331Srillig 101e48be331Srillig 102471ee992Srillig /* 103471ee992Srillig * A variable that has an ad-hoc struct/union/enum type does not need to be 104471ee992Srillig * indented to the right of the keyword 'struct', it only needs a single space 105471ee992Srillig * of indentation. 106471ee992Srillig * 107471ee992Srillig * Before NetBSD indent.c 1.151 from 2021-10-24, the indentation depended on 108471ee992Srillig * the length of the keyword 'struct', 'union' or 'enum', together with type 109471ee992Srillig * qualifiers like 'const' or the storage class like 'static'. 110471ee992Srillig */ 111*47306038Srillig //indent input 112e48be331Srillig struct { 113e48be331Srillig int member; 114e48be331Srillig } var = { 115e48be331Srillig 3, 116e48be331Srillig }; 117*47306038Srillig //indent end 118e48be331Srillig 119*47306038Srillig //indent run-equals-input -di0 120e48be331Srillig 121*47306038Srillig //indent run 122e48be331Srillig struct { 123e48be331Srillig int member; 124e48be331Srillig } var = { 125e48be331Srillig 3, 126e48be331Srillig }; 127*47306038Srillig //indent end 128