ps_ind_level.c revision 1.1
11.1Srillig/* $NetBSD: ps_ind_level.c,v 1.1 2021/10/18 22:46:33 rillig Exp $ */ 21.1Srillig/* $FreeBSD$ */ 31.1Srillig 41.1Srillig/* 51.1Srillig * The indentation of the very first line of a file determines the 61.1Srillig * indentation of the remaining code. Even if later code has a smaller 71.1Srillig * indentation, it is nevertheless indented to the level given by the first 81.1Srillig * line of code. 91.1Srillig * 101.1Srillig * In this particular test, the indentation is set to 5 and the tabulator 111.1Srillig * width is set to 8, to demonstrate an off-by-one error in 121.1Srillig * main_prepare_parsing that has been fixed in indent.c 1.107 from 2021-10-05. 131.1Srillig * 141.1Srillig * The declaration in the first line is indented by 3 tabs, amounting to 24 151.1Srillig * spaces. The initial indentation of the code is intended to be rounded down, 161.1Srillig * to 4 levels of indentation, amounting to 20 spaces. 171.1Srillig */ 181.1Srillig#indent input 191.1Srillig int declaration_in_column_25; 201.1Srillig 211.1Srilligvoid function_in_column_1(void){} 221.1Srillig#indent end 231.1Srillig 241.1Srillig/* 5 spaces indentation, 8 spaces per tabulator */ 251.1Srillig#indent run -i5 -ts8 261.1Srillig int declaration_in_column_25; 271.1Srillig 281.1Srillig void function_in_column_1(void){ 291.1Srillig } 301.1Srillig#indent end 311.1Srillig/* 321.1Srillig * In the above function declaration, the space between '){' is missing. This 331.1Srillig * is because the tokenizer only recognizes function definitions if they start 341.1Srillig * at indentation level 0, but this declaration starts at indentation level 4, 351.1Srillig * due to the indentation in line 1. It's an edge case and probably not worth 361.1Srillig * fixing. 371.1Srillig * 381.1Srillig * See 'in_parameter_declaration = true'. 391.1Srillig */ 401.1Srillig 411.1Srillig 421.1Srillig/* 431.1Srillig * Labels are always indented 2 levels left of the code. The first line starts 441.1Srillig * at indentation level 3, the code in the function is therefore at level 4, 451.1Srillig * and the label is at level 2, sticking out of the code. 461.1Srillig */ 471.1Srillig#indent input 481.1Srillig int indent_by_24; 491.1Srillig 501.1Srilligvoid function(void) { 511.1Srilliglabel:; 521.1Srillig} 531.1Srillig#indent end 541.1Srillig 551.1Srillig#indent run -i8 -ts8 -di0 561.1Srillig int indent_by_24; 571.1Srillig 581.1Srillig void function(void){ 591.1Srillig label: ; 601.1Srillig } 611.1Srillig#indent end 62