summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/c/freebsd.c
blob: c9ef164f30926de36fe0f8eee3008288be82ae2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Make the structure name match the typedef. */
typedef struct bar {
	int	level;
} BAR;
typedef int		foo;	/* This is foo. */
typedef const long	baz;	/* This is baz. */


static char	*function(int _arg, const char *_arg2, struct foo *_arg3,
		    struct bar *_arg4);
static void	 usage(void);

/*
 * All major routines should have a comment briefly describing what
 * they do.  The comment before the "main" routine should describe
 * what the program does.
 */
int
main(int argc, char *argv[])
{
	char *ep;
	long num;
	int ch;

	while ((ch = getopt(argc, argv, "abNn:")) != -1)
		switch (ch) {		/* Indent the switch. */
		case 'a':		/* Don't indent the case. */
			aflag = 1;	/* Indent case body one tab. */
			/* FALLTHROUGH */
		case 'b':
			bflag = 1;
			break;
		case 'N':
			Nflag = 1;
			break;
		case 'n':
			num = strtol(optarg, &ep, 10);
			if (num <= 0 || *ep != '\0') {
				warnx("illegal number, -n argument -- %s",
				    optarg);
				usage();
			}
			break;
		case '?':
		default:
			usage();
			/* NOTREACHED */
		}
	argc -= optind;
	argv += optind;

	for (p = buf; *p != '\0'; ++p)
		;	/* nothing */
	for (;;)
		stmt;
	for (;;) {
		zed = a + really + long + statement + that + needs +
		    two + lines + gets + indented + four + spaces +
		    on + the + second + and + subsequent + lines;
	}
	for (;;) {
		if (cond)
			stmt;
	}
	if (val != NULL)
		val = realloc(val, newsize);

        fcn_call(with, a, really, long, list, of, parameters,
                 that, spans, two, lines);

	for (; cnt < 15; cnt++) {
		stmt1;
		stmt2;
	}

        almod = (chunk_is_single_line_comment(pc) &&
                cpd.settings[UO_indent_relative_single_line_comments].b) ?
            ALMODE_KEEP_REL : ALMODE_KEEP_ABS;

	/* Indentation is an 8 character tab.  Second level indents are four spaces.
	 * If you have to wrap a long statement, put the operator at the end of the
	 * line.
	 */

	while (cnt < 20 && this_variable_name_is_too_long &&
	    ep != NULL)
		zappy = a + really + long + statement + that + needs
		    + two + lines + gets + indented + four + spaces +
		    on + the + second + and + subsequent + lines;

   // Do not add whitespace at the end of a line, and only use tabs followed by
   // spaces to form the indentation.  Do not use more spaces than a tab will
   // produce and do not use spaces in front of tabs.
   //
   // Closing and opening braces go on the same line as the else.  Braces that
   // are not necessary may be left out.

	if (test)
		stmt;
	else if (bar) {
		stmt;
		stmt;
	} else
		stmt;

        // No spaces after function names.  Commas have a space after them.  No spa-
        // ces after `(' or `[' or preceding `]' or `)' characters.

	error = function(a1, a2);
	if (error != 0)
		exit(error);

        // Unary operators do not require spaces, binary operators do.  Do not use
        // parentheses unless they are required for precedence or unless the state-
        // ment is confusing without them.  Remember that other people may confuse
        // easier than you.  Do YOU understand the following?

	a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
	k = !(l & FLAGS);


        // Exits should be 0 on success, or 1 on failure.

	exit(0);	   /*
			    * Avoid obvious comments such as
			    * "Exit 0 on success."
                            */
}

static char *
     function(a1, a2, fl, a4)
	     int a1, a2;     /* Declare ints, too, don't default them. */
	     float fl;	     /* Beware double vs. float prototype differences. */
	     int a4;	     /* List in order declared. */
     {
     }