Module Name: src Committed By: rillig Date: Tue Oct 5 18:09:13 UTC 2021
Modified Files: src/tests/usr.bin/indent: token-comment.0 token-comment.0.pro token-comment.0.stdout Log Message: indent: test various forms of comments To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token-comment.0 cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-comment.0.pro cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token-comment.0.stdout Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/indent/token-comment.0 diff -u src/tests/usr.bin/indent/token-comment.0:1.2 src/tests/usr.bin/indent/token-comment.0:1.3 --- src/tests/usr.bin/indent/token-comment.0:1.2 Sun Mar 14 00:50:39 2021 +++ src/tests/usr.bin/indent/token-comment.0 Tue Oct 5 18:09:13 2021 @@ -1,16 +1,100 @@ -/* $NetBSD: token-comment.0,v 1.2 2021/03/14 00:50:39 rillig Exp $ */ +/* $NetBSD: token-comment.0,v 1.3 2021/10/05 18:09:13 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for formatting comments. C99 defines block comments and end-of-line * comments. Indent further distinguishes box comments that are a special * kind of block comments. + * + * See opt-fc1, opt-nfc1. */ -/* TODO: Add some code to be formatted. */ - /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */ /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */ /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */ /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678 */ /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */ + +/* This is a traditional C block comment. */ + +// This is a C99 line comment. + +/* + * This is a box comment since its first line (above this line) is empty. + * + * + * + * Its text gets wrapped. + * Empty lines serve as paragraphs. + */ + +/** + * This is a box comment + * that is not re-wrapped. + */ + +/*- + * This is a box comment + * that is not re-wrapped. + * It is often used for copyright declarations. + */ + +void +function(void) +{ + /* This is a traditional C block comment. */ + + /* + * This is a box comment. + * + * It starts in column 9, not 1, + * therefore it gets re-wrapped. + */ + + /** + * This is a box comment + * that is not re-wrapped, even though it starts in column 9, not 1. + */ + + /*- + * This is a box comment + * that is not re-wrapped. + * It is often used for copyright declarations. + */ + + int decl; /* declaration comment */ + + int decl; /* short + * multi-line + * declaration + * comment */ + + int decl; /* long single-line declaration comment that is longer than the allowed line width */ + + int decl; /* long multi-line declaration comment + * that is longer than + * the allowed line width */ + + int decl; // C99 declaration comment + + code(); /* code comment */ + + code(); /* short + * multi-line + * code + * comment */ + + code(); /* long single-line code comment that is longer than the allowed line width */ + + code(); /* long multi-line code comment + * that is longer than + * the allowed line width */ + + code(); // C99 code comment +} + +/*INDENT OFF*/ +/* No formatting takes place here. */ +int format( void ) {{{ +/*INDENT ON*/ +}}} Index: src/tests/usr.bin/indent/token-comment.0.pro diff -u src/tests/usr.bin/indent/token-comment.0.pro:1.1 src/tests/usr.bin/indent/token-comment.0.pro:1.2 --- src/tests/usr.bin/indent/token-comment.0.pro:1.1 Fri Mar 12 00:13:06 2021 +++ src/tests/usr.bin/indent/token-comment.0.pro Tue Oct 5 18:09:13 2021 @@ -1,8 +1,14 @@ -/* $NetBSD: token-comment.0.pro,v 1.1 2021/03/12 00:13:06 rillig Exp $ */ +/* $NetBSD: token-comment.0.pro,v 1.2 2021/10/05 18:09:13 rillig Exp $ */ /* $FreeBSD$ */ -/* - * TODO: Explain the command line options of the test. - */ +-ldi0 /* do not indent local variable declarations */ -/* TODO: Add some command line options */ +/* For variations on this theme, try some of these options: */ +/* -c20 */ +/* -cd20 */ +/* -cdb */ +/* -d */ +/* -fc1 */ +/* -fcb */ +/* -lc60 */ +/* -sc */ Index: src/tests/usr.bin/indent/token-comment.0.stdout diff -u src/tests/usr.bin/indent/token-comment.0.stdout:1.3 src/tests/usr.bin/indent/token-comment.0.stdout:1.4 --- src/tests/usr.bin/indent/token-comment.0.stdout:1.3 Sun Mar 14 01:34:13 2021 +++ src/tests/usr.bin/indent/token-comment.0.stdout Tue Oct 5 18:09:13 2021 @@ -1,14 +1,14 @@ -/* $NetBSD: token-comment.0.stdout,v 1.3 2021/03/14 01:34:13 rillig Exp $ */ +/* $NetBSD: token-comment.0.stdout,v 1.4 2021/10/05 18:09:13 rillig Exp $ */ /* $FreeBSD$ */ /* * Tests for formatting comments. C99 defines block comments and end-of-line * comments. Indent further distinguishes box comments that are a special * kind of block comments. + * + * See opt-fc1, opt-nfc1. */ -/* TODO: Add some code to be formatted. */ - /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */ /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */ /* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */ @@ -19,3 +19,83 @@ * 456789 123456789 123456789 123456789 123456789 123456789 123456789 * 123456789 */ + +/* This is a traditional C block comment. */ + +// This is a C99 line comment. + +/* + * This is a box comment since its first line (above this line) is empty. + * + * + * + * Its text gets wrapped. Empty lines serve as paragraphs. + */ + +/** + * This is a box comment + * that is not re-wrapped. + */ + +/*- + * This is a box comment + * that is not re-wrapped. + * It is often used for copyright declarations. + */ + +void +function(void) +{ + /* This is a traditional C block comment. */ + + /* + * This is a box comment. + * + * It starts in column 9, not 1, therefore it gets re-wrapped. + */ + + /** + * This is a box comment + * that is not re-wrapped, even though it starts in column 9, not 1. + */ + + /*- + * This is a box comment + * that is not re-wrapped. + * It is often used for copyright declarations. + */ + + int decl; /* declaration comment */ + + int decl; /* short multi-line declaration comment */ + + int decl; /* long single-line declaration comment that + * is longer than the allowed line width */ + + int decl; /* long multi-line declaration comment that is + * longer than the allowed line width */ + + int decl; // C99 declaration comment + + code(); /* code comment */ + + code(); /* short multi-line code comment */ + + code(); /* long single-line code comment that is + * longer than the allowed line width */ + + code(); /* long multi-line code comment that is longer + * than the allowed line width */ + + code(); // C99 code comment +} +/* $ FIXME: Missing empty line. */ +/*INDENT OFF*/ +/* No formatting takes place here. */ +int format( void ) {{{ +/* $ XXX: Why is the INDENT ON comment indented? */ +/* $ XXX: Why does the INDENT ON comment get spaces, but not the OFF comment? */ + /* INDENT ON */ +} +} +}