blob: 59c5f8e4fe42c6c5a6b635929dd3e1f301d920ff (
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
|
// The { coming up should be on its own line.
int
foo(void) {
// There should be a space before (1)
if(1) x += 1;
// The following empty line is unnecessary.
}
// There should be a newline between void and bar.
void bar(void)
{
// too wide:
testing("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}
long
bad_spacing()
{
// here comes a tab
return 2;
// here comes a label without space:
foo:
;
}
// Here comes a CR:
// Trailing space:
int
non_k_and_r(void)
{
// non-k&r
if (foo)
{
// double-semi
return 1;;
}
else
{
return 2;
}
}
// #else #if causes a warning.
#if 1
#else
#if 2
#else
#endif
#endif
// always space before a brace.
foo{
}
void
unexpected_space(void)
{
// This space gives a warning.
foobar (77);
}
void
bad_function_calls(long)
{
// These are forbidden:
assert(1);
memcmp("a","b",1);
strcat(foo,x);
strcpy(foo,y);
sprintf(foo,"x");
malloc(7);
free(p);
realloc(p);
strdup(s);
strndup(s,10);
calloc(a,b);
}
|