Home | History | Annotate | Line # | Download | only in indent
      1 /*	$NetBSD: fmt_decl.c,v 1.60 2023/06/25 19:19:42 rillig Exp $	*/
      2 
      3 /*
      4  * Tests for declarations of global variables, external functions, and local
      5  * variables.
      6  *
      7  * See also:
      8  *	opt_di.c
      9  */
     10 
     11 /* See FreeBSD r303570 */
     12 
     13 /*
     14  * A type definition usually declares a single type, so there is no need to
     15  * align the newly declared type name with the other variables.
     16  */
     17 //indent input
     18 typedef   void   (   *   function_ptr   )   (   int   *   )   ;
     19 //indent end
     20 
     21 //indent run
     22 typedef void (*function_ptr)(int *);
     23 //indent end
     24 
     25 
     26 /*
     27  * In variable declarations, the names of the first declarators are indented
     28  * by the amount given in '-di', which defaults to 16.
     29  */
     30 //indent input
     31 extern   void   (   *   function_pointer   )   (   int   *   )   ;
     32 extern   void   *   pointer;
     33 //indent end
     34 
     35 //indent run
     36 /* $ XXX: Why is the token 'function_pointer' not aligned with 'pointer'? */
     37 extern void	(*function_pointer)(int *);
     38 extern void    *pointer;
     39 //indent end
     40 
     41 
     42 //indent input
     43 static const struct
     44 {
     45 	double		x;
     46 	double		y, z;
     47 } n[m + 1] =
     48 {
     49 	{
     50 		.0,
     51 		.9,
     52 		5
     53 	}
     54 };
     55 //indent end
     56 
     57 //indent run
     58 static const struct
     59 {
     60 	double		x;
     61 	double		y, z;
     62 }		n[m + 1] =
     63 {
     64 	{
     65 		.0,
     66 		.9,
     67 		5
     68 	}
     69 };
     70 //indent end
     71 
     72 
     73 //indent input
     74 typedef struct Complex
     75 {
     76 	double		x;
     77 	double		y;
     78 }	Complex;
     79 //indent end
     80 
     81 //indent run
     82 typedef struct Complex
     83 {
     84 	double		x;
     85 	double		y;
     86 } Complex;
     87 //indent end
     88 
     89 
     90 /*
     91  * Ensure that function definitions are reasonably indented.  Before
     92  * 2023-05-11, tokens were repeatedly read, and the line numbers were wrong.
     93  */
     94 //indent input
     95 void
     96 t1 (char *a, int b,
     97 	void (*fn)(void))
     98 {}
     99 //indent end
    100 
    101 //indent run
    102 void
    103 t1(char *a, int b,
    104    void (*fn)(void))
    105 {
    106 }
    107 //indent end
    108 
    109 
    110 /* See opt_bc.c. */
    111 //indent input
    112 void t2 (char *x, int y)
    113 {
    114 	int a,
    115 	b,
    116 	c;
    117 	int
    118 	*d,
    119 	*e,
    120 	*f;
    121 	int (*g)(),
    122 	(*h)(),
    123 	(*i)();
    124 	int j,
    125 	k,
    126 	l;
    127 	int m
    128 	,n
    129 	,o
    130 	;
    131 	int		chars[ /* push the comma beyond column 74 ...... */ ], x;
    132 }
    133 //indent end
    134 
    135 //indent run
    136 void
    137 t2(char *x, int y)
    138 {
    139 	int		a, b, c;
    140 	int
    141 		       *d, *e, *f;
    142 	int		(*g)(), (*h)(), (*i)();
    143 	int		j, k, l;
    144 	int		m
    145 		       ,n
    146 		       ,o
    147 		       ;
    148 	int		chars[/* push the comma beyond column 74 ...... */],
    149 			x;
    150 }
    151 //indent end
    152 
    153 
    154 //indent input
    155 const int	int_minimum_size =
    156 // $ FIXME: Missing indentation.
    157 MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF;
    158 //indent end
    159 
    160 //indent run-equals-input
    161 
    162 
    163 /*
    164  * Ensure that the usual GCC-style function attributes are formatted in a
    165  * sensible way.
    166  */
    167 //indent input
    168 void single_param(int) __attribute__((__noreturn__)) ;
    169 void function(const char *, ...) __attribute__((format(printf, 1, 2))) ;
    170 //indent end
    171 
    172 //indent run -di0
    173 void single_param(int) __attribute__((__noreturn__));
    174 void function(const char *, ...) __attribute__((format(printf, 1, 2)));
    175 //indent end
    176 
    177 //indent run
    178 void		single_param(int) __attribute__((__noreturn__));
    179 void		function(const char *, ...) __attribute__((format(printf, 1, 2)));
    180 //indent end
    181 
    182 
    183 //indent input
    184 static
    185 _attribute_printf(1, 2)
    186 void
    187 print_error(const char *fmt,...)
    188 {
    189 }
    190 //indent end
    191 
    192 //indent run
    193 static
    194 _attribute_printf(1, 2)
    195 void
    196 print_error(const char *fmt, ...)
    197 {
    198 }
    199 //indent end
    200 
    201 
    202 //indent input
    203 static _attribute_printf(1, 2)
    204 void
    205 print_error(const char *fmt,...)
    206 {
    207 }
    208 //indent end
    209 
    210 //indent run
    211 static _attribute_printf(1, 2)
    212 void
    213 print_error(const char *fmt, ...)
    214 {
    215 }
    216 //indent end
    217 
    218 
    219 //indent input
    220 static void _attribute_printf(1, 2)
    221 print_error(const char *fmt,...)
    222 {
    223 }
    224 //indent end
    225 
    226 //indent run
    227 static void
    228 _attribute_printf(1, 2)
    229 print_error(const char *fmt, ...)
    230 {
    231 }
    232 //indent end
    233 
    234 
    235 /* See FreeBSD r309380 */
    236 //indent input
    237 static LIST_HEAD(, alq) ald_active;
    238 static int ald_shutting_down = 0;
    239 struct thread *ald_thread;
    240 //indent end
    241 
    242 //indent run
    243 static LIST_HEAD(, alq) ald_active;
    244 static int	ald_shutting_down = 0;
    245 struct thread  *ald_thread;
    246 //indent end
    247 
    248 
    249 //indent input
    250 static int
    251 old_style_definition(a, b, c)
    252 	struct thread *a;
    253 	int b;
    254 	double ***c;
    255 {
    256 
    257 }
    258 //indent end
    259 
    260 //indent run
    261 static int
    262 old_style_definition(a, b, c)
    263 	struct thread  *a;
    264 	int		b;
    265 	double	     ***c;
    266 {
    267 
    268 }
    269 //indent end
    270 
    271 
    272 /*
    273  * Demonstrate how variable declarations are broken into several lines when
    274  * the line length limit is set quite low.
    275  */
    276 //indent input
    277 struct s a,b;
    278 struct s0 a,b;
    279 struct s01 a,b;
    280 struct s012 a,b;
    281 struct s0123 a,b;
    282 struct s01234 a,b;
    283 struct s012345 a,b;
    284 struct s0123456 a,b;
    285 struct s01234567 a,b;
    286 struct s012345678 a,b;
    287 struct s0123456789 a,b;
    288 struct s01234567890 a,b;
    289 struct s012345678901 a,b;
    290 struct s0123456789012 a,b;
    291 struct s01234567890123 a,b;
    292 //indent end
    293 
    294 //indent run -l20 -di0
    295 struct s a, b;
    296 /* $ XXX: See process_comma, varname_len for why this line is broken. */
    297 struct s0 a,
    298           b;
    299 struct s01 a,
    300            b;
    301 struct s012 a,
    302             b;
    303 struct s0123 a,
    304              b;
    305 struct s01234 a,
    306               b;
    307 struct s012345 a,
    308                b;
    309 struct s0123456 a,
    310                 b;
    311 struct s01234567 a,
    312                  b;
    313 struct s012345678 a,
    314                   b;
    315 struct s0123456789 a,
    316                    b;
    317 struct s01234567890 a,
    318                     b;
    319 struct s012345678901 a,
    320                      b;
    321 struct s0123456789012 a,
    322                       b;
    323 struct s01234567890123 a,
    324                        b;
    325 //indent end
    326 
    327 
    328 //indent input
    329 char * x(void)
    330 {
    331     type identifier;
    332     type *pointer;
    333     unused * value;
    334     (void)unused * value;
    335 
    336     dmax = (double)3 * 10.0;
    337     dmin = (double)dmax * 10.0;
    338     davg = (double)dmax * dmin;
    339 
    340     return NULL;
    341 }
    342 //indent end
    343 
    344 //indent run
    345 char *
    346 x(void)
    347 {
    348 	type		identifier;
    349 	type	       *pointer;
    350 	unused	       *value;
    351 	(void)unused * value;
    352 
    353 	dmax = (double)3 * 10.0;
    354 	dmin = (double)dmax * 10.0;
    355 	davg = (double)dmax * dmin;
    356 
    357 	return NULL;
    358 }
    359 //indent end
    360 
    361 
    362 //indent input
    363 int *
    364 y(void) {
    365 
    366 }
    367 
    368 int
    369 z(void) {
    370 
    371 }
    372 //indent end
    373 
    374 //indent run
    375 int *
    376 y(void)
    377 {
    378 
    379 }
    380 
    381 int
    382 z(void)
    383 {
    384 
    385 }
    386 //indent end
    387 
    388 
    389 //indent input
    390 int x;
    391 int *y;
    392 int * * * * z;
    393 //indent end
    394 
    395 //indent run
    396 int		x;
    397 int	       *y;
    398 int	    ****z;
    399 //indent end
    400 
    401 
    402 //indent input
    403 int main(void) {
    404     char (*f1)() = NULL;
    405     char *(*f1)() = NULL;
    406     char *(*f2)();
    407 }
    408 //indent end
    409 
    410 /*
    411  * Before NetBSD io.c 1.103 from 2021-10-27, indent wrongly placed the second
    412  * and third variable declaration in column 1. This bug has been introduced
    413  * to NetBSD when FreeBSD indent was imported in 2019.
    414  */
    415 //indent run -ldi0
    416 int
    417 main(void)
    418 {
    419 	char (*f1)() = NULL;
    420 	char *(*f1)() = NULL;
    421 	char *(*f2)();
    422 }
    423 //indent end
    424 
    425 //indent run
    426 int
    427 main(void)
    428 {
    429 /* $ XXX: Not really pretty, the name 'f1' should be aligned, if at all. */
    430 	char		(*f1)() = NULL;
    431 /* $ XXX: Not really pretty, the name 'f1' should be aligned, if at all. */
    432 	char *(*	f1)() = NULL;
    433 /* $ XXX: Not really pretty, the name 'f2' should be aligned, if at all. */
    434 	char *(*	f2)();
    435 }
    436 //indent end
    437 
    438 
    439 /*
    440  * In some ancient time long before ISO C90, variable declarations with
    441  * initializer could be written without '='. The C Programming Language from
    442  * 1978 doesn't mention this form anymore.
    443  *
    444  * Before NetBSD lexi.c 1.123 from 2021-10-31, indent treated the '-' as a
    445  * unary operator.
    446  */
    447 //indent input
    448 int a - 1;
    449 {
    450 int a - 1;
    451 }
    452 //indent end
    453 
    454 //indent run -di0
    455 int a - 1;
    456 {
    457 	int a - 1;
    458 }
    459 //indent end
    460 
    461 
    462 /*
    463  * Between 2019-04-04 and before lexi.c 1.146 from 2021-11-19, the indentation
    464  * of the '*' depended on the function name, which did not make sense.  For
    465  * function names that matched [A-Za-z]+, the '*' was placed correctly, for
    466  * all other function names (containing [$0-9_]) the '*' was right-aligned on
    467  * the declaration indentation, which defaults to 16.
    468  */
    469 //indent input
    470 int *
    471 f2(void)
    472 {
    473 }
    474 
    475 int *
    476 yy(void)
    477 {
    478 }
    479 
    480 int *
    481 int_create(void)
    482 {
    483 }
    484 //indent end
    485 
    486 //indent run-equals-input
    487 
    488 
    489 /*
    490  * Since 2019-04-04, the space between the '){' is missing.
    491  */
    492 //indent input
    493 int *
    494 function_name_____20________30________40________50
    495 (void)
    496 {}
    497 //indent end
    498 
    499 /*
    500  * Before 2023-05-11, indent moved the '{' right after the '(void)', without
    501  * any space in between.
    502  */
    503 //indent run
    504 int	       *function_name_____20________30________40________50
    505 		(void)
    506 {
    507 }
    508 //indent end
    509 
    510 
    511 /*
    512  * Since 2019-04-04 and before lexi.c 1.144 from 2021-11-19, some function
    513  * names were preserved while others were silently discarded.
    514  */
    515 //indent input
    516 int *
    517 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    518 (void)
    519 {}
    520 //indent end
    521 
    522 /*
    523  * Before 2023-05-11, indent moved the '{' right after the '(void)', without
    524  * any space in between.
    525  */
    526 //indent run
    527 int	       *aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    528 		(void)
    529 {
    530 }
    531 //indent end
    532 
    533 
    534 /*
    535  * Before 1990, when C90 standardized function prototypes, a function
    536  * declaration or definition did not contain a '*' that may have looked
    537  * similar to the binary operator '*' because it was surrounded by two
    538  * identifiers.
    539  *
    540  * As of 2021-11-21, indent interpreted the '*' in the function declaration in
    541  * line 1 as a binary operator, even though the '*' was followed by a ','
    542  * directly. This was not visible in the output though since indent never
    543  * outputs a space before a comma.
    544  *
    545  * In the function declaration in line 2 and the function definition in line
    546  * 5, indent interpreted the '*' as a binary operator as well and accordingly
    547  * placed spaces around the '*'. On a very low syntactical analysis level,
    548  * this may have made sense since the '*' was surrounded by words, but still
    549  * the '*' is part of a declaration, where a binary operator does not make
    550  * sense.
    551  *
    552  * Essentially, as of 2021, indent had missed the last 31 years of advances in
    553  * the C programming language, in particular the invention of function
    554  * prototypes. Instead, the workaround had been to require all type names to
    555  * be specified via the options '-ta' and '-T'. This put the burden on the
    556  * user instead of the implementer.
    557  *
    558  * Fixed in lexi.c 1.156 from 2021-11-25.
    559  */
    560 //indent input
    561 void		buffer_add(buffer *, char);
    562 void		buffer_add(buffer *buf, char ch);
    563 
    564 void
    565 buffer_add(buffer *buf, char ch)
    566 {
    567 	*buf->e++ = ch;
    568 }
    569 //indent end
    570 
    571 //indent run
    572 void		buffer_add(buffer *, char);
    573 // $ FIXME: There should be no space after the '*'.
    574 void		buffer_add(buffer * buf, char ch);
    575 
    576 void
    577 buffer_add(buffer *buf, char ch)
    578 {
    579 	*buf->e++ = ch;
    580 }
    581 //indent end
    582 
    583 
    584 /*
    585  * Before lexi.c 1.153 from 2021-11-25, indent did not recognize 'Token' as a
    586  * type name and then messed up the positioning of the '{'.
    587  */
    588 //indent input
    589 static Token
    590 ToToken(bool cond)
    591 {
    592 }
    593 //indent end
    594 
    595 //indent run-equals-input -TToken
    596 
    597 /* Since lexi.c 1.153 from 2021-11-25. */
    598 //indent run-equals-input
    599 
    600 
    601 /*
    602  * Before indent.c 1.309 from 2023-05-23, indent easily got confused by unknown
    603  * type names in struct declarations, as a ';' did not finish a declaration.
    604  */
    605 //indent input
    606 typedef struct OpenDirs {
    607 	CachedDirList	list;
    608 	HashTable /* of CachedDirListNode */ table;
    609 } OpenDirs;
    610 //indent end
    611 
    612 //indent run-equals-input -THashTable
    613 
    614 //indent run-equals-input
    615 
    616 
    617 /*
    618  * Before lexi.c 1.153 from 2021-11-25, indent easily got confused by unknown
    619  * type names, even in declarations that are syntactically unambiguous.
    620  */
    621 //indent input
    622 static CachedDir *dot = NULL;
    623 //indent end
    624 
    625 //indent run-equals-input -TCachedDir
    626 
    627 //indent run-equals-input
    628 
    629 
    630 /*
    631  * Before lexi.c 1.153 from 2021-11-25, indent easily got confused by unknown
    632  * type names in declarations.
    633  */
    634 //indent input
    635 static CachedDir *
    636 CachedDir_New(const char *name)
    637 {
    638 }
    639 //indent end
    640 
    641 //indent run-equals-input
    642 
    643 
    644 /*
    645  * Before lexi.c 1.156 from 2021-11-25, indent easily got confused by unknown
    646  * type names in declarations and generated 'CachedDir * dir' with an extra
    647  * space.
    648  */
    649 //indent input
    650 static CachedDir *
    651 CachedDir_Ref(CachedDir *dir)
    652 {
    653 }
    654 //indent end
    655 
    656 //indent run-equals-input
    657 
    658 
    659 /*
    660  * Before lexi.c 1.156 from 2021-11-25, indent easily got confused by unknown
    661  * type names in declarations and generated 'HashEntry * he' with an extra
    662  * space.
    663  *
    664  * Before lexi.c 1.153 from 2021-11-25, indent also placed the '{' at the end
    665  * of the line.
    666  */
    667 //indent input
    668 static bool
    669 HashEntry_KeyEquals(const HashEntry *he, Substring key)
    670 {
    671 }
    672 //indent end
    673 
    674 //indent run-equals-input
    675 
    676 
    677 /*
    678  * Before lexi.c 1.156 from 2021-11-25, indent didn't notice that the two '*'
    679  * are in a declaration, instead it interpreted the first '*' as a binary
    680  * operator, therefore generating 'CachedDir * *var' with an extra space.
    681  */
    682 //indent input
    683 static void
    684 CachedDir_Assign(CachedDir **var, CachedDir *dir)
    685 {
    686 }
    687 //indent end
    688 
    689 //indent run-equals-input -TCachedDir
    690 
    691 //indent run-equals-input
    692 
    693 
    694 /*
    695  * Before lexi.c 1.153 from 2021-11-25, all initializer expressions after the
    696  * first one were indented as if they were statement continuations. This was
    697  * caused by the token 'Shell' being identified as a word, not as a type name.
    698  */
    699 //indent input
    700 static Shell	shells[] = {
    701 	{
    702 		first,
    703 		second,
    704 	},
    705 };
    706 //indent end
    707 
    708 //indent run-equals-input
    709 
    710 
    711 /*
    712  * Before lexi.c 1.158 from 2021-11-25, indent easily got confused by function
    713  * attribute macros that followed the function declaration. Its primitive
    714  * heuristic between deciding between a function declaration and a function
    715  * definition only looked for ')' immediately followed by ',' or ';'. This was
    716  * sufficient for well-formatted code before 1990. With the addition of
    717  * function prototypes and GCC attributes, the situation became more
    718  * complicated, and it took indent 31 years to adapt to this new reality.
    719  */
    720 //indent input
    721 static void JobInterrupt(bool, int) MAKE_ATTR_DEAD;
    722 static void JobRestartJobs(void);
    723 //indent end
    724 
    725 //indent run
    726 static void	JobInterrupt(bool, int) MAKE_ATTR_DEAD;
    727 static void	JobRestartJobs(void);
    728 //indent end
    729 
    730 
    731 /*
    732  * Before lexi.c 1.158 from 2021-11-25, indent easily got confused by the
    733  * tokens ')' and ';' in the function body. It wrongly regarded them as
    734  * finishing a function declaration.
    735  */
    736 //indent input
    737 MAKE_INLINE const char *
    738 GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
    739 //indent end
    740 
    741 /*
    742  * Before lexi.c 1.156 from 2021-11-25, indent generated 'GNode * gn' with an
    743  * extra space.
    744  *
    745  * Before lexi.c 1.158 from 2021-11-25, indent wrongly placed the function
    746  * name in line 1, together with the '{'.
    747  */
    748 //indent run
    749 MAKE_INLINE const char *
    750 GNode_VarTarget(GNode *gn)
    751 {
    752 	return GNode_ValueDirect(gn, TARGET);
    753 }
    754 //indent end
    755 
    756 //indent run-equals-prev-output -TGNode
    757 
    758 
    759 /*
    760  * Ensure that '*' in declarations is interpreted (or at least formatted) as
    761  * a 'pointer to' type derivation, not as a binary or unary operator.
    762  */
    763 //indent input
    764 number *var = a * b;
    765 
    766 void
    767 function(void)
    768 {
    769 	number *var = a * b;
    770 }
    771 //indent end
    772 
    773 //indent run-equals-input -di0
    774 
    775 
    776 /*
    777  * In declarations, most occurrences of '*' are pointer type derivations.
    778  * There are a few exceptions though. Some of these are hard to detect
    779  * without knowing which identifiers are type names.
    780  */
    781 //indent input
    782 char str[expr * expr];
    783 char str[expr**ptr];
    784 char str[*ptr**ptr];
    785 char str[sizeof(expr * expr)];
    786 char str[sizeof(int) * expr];
    787 char str[sizeof(*ptr)];
    788 char str[sizeof(type**)];
    789 char str[sizeof(**ptr)];
    790 //indent end
    791 
    792 //indent run -di0
    793 char str[expr * expr];
    794 char str[expr * *ptr];
    795 char str[*ptr * *ptr];
    796 char str[sizeof(expr * expr)];
    797 char str[sizeof(int) * expr];
    798 char str[sizeof(*ptr)];
    799 char str[sizeof(type **)];
    800 char str[sizeof(**ptr)];
    801 //indent end
    802 
    803 
    804 /*
    805  * Since lexi.c 1.158 from 2021-11-25, whether the function 'a' was considered
    806  * a declaration or a definition depended on the preceding struct, in
    807  * particular the length of the 'pn' line. This didn't make sense at all and
    808  * was due to an out-of-bounds memory access.
    809  *
    810  * Seen amongst others in args.c 1.72, function add_typedefs_from_file.
    811  * Fixed in lexi.c 1.165 from 2021-11-27.
    812  */
    813 //indent input
    814 struct {
    815 } v = {
    816     pn("ta"),
    817 };
    818 
    819 static void
    820 a(char *fe)
    821 {
    822 }
    823 
    824 struct {
    825 } v = {
    826     pn("t"),
    827 };
    828 
    829 static void
    830 a(char *fe)
    831 {
    832 }
    833 //indent end
    834 
    835 //indent run -di0
    836 struct {
    837 } v = {
    838 	pn("ta"),
    839 };
    840 
    841 static void
    842 a(char *fe)
    843 {
    844 }
    845 
    846 struct {
    847 } v = {
    848 	pn("t"),
    849 };
    850 
    851 static void
    852 a(char *fe)
    853 {
    854 }
    855 //indent end
    856 
    857 
    858 /*
    859  * Before NetBSD indent.c 1.178 from 2021-10-29, indent removed the blank
    860  * before the '=', in the second and third of these function pointer
    861  * declarations. This was because indent interpreted the prototype parameters
    862  * 'int' and 'int, int' as type casts, which doesn't make sense at all. Fixing
    863  * this properly requires large style changes since indent is based on simple
    864  * heuristics all over. This didn't change in indent.c 1.178; instead, the
    865  * rule for inserting a blank before a binary operator was changed to always
    866  * insert a blank, except at the beginning of a line.
    867  */
    868 //indent input
    869 char *(*fn)() = NULL;
    870 char *(*fn)(int) = NULL;
    871 char *(*fn)(int, int) = NULL;
    872 //indent end
    873 
    874 /* XXX: The parameter '(int)' is wrongly interpreted as a type cast. */
    875 /* XXX: The parameter '(int, int)' is wrongly interpreted as a type cast. */
    876 //indent run-equals-input -di0
    877 
    878 
    879 /*
    880  * Depending on whether there was a line break in the function header, the
    881  * spaces around the '||' operator were erroneously removed.
    882  */
    883 //indent input
    884 bool is_identifier_start(char ch)
    885 {
    886 	return ch_isalpha(ch) || ch == '_';
    887 }
    888 
    889 bool
    890 is_identifier_start(char ch)
    891 {
    892 	return ch_isalpha(ch) || ch == '_';
    893 }
    894 //indent end
    895 
    896 //indent run
    897 bool
    898 is_identifier_start(char ch)
    899 {
    900 	return ch_isalpha(ch) || ch == '_';
    901 }
    902 
    903 bool
    904 is_identifier_start(char ch)
    905 {
    906 	return ch_isalpha(ch) || ch == '_';
    907 }
    908 //indent end
    909 
    910 
    911 //indent input
    912 void buf_add_chars(struct buffer *, const char *, size_t);
    913 
    914 static inline bool
    915 ch_isalnum(char ch)
    916 {
    917     return isalnum((unsigned char)ch) != 0;
    918 }
    919 
    920 static inline bool
    921 ch_isalpha(char ch)
    922 {
    923     return isalpha((unsigned char)ch) != 0;
    924 }
    925 //indent end
    926 
    927 //indent run -i4 -di0
    928 // $ FIXME: 'buffer' is classified as 'word'.
    929 // $
    930 // $ FIXME: 'size_t' is classified as 'word'.
    931 void buf_add_chars(struct buffer *, const char *, size_t);
    932 
    933 static inline bool
    934 ch_isalnum(char ch)
    935 {
    936     return isalnum((unsigned char)ch) != 0;
    937 }
    938 
    939 static inline bool
    940 ch_isalpha(char ch)
    941 {
    942     return isalpha((unsigned char)ch) != 0;
    943 }
    944 //indent end
    945 
    946 //indent run-equals-input -i4 -di0
    947 
    948 
    949 //indent input
    950 void __printflike(1, 2)
    951 debug_printf(const char *fmt, ...)
    952 {
    953 }
    954 //indent end
    955 
    956 //indent run
    957 void
    958 // $ FIXME: No line break here.
    959 __printflike(1, 2)
    960 debug_printf(const char *fmt, ...)
    961 {
    962 }
    963 //indent end
    964 
    965 
    966 /*
    967  * When a name is defined both as a function and as a macro, the name in the
    968  * function definition must be enclosed in parentheses, to prevent the macro
    969  * from being expanded. It is also possible to undefine the macro, but that is
    970  * often not done in practice.
    971  */
    972 //indent input
    973 void
    974 (error_at)(int msgid, const pos_t *pos, ...)
    975 {
    976 }
    977 //indent end
    978 
    979 //indent run-equals-input
    980 
    981 
    982 //indent input
    983 struct a {
    984 	struct b {
    985 		struct c {
    986 			struct d1 {
    987 				int e;
    988 			} d1;
    989 			struct d2 {
    990 				int e;
    991 			} d2;
    992 		} c;
    993 	} b;
    994 };
    995 //indent end
    996 
    997 //indent run-equals-input -di0
    998 
    999 
   1000 //indent input
   1001 static FILE *ArchFindMember(const char *, const char *,
   1002 			    struct ar_hdr *, const char *);
   1003 
   1004 bool
   1005 Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
   1006 {
   1007 }
   1008 
   1009 static void MAKE_ATTR_PRINTFLIKE(5, 0)
   1010 ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn,
   1011 		    ParseErrorLevel level, const char *fmt, va_list ap)
   1012 {
   1013 }
   1014 
   1015 typedef struct {
   1016 	const char *m_name;
   1017 } mod_t;
   1018 //indent end
   1019 
   1020 //indent run -fbs -di0 -psl
   1021 // $ Must be detected as a function declaration, not a definition.
   1022 static FILE *ArchFindMember(const char *, const char *,
   1023 			    struct ar_hdr *, const char *);
   1024 
   1025 bool
   1026 Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
   1027 {
   1028 }
   1029 
   1030 static void
   1031 MAKE_ATTR_PRINTFLIKE(5, 0)
   1032 ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn,
   1033 		    ParseErrorLevel level, const char *fmt, va_list ap)
   1034 {
   1035 }
   1036 
   1037 typedef struct {
   1038 	const char *m_name;
   1039 } mod_t;
   1040 //indent end
   1041 
   1042 
   1043 //indent input
   1044 int a[] = {1, 2},
   1045 b[] = {1, 2};
   1046 {
   1047 int a[] = {1, 2},
   1048 b[] = {1, 2};
   1049 }
   1050 //indent end
   1051 
   1052 //indent run -di0
   1053 int a[] = {1, 2},
   1054 // $ FIXME: Missing indentation.
   1055 b[] = {1, 2};
   1056 {
   1057 	int a[] = {1, 2},
   1058 	// $ FIXME: Missing indentation.
   1059 	b[] = {1, 2};
   1060 }
   1061 //indent end
   1062 
   1063 
   1064 /*
   1065  * When a type occurs at the top level, it forces a line break before.
   1066  */
   1067 //indent input
   1068 __attribute__((__dead__)) void die(void) {}
   1069 //indent end
   1070 
   1071 //indent run
   1072 __attribute__((__dead__))
   1073 void
   1074 die(void)
   1075 {
   1076 }
   1077 //indent end
   1078 
   1079 
   1080 /*
   1081  * In very rare cases, the type of a declarator might include literal tab
   1082  * characters. This tab might affect the indentation of the declarator, but
   1083  * only if it occurs before the declarator, and that is hard to achieve.
   1084  */
   1085 //indent input
   1086 int		arr[sizeof "	"];
   1087 //indent end
   1088 
   1089 //indent run-equals-input
   1090 
   1091 
   1092 /*
   1093  * The '}' of an initializer is not supposed to end the statement, it only ends
   1094  * the brace level of the initializer expression.
   1095  */
   1096 //indent input
   1097 int multi_line[1][1][1] = {
   1098 {
   1099 {
   1100 1
   1101 },
   1102 },
   1103 };
   1104 int single_line[2][1][1] = {{{1},},{{2}}};
   1105 //indent end
   1106 
   1107 //indent run -di0
   1108 int multi_line[1][1][1] = {
   1109 	{
   1110 		{
   1111 			1
   1112 		},
   1113 	},
   1114 };
   1115 int single_line[2][1][1] = {{{1},}, {{2}}};
   1116 //indent end
   1117 
   1118 
   1119 /*
   1120  * The '}' of an initializer is not supposed to end the statement, it only ends
   1121  * the brace level of the initializer expression.
   1122  */
   1123 //indent input
   1124 {
   1125 int multi_line = {
   1126 {
   1127 {
   1128 b
   1129 },
   1130 },
   1131 };
   1132 int single_line = {{{b},},{}};
   1133 }
   1134 //indent end
   1135 
   1136 //indent run -di0
   1137 {
   1138 	int multi_line = {
   1139 		{
   1140 			{
   1141 				b
   1142 			},
   1143 		},
   1144 	};
   1145 	int single_line = {{{b},}, {}};
   1146 }
   1147 //indent end
   1148 
   1149 
   1150 /*
   1151  * In initializers, multi-line expressions don't have their second line
   1152  * indented, even though they should.
   1153  */
   1154 //indent input
   1155 {
   1156 multi_line = (int[]){
   1157 {1
   1158 +1},
   1159 {1
   1160 +1},
   1161 {1
   1162 +1},
   1163 };
   1164 }
   1165 //indent end
   1166 
   1167 //indent run
   1168 {
   1169 	multi_line = (int[]){
   1170 		{1
   1171 		+ 1},
   1172 		{1
   1173 		+ 1},
   1174 		{1
   1175 		+ 1},
   1176 	};
   1177 }
   1178 //indent end
   1179 
   1180 
   1181 /*
   1182  *
   1183  */
   1184 //indent input
   1185 int
   1186 old_style(a)
   1187 	struct {
   1188 		int		member;
   1189 	}		a;
   1190 {
   1191 	stmt;
   1192 }
   1193 //indent end
   1194 
   1195 //indent run-equals-input
   1196