opt_v.c revision 1.12
11.12Srillig/* $NetBSD: opt_v.c,v 1.12 2023/05/12 10:53:33 rillig Exp $ */
21.1Srillig
31.2Srillig/*
41.2Srillig * Tests for the options '-v' and '-nv'.
51.2Srillig *
61.2Srillig * The option '-v' enables verbose mode. It outputs some information about
71.12Srillig * what's going on under the hood, especially when lines are broken.
81.2Srillig *
91.2Srillig * The option '-nv' disables verbose mode. Only errors and warnings are output
101.2Srillig * in this mode, but no progress messages.
111.2Srillig */
121.2Srillig
131.12Srillig/*
141.12Srillig * XXX: It's rather strange that -v writes to stdout, even in filter mode.
151.12Srillig * This output belongs on stderr instead.
161.12Srillig */
171.12Srillig
181.8Srillig//indent input
191.1Srillig/*
201.6Srillig * A block comment.
211.1Srillig */
221.1Srilligvoid
231.1Srilligexample(void)
241.1Srillig{
251.1Srillig	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
261.1Srillig}
271.1Srillig
281.6Srillig/* $ The below comment is neither counted nor formatted. */
291.1Srillig#define macro1 /* prefix */ suffix
301.1Srillig
311.6Srillig/* $ The below comment is formatted and counted. */
321.1Srillig#define macro2 prefix /* suffix */
331.8Srillig//indent end
341.1Srillig
351.8Srillig//indent run -v
361.1Srillig/*
371.6Srillig * A block comment.
381.1Srillig */
391.1Srilligvoid
401.1Srilligexample(void)
411.1Srillig{
421.1Srillig	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
431.1Srillig}
441.1Srillig
451.1Srillig#define macro1 /* prefix */ suffix
461.1Srillig
471.11Srillig#define macro2 prefix /* suffix */
481.8Srillig//indent end
491.1Srillig
501.5Srillig
511.8Srillig//indent input
521.1Srilligvoid
531.1Srilligexample(void)
541.1Srillig{
551.1Srillig	int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21;
561.1Srillig	int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21);
571.1Srillig}
581.8Srillig//indent end
591.1Srillig
601.8Srillig//indent run -nv
611.1Srilligvoid
621.1Srilligexample(void)
631.1Srillig{
641.1Srillig/* $ XXX: The following lines are too long and should thus be broken. */
651.1Srillig/* $ XXX: If they are broken, -nv does NOT output 'Line broken'. */
661.1Srillig	int		sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
671.1Srillig	int		sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
681.1Srillig}
691.8Srillig//indent end
701.3Srillig
711.3Srillig
721.3Srillig/*
731.12Srillig * Before 2023-05-12, indent wrote some wrong statistics to stdout, in which
741.12Srillig * the line numbers were counted wrong.
751.4Srillig */
761.8Srillig//indent input
771.4Srillig#if 0
781.4Srilligint line = 1;
791.4Srilligint line = 2;
801.4Srilligint line = 3;
811.4Srillig#else
821.4Srilligint line = 5;
831.4Srillig#endif
841.8Srillig//indent end
851.4Srillig
861.12Srillig//indent run-equals-input -v -di0
87