Home | History | Annotate | Line # | Download | only in indent
opt_fc1.c revision 1.5
      1 /* $NetBSD: opt_fc1.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */
      2 /* $FreeBSD$ */
      3 
      4 /*
      5  * Tests for the options '-fc1' and '-nfc1'.
      6  *
      7  * The option '-fc1' formats comments in column 1.
      8  *
      9  * The option '-nfc1' preserves the original formatting of comments that start
     10  * in column 1.
     11  */
     12 
     13 #indent input
     14 /*
     15  * A comment
     16  * in column 1.
     17  *
     18  *
     19  *
     20  */
     21 #indent end
     22 
     23 #indent run -fc1
     24 /*
     25  * A comment in column 1.
     26  *
     27  *
     28  *
     29  */
     30 #indent end
     31 
     32 #indent run-equals-input -nfc1
     33 
     34 
     35 #indent input
     36 /* $ Neither indentation nor surrounding spaces. */
     37 /*narrow*/
     38 
     39 /* $ Indented by a single space, single spaces around the text. */
     40  /* space */
     41 
     42 /* $ Indented by a single tab, single tabs around the text. */
     43 	/*	indented tab	*/
     44 
     45 /* $ The space between these comments gets removed. */
     46 /* block1 */ /* block2 */
     47 
     48 /* $ Both comment texts get surrounded by spaces. */
     49 /*block1*//*block2*/
     50 #indent end
     51 
     52 #indent run -fc1
     53 /* $ The comment text got surrounded by spaces. */
     54 /* narrow */
     55 
     56 /* $ The indentation got removed. */
     57 /* space */
     58 
     59 /* $ The indentation got removed, only the leading tab got replaced by a space. */
     60 /* indented tab	*/
     61 
     62 /* $ The space between these comments got removed. */
     63 /* block1 *//* block2 */
     64 
     65 /* $ Both comment texts got surrounded by spaces. */
     66 /* block1 *//* block2 */
     67 #indent end
     68 
     69 #indent run -nfc1
     70 /* $ No spaces got added around the comment text. */
     71 /*narrow*/
     72 
     73 /* $ The indentation of a single space was preserved. */
     74 /* $ If the comment were moved to column 1, it would change from the area */
     75 /* $ of 'comments that may be formatted' to the area of 'comments that must */
     76 /* $ not be formatted. The indentation of a single space prevents this. */
     77  /* space */
     78 
     79 /* $ The indentation was changed from a single tab to a single space. */
     80  /* indented tab	*/
     81 
     82 /* $ The space between these two comments got removed. */
     83 /* $ XXX: The option '-nfc1' says that comments in column 1 do not get */
     84 /* $ formatted, but the comment 'block1' was moved from column 1 to 2. */
     85 /* $ This is probably because there is a second comment in the same line. */
     86  /* block1 *//* block2 */
     87 
     88 /* $ It may seem strange at first that the left comment is not touched */
     89 /* $ but the right comment gets spaces added. This difference is the */
     90 /* $ exact purpose of the option '-nfc1', which says "do not touch comments */
     91 /* $ that start in column 1. The first comment starts in column 1, the */
     92 /* $ second comment doesn't. */
     93 /* $ XXX: The option '-nfc1' says that comments in column 1 do not get */
     94 /* $ formatted, but the comment 'block1' was moved from column 1 to 2. */
     95 /* $ This is probably because there is a second comment in the same line. */
     96  /*block1*//* block2 */
     97 #indent end
     98 
     99 
    100 #indent input
    101 /*
    102  * A multi-line comment that starts
    103  * in column 1.
    104  *//* followed by another multi-line comment
    105  * that starts in column 4.
    106  */
    107 #indent end
    108 
    109 #indent run -fc1
    110 /*
    111  * A multi-line comment that starts in column 1.
    112  *
    113  * followed by another multi-line comment that starts in column 4.
    114  */
    115 /* $ FIXME: The two comments have been merged into a single comment. */
    116 #indent end
    117 
    118 #indent run -nfc1
    119 /*
    120  * A multi-line comment that starts
    121  * in column 1.
    122   *
    123   * followed by another multi-line comment that starts in column 4.
    124   */
    125 /* $ FIXME: The two comments have been merged into a single comment. */
    126 #indent end
    127 
    128 
    129 #indent input
    130 /* comment */ int decl2; /* comment */
    131 /* looooooooooooooooooooooooooooooooooooooooong first comment */ int decl2; /* second comment */
    132 /* first comment */ int decl2; /* looooooooooooooooooooooooooooooooooooooooong second comment */
    133 #indent end
    134 
    135 #indent run -fc1
    136  /* comment */ int decl2;	/* comment */
    137  /* looooooooooooooooooooooooooooooooooooooooong first comment */ int decl2;	/* second comment */
    138  /* first comment */ int decl2;	/* looooooooooooooooooooooooooooooooooooooooong
    139 				 * second comment */
    140 #indent end
    141 
    142 #indent run-equals-prev-output -nfc1
    143