Home | History | Annotate | Line # | Download | only in indent
opt_l.c revision 1.3
      1 /* $NetBSD: opt_l.c,v 1.3 2022/04/22 21:21:20 rillig Exp $ */
      2 
      3 /*
      4  * Tests for the option '-l', which specifies the maximum length of a line.
      5  *
      6  * As of 2021-11-20, indent assumes that each byte occupies a single column,
      7  * it does not properly handle Unicode.
      8  */
      9 
     10 #indent input
     11 /*
     12  * With a line length of 38, this comment and the next one are broken.
     13  */
     14 
     15 /* The options -l and -lc produce the same output. */
     16 #indent end
     17 
     18 #indent run -l38
     19 /*
     20  * With a line length of 38, this
     21  * comment and the next one are
     22  * broken.
     23  */
     24 
     25 /*
     26  * The options -l and -lc produce the
     27  * same output.
     28  */
     29 #indent end
     30 #indent run-equals-prev-output -lc38
     31 
     32 #indent run-equals-input -l78
     33 #indent run-equals-input -lc78
     34 
     35 
     36 #indent input
     37 int decl; /* comment comment comment comment */
     38 #indent end
     39 
     40 /*
     41  * The option '-lc' only applies to block comments, not to comments to the
     42  * right of code or declarations.
     43  */
     44 #indent run -di8 -c17 -lc32
     45 int	decl;	/* comment comment comment comment */
     46 #indent end
     47 
     48 #indent run -di8 -c17 -l32
     49 int	decl;	/* comment comment
     50 		 * comment comment */
     51 #indent end
     52 
     53 
     54 /*
     55  * FIXME: Even though the line length is limited with -l38,
     56  * the overly long lines in the code are not broken.
     57  */
     58 #indent input
     59 void
     60 example(int a, int b, int c, const char *cp)
     61 {
     62 	for (const char *p = cp; *p != '\0'; p++)
     63 		if (*p > a)
     64 			if (*p > b)
     65 				if (*p > c)
     66 					return;
     67 
     68 	function(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
     69 }
     70 #indent end
     71 
     72 #indent run-equals-input -l38
     73