Skip to content

Commit 973f2dd

Browse files
committed
chore: Indent with tab for C/C++ sources
1 parent 8fb8010 commit 973f2dd

33 files changed

+5920
-6020
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ end_of_line = lf
99
indent_style = space
1010
indent_size = 2
1111

12-
[{Dockerfile,*.py,judge_client,testlib.h}]
12+
[{Dockerfile,*.py,judge_client,*.{c,h}{pp,}}]
1313
indent_style = space
1414
indent_size = 4

judger/uoj_judger/.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BasedOnStyle: Google
99
# ------------------------------------------------------------------------------
1010

1111
# 核心缩进规则,与 .editorconfig 保持一致
12-
UseTab: ForIndentation
12+
UseTab: Never
1313
IndentWidth: 4
1414
TabWidth: 4
1515
ContinuationIndentWidth: 4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/testlib.h
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
#include "testlib.h"
2-
#include <stdio.h>
31
#include <math.h>
42

3+
#include "testlib.h"
4+
55
const double EPS = 1.5E-6;
66

7-
int main(int argc, char * argv[])
8-
{
7+
int main(int argc, char *argv[]) {
98
setName("compare two doubles, maximal absolute error = %.10lf", EPS);
109
registerTestlibCmd(argc, argv);
11-
10+
1211
double ja = ans.readDouble();
1312
double pa = ouf.readDouble();
1413

15-
if (fabs(ja - pa) > EPS + 1E-15)
16-
quitf(_wa, "expected %.10lf, found %.10lf", ja, pa);
17-
14+
if (fabs(ja - pa) > EPS + 1E-15) quitf(_wa, "expected %.10lf, found %.10lf", ja, pa);
15+
1816
quitf(_ok, "answer is %.10lf", ja);
1917
}
Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
11
#include <cstdio>
22

3-
inline const char *englishEnding(int x)
4-
{
5-
x %= 100;
6-
if (x / 10 == 1)
7-
return "th";
8-
if (x % 10 == 1)
9-
return "st";
10-
if (x % 10 == 2)
11-
return "nd";
12-
if (x % 10 == 3)
13-
return "rd";
14-
return "th";
3+
inline const char *englishEnding(int x) {
4+
x %= 100;
5+
if (x / 10 == 1) return "th";
6+
if (x % 10 == 1) return "st";
7+
if (x % 10 == 2) return "nd";
8+
if (x % 10 == 3) return "rd";
9+
return "th";
1510
}
1611

17-
int main(int argc, char * argv[])
18-
{
19-
if (argc != 4)
20-
return 1;
21-
FILE *fout = fopen(argv[2], "r");
22-
FILE *fans = fopen(argv[3], "r");
12+
int main(int argc, char *argv[]) {
13+
if (argc != 4) return 1;
14+
FILE *fout = fopen(argv[2], "r");
15+
FILE *fans = fopen(argv[3], "r");
2316

24-
if (fout == NULL || fans == NULL)
25-
return 1;
17+
if (fout == NULL || fans == NULL) return 1;
2618

27-
int n = 0;
28-
while (true)
29-
{
30-
n++;
31-
int c, d;
32-
c = fgetc(fout);
33-
d = fgetc(fans);
34-
if (c == EOF && d == EOF)
35-
break;
36-
if (c != d)
37-
{
38-
if (c == EOF)
39-
fprintf(stderr, "wrong answer %d%s byte differ - expected EOF found '%c'\n", n, englishEnding(n), (char)d);
40-
else if (d == EOF)
41-
fprintf(stderr, "wrong answer %d%s byte differ - expected '%c' found EOF\n", n, englishEnding(n), (char)c);
42-
else
43-
fprintf(stderr, "wrong answer %d%s byte differ - expected '%c' found '%c'\n", n, englishEnding(n), (char)c, (char)d);
44-
return 1;
45-
}
46-
}
19+
int n = 0;
20+
while (true) {
21+
n++;
22+
int c, d;
23+
c = fgetc(fout);
24+
d = fgetc(fans);
25+
if (c == EOF && d == EOF) break;
26+
if (c != d) {
27+
if (c == EOF)
28+
fprintf(stderr, "wrong answer %d%s byte differ - expected EOF found '%c'\n", n,
29+
englishEnding(n), (char)d);
30+
else if (d == EOF)
31+
fprintf(stderr, "wrong answer %d%s byte differ - expected '%c' found EOF\n", n,
32+
englishEnding(n), (char)c);
33+
else
34+
fprintf(stderr, "wrong answer %d%s byte differ - expected '%c' found '%c'\n", n,
35+
englishEnding(n), (char)c, (char)d);
36+
return 1;
37+
}
38+
}
4739

48-
if (n == 0)
49-
fprintf(stderr, "ok empty file\n");
50-
else if (n == 1)
51-
fprintf(stderr, "ok single byte\n");
52-
else
53-
fprintf(stderr, "ok %d byte\n", n);
54-
return 0;
40+
if (n == 0)
41+
fprintf(stderr, "ok empty file\n");
42+
else if (n == 1)
43+
fprintf(stderr, "ok single byte\n");
44+
else
45+
fprintf(stderr, "ok %d byte\n", n);
46+
return 0;
5547
}

judger/uoj_judger/builtin/checker/caseicmp.cpp

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,33 @@
88
*
99
*/
1010

11-
#include "testlib.h"
12-
13-
#include <iostream>
14-
#include <sstream>
15-
#include <fstream>
16-
#include <iomanip>
17-
#include <string>
18-
#include <cstdlib>
11+
#include <algorithm>
12+
#include <cassert>
13+
#include <climits>
14+
#include <cmath>
1915
#include <cstdio>
16+
#include <cstdlib>
2017
#include <cstring>
21-
#include <cmath>
2218
#include <ctime>
23-
#include <climits>
24-
#include <cassert>
19+
#include <iostream>
20+
#include <sstream>
21+
#include <string>
2522
#include <vector>
26-
#include <queue>
27-
#include <stack>
28-
#include <deque>
29-
#include <set>
30-
#include <map>
31-
#include <bitset>
32-
#include <utility>
33-
#include <algorithm>
23+
24+
#include "testlib.h"
3425

3526
using namespace std;
3627

3728
#define forn(i, n) for (int i = 0; i < int(n); i++)
3829

39-
vector<long long> readStream(InStream& in, TResult pe)
40-
{
30+
vector<long long> readStream(InStream& in, TResult pe) {
4131
vector<long long> result;
4232

43-
for (int testCase = 1; !in.seekEof(); testCase++)
44-
{
33+
for (int testCase = 1; !in.seekEof(); testCase++) {
4534
string caseStr = in.readToken();
4635
if (caseStr != "Case")
47-
quitf(pe, "Expected 'Case' but found '%s' [test case %d]", compress(caseStr).c_str(), testCase);
36+
quitf(pe, "Expected 'Case' but found '%s' [test case %d]", compress(caseStr).c_str(),
37+
testCase);
4838

4939
string numExpStr;
5040
stringstream ss;
@@ -53,42 +43,36 @@ vector<long long> readStream(InStream& in, TResult pe)
5343
numExpStr += ":";
5444
string numStr = in.readToken();
5545
if (numExpStr != numStr)
56-
quitf(pe, "Expected '%s' but found '%s' [test case %d]", compress(numExpStr).c_str(), compress(numStr).c_str(), testCase);
46+
quitf(pe, "Expected '%s' but found '%s' [test case %d]", compress(numExpStr).c_str(),
47+
compress(numStr).c_str(), testCase);
5748

5849
result.push_back(in.readLong());
5950
}
6051

6152
return result;
6253
}
6354

64-
int main(int argc, char* argv[])
65-
{
55+
int main(int argc, char* argv[]) {
6656
setName("Single int64 checker with testcase-support");
6757
registerTestlibCmd(argc, argv);
6858

6959
vector<long long> ja = readStream(ans, _fail);
7060
vector<long long> pa = readStream(ouf, _pe);
7161

72-
forn(i, min(ja.size(), pa.size()))
73-
if (ja[i] != pa[i])
74-
quitf(_wa, "Expected %s found %s [test case %d]", vtos(ja[i]).c_str(), vtos(pa[i]).c_str(), i + 1);
62+
forn(i, min(ja.size(), pa.size())) if (ja[i] != pa[i])
63+
quitf(_wa, "Expected %s found %s [test case %d]", vtos(ja[i]).c_str(), vtos(pa[i]).c_str(),
64+
i + 1);
7565

7666
if (ja.size() != pa.size())
7767
quitf(_pe, "Expected %d test case(s) but found %d", (int)ja.size(), (int)pa.size());
7868

7969
string message = format("%d case(s):", (int)ja.size());
80-
if (ja.size() <= 5)
81-
{
82-
forn(i, ja.size())
83-
message += " " + vtos(ja[i]);
84-
}
85-
else
86-
{
87-
forn(i, 3)
88-
message += " " + vtos(ja[i]);
70+
if (ja.size() <= 5) {
71+
forn(i, ja.size()) message += " " + vtos(ja[i]);
72+
} else {
73+
forn(i, 3) message += " " + vtos(ja[i]);
8974
message += " ...";
90-
forn(i, 2)
91-
message += " " + vtos(ja[ja.size() - 2 + i]);
75+
forn(i, 2) message += " " + vtos(ja[ja.size() - 2 + i]);
9276
}
9377

9478
quitf(_ok, "%s", message.c_str());

judger/uoj_judger/builtin/checker/casencmp.cpp

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,32 @@
88
*
99
*/
1010

11-
#include "testlib.h"
12-
13-
#include <iostream>
14-
#include <sstream>
15-
#include <fstream>
16-
#include <iomanip>
17-
#include <string>
18-
#include <cstdlib>
11+
#include <cassert>
12+
#include <climits>
13+
#include <cmath>
1914
#include <cstdio>
15+
#include <cstdlib>
2016
#include <cstring>
21-
#include <cmath>
2217
#include <ctime>
23-
#include <climits>
24-
#include <cassert>
18+
#include <iostream>
19+
#include <sstream>
20+
#include <string>
2521
#include <vector>
26-
#include <queue>
27-
#include <stack>
28-
#include <deque>
29-
#include <set>
30-
#include <map>
31-
#include <bitset>
32-
#include <utility>
33-
#include <algorithm>
22+
23+
#include "testlib.h"
3424

3525
using namespace std;
3626

3727
#define forn(i, n) for (int i = 0; i < int(n); i++)
3828

3929
string token;
4030

41-
vector<long long> readStreamCase(InStream& in, TResult pe, int testCase, bool& prereadCase)
42-
{
43-
if (!prereadCase)
44-
{
31+
vector<long long> readStreamCase(InStream& in, TResult pe, int testCase, bool& prereadCase) {
32+
if (!prereadCase) {
4533
string caseStr = in.readToken();
4634
if (caseStr != "Case")
47-
quitf(pe, "Expected 'Case' but found '%s' [test case %d]", compress(caseStr).c_str(), testCase);
35+
quitf(pe, "Expected 'Case' but found '%s' [test case %d]", compress(caseStr).c_str(),
36+
testCase);
4837
}
4938

5039
string numExpStr;
@@ -54,14 +43,13 @@ vector<long long> readStreamCase(InStream& in, TResult pe, int testCase, bool& p
5443
numExpStr += ":";
5544
string numStr = in.readToken();
5645
if (numExpStr != numStr)
57-
quitf(pe, "Expected '%s' but found '%s' [test case %d]", compress(numExpStr).c_str(), compress(numStr).c_str(), testCase);
46+
quitf(pe, "Expected '%s' but found '%s' [test case %d]", compress(numExpStr).c_str(),
47+
compress(numStr).c_str(), testCase);
5848

5949
vector<long long> result;
60-
while (!in.seekEof())
61-
{
50+
while (!in.seekEof()) {
6251
in.readTokenTo(token);
63-
if (token == "Case")
64-
{
52+
if (token == "Case") {
6553
prereadCase = true;
6654
break;
6755
}
@@ -72,31 +60,22 @@ vector<long long> readStreamCase(InStream& in, TResult pe, int testCase, bool& p
7260
return result;
7361
}
7462

75-
string longLongsToString(const vector<long long>& a)
76-
{
77-
if (a.empty())
78-
return "\"\" [size=0]";
79-
63+
string longLongsToString(const vector<long long>& a) {
64+
if (a.empty()) return "\"\" [size=0]";
65+
8066
string elems;
81-
if (a.size() <= 5)
82-
{
83-
forn(i, a.size())
84-
elems += vtos(a[i]) + " ";
85-
}
86-
else
87-
{
88-
forn(i, 3)
89-
elems += vtos(a[i]) + " ";
67+
if (a.size() <= 5) {
68+
forn(i, a.size()) elems += vtos(a[i]) + " ";
69+
} else {
70+
forn(i, 3) elems += vtos(a[i]) + " ";
9071
elems += "... ";
91-
forn(i, 2)
92-
elems += vtos(a[a.size() - 2 + i]) + " ";
72+
forn(i, 2) elems += vtos(a[a.size() - 2 + i]) + " ";
9373
}
9474

9575
return format("\"%s\" [size=%d]", trim(elems).c_str(), (int)a.size());
9676
}
9777

98-
int main(int argc, char* argv[])
99-
{
78+
int main(int argc, char* argv[]) {
10079
setName("Many int64s checker with testcase-support");
10180
registerTestlibCmd(argc, argv);
10281

@@ -105,18 +84,17 @@ int main(int argc, char* argv[])
10584
bool ansPrereadCase = false;
10685
bool oufPrereadCase = false;
10786

108-
while (!ans.seekEof())
109-
{
87+
while (!ans.seekEof()) {
11088
testCase++;
11189

11290
vector<long long> ja = readStreamCase(ans, _fail, testCase, ansPrereadCase);
11391
vector<long long> pa = readStreamCase(ouf, _pe, testCase, oufPrereadCase);
11492

115-
if (ja != pa)
116-
{
93+
if (ja != pa) {
11794
string js = longLongsToString(ja);
11895
string ps = longLongsToString(pa);
119-
quitf(_wa, "Sequences differ: jury has %s, but participant has %s [test case %d]", js.c_str(), ps.c_str(), testCase);
96+
quitf(_wa, "Sequences differ: jury has %s, but participant has %s [test case %d]",
97+
js.c_str(), ps.c_str(), testCase);
12098
}
12199
}
122100

0 commit comments

Comments
 (0)