opt_v.c revision 1.3
11.3Srillig/* $NetBSD: opt_v.c,v 1.3 2021/10/22 19:27:53 rillig Exp $ */
21.1Srillig/* $FreeBSD$ */
31.1Srillig
41.2Srillig/*
51.2Srillig * Tests for the options '-v' and '-nv'.
61.2Srillig *
71.2Srillig * The option '-v' enables verbose mode. It outputs some information about
81.2Srillig * what's going on under the hood, especially when lines are broken. It also
91.2Srillig * outputs a few statistics about line counts and comments at the end.
101.2Srillig *
111.2Srillig * The option '-nv' disables verbose mode. Only errors and warnings are output
121.2Srillig * in this mode, but no progress messages.
131.2Srillig */
141.2Srillig
151.1Srillig#indent input
161.1Srillig/*
171.1Srillig * A long comment.
181.1Srillig */
191.1Srilligvoid
201.1Srilligexample(void)
211.1Srillig{
221.1Srillig	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
231.1Srillig}
241.1Srillig
251.1Srillig/* $ This comment is neither counted nor formatted. */
261.1Srillig#define macro1 /* prefix */ suffix
271.1Srillig
281.1Srillig/* $ This comment is formatted and counted. */
291.1Srillig#define macro2 prefix /* suffix */
301.1Srillig#indent end
311.1Srillig
321.1Srillig#indent run -v
331.1Srillig/*
341.1Srillig * A long comment.
351.1Srillig */
361.1Srilligvoid
371.1Srilligexample(void)
381.1Srillig{
391.1Srillig	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
401.1Srillig}
411.1Srillig
421.1Srillig#define macro1 /* prefix */ suffix
431.1Srillig
441.1Srillig#define macro2 prefix		/* suffix */
451.1SrilligThere were 10 output lines and 2 comments
461.1Srillig(Lines with comments)/(Lines with code):  0.571
471.1Srillig#indent end
481.1Srillig
491.1Srillig#indent input
501.1Srilligvoid
511.1Srilligexample(void)
521.1Srillig{
531.1Srillig	int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21;
541.1Srillig	int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21);
551.1Srillig}
561.1Srillig#indent end
571.1Srillig
581.1Srillig#indent run -nv
591.1Srilligvoid
601.1Srilligexample(void)
611.1Srillig{
621.1Srillig/* $ XXX: The following lines are too long and should thus be broken. */
631.1Srillig/* $ XXX: If they are broken, -nv does NOT output 'Line broken'. */
641.1Srillig	int		sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
651.1Srillig	int		sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
661.1Srillig}
671.1Srillig#indent end
681.3Srillig
691.3Srillig
701.3Srillig#indent input
711.3Srillig/* Demonstrates line number counting in verbose mode. */
721.3Srillig
731.3Srilligint *function(void)
741.3Srillig{}
751.3Srillig#indent end
761.3Srillig
771.3Srillig#indent run -v
781.3Srillig/* Demonstrates line number counting in verbose mode. */
791.3Srillig
801.3Srilligint *
811.3Srilligfunction(void)
821.3Srillig{
831.3Srillig}
841.3SrilligThere were 5 output lines and 1 comments
851.3Srillig(Lines with comments)/(Lines with code):  0.250
861.3Srillig#indent end
871.3Srillig/* In the above output, the '5' means 5 non-empty lines. */
881.3Srillig
891.3Srillig/*
901.3Srillig * XXX: It's rather strange that -v writes to stdout, even in filter mode.
911.3Srillig * This output belongs on stderr instead.
921.3Srillig */
93